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

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


 sc/source/filter/inc/addressconverter.hxx |    4 ++++
 sc/source/filter/inc/pivottablebuffer.hxx |    4 +---
 sc/source/filter/inc/workbookhelper.hxx   |    3 +++
 sc/source/filter/oox/addressconverter.cxx |   23 +++++++++++++++++++++++
 sc/source/filter/oox/pivottablebuffer.cxx |    4 ++--
 sc/source/filter/oox/workbookhelper.cxx   |   14 ++++++++++++++
 6 files changed, 47 insertions(+), 5 deletions(-)

New commits:
commit 9efa11a1090ab088c64a26dacea5d6f40d7878e6
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Fri Dec 30 12:32:14 2016 +0100

    tdf#48140 replace CellRangeAddress in xlsx import (1)
    
    Change-Id: I0ce4101c4f9f5554e505f170e95119431a8963f8
    Reviewed-on: https://gerrit.libreoffice.org/32570
    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/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index f1afeb2d..9e6a71e 100644
--- a/sc/source/filter/inc/addressconverter.hxx
+++ b/sc/source/filter/inc/addressconverter.hxx
@@ -400,6 +400,10 @@ public:
                             css::table::CellRangeAddress& orRange,
                             bool bAllowOverflow, bool bTrackOverflow );
 
+    bool                validateCellRange(
+                            ScRange& orRange,
+                            bool bAllowOverflow, bool bTrackOverflow );
+
     /** Converts the passed string to a cell range address, without checking
         any sheet limits.
 
diff --git a/sc/source/filter/inc/pivottablebuffer.hxx b/sc/source/filter/inc/pivottablebuffer.hxx
index 1838c53..f3bc3da 100644
--- a/sc/source/filter/inc/pivottablebuffer.hxx
+++ b/sc/source/filter/inc/pivottablebuffer.hxx
@@ -20,7 +20,6 @@
 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_PIVOTTABLEBUFFER_HXX
 #define INCLUDED_SC_SOURCE_FILTER_INC_PIVOTTABLEBUFFER_HXX
 
-#include <com/sun/star/table/CellRangeAddress.hpp>
 #include "pivotcachebuffer.hxx"
 #include "stylesbuffer.hxx"
 
@@ -271,8 +270,7 @@ struct PTDefinitionModel : public AutoFormatModel
 
 struct PTLocationModel
 {
-    css::table::CellRangeAddress
-                        maRange;            /// Target cell range for the pivot table.
+    ScRange             maRange;            /// Target cell range for the pivot table.
     sal_Int32           mnFirstHeaderRow;   /// First row of header cells (relative in pivot table).
     sal_Int32           mnFirstDataRow;     /// First row of data cells (relative in pivot table).
     sal_Int32           mnFirstDataCol;     /// First column of data cells (relative in pivot table).
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index c694e99..2887d4d 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -156,6 +156,9 @@ public:
     css::uno::Reference< css::table::XCellRange >
                         getCellRangeFromDoc(
                             const css::table::CellRangeAddress& rRange ) const;
+    css::uno::Reference< css::table::XCellRange >
+                        getCellRangeFromDoc( const ScRange& rRange ) const;
+
 
     /** Returns the cell styles container from the Calc document. */
     css::uno::Reference< css::container::XNameContainer >
diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx
index 47132e8..d071df4 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -383,6 +383,29 @@ bool AddressConverter::checkCellRange( const CellRangeAddress& rRange, bool bAll
         checkRow( rRange.StartRow, bTrackOverflow );
 }
 
+bool AddressConverter::validateCellRange( ScRange& orRange, bool bAllowOverflow, bool bTrackOverflow )
+{
+    if( orRange.aStart.Col() > orRange.aEnd.Col() )
+    {
+        SCCOL nCol = orRange.aStart.Col();
+        orRange.aStart.SetCol( orRange.aEnd.Col() );
+        orRange.aEnd.SetCol( nCol );
+    }
+    if( orRange.aStart.Row() > orRange.aEnd.Row() )
+    {
+        SCROW nRow = orRange.aStart.Row();
+        orRange.aStart.SetRow( orRange.aEnd.Row() );
+        orRange.aEnd.SetRow( nRow );
+    }
+    if( !checkCellRange( orRange, bAllowOverflow, bTrackOverflow ) )
+        return false;
+    if( orRange.aEnd.Col() > maMaxPos.Col() )
+        orRange.aEnd.SetCol( maMaxPos.Col() );
+    if( orRange.aEnd.Row() > maMaxPos.Row() )
+        orRange.aEnd.SetRow( maMaxPos.Row() );
+    return true;
+}
+
 bool AddressConverter::validateCellRange( CellRangeAddress& orRange, bool bAllowOverflow, bool bTrackOverflow )
 {
     if( orRange.StartColumn > orRange.EndColumn )
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 5a0281b..37a1c46 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -1199,7 +1199,7 @@ void PivotTable::finalizeImport()
             try
             {
                 // create a new data pilot descriptor based on the source data
-                Reference< XDataPilotTablesSupplier > xDPTablesSupp( getSheetFromDoc( maLocationModel.maRange.Sheet ), UNO_QUERY_THROW );
+                Reference< XDataPilotTablesSupplier > xDPTablesSupp( getSheetFromDoc( maLocationModel.maRange.aStart.Tab() ), UNO_QUERY_THROW );
                 Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
                 mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
                 ScRange aRange = mpPivotCache->getSourceRange();
@@ -1269,7 +1269,7 @@ void PivotTable::finalizeImport()
                 maFilters.forEachMem( &PivotTableFilter::finalizeImport );
 
                 // calculate base position of table
-                CellAddress aPos( maLocationModel.maRange.Sheet, maLocationModel.maRange.StartColumn, maLocationModel.maRange.StartRow );
+                CellAddress aPos( maLocationModel.maRange.aStart.Tab(), maLocationModel.maRange.aStart.Col(), maLocationModel.maRange.aStart.Row() );
                 /*  If page fields exist, include them into the destination
                     area (they are excluded in Excel). Add an extra blank row. */
                 if( !maPageFields.empty() )
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 73cc67c..2d7d6a0 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -799,6 +799,20 @@ Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const CellRangeAddr
     return xRange;
 }
 
+Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
+{
+    Reference< XCellRange > xRange;
+    try
+    {
+        Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
+        xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
+    }
+    catch( Exception& )
+    {
+    }
+    return xRange;
+}
+
 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
 {
     return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );


More information about the Libreoffice-commits mailing list