diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-15 10:12:52 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-02-17 15:14:39 +0000 |
commit | fc7d5cfe5611a90beb16c15cc0a2304ef2c15acc (patch) | |
tree | 3549369d11a48ad815719a5d2e42109b0136e3d1 | |
parent | 9cc2ab21d3e18d6ab331e06fd96309bad047615c (diff) |
fdo#74512: Fix the ODS export as well.
Change-Id: I54a2b2f405f9172d2ec5646346ef4e8a7ae27cb2
(cherry picked from commit 9a5ce676ede4828db0acde5db79d91320575ec08)
Reviewed-on: https://gerrit.libreoffice.org/8074
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/inc/tokenstringcontext.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/tokenstringcontext.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 20 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.hxx | 7 |
5 files changed, 28 insertions, 7 deletions
diff --git a/sc/inc/tokenstringcontext.hxx b/sc/inc/tokenstringcontext.hxx index 3740f60146bf..aa61adad0288 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 13b3a8509f30..22a5035a20ab 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 203d36aaf3e8..7586a31e7a43 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 62c0da4a4264..d5c025d45c18 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> @@ -3175,21 +3176,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 564009d4eb63..430832814958 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; |