[Libreoffice-commits] core.git: Branch 'libreoffice-4-2-1' - 2 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Feb 18 01:20:55 CET 2014


 sc/inc/tokenstringcontext.hxx              |    1 +
 sc/source/core/tool/compiler.cxx           |    1 +
 sc/source/core/tool/tokenstringcontext.cxx |    6 ++++++
 sc/source/filter/xml/xmlexprt.cxx          |   27 +++++++++++++--------------
 sc/source/filter/xml/xmlexprt.hxx          |    7 +++++++
 5 files changed, 28 insertions(+), 14 deletions(-)

New commits:
commit a8a4d42c15f38ed7c8595179263239f9e8b7824f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Feb 14 11:41:02 2014 -0500

    fdo#72390: Let's not skip auto styles from unmodified sheets.
    
    We do re-use sheet XML stream for unmodified sheets on re-save, which
    is okay.  But skipping auto style population from unmodified sheets
    is not okay because autostyles are shared across all sheets and written
    outside the sheet XML streams. Skipping styles from unmodified sheets
    could potentially fail to export used styles, not to mention could
    cause a crash as reported in the bug.
    
    Change-Id: I73e439f7354e341c2c07e28ecca5452193985860
    (cherry picked from commit 5000e64ecc55efd47d92714cf6db375ff37aac4b)
    (cherry picked from commit 47e540d8323e8ea2db5e7aae455503b32f306ca3)
    Reviewed-on: https://gerrit.libreoffice.org/8050
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-by: Jacobo Aragunde Pérez <jaragunde at igalia.com>
    Tested-by: Jacobo Aragunde Pérez <jaragunde at igalia.com>

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 2bb6769..d5c025d 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2533,10 +2533,6 @@ void ScXMLExport::_ExportAutoStyles()
         CollectShapesAutoStyles(nTableCount);
         for (sal_Int32 nTable = 0; nTable < nTableCount; ++nTable, IncrementProgressBar(false))
         {
-            bool bUseStream = pSheetData && pDoc && pDoc->IsStreamValid((SCTAB)nTable) &&
-                              pSheetData->HasStreamPos(nTable) && xSourceStream.is() &&
-                              !pDoc->GetChangeTrack();
-
             Reference <sheet::XSpreadsheet> xTable(xIndex->getByIndex(nTable), uno::UNO_QUERY);
             if (!xTable.is())
                 continue;
@@ -2555,9 +2551,6 @@ void ScXMLExport::_ExportAutoStyles()
                 }
             }
 
-            if (bUseStream)
-                continue;
-
             // collect other auto-styles only for non-copied sheets
             Reference<sheet::XUniqueCellFormatRangesSupplier> xCellFormatRanges ( xTable, uno::UNO_QUERY );
             if ( xCellFormatRanges.is() )
commit 8deefff6659fda0e38734c2b3176826276debb5d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Sat Feb 15 10:12:52 2014 -0500

    fdo#74512: Fix the ODS export as well.
    
    Change-Id: I54a2b2f405f9172d2ec5646346ef4e8a7ae27cb2
    (cherry picked from commit 9a5ce676ede4828db0acde5db79d91320575ec08)
    Reviewed-on: https://gerrit.libreoffice.org/8075
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-by: Jacobo Aragunde Pérez <jaragunde at igalia.com>
    Tested-by: Jacobo Aragunde Pérez <jaragunde at igalia.com>

diff --git a/sc/inc/tokenstringcontext.hxx b/sc/inc/tokenstringcontext.hxx
index 3740f60..aa61ada 100644
--- a/sc/inc/tokenstringcontext.hxx
+++ b/sc/inc/tokenstringcontext.hxx
@@ -56,6 +56,7 @@ class CompileFormulaContext
 
 public:
     CompileFormulaContext( ScDocument* pDoc );
