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

Jochen Nitschke j.nitschke+logerrit at ok.de
Tue Jan 3 00:21:25 UTC 2017


 sc/source/filter/inc/formulabuffer.hxx    |    8 +++-----
 sc/source/filter/inc/worksheethelper.hxx  |    2 +-
 sc/source/filter/oox/formulabuffer.cxx    |   19 +++++++------------
 sc/source/filter/oox/sheetdatacontext.cxx |    6 +++++-
 sc/source/filter/oox/worksheethelper.cxx  |    2 +-
 5 files changed, 17 insertions(+), 20 deletions(-)

New commits:
commit b144ec03020b9d717bd7ccad0e6e4c84aa3f9898
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Sat Dec 31 03:53:42 2016 +0100

    tdf#48140 replace CellRangeAddress in xlsx import (11)
    
    Change-Id: I033b2ddb720942882aad5ceaa8b140546f32356d
    Reviewed-on: https://gerrit.libreoffice.org/32580
    Tested-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/sc/source/filter/inc/formulabuffer.hxx b/sc/source/filter/inc/formulabuffer.hxx
index 1d1bc77..9b0f28c 100644
--- a/sc/source/filter/inc/formulabuffer.hxx
+++ b/sc/source/filter/inc/formulabuffer.hxx
@@ -16,8 +16,6 @@
 #include <salhelper/thread.hxx>
 #include <osl/mutex.hxx>
 #include "workbookhelper.hxx"
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
 #include <map>
 #include <vector>
 #include "worksheethelper.hxx"
@@ -67,8 +65,8 @@ public:
     struct TokenRangeAddressItem
     {
         TokenAddressItem maTokenAndAddress;
-        css::table::CellRangeAddress maCellRangeAddress;
-        TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const css::table::CellRangeAddress& rCellRangeAddress ) : maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) {}
+        ScRange maRange;
+        TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ScRange& rRange ) : maTokenAndAddress( rTokenAndAddress ), maRange( rRange ) {}
     };
 
     struct FormulaValue
@@ -121,7 +119,7 @@ public:
     void setCellFormulaValue(
         const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
 
-    void                setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress,
+    void                setCellArrayFormula( const ScRange& rRangeAddress,
                                              const ScAddress& rTokenAddress,
                                              const OUString& );
 
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index e0d04ce..fdd2812 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -294,7 +294,7 @@ public:
         const ScAddress& rAddr, sal_Int32 nSharedId,
         const OUString& rCellValue, sal_Int32 nValueType );
 
-    void                setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const ScAddress& rTokenAddress, const OUString&  );
+    void                setCellArrayFormula( const ScRange& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr );
 
     void createSharedFormulaMapEntry(
         const ScAddress& rAddress,
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 003d0b9..dd00d45 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -13,7 +13,6 @@
 #include "formulacell.hxx"
 #include "document.hxx"
 #include "documentimport.hxx"
-#include "convuno.hxx"
 
 #include "rangelst.hxx"
 #include "autonamecache.hxx"
@@ -27,7 +26,6 @@
 
 using namespace com::sun::star;
 using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::table;
 using namespace ::com::sun::star::sheet;
 using namespace ::com::sun::star::container;
 
@@ -233,19 +231,16 @@ void applyArrayFormulas(
     ScDocumentImport& rDoc, SvNumberFormatter& rFormatter,
     const std::vector<FormulaBuffer::TokenRangeAddressItem>& rArrays )
 {
-    std::vector<FormulaBuffer::TokenRangeAddressItem>::const_iterator it = rArrays.begin(), itEnd = rArrays.end();
-    for (; it != itEnd; ++it)
+    for (const FormulaBuffer::TokenRangeAddressItem& rAddressItem : rArrays)
     {
-        const ScAddress& aPos = it->maTokenAndAddress.maCellAddress;
-        ScRange aRange;
-        ScUnoConversion::FillScRange(aRange, it->maCellRangeAddress);
+        const ScAddress& aPos = rAddressItem.maTokenAndAddress.maCellAddress;
 
         ScCompiler aComp(&rDoc.getDoc(), aPos);
         aComp.SetNumberFormatter(&rFormatter);
         aComp.SetGrammar(formula::FormulaGrammar::GRAM_OOXML);
-        std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(it->maTokenAndAddress.maTokenStr));
+        std::unique_ptr<ScTokenArray> pArray(aComp.CompileString(rAddressItem.maTokenAndAddress.maTokenStr));
         if (pArray)
-            rDoc.setMatrixCells(aRange, *pArray, formula::FormulaGrammar::GRAM_OOXML);
+            rDoc.setMatrixCells(rAddressItem.maRange, *pArray, formula::FormulaGrammar::GRAM_OOXML);
     }
 }
 
@@ -430,12 +425,12 @@ void FormulaBuffer::setCellFormula(
         SharedFormulaDesc(rAddress, nSharedId, rCellValue, nValueType));
 }
 
-void FormulaBuffer::setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
+void FormulaBuffer::setCellArrayFormula( const ScRange& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
 {
 
     TokenAddressItem tokenPair( rTokenStr, rTokenAddress );
-    assert( rRangeAddress.Sheet >= 0 && (size_t)rRangeAddress.Sheet < maCellArrayFormulas.size() );
-    maCellArrayFormulas[ rRangeAddress.Sheet ].push_back( TokenRangeAddressItem( tokenPair, rRangeAddress ) );
+    assert( rRangeAddress.aStart.Tab() >= 0 && (size_t)rRangeAddress.aStart.Tab() < maCellArrayFormulas.size() );
+    maCellArrayFormulas[ rRangeAddress.aStart.Tab() ].push_back( TokenRangeAddressItem( tokenPair, rRangeAddress ) );
 }
 
 void FormulaBuffer::setCellFormulaValue(
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index 9c47da5..dc679314 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -173,7 +173,11 @@ void SheetDataContext::onEndElement()
             break;
             case XML_array:
                 if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
-                    setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr );
+                {
+                    ScRange aRangeAddr( maFmlaData.maFormulaRef.StartColumn, maFmlaData.maFormulaRef.StartRow, maFmlaData.maFormulaRef.Sheet,
+                                        maFmlaData.maFormulaRef.EndColumn, maFmlaData.maFormulaRef.EndRow, maFmlaData.maFormulaRef.Sheet);
+                    setCellArrayFormula( aRangeAddr, maCellData.maCellAddr, maFormulaStr );
+                }
                 // set cell formatting, but do not set result as cell value
                 mrSheetData.setBlankCell( maCellData );
             break;
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 832f97e..2eccb82 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1592,7 +1592,7 @@ void WorksheetHelper::setCellFormula(
     getFormulaBuffer().setCellFormula(rAddr, nSharedId, rCellValue, nValueType);
 }
 
-void WorksheetHelper::setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
+void WorksheetHelper::setCellArrayFormula( const ScRange& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
 {
     getFormulaBuffer().setCellArrayFormula( rRangeAddress,  rTokenAddress, rTokenStr );
 }


More information about the Libreoffice-commits mailing list