sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx                 |   74 ++++++++++++++++++
 sc/source/filter/excel/xecontent.cxx                  |   12 +-
 sc/source/filter/excel/xeextlst.cxx                   |    2 
 sc/source/filter/excel/xeroot.cxx                     |    6 -
 sc/source/filter/excel/xestream.cxx                   |   17 ----
 sc/source/filter/excel/xetable.cxx                    |    4 
 sc/source/filter/inc/xeroot.hxx                       |    2 
 sc/source/filter/inc/xestream.hxx                     |    4 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx          |    3 
 10 files changed, 87 insertions(+), 37 deletions(-)

New commits:
commit ca8ca8c28742879220f3ff88ae0d71c8d69b11cd
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Mon Mar 10 14:02:00 2014 -0400

    fdo#75950: Just set the right grammar and be done with it.
    
    Using the Excel A1 syntax with custom opcode was probably a hack back
    in the day.  These days we can just set the right grammar and expect the
    compiler to do the right thing.
    
    Change-Id: Iae98f9f09a7da0b7b9549e06308d5d313bbff1ea

diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index 14baaea..0df97bb 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -946,13 +946,13 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
     {
         rWorksheet->startElement( XML_formula, FSEND );
         rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-                    mrFormatEntry.CreateTokenArry( 0 ), 
GetRoot().GetOpCodeMap() ));
+                    mrFormatEntry.CreateTokenArry(0)));
         rWorksheet->endElement( XML_formula );
         if (bFmla2)
         {
             rWorksheet->startElement( XML_formula, FSEND );
             rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-                        mrFormatEntry.CreateTokenArry( 1 ), 
GetRoot().GetOpCodeMap() ));
+                        mrFormatEntry.CreateTokenArry(1)));
             rWorksheet->endElement( XML_formula );
         }
     }
@@ -1093,7 +1093,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm )
     if(mrEntry.GetType() == COLORSCALE_FORMULA)
     {
         OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
maSrcPos,
-                mrEntry.GetFormula()->Clone(), GetRoot().GetOpCodeMap() );
+                mrEntry.GetFormula()->Clone());
         aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
     }
     else
@@ -1602,7 +1602,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
                         CreateDataValFormula() and CreateListValFormula(). */
                     mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, 
*xScTokArr );
                     msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-                            xScTokArr.get(), GetRoot().GetOpCodeMap() );
+                            xScTokArr.get());
                 }
             }
             else
@@ -1610,7 +1610,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
                 // no list validation -> convert the formula
                 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
                 msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-                        xScTokArr.get(), GetRoot().GetOpCodeMap() );
+                        xScTokArr.get());
             }
         }
 
@@ -1620,7 +1620,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
         {
             mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
             msFormula2 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-                    xScTokArr.get(), GetRoot().GetOpCodeMap() );
+                    xScTokArr.get());
         }
     }
     else
diff --git a/sc/source/filter/excel/xeextlst.cxx 
b/sc/source/filter/excel/xeextlst.cxx
index 92fb6c6..852647c 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -63,7 +63,7 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const 
ScColorScaleEntry&
         if(pArr)
         {
             aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos,
-                    pArr->Clone(), GetRoot().GetOpCodeMap() );
+                    pArr->Clone());
         }
         maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
     }
diff --git a/sc/source/filter/excel/xeroot.cxx 
b/sc/source/filter/excel/xeroot.cxx
index 88ab3e3..3da4427 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -167,12 +167,6 @@ XclExpPivotTableManager& 
XclExpRoot::GetPivotTableManager() const
     return *mrExpData.mxPTableMgr;
 }
 
