Blob Blame History Raw
From e8a321db4419be43c693d5b5d06bfda25709d2f5 Mon Sep 17 00:00:00 2001
Message-Id: <e8a321db4419be43c693d5b5d06bfda25709d2f5.1328721558.git.erack@redhat.com>
From: Eike Rathke <erack@erack.de>
Date: Wed, 8 Feb 2012 10:42:04 -0500
Subject: [PATCH] fix fdo#40590 stop abusing regular string token for XML
 import
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------erAck-patch-parts"

This is a multi-part message in MIME format.
--------------erAck-patch-parts
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


During XML import formulas of defined names and conditional formatting
were remembered as regular svString tokens that then later were
retrieved without quotes for compilation. This didn't go along with the
new ScRangeData::CompileUnresolvedXML() that recreates the formula
string from an already tokenized form of the formula.

Introduced FormulaToken::AddStringXML() with ocStringXML to sort those
out and removed the IsImportingXML() hack from
FormulaCompiler::AppendString(), the ocStringXML case is handled in
FormulaCompiler::CreateStringFromToken().

Signed-off-by: Kohei Yoshida <kohei.yoshida@suse.com>
---
 sc/inc/compiler.hxx               |    1 -
 sc/source/core/data/conditio.cxx  |   12 ++++++------
 sc/source/core/tool/compiler.cxx  |    4 ----
 sc/source/ui/docshell/docfunc.cxx |    4 ++--
 4 files changed, 8 insertions(+), 13 deletions(-)


--------------erAck-patch-parts
Content-Type: text/x-patch; name="0002-fix-fdo-40590-stop-abusing-regular-string-token-for-.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0002-fix-fdo-40590-stop-abusing-regular-string-token-for-.patch"

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 6947460..d317150 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -542,7 +542,6 @@ private:
     virtual void CreateStringFromMatrix( rtl::OUStringBuffer& rBuffer, formula::FormulaToken* _pTokenP);
     virtual void CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
     virtual void LocalizeString( String& rName );	// modify rName - input: exact name
-    virtual sal_Bool IsImportingXML() const;
 
     /// Access the CharTable flags
     inline sal_uLong GetCharTableFlags( sal_Unicode c, sal_Unicode cLast )
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 642c39b..f3571c5 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -316,10 +316,10 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
             aComp.SetGrammar( eGrammar1 );
             if ( pDoc->IsImportingXML() && !bTextToReal )
             {
-                //	temporary formula string as string tokens
-                //!	merge with lcl_ScDocFunc_CreateTokenArrayXML
+                //  temporary formula string as string tokens
+                //! merge with lcl_ScDocFunc_CreateTokenArrayXML
                 pFormula1 = new ScTokenArray;
-                pFormula1->AddString( rExpr1 );
+                pFormula1->AddStringXML( rExpr1 );
                 // bRelRef1 is set when the formula is compiled again (CompileXML)
             }
             else
@@ -353,10 +353,10 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
             aComp.SetGrammar( eGrammar2 );
             if ( pDoc->IsImportingXML() && !bTextToReal )
             {
-                //	temporary formula string as string tokens
-                //!	merge with lcl_ScDocFunc_CreateTokenArrayXML
+                //  temporary formula string as string tokens
+                //! merge with lcl_ScDocFunc_CreateTokenArrayXML
                 pFormula2 = new ScTokenArray;
-                pFormula2->AddString( rExpr2 );
+                pFormula2->AddStringXML( rExpr2 );
                 // bRelRef2 is set when the formula is compiled again (CompileXML)
             }
             else
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a4938f1..542b1d0 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5123,10 +5123,6 @@ void ScCompiler::LocalizeString( String& rName )
     ScGlobal::GetAddInCollection()->LocalizeString( rName );
 }
 // -----------------------------------------------------------------------------
-sal_Bool ScCompiler::IsImportingXML() const
-{
-    return pDoc->IsImportingXML();
-}
 
 // Put quotes around string if non-alphanumeric characters are contained,
 // quote characters contained within are escaped by '\\'.
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index c4df591..9349da8 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1008,9 +1008,9 @@ sal_Bool ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngi
 ScTokenArray* lcl_ScDocFunc_CreateTokenArrayXML( const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
 {
     ScTokenArray* pCode = new ScTokenArray;
-    pCode->AddString( rText );
+    pCode->AddStringXML( rText );
     if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && (rFormulaNmsp.Len() > 0) )
-        pCode->AddString( rFormulaNmsp );
+        pCode->AddStringXML( rFormulaNmsp );
     return pCode;
 }
 

--------------erAck-patch-parts--