diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2016-02-21 04:37:20 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-02-26 15:56:03 +0000 |
commit | 4b63e7ee7e286b116d60dda676349024808182ed (patch) | |
tree | 3e60ea89d5ca74fca923692af2d418b183505961 | |
parent | 9d198be7395cc236fd3453de1005b5abeb2ed801 (diff) |
tdf#97654 - replaced CellAddress types with ScAddress.
Differences in default constructors is compensated and other changes have
been made as suggested.
Change-Id: I15bdf5043816502ace797c352242a4a59f1cd64e
Reviewed-on: https://gerrit.libreoffice.org/22579
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
22 files changed, 258 insertions, 149 deletions
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx index a85ee973d819..662d044ed2d8 100644 --- a/sc/source/filter/inc/addressconverter.hxx +++ b/sc/source/filter/inc/addressconverter.hxx @@ -237,17 +237,17 @@ public: sal_Int32 nLength = SAL_MAX_INT32 ); /** Returns the biggest valid cell address in the own Calc document. */ - inline const css::table::CellAddress& + inline const ScAddress& getMaxApiAddress() const { return maMaxApiPos; } /** Returns the biggest valid cell address in the imported/exported Excel document. */ - inline const css::table::CellAddress& + inline const ScAddress& getMaxXlsAddress() const { return maMaxXlsPos; } /** Returns the biggest valid cell address in both Calc and the imported/exported Excel document. */ - inline const css::table::CellAddress& + inline const ScAddress& getMaxAddress() const { return maMaxPos; } /** Checks if the passed column index is valid. @@ -376,8 +376,7 @@ public: @param bTrackOverflow true = Update the internal overflow flags, if the address is outside of the supported sheet limits. @return A valid API cell address struct. */ - css::table::CellAddress - createValidCellAddress( + ScAddress createValidCellAddress( const OUString& rString, sal_Int16 nSheet, bool bTrackOverflow ); @@ -443,8 +442,7 @@ public: @param bTrackOverflow true = Update the internal overflow flags, if the address is outside of the supported sheet limits. @return A valid API cell address struct. */ - css::table::CellAddress - createValidCellAddress( + ScAddress createValidCellAddress( const BinAddress& rBinAddress, sal_Int16 nSheet, bool bTrackOverflow ); @@ -653,9 +651,9 @@ private: sal_Unicode cSameSheet ); }; - css::table::CellAddress maMaxApiPos; /// Maximum valid cell address in Calc. - css::table::CellAddress maMaxXlsPos; /// Maximum valid cell address in Excel. - css::table::CellAddress maMaxPos; /// Maximum valid cell address in Calc/Excel. + ScAddress maMaxApiPos; /// Maximum valid cell address in Calc. + ScAddress maMaxXlsPos; /// Maximum valid cell address in Excel. + ScAddress maMaxPos; /// Maximum valid cell address in Calc/Excel. ControlCharacters maLinkChars; /// Control characters for external link import (BIFF). ControlCharacters maDConChars; /// Control characters for DCON* record import (BIFF). bool mbColOverflow; /// Flag for "columns overflow". diff --git a/sc/source/filter/inc/defnamesbuffer.hxx b/sc/source/filter/inc/defnamesbuffer.hxx index 5b0c36ebeeb1..95b26d312902 100644 --- a/sc/source/filter/inc/defnamesbuffer.hxx +++ b/sc/source/filter/inc/defnamesbuffer.hxx @@ -82,6 +82,7 @@ public: const OUString& getUpcaseModelName() const; /** Returns an Any with a SingleReference or ComplexReference, or an empty Any. */ css::uno::Any getReference( const css::table::CellAddress& rBaseAddr ) const; + css::uno::Any getReference( const ScAddress& rBaseAddr ) const; protected: DefinedNameModel maModel; /// Model data for this defined name. diff --git a/sc/source/filter/inc/externallinkfragment.hxx b/sc/source/filter/inc/externallinkfragment.hxx index 6a320ff23c7d..1d5f5c3c9e79 100644 --- a/sc/source/filter/inc/externallinkfragment.hxx +++ b/sc/source/filter/inc/externallinkfragment.hxx @@ -67,7 +67,7 @@ private: private: css::uno::Reference< css::sheet::XExternalSheetCache > mxSheetCache; /// The sheet cache used to store external cell values. - css::table::CellAddress maCurrPos; /// Position of current cell. + ScAddress maCurrPos; /// Position of current cell. sal_Int32 mnCurrType; /// Data type of current cell. }; diff --git a/sc/source/filter/inc/formulabuffer.hxx b/sc/source/filter/inc/formulabuffer.hxx index e718b1587262..b72dc086fa09 100644 --- a/sc/source/filter/inc/formulabuffer.hxx +++ b/sc/source/filter/inc/formulabuffer.hxx @@ -37,7 +37,7 @@ public: */ struct SharedFormulaEntry { - css::table::CellAddress maAddress; + ScAddress maAddress; OUString maTokenStr; sal_Int32 mnSharedId; @@ -54,7 +54,7 @@ public: */ struct SharedFormulaDesc { - css::table::CellAddress maAddress; + ScAddress maAddress; sal_Int32 mnSharedId; OUString maCellValue; sal_Int32 mnValueType; @@ -70,9 +70,9 @@ public: struct TokenAddressItem { OUString maTokenStr; - css::table::CellAddress maCellAddress; - TokenAddressItem( const OUString& rTokenStr, const css::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress ) {} - TokenAddressItem( const OUString& rTokenStr, const ScAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress.Tab(), rCellAddress.Col(), rCellAddress.Row() ) {} + ScAddress maCellAddress; + TokenAddressItem( const OUString& rTokenStr, const ScAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress ) {} + TokenAddressItem( const OUString& rTokenStr, const css::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress.Column, rCellAddress.Row, rCellAddress.Sheet ) {} }; struct TokenRangeAddressItem @@ -84,11 +84,11 @@ public: struct FormulaValue { - css::table::CellAddress maCellAddress; + ScAddress maCellAddress; OUString maValueStr; sal_Int32 mnCellType; }; - typedef std::pair<css::table::CellAddress, double> ValueAddressPair; + typedef std::pair<ScAddress, double> ValueAddressPair; struct SheetItem { @@ -141,6 +141,10 @@ public: void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const css::table::CellAddress& rTokenAddress, const OUString& ); + void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, + const ScAddress& rTokenAddress, + const OUString& ); + void createSharedFormulaMapEntry( const css::table::CellAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens ); void createSharedFormulaMapEntry( const ScAddress& rAddress, diff --git a/sc/source/filter/inc/scenariobuffer.hxx b/sc/source/filter/inc/scenariobuffer.hxx index 784548f31fa2..d0c117fb2044 100644 --- a/sc/source/filter/inc/scenariobuffer.hxx +++ b/sc/source/filter/inc/scenariobuffer.hxx @@ -30,7 +30,7 @@ namespace xls { struct ScenarioCellModel { - css::table::CellAddress maPos; + ScAddress maPos; OUString maValue; sal_Int32 mnNumFmtId; bool mbDeleted; diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx index 7a1c282de09c..c5f80b688cb8 100644 --- a/sc/source/filter/inc/sheetdatabuffer.hxx +++ b/sc/source/filter/inc/sheetdatabuffer.hxx @@ -57,6 +57,7 @@ struct CellFormulaModel /** Returns true, if the passed cell address is valid for an array formula. */ bool isValidArrayRef( const css::table::CellAddress& rCellAddr ); + bool isValidArrayRef( const ScAddress& rCellAddr ); /** Returns true, if the passed cell address is valid for a shared formula. */ bool isValidSharedRef( const css::table::CellAddress& rCellAddr ); bool isValidSharedRef( const ScAddress& rCellAddr ); @@ -127,6 +128,9 @@ public: void createSharedFormula( const css::table::CellAddress& rRange, const ApiTokenSequence& rTokens); + void createSharedFormula( + const ScAddress& rRange, + const ApiTokenSequence& rTokens); /** Inserts the passed token array as array formula. */ void createArrayFormula( @@ -171,6 +175,7 @@ private: /** Creates a formula token array representing the shared formula with the passed identifier. */ ApiTokenSequence resolveSharedFormula( const css::table::CellAddress& rMapKey ) const; + ApiTokenSequence resolveSharedFormula( const ScAddress& rMapKey ) const; /** Inserts the passed array formula into the sheet. */ void finalizeArrayFormula( @@ -243,9 +248,8 @@ private: TableOperationList maTableOperations; /// All table operations in the sheet. ::std::map< BinAddress, ApiTokenSequence > maSharedFormulas; /// Maps shared formula base address to defined name token index. - css::table::CellAddress - maSharedFmlaAddr; /// Address of a cell containing a pending shared formula. - css::table::CellAddress maSharedBaseAddr; /// Base address of the pending shared formula. + ScAddress maSharedFmlaAddr; /// Address of a cell containing a pending shared formula. + ScAddress maSharedBaseAddr; /// Base address of the pending shared formula. XfIdRowRange maXfIdRowRange; /// Cached XF identifier for a range of rows. XfIdRangeListMap maXfIdRangeLists; /// Collected XF identifiers for cell rangelists. MergedRangeList maMergedRanges; /// Merged cell ranges. diff --git a/sc/source/filter/inc/viewsettings.hxx b/sc/source/filter/inc/viewsettings.hxx index 5e8b5b656807..7cbbf1a0d03c 100644 --- a/sc/source/filter/inc/viewsettings.hxx +++ b/sc/source/filter/inc/viewsettings.hxx @@ -32,7 +32,7 @@ namespace xls { /** Contains all settings for a selection in a single pane of a sheet. */ struct PaneSelectionModel { - css::table::CellAddress maActiveCell; /// Position of active cell (cursor). + ScAddress maActiveCell; /// Position of active cell (cursor). ApiCellRangeList maSelection; /// Selected cell ranges. sal_Int32 mnActiveCellId; /// Index of active cell in selection list. @@ -46,8 +46,8 @@ struct SheetViewModel PaneSelectionModelMap maPaneSelMap; /// Selections of all panes. Color maGridColor; /// Grid color. - css::table::CellAddress maFirstPos; /// First visible cell. - css::table::CellAddress maSecondPos; /// First visible cell in additional panes. + ScAddress maFirstPos; /// First visible cell. + ScAddress maSecondPos; /// First visible cell in additional panes. sal_Int32 mnWorkbookViewId; /// Index into list of workbookView elements. sal_Int32 mnViewType; /// View type (normal, page break, layout). sal_Int32 mnActivePaneId; /// Active pane (with cell cursor). diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx index c6718ebf749b..20be70ad824b 100644 --- a/sc/source/filter/inc/worksheethelper.hxx +++ b/sc/source/filter/inc/worksheethelper.hxx @@ -251,6 +251,7 @@ public: /** Extends the used area of this sheet by the passed cell position. */ void extendUsedArea( const css::table::CellAddress& rAddress ); + void extendUsedArea( const ScAddress& rAddress ); /** Extends the used area of this sheet by the passed cell range. */ void extendUsedArea( const css::table::CellRangeAddress& rRange ); /** Extends the shape bounding box by the position and size of the passed rectangle (in 1/100 mm). */ @@ -317,6 +318,7 @@ public: const OUString& rCellValue, sal_Int32 nValueType ); void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const css::table::CellAddress& rTokenAddress, const OUString& ); + void setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const ScAddress& rTokenAddress, const OUString& ); void createSharedFormulaMapEntry( const css::table::CellAddress& rAddress, diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx index a740f97e3cfe..46e2585dfb23 100644 --- a/sc/source/filter/oox/addressconverter.cxx +++ b/sc/source/filter/oox/addressconverter.cxx @@ -311,7 +311,7 @@ bool AddressConverter::parseOoxRange2d( bool AddressConverter::checkCol( sal_Int32 nCol, bool bTrackOverflow ) { - bool bValid = (0 <= nCol) && (nCol <= maMaxPos.Column); + bool bValid = (0 <= nCol) && ( nCol <= maMaxPos.Col() ); if( !bValid && bTrackOverflow ) mbColOverflow = true; return bValid; @@ -319,7 +319,7 @@ bool AddressConverter::checkCol( sal_Int32 nCol, bool bTrackOverflow ) bool AddressConverter::checkRow( sal_Int32 nRow, bool bTrackOverflow ) { - bool bValid = (0 <= nRow) && (nRow <= maMaxPos.Row); + bool bValid = (0 <= nRow) && ( nRow <= maMaxPos.Row() ); if( !bValid && bTrackOverflow ) mbRowOverflow = true; return bValid; @@ -327,9 +327,9 @@ bool AddressConverter::checkRow( sal_Int32 nRow, bool bTrackOverflow ) bool AddressConverter::checkTab( sal_Int16 nSheet, bool bTrackOverflow ) { - bool bValid = (0 <= nSheet) && (nSheet <= maMaxPos.Sheet); + bool bValid = (0 <= nSheet) && ( nSheet <= maMaxPos.Tab() ); if( !bValid && bTrackOverflow ) - mbTabOverflow |= (nSheet > maMaxPos.Sheet); // do not warn for deleted refs (-1) + mbTabOverflow |= ( nSheet > maMaxPos.Tab() ); // do not warn for deleted refs (-1) return bValid; } @@ -425,15 +425,15 @@ bool AddressConverter::convertToCellAddress( return checkCellAddress(rAddress, bTrackOverflow); } -CellAddress AddressConverter::createValidCellAddress( +ScAddress AddressConverter::createValidCellAddress( const OUString& rString, sal_Int16 nSheet, bool bTrackOverflow ) { - CellAddress aAddress; + ScAddress aAddress( 0, 0, 0 ); if( !convertToCellAddress( aAddress, rString, nSheet, bTrackOverflow ) ) { - aAddress.Sheet = getLimitedValue< sal_Int16, sal_Int16 >( nSheet, 0, maMaxPos.Sheet ); - aAddress.Column = ::std::min( aAddress.Column, maMaxPos.Column ); - aAddress.Row = ::std::min( aAddress.Row, maMaxPos.Row ); + aAddress.SetTab( getLimitedValue< sal_Int16, sal_Int16 >( nSheet, 0, maMaxPos.Tab() ) ); + aAddress.SetCol( ::std::min( aAddress.Col(), maMaxPos.Col() ) ); + aAddress.SetRow( ::std::min( aAddress.Row(), maMaxPos.Row() ) ); } return aAddress; } @@ -468,15 +468,15 @@ bool AddressConverter::convertToCellAddress( ScAddress& orAddress, return checkCellAddress( orAddress, bTrackOverflow ); } -CellAddress AddressConverter::createValidCellAddress( +ScAddress AddressConverter::createValidCellAddress( const BinAddress& rBinAddress, sal_Int16 nSheet, bool bTrackOverflow ) { - CellAddress aAddress; + ScAddress aAddress ( 0, 0, 0 ); if( !convertToCellAddress( aAddress, rBinAddress, nSheet, bTrackOverflow ) ) { - aAddress.Sheet = getLimitedValue< sal_Int16, sal_Int16 >( nSheet, 0, maMaxPos.Sheet ); - aAddress.Column = getLimitedValue< sal_Int32, sal_Int32 >( rBinAddress.mnCol, 0, maMaxPos.Column ); - aAddress.Row = getLimitedValue< sal_Int32, sal_Int32 >( rBinAddress.mnRow, 0, maMaxPos.Row ); + aAddress.SetTab( getLimitedValue< sal_Int16, sal_Int16 >( nSheet, 0, maMaxPos.Tab() ) ); + aAddress.SetCol( getLimitedValue< sal_Int32, sal_Int32 >( rBinAddress.mnCol, 0, sal_Int32( maMaxPos.Col() ) ) ); + aAddress.SetRow( getLimitedValue< sal_Int32, sal_Int32 >( rBinAddress.mnRow, 0, sal_Int32( maMaxPos.Row() ) ) ); } return aAddress; } @@ -499,10 +499,10 @@ bool AddressConverter::validateCellRange( CellRangeAddress& orRange, bool bAllow ::std::swap( orRange.StartRow, orRange.EndRow ); if( !checkCellRange( orRange, bAllowOverflow, bTrackOverflow ) ) return false; - if( orRange.EndColumn > maMaxPos.Column ) - orRange.EndColumn = maMaxPos.Column; - if( orRange.EndRow > maMaxPos.Row ) - orRange.EndRow = maMaxPos.Row; + if( orRange.EndColumn > maMaxPos.Col() ) + orRange.EndColumn = maMaxPos.Col(); + if( orRange.EndRow > maMaxPos.Row() ) + orRange.EndRow = maMaxPos.Row(); return true; } @@ -584,9 +584,7 @@ void AddressConverter::ControlCharacters::set( void AddressConverter::initializeMaxPos( sal_Int16 nMaxXlsTab, sal_Int32 nMaxXlsCol, sal_Int32 nMaxXlsRow ) { - maMaxXlsPos.Sheet = nMaxXlsTab; - maMaxXlsPos.Column = nMaxXlsCol; - maMaxXlsPos.Row = nMaxXlsRow; + maMaxXlsPos.Set( nMaxXlsCol, nMaxXlsRow, nMaxXlsTab); // maximum cell position in Calc try @@ -594,7 +592,7 @@ void AddressConverter::initializeMaxPos( Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW ); Reference< XCellRangeAddressable > xAddressable( xSheetsIA->getByIndex( 0 ), UNO_QUERY_THROW ); CellRangeAddress aRange = xAddressable->getRangeAddress(); - maMaxApiPos = CellAddress( API_MAXTAB, aRange.EndColumn, aRange.EndRow ); + maMaxApiPos = ScAddress( aRange.EndColumn, aRange.EndRow, API_MAXTAB ); maMaxPos = getBaseFilter().isImportFilter() ? maMaxApiPos : maMaxXlsPos; } catch( Exception& ) diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 99ed9b71bdd6..acb6931c3d12 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -155,6 +155,17 @@ void lclConvertSingleRefFlags( SingleReference& orApiRef, const CellAddress& rBa rBaseAddr.Row, ROW_RELATIVE, bRowRel ); } +void lclConvertSingleRefFlags( SingleReference& orApiRef, const ScAddress& rBaseAddr, bool bColRel, bool bRowRel ) +{ + using namespace ::com::sun::star::sheet::ReferenceFlags; + lclConvertRefFlags( + orApiRef.Flags, orApiRef.Column, orApiRef.RelativeColumn, + sal_Int32( rBaseAddr.Col() ), COLUMN_RELATIVE, bColRel ); + lclConvertRefFlags( + orApiRef.Flags, orApiRef.Row, orApiRef.RelativeRow, + rBaseAddr.Row(), ROW_RELATIVE, bRowRel ); +} + Any lclConvertReference( const Any& rRefAny, const CellAddress& rBaseAddr, sal_uInt16 nRelFlags ) { if( rRefAny.has< SingleReference >() && !getFlag( nRelFlags, BIFF_REFFLAG_COL2REL ) && !getFlag( nRelFlags, BIFF_REFFLAG_ROW2REL ) ) @@ -175,6 +186,26 @@ Any lclConvertReference( const Any& rRefAny, const CellAddress& rBaseAddr, sal_u return Any(); } +Any lclConvertReference( const Any& rRefAny, const ScAddress& rBaseAddr, sal_uInt16 nRelFlags ) +{ + if( rRefAny.has< SingleReference >() && !getFlag( nRelFlags, BIFF_REFFLAG_COL2REL ) && !getFlag( nRelFlags, BIFF_REFFLAG_ROW2REL ) ) + { + SingleReference aApiRef; + rRefAny >>= aApiRef; + lclConvertSingleRefFlags( aApiRef, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL1REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW1REL ) ); + return Any( aApiRef ); + } + if( rRefAny.has< ComplexReference >() ) + { + ComplexReference aApiRef; + rRefAny >>= aApiRef; + lclConvertSingleRefFlags( aApiRef.Reference1, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL1REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW1REL ) ); + lclConvertSingleRefFlags( aApiRef.Reference2, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL2REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW2REL ) ); + return Any( aApiRef ); + } + return Any(); +} + } // namespace DefinedNameModel::DefinedNameModel() : @@ -227,6 +258,34 @@ Any DefinedNameBase::getReference( const CellAddress& rBaseAddr ) const return Any(); } +Any DefinedNameBase::getReference( const ScAddress& rBaseAddr ) const +{ + if( maRefAny.hasValue() && (maModel.maName.getLength() >= 2) && (maModel.maName[ 0 ] == '\x01') ) + { + sal_Unicode cFlagsChar = getUpcaseModelName()[ 1 ]; + if( ('A' <= cFlagsChar) && (cFlagsChar <= 'P') ) + { + sal_uInt16 nRelFlags = static_cast< sal_uInt16 >( cFlagsChar - 'A' ); + if( maRefAny.has< ExternalReference >() ) + { + ExternalReference aApiExtRef; + maRefAny >>= aApiExtRef; + Any aRefAny = lclConvertReference( aApiExtRef.Reference, rBaseAddr, nRelFlags ); + if( aRefAny.hasValue() ) + { + aApiExtRef.Reference <<= aRefAny; + return Any( aApiExtRef ); + } + } + else + { + return lclConvertReference( maRefAny, rBaseAddr, nRelFlags ); + } + } + } + return Any(); +} + DefinedName::DefinedName( const WorkbookHelper& rHelper ) : DefinedNameBase( rHelper ), mpScRangeData(nullptr), @@ -379,11 +438,11 @@ void DefinedName::convertFormula() { bool bHasRowTitles = false; bool bHasColTitles = false; - const CellAddress& rMaxPos = getAddressConverter().getMaxAddress(); + const ScAddress& rMaxPos = getAddressConverter().getMaxAddress(); for( ::std::vector< CellRangeAddress >::const_iterator aIt = aTitleRanges.begin(), aEnd = aTitleRanges.end(); (aIt != aEnd) && (!bHasRowTitles || !bHasColTitles); ++aIt ) { - bool bFullRow = (aIt->StartColumn == 0) && (aIt->EndColumn >= rMaxPos.Column); - bool bFullCol = (aIt->StartRow == 0) && (aIt->EndRow >= rMaxPos.Row); + bool bFullRow = (aIt->StartColumn == 0) && ( aIt->EndColumn >= rMaxPos.Col() ); + bool bFullCol = (aIt->StartRow == 0) && ( aIt->EndRow >= rMaxPos.Row() ); if( !bHasRowTitles && bFullRow && !bFullCol ) { xPrintAreas->setTitleRows( *aIt ); diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx index eb9b46649d98..08b10c43b6e3 100644 --- a/sc/source/filter/oox/drawingbase.cxx +++ b/sc/source/filter/oox/drawingbase.cxx @@ -233,18 +233,18 @@ EmuRectangle ShapeAnchor::calcAnchorRectEmu( const css::awt::Size& rPageSizeHmm { /* Pass a valid cell address to calcCellAnchorEmu(), otherwise nothing useful is returned, even if either row or column is valid. */ - CellAddress aToCell = rAddrConv.createValidCellAddress( BinAddress( maTo.mnCol, maTo.mnRow ), getSheetIndex(), true ); + ScAddress aToCell = rAddrConv.createValidCellAddress( BinAddress( maTo.mnCol, maTo.mnRow ), getSheetIndex(), true ); CellAnchorModel aValidTo = maTo; - aValidTo.mnCol = aToCell.Column; - aValidTo.mnRow = aToCell.Row; + aValidTo.mnCol = aToCell.Col(); + aValidTo.mnRow = aToCell.Row(); EmuPoint aPoint = calcCellAnchorEmu( aValidTo ); // width (if column index is valid, use the calculated offset, otherwise stretch to maximum available X position) aAnchorRect.Width = aPageSize.Width - aAnchorRect.X; - if( aToCell.Column == maTo.mnCol ) + if( aToCell.Col() == maTo.mnCol ) aAnchorRect.Width = ::std::min< sal_Int64 >( aPoint.X - aAnchorRect.X + 1, aAnchorRect.Width ); // height (if row index is valid, use the calculated offset, otherwise stretch to maximum available Y position) aAnchorRect.Height = aPageSize.Height - aAnchorRect.Y; - if( aToCell.Row == maTo.mnRow ) + if( aToCell.Row() == maTo.mnRow ) aAnchorRect.Height = ::std::min< sal_Int64 >( aPoint.Y - aAnchorRect.Y + 1, aAnchorRect.Height ); } break; diff --git a/sc/source/filter/oox/externallinkbuffer.cxx b/sc/source/filter/oox/externallinkbuffer.cxx index 5b4a314f9477..3014da75ad15 100644 --- a/sc/source/filter/oox/externallinkbuffer.cxx +++ b/sc/source/filter/oox/externallinkbuffer.cxx @@ -257,8 +257,8 @@ void ExternalName::setResultSize( sal_Int32 nColumns, sal_Int32 nRows ) OSL_ENSURE( (mrParentLink.getLinkType() == LINKTYPE_DDE) || (mrParentLink.getLinkType() == LINKTYPE_OLE) || (mrParentLink.getLinkType() == LINKTYPE_MAYBE_DDE_OLE), "ExternalName::setResultSize - wrong link type" ); OSL_ENSURE( (nRows > 0) && (nColumns > 0), "ExternalName::setResultSize - invalid matrix size" ); - const CellAddress& rMaxPos = getAddressConverter().getMaxApiAddress(); - if( (0 < nRows) && (nRows <= rMaxPos.Row + 1) && (0 < nColumns) && (nColumns <= rMaxPos.Column + 1) ) + const ScAddress& rMaxPos = getAddressConverter().getMaxApiAddress(); + if( (0 < nRows) && (nRows <= rMaxPos.Row() + 1) && (0 < nColumns) && (nColumns <= rMaxPos.Col() + 1) ) maResults.resize( static_cast< size_t >( nColumns ), static_cast< size_t >( nRows ), Any( BiffHelper::calcDoubleFromError( BIFF_ERR_NA ) ) ); else maResults.clear(); diff --git a/sc/source/filter/oox/externallinkfragment.cxx b/sc/source/filter/oox/externallinkfragment.cxx index 0ed09f50f816..5b56b2a9db53 100644 --- a/sc/source/filter/oox/externallinkfragment.cxx +++ b/sc/source/filter/oox/externallinkfragment.cxx @@ -86,7 +86,7 @@ ContextHandlerRef ExternalSheetDataContext::onCreateRecordContext( sal_Int32 nRe switch( getCurrentElement() ) { case BIFF12_ID_EXTSHEETDATA: - if( nRecId == BIFF12_ID_EXTROW ) { maCurrPos.Row = rStrm.readInt32(); return this; } + if( nRecId == BIFF12_ID_EXTROW ) { maCurrPos.SetRow( rStrm.readInt32() ); return this; } break; case BIFF12_ID_EXTROW: switch( nRecId ) @@ -114,32 +114,32 @@ void ExternalSheetDataContext::importCell( const AttributeList& rAttribs ) void ExternalSheetDataContext::importExtCellBlank( SequenceInputStream& rStrm ) { - maCurrPos.Column = rStrm.readInt32(); + maCurrPos.SetCol( rStrm.readInt32() ); setCellValue( Any( OUString() ) ); } void ExternalSheetDataContext::importExtCellBool( SequenceInputStream& rStrm ) { - maCurrPos.Column = rStrm.readInt32(); + maCurrPos.SetCol( rStrm.readInt32() ); double fValue = (rStrm.readuInt8() == 0) ? 0.0 : 1.0; setCellValue( Any( fValue ) ); } void ExternalSheetDataContext::importExtCellDouble( SequenceInputStream& rStrm ) { - maCurrPos.Column = rStrm.readInt32(); + maCurrPos.SetCol( rStrm.readInt32() ); setCellValue( Any( rStrm.readDouble() ) ); } void ExternalSheetDataContext::importExtCellError( SequenceInputStream& rStrm ) { - maCurrPos.Column = rStrm.readInt32(); + maCurrPos.SetCol( rStrm.readInt32() ); setCellValue( Any( BiffHelper::calcDoubleFromError( rStrm.readuInt8() ) ) ); } void ExternalSheetDataContext::importExtCellString( SequenceInputStream& rStrm ) { - maCurrPos.Column = rStrm.readInt32(); + maCurrPos.SetCol( rStrm.readInt32() ); setCellValue( Any( BiffHelper::readString( rStrm ) ) ); } @@ -147,7 +147,7 @@ void ExternalSheetDataContext::setCellValue( const Any& rValue ) { if( mxSheetCache.is() && getAddressConverter().checkCellAddress( maCurrPos, false ) ) try { - mxSheetCache->setCellValue( maCurrPos.Column, maCurrPos.Row, rValue ); + mxSheetCache->setCellValue( maCurrPos.Col(), maCurrPos.Row(), rValue ); } catch( Exception& ) { diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index 5ea3c151962e..7d34721ad0ba 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -1522,10 +1522,9 @@ ApiTokenSequence ApiParserWrapper::parseFormula( const OUString& rFormula, const namespace { -bool lclConvertToCellAddress( CellAddress& orAddress, const SingleReference& rSingleRef, sal_Int32 nForbiddenFlags, sal_Int32 nFilterBySheet ) +bool lclConvertToCellAddress( ScAddress& orAddress, const SingleReference& rSingleRef, sal_Int32 nForbiddenFlags, sal_Int32 nFilterBySheet ) { - orAddress = CellAddress( static_cast< sal_Int16 >( rSingleRef.Sheet ), - rSingleRef.Column, rSingleRef.Row ); + orAddress = ScAddress( rSingleRef.Column, rSingleRef.Row, rSingleRef.Sheet ); return !getFlag( rSingleRef.Flags, nForbiddenFlags ) && ((nFilterBySheet < 0) || (nFilterBySheet == rSingleRef.Sheet)); @@ -1555,10 +1554,10 @@ TokenToRangeListState lclProcessRef( ApiCellRangeList& orRanges, const Any& rDat SingleReference aSingleRef; if( rData >>= aSingleRef ) { - CellAddress aAddress; + ScAddress aAddress ( 0, 0, 0 ); // ignore invalid addresses (with #REF! errors), but do not stop parsing if( lclConvertToCellAddress( aAddress, aSingleRef, nForbiddenFlags, nFilterBySheet ) ) - orRanges.push_back( CellRangeAddress( aAddress.Sheet, aAddress.Column, aAddress.Row, aAddress.Column, aAddress.Row ) ); + orRanges.push_back( CellRangeAddress( aAddress.Tab(), aAddress.Col(), aAddress.Row(), aAddress.Col(), aAddress.Row() ) ); return STATE_REF; } ComplexReference aComplexRef; diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index 9f957dab0fa3..818dd4da166d 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -123,12 +123,10 @@ void applySharedFormulas( std::vector<FormulaBuffer::SharedFormulaEntry>::const_iterator it = rSharedFormulas.begin(), itEnd = rSharedFormulas.end(); for (; it != itEnd; ++it) { - const table::CellAddress& rAddr = it->maAddress; + const ScAddress& aPos = it->maAddress; sal_Int32 nId = it->mnSharedId; const OUString& rTokenStr = it->maTokenStr; - ScAddress aPos; - ScUnoConversion::FillScAddress(aPos, rAddr); ScCompiler aComp(&rDoc.getDoc(), aPos); aComp.SetNumberFormatter(&rFormatter); aComp.SetGrammar(formula::FormulaGrammar::GRAM_OOXML); @@ -146,13 +144,11 @@ void applySharedFormulas( std::vector<FormulaBuffer::SharedFormulaDesc>::const_iterator it = rCells.begin(), itEnd = rCells.end(); for (; it != itEnd; ++it) { - const table::CellAddress& rAddr = it->maAddress; + const ScAddress& aPos = it->maAddress; const ScTokenArray* pArray = aGroups.get(it->mnSharedId); if (!pArray) continue; - ScAddress aPos; - ScUnoConversion::FillScAddress(aPos, rAddr); ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, *pArray); rDoc.setFormulaCell(aPos, pCell); if (it->maCellValue.isEmpty()) @@ -186,8 +182,7 @@ void applyCellFormulas( std::vector<FormulaBuffer::TokenAddressItem>::const_iterator it = rCells.begin(), itEnd = rCells.end(); for (; it != itEnd; ++it) { - ScAddress aPos; - ScUnoConversion::FillScAddress(aPos, it->maCellAddress); + const ScAddress& aPos = it->maCellAddress; CachedTokenArray::Item* p = rCache.get(aPos, it->maTokenStr); if (p) { @@ -242,8 +237,7 @@ void applyArrayFormulas( std::vector<FormulaBuffer::TokenRangeAddressItem>::const_iterator it = rArrays.begin(), itEnd = rArrays.end(); for (; it != itEnd; ++it) { - ScAddress aPos; - ScUnoConversion::FillScAddress(aPos, it->maTokenAndAddress.maCellAddress); + const ScAddress& aPos = it->maTokenAndAddress.maCellAddress; ScRange aRange; ScUnoConversion::FillScRange(aRange, it->maCellRangeAddress); @@ -264,8 +258,7 @@ void applyCellFormulaValues( std::vector<FormulaBuffer::FormulaValue>::const_iterator it = rVector.begin(), itEnd = rVector.end(); for (; it != itEnd; ++it) { - ScAddress aCellPos; - ScUnoConversion::FillScAddress(aCellPos, it->maCellAddress); + const ScAddress& aCellPos = it->maCellAddress; ScFormulaCell* pCell = rDoc.getDoc().GetFormulaCell(aCellPos); const OUString& rValueStr = it->maValueStr; if (!pCell) @@ -340,24 +333,24 @@ protected: } FormulaBuffer::SharedFormulaEntry::SharedFormulaEntry( - const table::CellAddress& rAddr, + const ScAddress& rAddr, const OUString& rTokenStr, sal_Int32 nSharedId ) : maAddress(rAddr), maTokenStr(rTokenStr), mnSharedId(nSharedId) {} FormulaBuffer::SharedFormulaEntry::SharedFormulaEntry( - const ScAddress& rAddr, + const css::table::CellAddress& rAddr, const OUString& rTokenStr, sal_Int32 nSharedId ) : - maAddress( CellAddress( rAddr.Tab(), rAddr.Col(), rAddr.Row() ) ), maTokenStr(rTokenStr), mnSharedId(nSharedId) {} + maAddress( ScAddress( rAddr.Column, rAddr.Row, rAddr.Sheet ) ), maTokenStr(rTokenStr), mnSharedId(nSharedId) {} FormulaBuffer::SharedFormulaDesc::SharedFormulaDesc( - const css::table::CellAddress& rAddr, sal_Int32 nSharedId, + const ScAddress& rAddr, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType ) : maAddress(rAddr), mnSharedId(nSharedId), maCellValue(rCellValue), mnValueType(nValueType) {} FormulaBuffer::SharedFormulaDesc::SharedFormulaDesc( - const ScAddress& rAddr, sal_Int32 nSharedId, + const css::table::CellAddress& rAddr, sal_Int32 nSharedId, const OUString& rCellValue, sal_Int32 nValueType ) : - maAddress( CellAddress( rAddr.Tab(), rAddr.Col(), rAddr.Row() ) ), mnSharedId(nSharedId), maCellValue(rCellValue), mnValueType(nValueType) {} + maAddress( ScAddress( rAddr.Column, rAddr.Row, rAddr.Sheet ) ), mnSharedId(nSharedId), maCellValue(rCellValue), mnValueType(nValueType) {} FormulaBuffer::SheetItem::SheetItem() : mpCellFormulas(nullptr), @@ -522,12 +515,20 @@ void FormulaBuffer::setCellArrayFormula( const css::table::CellRangeAddress& rRa maCellArrayFormulas[ rRangeAddress.Sheet ].push_back( TokenRangeAddressItem( tokenPair, rRangeAddress ) ); } +void FormulaBuffer::setCellArrayFormula( const css::table::CellRangeAddress& 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 ) ); +} + void FormulaBuffer::setCellFormulaValue( const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType ) { assert( rAddress.Sheet >= 0 && (size_t)rAddress.Sheet < maCellFormulaValues.size() ); FormulaValue aVal; - aVal.maCellAddress = rAddress; + aVal.maCellAddress = ScAddress ( rAddress.Column, rAddress.Row, rAddress.Sheet ); aVal.maValueStr = rValueStr; aVal.mnCellType = nCellType; maCellFormulaValues[rAddress.Sheet].push_back(aVal); @@ -538,7 +539,7 @@ void FormulaBuffer::setCellFormulaValue( { assert( rAddress.Tab() >= 0 && (size_t)rAddress.Tab() < maCellFormulaValues.size() ); FormulaValue aVal; - aVal.maCellAddress = CellAddress( rAddress.Tab(), rAddress.Col(), rAddress.Row() ); + aVal.maCellAddress = rAddress; aVal.maValueStr = rValueStr; aVal.mnCellType = nCellType; maCellFormulaValues[rAddress.Tab()].push_back(aVal); diff --git a/sc/source/filter/oox/formulaparser.cxx b/sc/source/filter/oox/formulaparser.cxx index 685f60979874..975005ce761e 100644 --- a/sc/source/filter/oox/formulaparser.cxx +++ b/sc/source/filter/oox/formulaparser.cxx @@ -544,7 +544,7 @@ protected: const sal_Int32 mnMaxXlsCol; /// Maximum column index in imported document. const sal_Int32 mnMaxXlsRow; /// Maximum row index in imported document. - CellAddress maBaseAddr; /// Base address for relative references. + ScAddress maBaseAddr; /// Base address for relative references. bool mbRelativeAsOffset; /// True = relative row/column index is (signed) offset, false = explicit index. bool mb2dRefsAs3dRefs; /// True = convert all 2D references to 3D references in sheet specified by base address. bool mbSpecialTokens; /// True = special handling for tExp and tTbl tokens, false = exit with error. @@ -564,10 +564,10 @@ private: FormulaParserImpl::FormulaParserImpl( const FormulaParser& rParent ) : FormulaFinalizer( rParent ), WorkbookHelper( rParent ), - mnMaxApiCol( rParent.getAddressConverter().getMaxApiAddress().Column ), - mnMaxApiRow( rParent.getAddressConverter().getMaxApiAddress().Row ), - mnMaxXlsCol( rParent.getAddressConverter().getMaxXlsAddress().Column ), - mnMaxXlsRow( rParent.getAddressConverter().getMaxXlsAddress().Row ), + mnMaxApiCol( rParent.getAddressConverter().getMaxApiAddress().Col() ), + mnMaxApiRow( rParent.getAddressConverter().getMaxApiAddress().Row() ), + mnMaxXlsCol( rParent.getAddressConverter().getMaxXlsAddress().Col() ), + mnMaxXlsRow( rParent.getAddressConverter().getMaxXlsAddress().Row() ), mbRelativeAsOffset( false ), mb2dRefsAs3dRefs( false ), mbSpecialTokens( false ), @@ -618,7 +618,7 @@ OUString FormulaParserImpl::resolveOleTarget( sal_Int32 nRefId, bool bUseRefShee void FormulaParserImpl::initializeImport( const CellAddress& rBaseAddr, FormulaType eType ) { - maBaseAddr = rBaseAddr; + maBaseAddr = ScAddress( rBaseAddr.Column, rBaseAddr.Row, rBaseAddr.Sheet ); mbRelativeAsOffset = mb2dRefsAs3dRefs = mbSpecialTokens = mbAllowNulChars = false; switch( eType ) { @@ -1057,7 +1057,7 @@ bool FormulaParserImpl::pushExternalNameOperand( const ExternalNameRef& rxExtNam bool FormulaParserImpl::pushSpecialTokenOperand( const BinAddress& rBaseAddr, bool bTable ) { - CellAddress aBaseAddr( maBaseAddr.Sheet, rBaseAddr.mnCol, rBaseAddr.mnRow ); + CellAddress aBaseAddr( maBaseAddr.Tab(), rBaseAddr.mnCol, rBaseAddr.mnRow ); ApiSpecialTokenInfo aTokenInfo( aBaseAddr, bTable ); return mbSpecialTokens && (getFormulaSize() == 0) && pushValueOperand( aTokenInfo, OPCODE_BAD ); } @@ -1098,13 +1098,13 @@ void FormulaParserImpl::initReference2d( SingleReference& orApiRef ) const { if( mb2dRefsAs3dRefs ) { - initReference3d( orApiRef, maBaseAddr.Sheet, false ); + initReference3d( orApiRef, sal_Int32 (maBaseAddr.Tab() ), false ); } else { orApiRef.Flags = SHEET_RELATIVE; // #i10184# absolute sheet index needed for relative references in shared formulas - orApiRef.Sheet = maBaseAddr.Sheet; + orApiRef.Sheet = sal_Int32( maBaseAddr.Tab() ); orApiRef.RelativeSheet = 0; } } @@ -1149,9 +1149,9 @@ void FormulaParserImpl::convertReference( SingleReference& orApiRef, const BinSi if( !bRelativeAsOffset ) { if( rRef.mbColRel ) - orApiRef.RelativeColumn -= maBaseAddr.Column; + orApiRef.RelativeColumn -= sal_Int32( maBaseAddr.Col() ); if( rRef.mbRowRel ) - orApiRef.RelativeRow -= maBaseAddr.Row; + orApiRef.RelativeRow -= maBaseAddr.Row(); } } } @@ -1572,7 +1572,7 @@ bool OoxFormulaParserImpl::importTableToken( SequenceInputStream& rStrm ) } else if( bThisRow ) { - nStartRow = nEndRow = maBaseAddr.Row - xTable->getRange().StartRow; + nStartRow = nEndRow = maBaseAddr.Row() - xTable->getRange().StartRow; bFixedHeight = true; } else diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx index 2a6cfd19b50f..b13fadd3ec75 100644 --- a/sc/source/filter/oox/pivotcachebuffer.cxx +++ b/sc/source/filter/oox/pivotcachebuffer.cxx @@ -1262,7 +1262,7 @@ void PivotCache::writeSourceHeaderCells( WorksheetHelper& rSheetHelper ) const OSL_ENSURE( static_cast< size_t >( maSheetSrcModel.maRange.EndColumn - maSheetSrcModel.maRange.StartColumn + 1 ) == maDatabaseFields.size(), "PivotCache::writeSourceHeaderCells - source cell range width does not match number of source fields" ); sal_Int32 nCol = maSheetSrcModel.maRange.StartColumn; - sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Column; + sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Col(); sal_Int32 nRow = maSheetSrcModel.maRange.StartRow; mnCurrRow = -1; updateSourceDataRow( rSheetHelper, nRow ); @@ -1286,7 +1286,7 @@ void PivotCache::importPCRecord( SequenceInputStream& rStrm, WorksheetHelper& rS sal_Int32 nRow = maSheetSrcModel.maRange.StartRow + nRowIdx; OSL_ENSURE( (maSheetSrcModel.maRange.StartRow < nRow) && (nRow <= maSheetSrcModel.maRange.EndRow), "PivotCache::importPCRecord - invalid row index" ); sal_Int32 nCol = maSheetSrcModel.maRange.StartColumn; - sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Column; + sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Col(); for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), aEnd = maDatabaseFields.end(); !rStrm.isEof() && (aIt != aEnd) && (nCol <= nMaxCol); ++aIt, ++nCol ) (*aIt)->importPCRecordItem( rStrm, rSheetHelper, nCol, nRow ); } @@ -1296,7 +1296,7 @@ void PivotCache::importPCItemIndexList( BiffInputStream& rStrm, WorksheetHelper& sal_Int32 nRow = maSheetSrcModel.maRange.StartRow + nRowIdx; OSL_ENSURE( (maSheetSrcModel.maRange.StartRow < nRow) && (nRow <= maSheetSrcModel.maRange.EndRow), "PivotCache::importPCItemIndexList - invalid row index" ); sal_Int32 nCol = maSheetSrcModel.maRange.StartColumn; - sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Column; + sal_Int32 nMaxCol = getAddressConverter().getMaxApiAddress().Col(); for( PivotCacheFieldVector::const_iterator aIt = maDatabaseFields.begin(), aEnd = maDatabaseFields.end(); !rStrm.isEof() && (aIt != aEnd) && (nCol <= nMaxCol); ++aIt, ++nCol ) if( (*aIt)->hasSharedItems() ) (*aIt)->importPCItemIndex( rStrm, rSheetHelper, nCol, nRow ); diff --git a/sc/source/filter/oox/scenariobuffer.cxx b/sc/source/filter/oox/scenariobuffer.cxx index 2308953879a8..6eb69b99e7f4 100644 --- a/sc/source/filter/oox/scenariobuffer.cxx +++ b/sc/source/filter/oox/scenariobuffer.cxx @@ -105,7 +105,7 @@ void Scenario::finalizeImport() ::std::vector< CellRangeAddress > aRanges; for( ScenarioCellVector::iterator aIt = maCells.begin(), aEnd = maCells.end(); aIt != aEnd; ++aIt ) if( !aIt->mbDeleted && rAddrConv.checkCellAddress( aIt->maPos, true ) ) - aRanges.push_back( CellRangeAddress( aIt->maPos.Sheet, aIt->maPos.Column, aIt->maPos.Row, aIt->maPos.Column, aIt->maPos.Row ) ); + aRanges.push_back( CellRangeAddress( aIt->maPos.Tab(), aIt->maPos.Col(), aIt->maPos.Row(), aIt->maPos.Col(), aIt->maPos.Row() ) ); if( !aRanges.empty() && !maModel.maName.isEmpty() ) try { @@ -126,7 +126,7 @@ void Scenario::finalizeImport() if( !aIt->mbDeleted ) try { // use XCell::setFormula to auto-detect values and strings - Reference< XCell > xCell( xSheet->getCellByPosition( aIt->maPos.Column, aIt->maPos.Row ), UNO_SET_THROW ); + Reference< XCell > xCell( xSheet->getCellByPosition( aIt->maPos.Col(), aIt->maPos.Row() ), UNO_SET_THROW ); xCell->setFormula( aIt->maValue ); } catch( Exception& ) diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index f6765b4d5b72..68bc3d27154c 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -87,6 +87,14 @@ bool CellFormulaModel::isValidArrayRef( const CellAddress& rCellAddr ) (maFormulaRef.StartRow == rCellAddr.Row); } +bool CellFormulaModel::isValidArrayRef( const ScAddress& rCellAddr ) +{ + return + (maFormulaRef.Sheet == rCellAddr.Tab() ) && + (maFormulaRef.StartColumn == rCellAddr.Col() ) && + (maFormulaRef.StartRow == rCellAddr.Row() ); +} + bool CellFormulaModel::isValidSharedRef( const CellAddress& rCellAddr ) { return @@ -232,6 +240,14 @@ void SheetDataBuffer::createSharedFormula(const CellAddress& rAddr, const ApiTok setCellFormula( maSharedFmlaAddr, resolveSharedFormula( maSharedBaseAddr ) ); } +void SheetDataBuffer::createSharedFormula(const ScAddress& rAddr, const ApiTokenSequence& rTokens) +{ + BinAddress aAddr(rAddr); + maSharedFormulas[aAddr] = rTokens; + if( mbPendingSharedFmla ) + setCellFormula( maSharedFmlaAddr, resolveSharedFormula( maSharedBaseAddr ) ); +} + void SheetDataBuffer::setFormulaCell( const CellModel& rModel, const ApiTokenSequence& rTokens ) { mbPendingSharedFmla = false; @@ -260,12 +276,13 @@ void SheetDataBuffer::setFormulaCell( const CellModel& rModel, const ApiTokenSeq array formula. In this case, the cell will be remembered. After reading the formula definition it will be retried to insert the formula via retryPendingSharedFormulaCell(). */ - BinAddress aBaseAddr( aTokenInfo.First ); - aTokens = resolveSharedFormula( aTokenInfo.First ); + ScAddress aTokenAddr = ScAddress ( aTokenInfo.First.Column, aTokenInfo.First.Row, aTokenInfo.First.Sheet ); + BinAddress aBaseAddr( aTokenAddr ); + aTokens = resolveSharedFormula( aTokenAddr ); if( !aTokens.hasElements() ) { - maSharedFmlaAddr = ( CellAddress( rModel.maCellAddr.Tab(), rModel.maCellAddr.Col(), rModel.maCellAddr.Row() ) ); //should change this later - maSharedBaseAddr = aTokenInfo.First; + maSharedFmlaAddr = rModel.maCellAddr; + maSharedBaseAddr = aTokenAddr; mbPendingSharedFmla = true; } } @@ -473,7 +490,7 @@ void SheetDataBuffer::finalizeImport() { if ( it->first == -1 ) // it's a dud skip it continue; - CellRangeAddress aRange( getSheetIndex(), 0, rangeIter->mnFirst, rAddrConv.getMaxApiAddress().Column, rangeIter->mnLast ); + CellRangeAddress aRange( getSheetIndex(), 0, rangeIter->mnFirst, rAddrConv.getMaxApiAddress().Col(), rangeIter->mnLast ); addColXfStyle( it->first, -1, aRange, true ); } @@ -619,6 +636,13 @@ ApiTokenSequence SheetDataBuffer::resolveSharedFormula( const CellAddress& rAddr return aTokens; } +ApiTokenSequence SheetDataBuffer::resolveSharedFormula( const ScAddress& rAddr ) const +{ + BinAddress aAddr(rAddr); + ApiTokenSequence aTokens = ContainerHelper::getMapElement( maSharedFormulas, aAddr, ApiTokenSequence() ); + return aTokens; +} + void SheetDataBuffer::finalizeArrayFormula( const CellRangeAddress& rRange, const ApiTokenSequence& rTokens ) const { Reference< XArrayFormulaTokens > xTokens( getCellRange( rRange ), UNO_QUERY ); @@ -640,7 +664,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co sal_Int16 nSheet = getSheetIndex(); - CellAddress aRef1; + ScAddress aRef1( 0, 0, 0 ); if (!getAddressConverter().convertToCellAddress(aRef1, rModel.maRef1, nSheet, true)) return; @@ -659,7 +683,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co if (rModel.maRef2.isEmpty()) return; - CellAddress aRef2; + ScAddress aRef2( 0, 0, 0 ); if (!getAddressConverter().convertToCellAddress(aRef2, rModel.maRef2, nSheet, true)) return; @@ -672,8 +696,8 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co aScRange.aStart.IncCol(-1); // Ref1 is row input cell and Ref2 is column input cell. - aParam.aRefRowCell.Set(aRef1.Column, aRef1.Row, aRef1.Sheet, false, false, false); - aParam.aRefColCell.Set(aRef2.Column, aRef2.Row, aRef2.Sheet, false, false, false); + aParam.aRefRowCell.Set(aRef1.Col(), aRef1.Row(), aRef1.Tab(), false, false, false); + aParam.aRefColCell.Set(aRef2.Col(), aRef2.Row(), aRef2.Tab(), false, false, false); rDoc.setTableOpCells(aScRange, aParam); return; @@ -685,7 +709,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co { // One-variable row input cell (horizontal). aParam.meMode = ScTabOpParam::Row; - aParam.aRefRowCell.Set(aRef1.Column, aRef1.Row, aRef1.Sheet, false, false, false); + 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.aRefFormulaEnd = aParam.aRefFormulaCell; aScRange.aStart.IncRow(-1); @@ -695,7 +719,7 @@ void SheetDataBuffer::finalizeTableOperation( const CellRangeAddress& rRange, co { // One-variable column input cell (vertical). aParam.meMode = ScTabOpParam::Column; - aParam.aRefColCell.Set(aRef1.Column, aRef1.Row, aRef1.Sheet, false, false, false); + 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.aRefFormulaEnd = aParam.aRefFormulaCell; aScRange.aStart.IncCol(-1); diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx index 7cf3be026d00..4bdace5083c3 100644 --- a/sc/source/filter/oox/sheetdatacontext.cxx +++ b/sc/source/filter/oox/sheetdatacontext.cxx @@ -171,8 +171,8 @@ void SheetDataContext::onEndElement() mbHasFormula = false; break; case XML_array: - if( mbValidRange && maFmlaData.isValidArrayRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) ) - setCellArrayFormula( maFmlaData.maFormulaRef, CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ), maFormulaStr ); + if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) ) + setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr ); // set cell formatting, but do not set result as cell value mrSheetData.setBlankCell( maCellData ); break; @@ -294,7 +294,7 @@ void SheetDataContext::importRow( const AttributeList& rAttribs ) // decode the column spans (space-separated list of colon-separated integer pairs) OUString aColSpansText = rAttribs.getString( XML_spans, OUString() ); - sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Column; + sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Col(); sal_Int32 nIndex = 0; while( nIndex >= 0 ) { @@ -340,8 +340,7 @@ bool SheetDataContext::importCell( const AttributeList& rAttribs ) mbHasFormula = false; // update used area of the sheet - CellAddress addrTemp = CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ); - extendUsedArea( addrTemp ); + extendUsedArea( maCellData.maCellAddr ); } return bValid; } @@ -395,7 +394,7 @@ void SheetDataContext::importRow( SequenceInputStream& rStrm ) aModel.mbThickBottom = getFlag( nFlags1, BIFF12_ROW_THICKBOTTOM ); // read the column spans - sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Column; + sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Col(); for( sal_Int32 nSpanIdx = 0; (nSpanIdx < nSpanCount) && !rStrm.isEof(); ++nSpanIdx ) { sal_Int32 nFirstCol, nLastCol; @@ -425,7 +424,7 @@ bool SheetDataContext::readCellHeader( SequenceInputStream& rStrm, CellType eCel // update used area of the sheet if( bValidAddr ) - extendUsedArea( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ); + extendUsedArea( maCellData.maCellAddr ); return bValidAddr; } @@ -539,7 +538,7 @@ void SheetDataContext::importCellString( SequenceInputStream& rStrm, CellType eC void SheetDataContext::importArray( SequenceInputStream& rStrm ) { - if( readFormulaRef( rStrm ) && maFmlaData.isValidArrayRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) ) + if( readFormulaRef( rStrm ) && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) ) { rStrm.skip( 1 ); ApiTokenSequence aTokens = mxFormulaParser->importFormula( maCellData.maCellAddr, FORMULATYPE_ARRAY, rStrm ); @@ -567,10 +566,10 @@ void SheetDataContext::importDataTable( SequenceInputStream& rStrm ) void SheetDataContext::importSharedFmla( SequenceInputStream& rStrm ) { - if( readFormulaRef( rStrm ) && maFmlaData.isValidSharedRef( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ) ) ) + if( readFormulaRef( rStrm ) && maFmlaData.isValidSharedRef( maCellData.maCellAddr ) ) { ApiTokenSequence aTokens = mxFormulaParser->importFormula( maCellData.maCellAddr, FORMULATYPE_SHAREDFORMULA, rStrm ); - mrSheetData.createSharedFormula( CellAddress ( maCellData.maCellAddr.Tab(), maCellData.maCellAddr.Col(), maCellData.maCellAddr.Row() ), aTokens ); + mrSheetData.createSharedFormula( maCellData.maCellAddr, aTokens ); } } diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx index fae30670bc01..508f9014b1c6 100644 --- a/sc/source/filter/oox/viewsettings.cxx +++ b/sc/source/filter/oox/viewsettings.cxx @@ -334,7 +334,7 @@ void SheetViewSettings::finalizeImport() if( getSheetType() == SHEETTYPE_CHARTSHEET ) { xModel->maPaneSelMap.clear(); - xModel->maFirstPos = xModel->maSecondPos = CellAddress( getSheetIndex(), 0, 0 ); + xModel->maFirstPos = xModel->maSecondPos = ScAddress( SCCOL ( 0 ), SCROW ( 0 ), SCTAB (getSheetIndex() ) ); xModel->mnViewType = XML_normal; xModel->mnActivePaneId = XML_topLeft; xModel->mnPaneState = XML_split; @@ -358,9 +358,9 @@ void SheetViewSettings::finalizeImport() aPropSet.setProperty( PROP_IsVisible, sal_True ); } // visible area and current cursor position (selection not supported via API) - CellAddress aFirstPos = xModel->maFirstPos; + ScAddress aFirstPos = xModel->maFirstPos; const PaneSelectionModel* pPaneSel = xModel->getActiveSelection(); - CellAddress aCursor = pPaneSel ? pPaneSel->maActiveCell : aFirstPos; + ScAddress aCursor = pPaneSel ? pPaneSel->maActiveCell : aFirstPos; // freeze/split position default sal_Int16 nHSplitMode = API_SPLITMODE_NONE; @@ -377,12 +377,12 @@ void SheetViewSettings::finalizeImport() #i35812# Excel uses number of visible rows/columns in the frozen area (rows/columns scolled outside are not included), Calc uses absolute position of first unfrozen row/column. */ - const CellAddress& rMaxApiPos = getAddressConverter().getMaxApiAddress(); - if( (xModel->mfSplitX >= 1.0) && (xModel->maFirstPos.Column + xModel->mfSplitX <= rMaxApiPos.Column) ) - nHSplitPos = static_cast< sal_Int32 >( xModel->maFirstPos.Column + xModel->mfSplitX ); + const ScAddress& rMaxApiPos = getAddressConverter().getMaxApiAddress(); + if( (xModel->mfSplitX >= 1.0) && ( xModel->maFirstPos.Col() + xModel->mfSplitX <= rMaxApiPos.Col() ) ) + nHSplitPos = static_cast< sal_Int32 >( xModel->maFirstPos.Col() + xModel->mfSplitX ); nHSplitMode = (nHSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; - if( (xModel->mfSplitY >= 1.0) && (xModel->maFirstPos.Row + xModel->mfSplitY <= rMaxApiPos.Row) ) - nVSplitPos = static_cast< sal_Int32 >( xModel->maFirstPos.Row + xModel->mfSplitY ); + if( (xModel->mfSplitY >= 1.0) && ( xModel->maFirstPos.Row() + xModel->mfSplitY <= rMaxApiPos.Row() ) ) + nVSplitPos = static_cast< sal_Int32 >( xModel->maFirstPos.Row() + xModel->mfSplitY ); nVSplitMode = (nVSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; } else if( xModel->mnPaneState == XML_split ) @@ -418,17 +418,17 @@ void SheetViewSettings::finalizeImport() // write the sheet view settings into the property sequence PropertyMap aPropMap; aPropMap.setProperty( PROP_TableSelected, bSelected); - aPropMap.setProperty( PROP_CursorPositionX, aCursor.Column); - aPropMap.setProperty( PROP_CursorPositionY, aCursor.Row); + aPropMap.setProperty( PROP_CursorPositionX, aCursor.Col() ); + aPropMap.setProperty( PROP_CursorPositionY, aCursor.Row() ); aPropMap.setProperty( PROP_HorizontalSplitMode, nHSplitMode); aPropMap.setProperty( PROP_VerticalSplitMode, nVSplitMode); aPropMap.setProperty( PROP_HorizontalSplitPositionTwips, nHSplitPos); aPropMap.setProperty( PROP_VerticalSplitPositionTwips, nVSplitPos); aPropMap.setProperty( PROP_ActiveSplitRange, nActivePane); - aPropMap.setProperty( PROP_PositionLeft, aFirstPos.Column); - aPropMap.setProperty( PROP_PositionTop, aFirstPos.Row); - aPropMap.setProperty( PROP_PositionRight, xModel->maSecondPos.Column); - aPropMap.setProperty( PROP_PositionBottom, ((nVSplitPos > 0) ? xModel->maSecondPos.Row : xModel->maFirstPos.Row)); + aPropMap.setProperty( PROP_PositionLeft, aFirstPos.Col() ); + aPropMap.setProperty( PROP_PositionTop, aFirstPos.Row() ); + aPropMap.setProperty( PROP_PositionRight, xModel->maSecondPos.Col() ); + aPropMap.setProperty( PROP_PositionBottom, ((nVSplitPos > 0) ? xModel->maSecondPos.Row() : xModel->maFirstPos.Row() ) ); aPropMap.setProperty( PROP_ZoomType, API_ZOOMTYPE_PERCENT); aPropMap.setProperty( PROP_ZoomValue, static_cast< sal_Int16 >( xModel->getNormalZoom() )); aPropMap.setProperty( PROP_PageViewZoomValue, static_cast< sal_Int16 >( xModel->getPageBreakZoom() )); diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 7b86d8573e16..1f8b670bc251 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -288,6 +288,8 @@ public: /** Extends the used area of this sheet by the passed cell position. */ void extendUsedArea( const CellAddress& rAddress ); + void extendUsedArea( const ScAddress& rAddress ); + /** Extends the used area of this sheet by the passed cell range. */ void extendUsedArea( const CellRangeAddress& rRange ); /** Extends the shape bounding box by the position and size of the passed rectangle. */ @@ -376,7 +378,7 @@ private: typedef ::std::unique_ptr< BiffSheetDrawing > BiffSheetDrawingPtr; const OUString maSheetCellRanges; /// Service name for a SheetCellRanges object. - const CellAddress& mrMaxApiPos; /// Reference to maximum Calc cell address from address converter. + const ScAddress& mrMaxApiPos; /// Reference to maximum Calc cell address from address converter. CellRangeAddress maUsedArea; /// Used area of the sheet, and sheet index of the sheet. ColumnModel maDefColModel; /// Default column formatting. ColumnModelRangeMap maColModels; /// Ranges of columns sorted by first column index. @@ -664,8 +666,8 @@ CellAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPos awt::Point aBegPos( 0, 0 ); // end cell address and its position in drawing layer (bottom-right edge) - sal_Int32 nEndCol = mrMaxApiPos.Column + 1; - sal_Int32 nEndRow = mrMaxApiPos.Row + 1; + sal_Int32 nEndCol = mrMaxApiPos.Col() + 1; + sal_Int32 nEndRow = mrMaxApiPos.Row() + 1; awt::Point aEndPos( maDrawPageSize.Width, maDrawPageSize.Height ); // starting point for interval search @@ -749,6 +751,14 @@ void WorksheetGlobals::extendUsedArea( const CellAddress& rAddress ) maUsedArea.EndRow = ::std::max( maUsedArea.EndRow, rAddress.Row ); } +void WorksheetGlobals::extendUsedArea( const ScAddress& rAddress ) +{ + maUsedArea.StartColumn = ::std::min( maUsedArea.StartColumn, sal_Int32( rAddress.Col() ) ); + maUsedArea.StartRow = ::std::min( maUsedArea.StartRow, sal_Int32( rAddress.Row() ) ); + maUsedArea.EndColumn = ::std::max( maUsedArea.EndColumn, sal_Int32( rAddress.Col() ) ); + maUsedArea.EndRow = ::std::max( maUsedArea.EndRow, sal_Int32( rAddress.Row() ) ); +} + void WorksheetGlobals::extendUsedArea( const CellRangeAddress& rRange ) { extendUsedArea( CellAddress( rRange.Sheet, rRange.StartColumn, rRange.StartRow ) ); @@ -804,7 +814,7 @@ void WorksheetGlobals::setColumnModel( const ColumnModel& rModel ) { // validate last column index if( !getAddressConverter().checkCol( nLastCol, true ) ) - nLastCol = mrMaxApiPos.Column; + nLastCol = mrMaxApiPos.Col(); // try to find entry in column model map that is able to merge with the passed model bool bInsertModel = true; if( !maColModels.empty() ) @@ -845,7 +855,7 @@ void WorksheetGlobals::setColumnModel( const ColumnModel& rModel ) void WorksheetGlobals::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId ) { - CellRangeAddress aRange( getSheetIndex(), nFirstCol, 0, nLastCol, mrMaxApiPos.Row ); + CellRangeAddress aRange( getSheetIndex(), nFirstCol, 0, nLastCol, mrMaxApiPos.Row() ); if( getAddressConverter().validateCellRange( aRange, true, false ) ) { const StylesBuffer& rStyles = getStyles(); @@ -1165,7 +1175,7 @@ void WorksheetGlobals::finalizeValidationRanges() const void WorksheetGlobals::convertColumns() { sal_Int32 nNextCol = 0; - sal_Int32 nMaxCol = mrMaxApiPos.Column; + sal_Int32 nMaxCol = mrMaxApiPos.Col(); // stores first grouped column index for each level OutlineLevelVec aColLevels; @@ -1243,7 +1253,7 @@ void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels, void WorksheetGlobals::convertRows() { sal_Int32 nNextRow = 0; - sal_Int32 nMaxRow = mrMaxApiPos.Row; + sal_Int32 nMaxRow = mrMaxApiPos.Row(); // stores first grouped row index for each level OutlineLevelVec aRowLevels; @@ -1352,7 +1362,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.Column, mrMaxApiPos.Row ) ) ); + PropertySet aRangeProp( getCellRange( CellRangeAddress( getSheetIndex(), 0, 0, mrMaxApiPos.Col(), mrMaxApiPos.Row() ) ) ); aRangeProp.getProperty( maDrawPageSize, PROP_Size ); switch( getFilterType() ) @@ -1553,6 +1563,11 @@ void WorksheetHelper::extendUsedArea( const CellAddress& rAddress ) mrSheetGlob.extendUsedArea( rAddress ); } +void WorksheetHelper::extendUsedArea( const ScAddress& rAddress ) +{ + mrSheetGlob.extendUsedArea( rAddress ); +} + void WorksheetHelper::extendUsedArea( const CellRangeAddress& rRange ) { mrSheetGlob.extendUsedArea( rRange ); @@ -1706,6 +1721,11 @@ void WorksheetHelper::setCellArrayFormula( const css::table::CellRangeAddress& r getFormulaBuffer().setCellArrayFormula( rRangeAddress, rTokenAddress, rTokenStr ); } +void WorksheetHelper::setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr ) +{ + getFormulaBuffer().setCellArrayFormula( rRangeAddress, rTokenAddress, rTokenStr ); +} + void WorksheetHelper::createSharedFormulaMapEntry( const table::CellAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens ) { |