sc/inc/document.hxx                     |    2 +-
 sc/source/filter/inc/defnamesbuffer.hxx |    5 +++++
 sc/source/filter/oox/defnamesbuffer.cxx |   17 +++++++++++++----
 sc/source/filter/oox/workbookhelper.cxx |   20 ++++++++++++++++++++
 4 files changed, 39 insertions(+), 5 deletions(-)

New commits:
commit 158b50763962f66515062300e265839828463efa
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Tue May 19 02:24:30 2015 +0200

    use XL_A1 as ref string syntax for excel produced documents
    
    Change-Id: Ieed3521674ef713d9c09313cd41d1edd6ba3dcc5

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 0a30c7b..7ea90f1 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2160,7 +2160,7 @@ public:
     SC_DLLPUBLIC void DumpAreaBroadcasters() const;
 #endif
 
-    void SetCalcConfig( const ScCalcConfig& rConfig );
+    SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig );
     const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; }
 
     void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo 
);
diff --git a/sc/source/filter/oox/workbookhelper.cxx 
b/sc/source/filter/oox/workbookhelper.cxx
index 96db289..f34332a 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -34,6 +34,8 @@
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/table/CellAddress.hpp>
 #include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <osl/thread.h>
 #include <oox/helper/progressbar.hxx>
 #include <oox/helper/propertyset.hxx>
@@ -521,6 +523,18 @@ void WorkbookGlobals::useInternalChartDataTable( bool 
bInternal )
 
 // private --------------------------------------------------------------------
 
+namespace {
+
+formula::FormulaGrammar::AddressConvention 
getConvention(css::uno::Reference<XDocumentProperties> xDocProps)
+{
+    if (xDocProps->getGenerator().startsWithIgnoreAsciiCase("Microsoft"))
+        return formula::FormulaGrammar::CONV_XL_A1;
+
+    return formula::FormulaGrammar::CONV_OOO;
+}
+
+}
+
 void WorkbookGlobals::initialize( bool bWorkbookFile )
 {
     maCellStyles = "CellStyles";
@@ -548,6 +562,12 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
     if (!mpDoc)
         throw RuntimeException("Workbookhelper::getScDocument(): Failed to 
access ScDocument from model");
 
+    Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
+    Reference< XDocumentProperties > xDocProps = 
xPropSupplier->getDocumentProperties();
+    ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
+    aCalcConfig.meStringRefAddressSyntax = getConvention(xDocProps);
+    mpDoc->SetCalcConfig(aCalcConfig);
+
     mxDocImport.reset(new ScDocumentImport(*mpDoc));
 
     mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
commit c43a25a7268c1b6ab81e9ba694a1f22223a24afa
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Tue May 19 01:45:57 2015 +0200

    replace import with direct ScCompiler calls, related tdf#91367
    
    Change-Id: Ib605536d002071ae753e7da87137deae00529272

diff --git a/sc/source/filter/inc/defnamesbuffer.hxx 
b/sc/source/filter/inc/defnamesbuffer.hxx
index 2ce6975..4177543 100644
--- a/sc/source/filter/inc/defnamesbuffer.hxx
+++ b/sc/source/filter/inc/defnamesbuffer.hxx
@@ -23,6 +23,10 @@
 #include "formulabase.hxx"
 #include "rangenam.hxx"
 
+#include <memory>
+
+class ScTokenArray;
+
 namespace com { namespace sun { namespace star {
     namespace sheet { class XNamedRange; }
 } } }
@@ -111,6 +115,7 @@ public:
     /** Converts the formula string or BIFF token array for this defined name. 
*/
     void                convertFormula();
     ApiTokenSequence    getTokens();
+    std::unique_ptr<ScTokenArray> getScTokens();
     /** Returns true, if this defined name is global in the document. */
     inline bool         isGlobalName() const { return mnCalcSheet < 0; }
     /** Returns true, if this defined name is a special builtin name. */
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx 
b/sc/source/filter/oox/defnamesbuffer.cxx
index dc30444..a24c96a 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -37,6 +37,7 @@
 #include "worksheetbuffer.hxx"
 #include "tokenarray.hxx"
 #include "tokenuno.hxx"
+#include "compiler.hxx"
 
 namespace oox {
 namespace xls {
@@ -380,6 +381,16 @@ DefinedName::getTokens()
     return aTokens;
 }
 
+std::unique_ptr<ScTokenArray> DefinedName::getScTokens()
+{
+    ScTokenArray aTokenArray;
+    ScCompiler aCompiler(&getScDocument(), ScAddress(0, 0, mnCalcSheet));
+    aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
+    std::unique_ptr<ScTokenArray> 
pArray(aCompiler.CompileString(maModel.maFormula));
+
+    return pArray;
+}
+
 void DefinedName::convertFormula()
 {
     // macro function or vba procedure
@@ -389,10 +400,8 @@ void DefinedName::convertFormula()
     // convert and set formula of the defined name
     if ( getFilterType() == FILTER_OOXML )
     {
-        ApiTokenSequence aTokens = getTokens();
-        ScTokenArray aTokenArray;
-        (void)ScTokenConversion::ConvertToTokenArray( this->getScDocument(), 
aTokenArray, aTokens );
-        mpScRangeData->SetCode( aTokenArray );
+        std::unique_ptr<ScTokenArray> pTokenArray = getScTokens();
+        mpScRangeData->SetCode( *pTokenArray );
     }
 
     ScTokenArray* pTokenArray = mpScRangeData->GetCode();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to