[Libreoffice-commits] .: formula/inc formula/source sc/inc sc/source
Eike Rathke
erack at kemper.freedesktop.org
Sun Sep 11 06:21:37 PDT 2011
formula/inc/formula/FormulaCompiler.hxx | 1 -
formula/inc/formula/compiler.hrc | 25 +++++++++++++------------
formula/inc/formula/opcode.hxx | 1 +
formula/inc/formula/tokenarray.hxx | 1 +
formula/source/core/api/FormulaCompiler.cxx | 24 +++++++-----------------
formula/source/core/api/token.cxx | 7 +++++++
sc/inc/compiler.hxx | 1 -
sc/source/core/data/conditio.cxx | 4 ++--
sc/source/core/tool/compiler.cxx | 4 ----
sc/source/ui/docshell/docfunc.cxx | 4 ++--
10 files changed, 33 insertions(+), 39 deletions(-)
New commits:
commit 34c9a01b075788653b89c244eb8b3fcee54bfa68
Author: Eike Rathke <erack at erack.de>
Date: Sun Sep 11 14:56:32 2011 +0200
fix fdo#40590 stop abusing regular string token for XML import
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().
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx
index 825a31e..2151152 100644
--- a/formula/inc/formula/FormulaCompiler.hxx
+++ b/formula/inc/formula/FormulaCompiler.hxx
@@ -273,7 +273,6 @@ protected:
virtual void CreateStringFromMatrix(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP);
virtual void CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken* pTokenP);
virtual void LocalizeString( String& rName ); // modify rName - input: exact name
- virtual bool IsImportingXML() const;
sal_uInt16 GetErrorConstant( const String& rName );
void AppendErrorConstant( rtl::OUStringBuffer& rBuffer, sal_uInt16 nError );
diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc
index a7b5cd8..49252ce 100755
--- a/formula/inc/formula/compiler.hrc
+++ b/formula/inc/formula/compiler.hrc
@@ -44,18 +44,19 @@
#define SC_OPCODE_SEP 10
#define SC_OPCODE_MISSING 11 /* special OpCodes */
#define SC_OPCODE_BAD 12
-#define SC_OPCODE_SPACES 13
-#define SC_OPCODE_MAT_REF 14
-#define SC_OPCODE_DB_AREA 15 /* additional access operators */
-#define SC_OPCODE_MACRO 16
-#define SC_OPCODE_COL_ROW_NAME 17
-#define SC_OPCODE_COL_ROW_NAME_AUTO 18
-#define SC_OPCODE_PERCENT_SIGN 19 /* operator _follows_ value */
-#define SC_OPCODE_ARRAY_OPEN 20
-#define SC_OPCODE_ARRAY_CLOSE 21
-#define SC_OPCODE_ARRAY_ROW_SEP 22
-#define SC_OPCODE_ARRAY_COL_SEP 23 /* some convs use sep != col_sep */
-#define SC_OPCODE_STOP_DIV 24
+#define SC_OPCODE_STRINGXML 13
+#define SC_OPCODE_SPACES 14
+#define SC_OPCODE_MAT_REF 15
+#define SC_OPCODE_DB_AREA 16 /* additional access operators */
+#define SC_OPCODE_MACRO 17
+#define SC_OPCODE_COL_ROW_NAME 18
+#define SC_OPCODE_COL_ROW_NAME_AUTO 19
+#define SC_OPCODE_PERCENT_SIGN 20 /* operator _follows_ value */
+#define SC_OPCODE_ARRAY_OPEN 21
+#define SC_OPCODE_ARRAY_CLOSE 22
+#define SC_OPCODE_ARRAY_ROW_SEP 23
+#define SC_OPCODE_ARRAY_COL_SEP 24 /* some convs use sep != col_sep */
+#define SC_OPCODE_STOP_DIV 25
/*** error constants #... ***/
#define SC_OPCODE_START_ERRORS 30
diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx
index 571e1b0..e562c27 100644
--- a/formula/inc/formula/opcode.hxx
+++ b/formula/inc/formula/opcode.hxx
@@ -55,6 +55,7 @@ enum OpCodeEnum
// Special OpCodes
ocMissing = SC_OPCODE_MISSING,
ocBad = SC_OPCODE_BAD,
+ ocStringXML = SC_OPCODE_STRINGXML,
ocSpaces = SC_OPCODE_SPACES,
ocMatRef = SC_OPCODE_MAT_REF,
// Access commands
diff --git a/formula/inc/formula/tokenarray.hxx b/formula/inc/formula/tokenarray.hxx
index 8ec6a56..3947ed5 100644
--- a/formula/inc/formula/tokenarray.hxx
+++ b/formula/inc/formula/tokenarray.hxx
@@ -214,6 +214,7 @@ public:
FormulaToken* AddExternal( const String& rStr, OpCode eOp = ocExternal );
FormulaToken* AddBad( const sal_Unicode* pStr ); /// ocBad with String
FormulaToken* AddBad( const String& rStr ); /// ocBad with String
+ FormulaToken* AddStringXML( const String& rStr ); /// ocStringXML with String, temporary during import
virtual FormulaToken* MergeArray( );
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index e1122c2..8108f11 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1683,7 +1683,7 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( rtl::OUStringBuffer& rBuff
break;
case svString:
- if( eOp == ocBad )
+ if( eOp == ocBad || eOp == ocStringXML )
rBuffer.append(t->GetString());
else
AppendString( rBuffer, t->GetString() );
@@ -1770,28 +1770,18 @@ void FormulaCompiler::AppendBoolean( rtl::OUStringBuffer& rBuffer, bool bVal )
rBuffer.append( mxSymbols->getSymbol(static_cast<OpCode>(bVal ? ocTrue : ocFalse)) );
}
// -----------------------------------------------------------------------------
-bool FormulaCompiler::IsImportingXML() const
-{
- return false;
-}
-// -----------------------------------------------------------------------------
void FormulaCompiler::AppendString( rtl::OUStringBuffer& rBuffer, const String & rStr )
{
- if (IsImportingXML())
+ rBuffer.append(sal_Unicode('"'));
+ if ( lcl_UnicodeStrChr( rStr.GetBuffer(), '"' ) == NULL )
rBuffer.append( rStr );
else
{
- rBuffer.append(sal_Unicode('"'));
- if ( lcl_UnicodeStrChr( rStr.GetBuffer(), '"' ) == NULL )
- rBuffer.append( rStr );
- else
- {
- String aStr( rStr );
- aStr.SearchAndReplaceAll( '"', String( RTL_CONSTASCII_USTRINGPARAM( "\"\"")));
- rBuffer.append(aStr);
- }
- rBuffer.append(sal_Unicode('"'));
+ String aStr( rStr );
+ aStr.SearchAndReplaceAll( '"', String( RTL_CONSTASCII_USTRINGPARAM( "\"\"")));
+ rBuffer.append(aStr);
}
+ rBuffer.append(sal_Unicode('"'));
}
void FormulaCompiler::UpdateSeparatorsNative(
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index 08a6738..745d628 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -329,6 +329,8 @@ bool FormulaTokenArray::AddFormulaToken(const sheet::FormulaToken& _aToken,Exter
AddString( aStrVal );
else if ( eOpCode == ocBad )
AddBad( aStrVal );
+ else if ( eOpCode == ocStringXML )
+ AddStringXML( aStrVal );
else if ( eOpCode == ocExternal || eOpCode == ocMacro )
AddToken( formula::FormulaExternalToken( eOpCode, aStrVal ) );
else
@@ -808,6 +810,11 @@ FormulaToken* FormulaTokenArray::AddBad( const String& rStr )
return Add( new FormulaStringOpToken( ocBad, rStr ) );
}
+FormulaToken* FormulaTokenArray::AddStringXML( const String& rStr )
+{
+ return Add( new FormulaStringOpToken( ocStringXML, rStr ) );
+}
+
void FormulaTokenArray::AddRecalcMode( ScRecalcMode nBits )
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index f7dde6a..371192c 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -544,7 +544,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 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 923f90d..757b738 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -319,7 +319,7 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
// 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
@@ -356,7 +356,7 @@ void ScConditionEntry::Compile( const String& rExpr1, const String& rExpr2,
// 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 3f227b4..cc6d69f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5206,10 +5206,6 @@ void ScCompiler::LocalizeString( String& rName )
ScGlobal::GetAddInCollection()->LocalizeString( rName );
}
// -----------------------------------------------------------------------------
-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 7410da8..dbb567f 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1010,9 +1010,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;
}
More information about the Libreoffice-commits
mailing list