sc/source/filter/inc/sheetdatabuffer.hxx | 4 - sc/source/filter/oox/sheetdatabuffer.cxx | 27 +------- sc/source/filter/oox/worksheethelper.cxx | 94 ++++++++++++++++++------------- 3 files changed, 59 insertions(+), 66 deletions(-)
New commits: commit 844bba4bb44966a1d27f55c4e511eb7f5887d147 Author: Daniel Bankston <[email protected]> Date: Fri May 11 12:04:14 2012 -0500 Replace extra XFormulaTokens call with direct ScDocument Change-Id: Ib7469c4214687021efdcfb9bbf162ee6eb6404c4 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 835324b..84b1678 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -69,6 +69,7 @@ #include "sharedstringsbuffer.hxx" #include "sheetdatabuffer.hxx" #include "stylesbuffer.hxx" +#include "tokenuno.hxx" #include "unitconverter.hxx" #include "viewsettings.hxx" #include "workbooksettings.hxx" @@ -1587,9 +1588,13 @@ void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichStri void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTokenSequence& rTokens ) const { - Reference< XFormulaTokens > xTokens( getCell( rAddress ), UNO_QUERY ); - OSL_ENSURE( xTokens.is(), "WorksheetHelper::putFormulaTokens - missing token interface" ); - if( xTokens.is() ) xTokens->setTokens( rTokens ); + ScDocument& rDoc = getScDocument(); + ScTokenArray aTokenArray; + ScAddress aCellPos; + ScUnoConversion::FillScAddress( aCellPos, rAddress ); + ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens ); + ScBaseCell* pNewCell = new ScFormulaCell( &rDoc, aCellPos, &aTokenArray ); + rDoc.PutCell( aCellPos, pNewCell, sal_True ); } void WorksheetHelper::initializeWorksheetImport() commit 82f91c909a49d3556e771f420c48d41eb71f506f Author: Daniel Bankston <[email protected]> Date: Fri May 11 10:37:44 2012 -0500 Get cell instance once and use c++style cast Change-Id: I0a2a06b805ba1fd7d03937e767568d622615b059 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index e9cefd7..835324b 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1558,9 +1558,10 @@ void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fVal ScDocument& rDoc = getScDocument(); ScAddress aCellPos; ScUnoConversion::FillScAddress( aCellPos, rAddress ); - if ( rDoc.GetCellType( aCellPos ) == CELLTYPE_FORMULA ) + ScBaseCell* pBaseCell = rDoc.GetCell( aCellPos ); + if ( pBaseCell->GetCellType() == CELLTYPE_FORMULA ) { - ScFormulaCell* pCell = (ScFormulaCell *)rDoc.GetCell( aCellPos ); + ScFormulaCell* pCell = static_cast< ScFormulaCell* >( pBaseCell ); pCell->SetHybridDouble( fValue ); pCell->ResetDirty(); pCell->ResetChanged(); commit 1158a8b833441b33ca30cfc1fae9f8f283745d81 Author: Daniel Bankston <[email protected]> Date: Fri May 11 10:14:43 2012 -0500 Use ScUnoConversion instead of casts for address conversion Change-Id: Ia3fbe15aeed9a3cb7928ada1a438b190f8fbb017 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 49ab86a..e9cefd7 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1548,7 +1548,9 @@ void WorksheetHelper::setManualRowHeight( sal_Int32 nRow ) void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) const { - getScDocument().SetValue( (SCCOL)rAddress.Column, (SCROW)rAddress.Row, (SCTAB)rAddress.Sheet, fValue ); + ScAddress aAddress; + ScUnoConversion::FillScAddress( aAddress, rAddress ); + getScDocument().SetValue( aAddress.Col(), aAddress.Row(), aAddress.Tab(), fValue ); } void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fValue ) const @@ -1567,7 +1569,9 @@ void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fVal void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const { - getScDocument().SetString( (SCCOL)rAddress.Column, (SCROW)rAddress.Row, (SCTAB)rAddress.Sheet, rText ); + ScAddress aAddress; + ScUnoConversion::FillScAddress( aAddress, rAddress ); + getScDocument().SetString( aAddress.Col(), aAddress.Row(), aAddress.Tab(), rText ); } void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichString& rString, const Font* pFirstPortionFont ) const commit ac409adb1926f6c4f865b3c6df7bfd57e298a60b Author: Daniel Bankston <[email protected]> Date: Thu May 10 17:01:37 2012 -0500 Pass forumlaResult value directly to ScDocument - Removed extra call to XCell2 and instead passed formula result directly to ScDocument. Change-Id: Ifea731e44f12a048b76f8d5a4cc2d0619a56bbbc diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 0f6fb0a..49ab86a 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -56,8 +56,10 @@ #include "oox/helper/propertyset.hxx" #include "addressconverter.hxx" #include "autofilterbuffer.hxx" +#include "cell.hxx" #include "commentsbuffer.hxx" #include "condformatbuffer.hxx" +#include "convuno.hxx" #include "document.hxx" #include "drawingfragment.hxx" #include "drawingmanager.hxx" @@ -1551,9 +1553,16 @@ void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) con void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fValue ) const { - Reference< XCell2 > xCell( getCell( rAddress ), UNO_QUERY ); - OSL_ENSURE( xCell.is(), "WorksheetHelper::putFormulaResult - missing cell interface" ); - if( xCell.is() ) xCell->setFormulaResult( fValue ); + ScDocument& rDoc = getScDocument(); + ScAddress aCellPos; + ScUnoConversion::FillScAddress( aCellPos, rAddress ); + if ( rDoc.GetCellType( aCellPos ) == CELLTYPE_FORMULA ) + { + ScFormulaCell* pCell = (ScFormulaCell *)rDoc.GetCell( aCellPos ); + pCell->SetHybridDouble( fValue ); + pCell->ResetDirty(); + pCell->ResetChanged(); + } } void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const commit 14f23858c617b8fa3872d743f6d4a78cf2338020 Author: Daniel Bankston <[email protected]> Date: Thu May 10 15:56:59 2012 -0500 Remove extra XText call and pass string directly to ScDocument Change-Id: I568b86f34335bb9290ae796a6140d6e4ff65752b diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 42e3f70..0f6fb0a 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1558,9 +1558,7 @@ void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fVal void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const { - Reference< XText > xText( getCell( rAddress ), UNO_QUERY ); - OSL_ENSURE( xText.is(), "WorksheetHelper::putString - missing text interface" ); - if( xText.is() ) xText->setString( rText ); + getScDocument().SetString( (SCCOL)rAddress.Column, (SCROW)rAddress.Row, (SCTAB)rAddress.Sheet, rText ); } void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichString& rString, const Font* pFirstPortionFont ) const commit 5057c65fed7e55982de5bda9626fe863b7316c64 Author: Daniel Bankston <[email protected]> Date: Thu May 10 15:10:01 2012 -0500 Remove getCellBlock() code that always returns null. - Removed CellBlockBuffer::getCellBlock() method that always returns null as per my IRC convo yesterday with Kohei. Change-Id: If57429c8cf48d309a610c703d97b53406653a767 diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx index 65612bc..c8dc451 100644 --- a/sc/source/filter/inc/sheetdatabuffer.hxx +++ b/sc/source/filter/inc/sheetdatabuffer.hxx @@ -152,10 +152,6 @@ public: /** Sets column span information for a row. */ void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans ); - /** Tries to find a cell block. Recalculates the map of cell blocks, if the - passed cell address is located in another row than the last cell. */ - CellBlock* getCellBlock( const ::com::sun::star::table::CellAddress& rCellAddr ); - /** Inserts all cells of all open cell blocks into the Calc document. */ void finalizeImport(); diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 245b167..6d4e305 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -211,13 +211,6 @@ void CellBlockBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpan maColSpans[ nRow ] = rColSpans.getRanges(); } -CellBlock* CellBlockBuffer::getCellBlock( const CellAddress& rCellAddr ) -{ - (void) rCellAddr; - // TODO: Fix this. - return NULL; -} - void CellBlockBuffer::finalizeImport() { maCellBlocks.forEachMem( &CellBlock::finalizeImport ); @@ -244,19 +237,13 @@ void SheetDataBuffer::setBlankCell( const CellModel& rModel ) void SheetDataBuffer::setValueCell( const CellModel& rModel, double fValue ) { - if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) - pCellBlock->getCellAny( rModel.maCellAddr.Column ) <<= fValue; - else - putValue( rModel.maCellAddr, fValue ); + putValue( rModel.maCellAddr, fValue ); setCellFormat( rModel ); } void SheetDataBuffer::setStringCell( const CellModel& rModel, const OUString& rText ) { - if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) - pCellBlock->getCellAny( rModel.maCellAddr.Column ) <<= rText; - else - putString( rModel.maCellAddr, rText ); + putString( rModel.maCellAddr, rText ); setCellFormat( rModel ); } @@ -271,10 +258,7 @@ void SheetDataBuffer::setStringCell( const CellModel& rModel, const RichStringRe } else { - if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rModel.maCellAddr ) ) - pCellBlock->insertRichString( rModel.maCellAddr, rxString, pFirstPortionFont ); - else - putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont ); + putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont ); setCellFormat( rModel ); } } @@ -574,10 +558,7 @@ void SheetDataBuffer::setCellFormula( const CellAddress& rCellAddr, const ApiTok { if( rTokens.hasElements() ) { - if( CellBlock* pCellBlock = maCellBlocks.getCellBlock( rCellAddr ) ) - pCellBlock->getCellAny( rCellAddr.Column ) <<= rTokens; - else - putFormulaTokens( rCellAddr, rTokens ); + putFormulaTokens( rCellAddr, rTokens ); } } commit 8f9099c01385fb6b72a352a07b11c2a1ed0e3ca1 Author: Daniel Bankston <[email protected]> Date: Thu May 10 14:04:42 2012 -0500 Remove extra XCell call and pass cell value directly to ScDocument. Change-Id: Idb16d82dad08f1028a065cba568682477fe41313 diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx index 3a3abc2..42e3f70 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -58,6 +58,7 @@ #include "autofilterbuffer.hxx" #include "commentsbuffer.hxx" #include "condformatbuffer.hxx" +#include "document.hxx" #include "drawingfragment.hxx" #include "drawingmanager.hxx" #include "formulaparser.hxx" @@ -77,7 +78,7 @@ namespace xls { // ============================================================================ -using namespace ::com::sun::star::awt; +using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::lang; @@ -263,17 +264,17 @@ public: /** Returns the XDrawPage interface of the draw page of the current sheet. */ Reference< XDrawPage > getDrawPage() const; /** Returns the size of the entire drawing page in 1/100 mm. */ - const Size& getDrawPageSize() const; + const awt::Size& getDrawPageSize() const; /** Returns the absolute position of the top-left corner of the cell in 1/100 mm. */ - Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const; + awt::Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const; /** Returns the size of the cell in 1/100 mm. */ - Size getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const; + awt::Size getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const; /** Returns the address of the cell that contains the passed point in 1/100 mm. */ - CellAddress getCellAddressFromPosition( const Point& rPosition ) const; + CellAddress getCellAddressFromPosition( const awt::Point& rPosition ) const; /** Returns the cell range address that contains the passed rectangle in 1/100 mm. */ - CellRangeAddress getCellRangeFromRectangle( const Rectangle& rRect ) const; + CellRangeAddress getCellRangeFromRectangle( const awt::Rectangle& rRect ) const; /** Returns the buffer for cell contents and cell formatting. */ inline SheetDataBuffer& getSheetData() { return maSheetData; } @@ -314,7 +315,7 @@ public: /** 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. */ - void extendShapeBoundingBox( const Rectangle& rShapeRect ); + void extendShapeBoundingBox( const awt::Rectangle& rShapeRect ); /** Sets base width for all columns (without padding pixels). This value is only used, if base width has not been set with setDefaultColumnWidth(). */ @@ -407,8 +408,8 @@ private: BiffSheetDrawingPtr mxBiffDrawing; /// Collection of all BIFF/DFF shapes. OUString maDrawingPath; /// Path to DrawingML fragment. OUString maVmlDrawingPath; /// Path to legacy VML drawing fragment. - Size maDrawPageSize; /// Current size of the drawing page in 1/100 mm. - Rectangle maShapeBoundingBox; /// Bounding box for all shapes from all drawings. + awt::Size maDrawPageSize; /// Current size of the drawing page in 1/100 mm. + awt::Rectangle maShapeBoundingBox; /// Bounding box for all shapes from all drawings. ISegmentProgressBarRef mxProgressBar; /// Sheet progress bar. ISegmentProgressBarRef mxRowProgress; /// Progress bar for row/cell processing. ISegmentProgressBarRef mxFinalProgress; /// Progress bar for finalization. @@ -589,23 +590,23 @@ Reference< XDrawPage > WorksheetGlobals::getDrawPage() const return xDrawPage; } -const Size& WorksheetGlobals::getDrawPageSize() const +const awt::Size& WorksheetGlobals::getDrawPageSize() const { OSL_ENSURE( (maDrawPageSize.Width > 0) && (maDrawPageSize.Height > 0), "WorksheetGlobals::getDrawPageSize - called too early, size invalid" ); return maDrawPageSize; } -Point WorksheetGlobals::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const +awt::Point WorksheetGlobals::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const { - Point aPoint; + awt::Point aPoint; PropertySet aCellProp( getCell( CellAddress( getSheetIndex(), nCol, nRow ) ) ); aCellProp.getProperty( aPoint, PROP_Position ); return aPoint; } -Size WorksheetGlobals::getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const +awt::Size WorksheetGlobals::getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const { - Size aSize; + awt::Size aSize; PropertySet aCellProp( getCell( CellAddress( getSheetIndex(), nCol, nRow ) ) ); aCellProp.getProperty( aSize, PROP_Size ); return aSize; @@ -680,23 +681,23 @@ bool lclUpdateInterval( sal_Int32& rnBegAddr, sal_Int32& rnMidAddr, sal_Int32& r } // namespace -CellAddress WorksheetGlobals::getCellAddressFromPosition( const Point& rPosition ) const +CellAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPosition ) const { // starting cell address and its position in drawing layer (top-left edge) sal_Int32 nBegCol = 0; sal_Int32 nBegRow = 0; - Point aBegPos( 0, 0 ); + 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; - Point aEndPos( maDrawPageSize.Width, maDrawPageSize.Height ); + awt::Point aEndPos( maDrawPageSize.Width, maDrawPageSize.Height ); // starting point for interval search sal_Int32 nMidCol, nMidRow; bool bLoopCols = lclPrepareInterval( nBegCol, nMidCol, nEndCol, aBegPos.X, aEndPos.X, rPosition.X ); bool bLoopRows = lclPrepareInterval( nBegRow, nMidRow, nEndRow, aBegPos.Y, aEndPos.Y, rPosition.Y ); - Point aMidPos = getCellPosition( nMidCol, nMidRow ); + awt::Point aMidPos = getCellPosition( nMidCol, nMidRow ); /* The loop will find the column/row index of the cell right of/below the cell containing the passed point, unless the point is located at @@ -716,10 +717,10 @@ CellAddress WorksheetGlobals::getCellAddressFromPosition( const Point& rPosition return CellAddress( getSheetIndex(), nMidCol, nMidRow ); } -CellRangeAddress WorksheetGlobals::getCellRangeFromRectangle( const Rectangle& rRect ) const +CellRangeAddress WorksheetGlobals::getCellRangeFromRectangle( const awt::Rectangle& rRect ) const { - CellAddress aStartAddr = getCellAddressFromPosition( Point( rRect.X, rRect.Y ) ); - Point aBotRight( rRect.X + rRect.Width, rRect.Y + rRect.Height ); + CellAddress aStartAddr = getCellAddressFromPosition( awt::Point( rRect.X, rRect.Y ) ); + awt::Point aBotRight( rRect.X + rRect.Width, rRect.Y + rRect.Height ); CellAddress aEndAddr = getCellAddressFromPosition( aBotRight ); bool bMultiCols = aStartAddr.Column < aEndAddr.Column; bool bMultiRows = aStartAddr.Row < aEndAddr.Row; @@ -727,7 +728,7 @@ CellRangeAddress WorksheetGlobals::getCellRangeFromRectangle( const Rectangle& r { /* Reduce end position of the cell range to previous column or row, if the rectangle ends exactly between two columns or rows. */ - Point aEndPos = getCellPosition( aEndAddr.Column, aEndAddr.Row ); + awt::Point aEndPos = getCellPosition( aEndAddr.Column, aEndAddr.Row ); if( bMultiCols && (aBotRight.X <= aEndPos.X) ) --aEndAddr.Column; if( bMultiRows && (aBotRight.Y <= aEndPos.Y) ) @@ -779,7 +780,7 @@ void WorksheetGlobals::extendUsedArea( const CellRangeAddress& rRange ) extendUsedArea( CellAddress( rRange.Sheet, rRange.EndColumn, rRange.EndRow ) ); } -void WorksheetGlobals::extendShapeBoundingBox( const Rectangle& rShapeRect ) +void WorksheetGlobals::extendShapeBoundingBox( const awt::Rectangle& rShapeRect ) { if( (maShapeBoundingBox.Width == 0) && (maShapeBoundingBox.Height == 0) ) { @@ -1413,17 +1414,17 @@ Reference< XDrawPage > WorksheetHelper::getDrawPage() const return mrSheetGlob.getDrawPage(); } -Point WorksheetHelper::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const +awt::Point WorksheetHelper::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const { return mrSheetGlob.getCellPosition( nCol, nRow ); } -Size WorksheetHelper::getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const +awt::Size WorksheetHelper::getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const { return mrSheetGlob.getCellSize( nCol, nRow ); } -Size WorksheetHelper::getDrawPageSize() const +awt::Size WorksheetHelper::getDrawPageSize() const { return mrSheetGlob.getDrawPageSize(); } @@ -1508,7 +1509,7 @@ void WorksheetHelper::extendUsedArea( const CellRangeAddress& rRange ) mrSheetGlob.extendUsedArea( rRange ); } -void WorksheetHelper::extendShapeBoundingBox( const Rectangle& rShapeRect ) +void WorksheetHelper::extendShapeBoundingBox( const awt::Rectangle& rShapeRect ) { mrSheetGlob.extendShapeBoundingBox( rShapeRect ); } @@ -1545,9 +1546,7 @@ void WorksheetHelper::setManualRowHeight( sal_Int32 nRow ) void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) const { - Reference< XCell > xCell = getCell( rAddress ); - OSL_ENSURE( xCell.is(), "WorksheetHelper::putValue - missing cell interface" ); - if( xCell.is() ) xCell->setValue( fValue ); + getScDocument().SetValue( (SCCOL)rAddress.Column, (SCROW)rAddress.Row, (SCTAB)rAddress.Sheet, fValue ); } void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fValue ) const _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
