summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-12-31 17:06:13 +0100
committerJochen Nitschke <j.nitschke+logerrit@ok.de>2017-01-04 00:43:19 +0000
commit0ab8a27244e74e1c0916b3737f15c6c949aead78 (patch)
treea586f442e4952c77b2d59497f9d3f6eef205efb7
parent25625f18a282209235214674f2b81604ecd067ad (diff)
tdf#48140 replace CellRangeAddress in xlsx import (13)
Change-Id: I4e06b536db63d8782662023a83cc92956b519e11 Reviewed-on: https://gerrit.libreoffice.org/32698 Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de> Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
-rw-r--r--sc/source/filter/inc/sheetdatabuffer.hxx15
-rw-r--r--sc/source/filter/inc/worksheethelper.hxx2
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx37
-rw-r--r--sc/source/filter/oox/sheetdatacontext.cxx4
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx10
5 files changed, 30 insertions, 38 deletions
diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx
index 79758dd15316..bfef48c0c593 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -48,8 +48,7 @@ struct CellModel
/** Stores data about cell formulas. */
struct CellFormulaModel
{
- css::table::CellRangeAddress
- maFormulaRef; /// Formula range for array/shared formulas and data tables.
+ ScRange maFormulaRef; /// Formula range for array/shared formulas and data tables.
sal_Int32 mnFormulaType; /// Type of the formula (regular, array, shared, table).
sal_Int32 mnSharedId; /// Identifier of a shared formula (OOXML only).
@@ -129,11 +128,11 @@ public:
/** Inserts the passed token array as array formula. */
void createArrayFormula(
- const css::table::CellRangeAddress& rRange,
+ const ScRange& rRange,
const ApiTokenSequence& rTokens );
/** Sets a multiple table operation to the passed range. */
void createTableOperation(
- const css::table::CellRangeAddress& rRange,
+ const ScRange& rRange,
const DataTableModel& rModel );
/** Sets default cell formatting for the specified range of rows. */
@@ -160,22 +159,22 @@ private:
/** Inserts the passed array formula into the sheet. */
void finalizeArrayFormula(
- const css::table::CellRangeAddress& rRange,
+ const ScRange& rRange,
const ApiTokenSequence& rTokens ) const;
/** Inserts the passed table operation into the sheet. */
void finalizeTableOperation(
- const css::table::CellRangeAddress& rRange, const DataTableModel& rModel );
+ const ScRange& rRange, const DataTableModel& rModel );
/** Writes all cell formatting attributes to the passed cell range list. (depreciates writeXfIdRangeProperties) */
void applyCellMerging( const ScRange& rRange );
void addColXfStyle( sal_Int32 nXfId, sal_Int32 nFormatId, const css::table::CellRangeAddress& rAddress, bool bProcessRowRange = false );
private:
/** Stores cell range address and formula token array of an array formula. */
- typedef ::std::pair< css::table::CellRangeAddress, ApiTokenSequence > ArrayFormula;
+ typedef std::pair< ScRange, ApiTokenSequence > ArrayFormula;
typedef ::std::list< ArrayFormula > ArrayFormulaList;
/** Stores cell range address and settings of a table operation. */
- typedef ::std::pair< css::table::CellRangeAddress, DataTableModel > TableOperation;
+ typedef std::pair< ScRange, DataTableModel > TableOperation;
typedef ::std::list< TableOperation > TableOperationList;
/** Stores information about a range of rows with equal cell formatting. */
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index fdd2812ed4d1..a571a894161f 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -200,7 +200,7 @@ public:
getCell( const ScAddress& rAddress ) const;
/** Returns the XCellRange interface for the passed cell range address. */
css::uno::Reference< css::table::XCellRange >
- getCellRange( const css::table::CellRangeAddress& rRange ) const;
+ getCellRange( const ScRange& rRange ) const;
/** Returns the XDrawPage interface of the draw page of the current sheet. */
css::uno::Reference< css::drawing::XDrawPage >
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index e0025ec81779..dc13e2d140c8 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -43,7 +43,6 @@
#include "formulaparser.hxx"
#include "sharedstringsbuffer.hxx"
#include "unitconverter.hxx"
-#include "convuno.hxx"
#include "markdata.hxx"
#include "rangelst.hxx"
#include "document.hxx"
@@ -80,18 +79,15 @@ CellFormulaModel::CellFormulaModel() :
bool CellFormulaModel::isValidArrayRef( const ScAddress& rCellAddr )
{
- return
- (maFormulaRef.Sheet == rCellAddr.Tab() ) &&
- (maFormulaRef.StartColumn == rCellAddr.Col() ) &&
- (maFormulaRef.StartRow == rCellAddr.Row() );
+ return (maFormulaRef.aStart == rCellAddr );
}
bool CellFormulaModel::isValidSharedRef( const ScAddress& rCellAddr )
{
return
- (maFormulaRef.Sheet == rCellAddr.Tab() ) &&
- (maFormulaRef.StartColumn <= rCellAddr.Col() ) && (rCellAddr.Col() <= maFormulaRef.EndColumn) &&
- (maFormulaRef.StartRow <= rCellAddr.Row() ) && (rCellAddr.Row() <= maFormulaRef.EndRow);
+ (maFormulaRef.aStart.Tab() == rCellAddr.Tab() ) &&
+ (maFormulaRef.aStart.Col() <= rCellAddr.Col() ) && (rCellAddr.Col() <= maFormulaRef.aEnd.Col()) &&
+ (maFormulaRef.aStart.Row() <= rCellAddr.Row() ) && (rCellAddr.Row() <= maFormulaRef.aEnd.Row());
}
DataTableModel::DataTableModel() :
@@ -285,7 +281,7 @@ void SheetDataBuffer::setFormulaCell( const CellModel& rModel, const ApiTokenSeq
setCellFormat( rModel );
}
-void SheetDataBuffer::createArrayFormula( const CellRangeAddress& rRange, const ApiTokenSequence& rTokens )
+void SheetDataBuffer::createArrayFormula( const ScRange& rRange, const ApiTokenSequence& rTokens )
{
/* Array formulas will be inserted later in finalizeImport(). This is
needed to not disturb collecting all the cells, which will be put into
@@ -293,7 +289,7 @@ void SheetDataBuffer::createArrayFormula( const CellRangeAddress& rRange, const
maArrayFormulas.push_back( ArrayFormula( rRange, rTokens ) );
}
-void SheetDataBuffer::createTableOperation( const CellRangeAddress& rRange, const DataTableModel& rModel )
+void SheetDataBuffer::createTableOperation( const ScRange& rRange, const DataTableModel& rModel )
{
/* Table operations will be inserted later in finalizeImport(). This is
needed to not disturb collecting all the cells, which will be put into
@@ -565,7 +561,7 @@ ApiTokenSequence SheetDataBuffer::resolveSharedFormula( const ScAddress& rAddr )
return aTokens;
}
-void SheetDataBuffer::finalizeArrayFormula( const CellRangeAddress& rRange, const ApiTokenSequence& rTokens ) const
+void SheetDataBuffer::finalizeArrayFormula( const ScRange& rRange, const ApiTokenSequence& rTokens ) const
{
Reference< XArrayFormulaTokens > xTokens( getCellRange( rRange ), UNO_QUERY );
OSL_ENSURE( xTokens.is(), "SheetDataBuffer::finalizeArrayFormula - missing formula token interface" );
@@ -573,7 +569,7 @@ void SheetDataBuffer::finalizeArrayFormula( const CellRangeAddress& rRange, cons
xTokens->setArrayTokens( rTokens );
}
-void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, const DataTableModel& rModel )
+void SheetDataBuffer::finalizeTableOperation( const ScRange& rRange, const DataTableModel& rModel )
{
if (rModel.mbRef1Deleted)
return;
@@ -581,7 +577,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co
if (rModel.maRef1.isEmpty())
return;
- if (rRange.StartColumn <= 0 || rRange.StartRow <= 0)
+ if (rRange.aStart.Col() <= 0 || rRange.aStart.Row() <= 0)
return;
sal_Int16 nSheet = getSheetIndex();
@@ -593,8 +589,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co
ScDocumentImport& rDoc = getDocImport();
ScTabOpParam aParam;
- ScRange aScRange;
- ScUnoConversion::FillScRange(aScRange, rRange);
+ ScRange aScRange(rRange);
if (rModel.mb2dTable)
{
@@ -611,11 +606,11 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co
aParam.meMode = ScTabOpParam::Both;
- aParam.aRefFormulaCell.Set(rRange.StartColumn-1, rRange.StartRow-1, nSheet, false, false, false);
- aParam.aRefFormulaEnd = aParam.aRefFormulaCell;
-
- aScRange.aStart.IncRow(-1);
aScRange.aStart.IncCol(-1);
+ aScRange.aStart.IncRow(-1);
+
+ aParam.aRefFormulaCell.Set(aScRange.aStart.Col(), aScRange.aStart.Row(), nSheet, false, false, false);
+ aParam.aRefFormulaEnd = aParam.aRefFormulaCell;
// Ref1 is row input cell and Ref2 is column input cell.
aParam.aRefRowCell.Set(aRef1.Col(), aRef1.Row(), aRef1.Tab(), false, false, false);
@@ -632,7 +627,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co
// One-variable row input cell (horizontal).
aParam.meMode = ScTabOpParam::Row;
aParam.aRefRowCell.Set(aRef1.Col(), aRef1.Row(), aRef1.Tab(), false, false, false);
- aParam.aRefFormulaCell.Set(rRange.StartColumn-1, rRange.StartRow, nSheet, false, true, false);
+ aParam.aRefFormulaCell.Set(rRange.aStart.Col()-1, rRange.aStart.Row(), nSheet, false, true, false);
aParam.aRefFormulaEnd = aParam.aRefFormulaCell;
aScRange.aStart.IncRow(-1);
rDoc.setTableOpCells(aScRange, aParam);
@@ -642,7 +637,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co
// One-variable column input cell (vertical).
aParam.meMode = ScTabOpParam::Column;
aParam.aRefColCell.Set(aRef1.Col(), aRef1.Row(), aRef1.Tab(), false, false, false);
- aParam.aRefFormulaCell.Set(rRange.StartColumn, rRange.StartRow-1, nSheet, true, false, false);
+ aParam.aRefFormulaCell.Set(rRange.aStart.Col(), rRange.aStart.Row()-1, nSheet, true, false, false);
aParam.aRefFormulaEnd = aParam.aRefFormulaCell;
aScRange.aStart.IncCol(-1);
rDoc.setTableOpCells(aScRange, aParam);
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index dc679314afc7..2db99b33ff32 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -174,9 +174,7 @@ void SheetDataContext::onEndElement()
case XML_array:
if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
{
- 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 );
+ setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr );
}
// set cell formatting, but do not set result as cell value
mrSheetData.setBlankCell( maCellData );
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 2eccb8244c3d..afed4ff47449 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -222,7 +222,7 @@ public:
Reference< XCell > getCell( const CellAddress& rAddress ) const;
Reference< XCell > getCell( const ScAddress& rAddress ) const;
/** Returns the XCellRange interface for the passed cell range address. */
- Reference< XCellRange > getCellRange( const CellRangeAddress& rRange ) const;
+ Reference< XCellRange > getCellRange( const ScRange& rRange ) const;
/** Returns the XSheetCellRanges interface for the passed cell range addresses. */
Reference< XSheetCellRanges > getCellRangeList( const ApiCellRangeList& rRanges ) const;
@@ -475,12 +475,12 @@ Reference< XCell > WorksheetGlobals::getCell( const ScAddress& rAddress ) const
return xCell;
}
-Reference< XCellRange > WorksheetGlobals::getCellRange( const CellRangeAddress& rRange ) const
+Reference< XCellRange > WorksheetGlobals::getCellRange( const ScRange& rRange ) const
{
Reference< XCellRange > xRange;
if( mxSheet.is() ) try
{
- xRange = mxSheet->getCellRangeByPosition( rRange.StartColumn, rRange.StartRow, rRange.EndColumn, rRange.EndRow );
+ xRange = mxSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
}
catch( Exception& )
{
@@ -1318,7 +1318,7 @@ void WorksheetGlobals::groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLa
void WorksheetGlobals::finalizeDrawings()
{
// calculate the current drawing page size (after rows/columns are imported)
- PropertySet aRangeProp( getCellRange( CellRangeAddress( getSheetIndex(), 0, 0, mrMaxApiPos.Col(), mrMaxApiPos.Row() ) ) );
+ PropertySet aRangeProp( getCellRange( ScRange( 0, 0, getSheetIndex(), mrMaxApiPos.Col(), mrMaxApiPos.Row(), getSheetIndex() ) ) );
aRangeProp.getProperty( maDrawPageSize, PROP_Size );
// import DML and VML
@@ -1408,7 +1408,7 @@ Reference< XCell > WorksheetHelper::getCell( const ScAddress& rAddress ) const
return mrSheetGlob.getCell( rAddress );
}
-Reference< XCellRange > WorksheetHelper::getCellRange( const CellRangeAddress& rRange ) const
+Reference< XCellRange > WorksheetHelper::getCellRange( const ScRange& rRange ) const
{
return mrSheetGlob.getCellRange( rRange );
}