[Libreoffice-commits] core.git: 2 commits - formula/source include/formula sc/source

Eike Rathke erack at redhat.com
Fri Apr 24 08:05:53 PDT 2015


 formula/source/core/api/FormulaCompiler.cxx |   14 +++++++++++++-
 include/formula/FormulaCompiler.hxx         |    6 ++++++
 sc/source/core/tool/compiler.cxx            |    2 +-
 sc/source/core/tool/token.cxx               |    1 +
 4 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit beb2b25c97bbbe37309a6186269b30be7b0d7a6f
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Apr 24 16:55:14 2015 +0200

    TableRef: clone mxAreaRefRPN
    
    ... in case formula is copied to rewrite some tokens.
    
    Change-Id: I005e9fa354da1a5ebc7a78670337b403ffb21567

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6612b64..9645663 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -839,6 +839,7 @@ ScTableRefToken::ScTableRefToken( sal_uInt16 nIndex, ScTableRefToken::Item eItem
 
 ScTableRefToken::ScTableRefToken( const ScTableRefToken& r ) :
     FormulaToken(r),
+    mxAreaRefRPN(r.mxAreaRefRPN),
     mnIndex(r.mnIndex),
     meItem(r.meItem)
 {
commit 13b9e62d66d1d34dcc66c0f6df592a7129fa3d0a
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Apr 24 16:51:36 2015 +0200

    TableRef: centralized FormulaCompiler::NeedsTableRefTransformation()
    
    ... and include OOXML until we actually write Table.
    
    Change-Id: I95fa65bd593c72af409728cea1ec599481beaaab

diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 515c1fa..dac5283 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1868,7 +1868,7 @@ const FormulaToken* FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuf
 
             case svIndex:
                 CreateStringFromIndex( rBuffer, t );
-                if (t->GetOpCode() == ocTableRef && bAllowArrAdvance && mxSymbols->getSymbol( ocTableRefOpen).isEmpty())
+                if (t->GetOpCode() == ocTableRef && bAllowArrAdvance && NeedsTableRefTransformation())
                 {
                     // Suppress all TableRef related tokens, the resulting
                     // range was written by CreateStringFromIndex().
@@ -1989,6 +1989,18 @@ void FormulaCompiler::AppendString( OUStringBuffer& rBuffer, const OUString & rS
     rBuffer.append( '"');
 }
 
+bool FormulaCompiler::NeedsTableRefTransformation() const
+{
+    /* TODO: currently only UI representations use Table structured
+     * references. Not defined in ODFF, and not implemented yet for OOXML
+     * export. Change this once OOXML export is implemented, until then write
+     * A1 style references also for OOXML to not lose functionality. */
+    // Unnecessary to explicitly check for ODFF grammar as the ocTableRefOpen
+    // symbol is not defined there.
+    return mxSymbols->getSymbol( ocTableRefOpen).isEmpty() || FormulaGrammar::isPODF( meGrammar)
+        || FormulaGrammar::isOOXML( meGrammar);
+}
+
 void FormulaCompiler::UpdateSeparatorsNative(
     const OUString& rSep, const OUString& rArrayColSep, const OUString& rArrayRowSep )
 {
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index 4137e62..7d95ff1 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -255,6 +255,12 @@ public:
         including an address reference convention. */
     inline  FormulaGrammar::Grammar   GetGrammar() const { return meGrammar; }
 
+    /** Whether current symbol set and grammar need transformation of Table
+        structured references to A1 style references when writing / exporting
+        (creating strings).
+     */
+    bool NeedsTableRefTransformation() const;
+
     static void UpdateSeparatorsNative( const OUString& rSep, const OUString& rArrayColSep, const OUString& rArrayRowSep );
     static void ResetNativeSymbols();
     static void SetNativeSymbols( const OpCodeMapPtr& xMap );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index e1e48a8..a2f83eb 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4597,7 +4597,7 @@ void ScCompiler::CreateStringFromIndex( OUStringBuffer& rBuffer, const FormulaTo
         break;
         case ocTableRef:
         {
-            if (mxSymbols->getSymbol( ocTableRefOpen).isEmpty())
+            if (NeedsTableRefTransformation())
             {
                 // Write the resulting reference if TableRef is not supported.
                 const ScTableRefToken* pTR = dynamic_cast<const ScTableRefToken*>(_pTokenP);


More information about the Libreoffice-commits mailing list