-ScCompiler::OpCodeMapPtr XclExpRoot::GetOpCodeMap() const
-{
-    OSL_ENSURE( mrExpData.mxOpCodeMap, "XclExpRoot::GetOpCodeMap - missing 
object (wrong BIFF?)" );
-    return mrExpData.mxOpCodeMap;
-}
-
 void XclExpRoot::InitializeConvert()
 {
     mrExpData.mxTabInfo.reset( new XclExpTabInfo( GetRoot() ) );
diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index 2c37fb1..290bd6d 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -842,23 +842,10 @@ OUString XclXmlUtils::ToOUString( const ScfUInt16Vec& 
rBuf, sal_Int32 nStart, sa
 }
 
 OUString XclXmlUtils::ToOUString(
-    ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* 
pTokenArray,
-    const FormulaCompiler::OpCodeMapPtr & xOpCodeMap )
+    ScDocument& rDocument, const ScAddress& rAddress, const ScTokenArray* 
pTokenArray )
 {
     ScCompiler aCompiler( &rDocument, rAddress, 
const_cast<ScTokenArray&>(*pTokenArray));
-    if (xOpCodeMap)
-    {
-        aCompiler.SetFormulaLanguage( xOpCodeMap );
-        /* TODO: The correct ref convention would be CONV_XL_OOX but that would
-         * need aCompiler.SetExternalLinks() and so far we don't have the links
-         * mapping. */
-        aCompiler.SetRefConvention( formula::FormulaGrammar::CONV_XL_A1 );
-    }
-    else
-    {
-        SAL_WARN( "sc", "XclXmlUtils::ToOUString - no opcodemap, dumb fallback 
to PODF");
-        aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH_XL_A1);
-    }
+    aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH_XL_OOX);
 
     OUStringBuffer aBuffer( pTokenArray->GetLen() * 5 );
     aCompiler.CreateStringFromTokenArray( aBuffer );
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index 5655910..18b9e0e 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -962,8 +962,8 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
             // OOXTODO: XML_si,     uint
             // OOXTODO: XML_bx      bool
             FSEND );
-    rWorksheet->writeEscaped( XclXmlUtils::ToOUString( 
*mrScFmlaCell.GetDocument(), mrScFmlaCell.aPos,
-                mrScFmlaCell.GetCode(), rStrm.GetRoot().GetOpCodeMap() ) );
+    rWorksheet->writeEscaped( XclXmlUtils::ToOUString(
+        *mrScFmlaCell.GetDocument(), mrScFmlaCell.aPos, 
mrScFmlaCell.GetCode()));
     rWorksheet->endElement( XML_f );
     if( strcmp( sType, "inlineStr" ) == 0 )
     {
diff --git a/sc/source/filter/inc/xeroot.hxx b/sc/source/filter/inc/xeroot.hxx
index 67c4f2e..80a7ee5 100644
--- a/sc/source/filter/inc/xeroot.hxx
+++ b/sc/source/filter/inc/xeroot.hxx
@@ -145,8 +145,6 @@ public:
     XclExpPivotTableManager& GetPivotTableManager() const;
     /** Returns the differential formatting list */
     XclExpDxfs&          GetDxfs() const;
-    /** Returns the op-code mapping */
-    ScCompiler::OpCodeMapPtr  GetOpCodeMap() const;
 
     /** Is called when export filter starts to create the Excel document (all 
BIFF versions). */
     void                InitializeConvert();
diff --git a/sc/source/filter/inc/xestream.hxx 
b/sc/source/filter/inc/xestream.hxx
index 8d58c8d..8d137ea 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -34,7 +34,6 @@
 
 #include "xlstream.hxx"
 #include "xestring.hxx"
-#include "compiler.hxx"
 
 #include <filter/msfilter/mscodec.hxx>
 #include <vector>
@@ -285,8 +284,7 @@ public:
 
     static OUString ToOUString( const char* s );
     static OUString ToOUString( const ScfUInt16Vec& rBuffer, sal_Int32 nStart 
= 0, sal_Int32 nLength = -1 );
-    static OUString ToOUString( ScDocument& rDocument, const ScAddress& 
rAddress,
-                                const ScTokenArray* pTokenArray, const 
ScCompiler::OpCodeMapPtr & xOpCodeMap );
+    static OUString ToOUString( ScDocument& rDocument, const ScAddress& 
rAddress, const ScTokenArray* pTokenArray );
     static OUString ToOUString( const XclExpString& s );
     static const char* ToPsz( bool b );
 
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx 
b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index f4e4ff3..bcfab7b 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -984,8 +984,7 @@ static void lcl_WriteCell( XclExpXmlStream& rStrm, 
sal_Int32 nElement, const ScA
                     FSEND );
             pStream->writeEscaped( XclXmlUtils::ToOUString(
                         *pData->mpFormulaCell->GetDocument(),
-                        pData->mpFormulaCell->aPos, 
pData->mpFormulaCell->GetCode(),
-                        rStrm.GetRoot().GetOpCodeMap() ) );
+                        pData->mpFormulaCell->aPos, 
pData->mpFormulaCell->GetCode()));
             pStream->endElement( XML_f );
             break;
         case EXC_CHTR_TYPE_STRING:
