summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-12-30 12:32:14 +0100
committerJochen Nitschke <j.nitschke+logerrit@ok.de>2017-01-03 00:14:16 +0000
commit9efa11a1090ab088c64a26dacea5d6f40d7878e6 (patch)
treebcc10d420bb7f26e0d9564da9327bdd51e674b17
parent6cea397a95dab91ebf37f25e443393c22da065f7 (diff)
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@ok.de> Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
-rw-r--r--sc/source/filter/inc/addressconverter.hxx4
-rw-r--r--sc/source/filter/inc/pivottablebuffer.hxx4
-rw-r--r--sc/source/filter/inc/workbookhelper.hxx3
-rw-r--r--sc/source/filter/oox/addressconverter.cxx23
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx4
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx14
6 files changed, 47 insertions, 5 deletions
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index f1afeb2d232b..9e6a71ecbdcb 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 1838c539fb5d..f3bc3daf4821 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 c694e993449e..2887d4d3a0bd 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 47132e817fa1..d071df437087 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 5a0281b4e207..37a1c4674622 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 73cc67c05fe9..2d7d6a0b7234 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*/ );