+    CompileFormulaContext( ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram );
 
     formula::FormulaGrammar::Grammar getGrammar() const;
     void setGrammar( formula::FormulaGrammar::Grammar eGram );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 13b3a85..22a5035 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1628,6 +1628,7 @@ void ScCompiler::CheckTabQuotes( OUString& rString,
         case FormulaGrammar::CONV_XL_A1 :
         case FormulaGrammar::CONV_XL_R1C1 :
         case FormulaGrammar::CONV_XL_OOX :
+        case FormulaGrammar::CONV_ODF :
             if( bNeedsQuote )
             {
                 const OUString one_quote('\'');
diff --git a/sc/source/core/tool/tokenstringcontext.cxx b/sc/source/core/tool/tokenstringcontext.cxx
index 203d36a..7586a31 100644
--- a/sc/source/core/tool/tokenstringcontext.cxx
+++ b/sc/source/core/tool/tokenstringcontext.cxx
@@ -114,6 +114,12 @@ CompileFormulaContext::CompileFormulaContext( ScDocument* pDoc ) :
     updateTabNames();
 }
 
+CompileFormulaContext::CompileFormulaContext( ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ) :
+    mpDoc(pDoc), meGram(eGram)
+{
+    updateTabNames();
+}
+
 void CompileFormulaContext::updateTabNames()
 {
     // Fetch all sheet names.
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 42c90fa..2bb6769 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -63,6 +63,7 @@
 #include <arealink.hxx>
 #include <datastream.hxx>
 #include <documentlinkmgr.hxx>
+#include <tokenstringcontext.hxx>
 
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnmspe.hxx>
@@ -3182,21 +3183,26 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
             {
                 if (aCell.maBaseCell.meType == CELLTYPE_FORMULA)
                 {
-                    OUStringBuffer sFormula;
                     ScFormulaCell* pFormulaCell = aCell.maBaseCell.mpFormula;
                     if (!bIsMatrix || (bIsMatrix && bIsFirstMatrixCell))
                     {
-                        const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
-                        sal_uInt16 nNamespacePrefix = (eGrammar == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
-                        pFormulaCell->GetFormula(sFormula, eGrammar);
-                        OUString sOUFormula(sFormula.makeStringAndClear());
+                        if (!mpCompileFormulaCxt)
+                        {
+                            const formula::FormulaGrammar::Grammar eGrammar = pDoc->GetStorageGrammar();
+                            mpCompileFormulaCxt.reset(new sc::CompileFormulaContext(pDoc, eGrammar));
+                        }
+
+                        OUString aFormula = pFormulaCell->GetFormula(*mpCompileFormulaCxt);
+                        sal_uInt16 nNamespacePrefix =
+                            (mpCompileFormulaCxt->getGrammar() == formula::FormulaGrammar::GRAM_ODFF ? XML_NAMESPACE_OF : XML_NAMESPACE_OOOC);
+
                         if (!bIsMatrix)
                         {
-                            AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula, false ));
+                            AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey(nNamespacePrefix, aFormula, false));
                         }
                         else
                         {
-                            AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey( nNamespacePrefix, sOUFormula.copy(1, sOUFormula.getLength() - 2), false ));
+                            AddAttribute(sAttrFormula, GetNamespaceMap().GetQNameByKey(nNamespacePrefix, aFormula.copy(1, aFormula.getLength()-2), false));
                         }
                     }
                     if (pFormulaCell->GetErrCode())
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 564009d..4308328 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -63,6 +63,12 @@ class ScXMLEditAttributeMap;
 class EditTextObject;
 class ScFormulaCell;
 
+namespace sc {
+
+class CompileFormulaContext;
+
+}
+
 typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec;
 
 class ScXMLExport : public SvXMLExport
@@ -76,6 +82,7 @@ class ScXMLExport : public SvXMLExport
 
     mutable boost::scoped_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
     boost::scoped_ptr<ScMyNotEmptyCellsIterator> mpCellsItr;
+    boost::scoped_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
     UniReference < XMLPropertyHandlerFactory >  xScPropHdlFactory;
     UniReference < XMLPropertySetMapper >       xCellStylesPropertySetMapper;
     UniReference < XMLPropertySetMapper >       xColumnStylesPropertySetMapper;


More information about the Libreoffice-commits mailing list