commit 5f5cce2ca3ed6aa05bdaa4cdb046efeb6904d9a3
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Mon Mar 10 13:18:01 2014 -0400

    fdo#75950: Add test for this.
    
    Change-Id: I92253daf4793b50eb2928a1e368fa6231d2f285a

diff --git a/sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx 
b/sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx
new file mode 100644
index 0000000..2fb95b5
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index f2f653b..5eb4eca 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -88,6 +88,7 @@ public:
     void testCellBordersXLSX();
 
     void testSharedFormulaExportXLS();
+    void testSharedFormulaExportXLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -113,6 +114,7 @@ public:
     CPPUNIT_TEST(testCellBordersXLS);
     CPPUNIT_TEST(testCellBordersXLSX);
     CPPUNIT_TEST(testSharedFormulaExportXLS);
+    CPPUNIT_TEST(testSharedFormulaExportXLSX);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1175,6 +1177,78 @@ void ScExportTest::testSharedFormulaExportXLS()
     xDocSh2->DoClose();
 }
 
+void ScExportTest::testSharedFormulaExportXLSX()
+{
+    struct
+    {
+        bool checkContent( ScDocument* pDoc )
+        {
+            // B2:B7 should show 1,2,3,4,5,6.
+            double fExpected = 1.0;
+            for (SCROW i = 1; i <= 6; ++i, ++fExpected)
+            {
+                ScAddress aPos(1,i,0);
+                double fVal = pDoc->GetValue(aPos);
+                if (fVal != fExpected)
+                {
+                    cerr << "Wrong value in B" << (i+1) << ": expected=" << 
fExpected << ", actual=" << fVal << endl;
+                    return false;
+                }
+            }
+
+            // C2:C7 should show 10,20,....,60.
+            fExpected = 10.0;
+            for (SCROW i = 1; i <= 6; ++i, fExpected+=10.0)
+            {
+                ScAddress aPos(2,i,0);
+                double fVal = pDoc->GetValue(aPos);
+                if (fVal != fExpected)
+                {
+                    cerr << "Wrong value in C" << (i+1) << ": expected=" << 
fExpected << ", actual=" << fVal << endl;
+                    return false;
+                }
+            }
+
+            // D2:D7 should show 1,2,...,6.
+            fExpected = 1.0;
+            for (SCROW i = 1; i <= 6; ++i, ++fExpected)
+            {
+                ScAddress aPos(3,i,0);
+                double fVal = pDoc->GetValue(aPos);
+                if (fVal != fExpected)
+                {
+                    cerr << "Wrong value in D" << (i+1) << ": expected=" << 
fExpected << ", actual=" << fVal << endl;
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+    } aTest;
+
+    ScDocShellRef xDocSh = loadDoc("shared-formula/3d-reference.", XLSX);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+    pDoc->CalcAll(); // Recalculate to flush all cached results.
+
+    bool bRes = aTest.checkContent(pDoc);
+    CPPUNIT_ASSERT_MESSAGE("Content check on the initial document failed.", 
bRes);
+
+    // Save and reload, and check the content again.
+    ScDocShellRef xDocSh2 = saveAndReload(xDocSh, XLSX);
+    xDocSh->DoClose();
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh2.Is());
+    pDoc = xDocSh2->GetDocument();
+    pDoc->CalcAll(); // Recalculate to flush all cached results.
+
+    bRes = aTest.checkContent(pDoc);
+    CPPUNIT_ASSERT_MESSAGE("Content check on the reloaded document failed.", 
bRes);
+
+    xDocSh2->DoClose();
+}
+
 ScExportTest::ScExportTest()
       : ScBootstrapFixture("/sc/qa/unit/data")
 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to