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

Bartosz Kosiorek gang65 at poczta.onet.pl
Mon Nov 21 17:09:14 UTC 2016


 sc/source/filter/inc/viewsettings.hxx    |    3 -
 sc/source/filter/inc/worksheethelper.hxx |    6 --
 sc/source/filter/oox/viewsettings.cxx    |   11 ++-
 sc/source/filter/oox/workbookhelper.cxx  |    4 -
 sc/source/filter/oox/worksheethelper.cxx |   93 +++++++++++++++----------------
 5 files changed, 59 insertions(+), 58 deletions(-)

New commits:
commit 597f7b1f02be79f2443230c963b6d1bb594cffa0
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Sun Nov 20 02:21:56 2016 +0100

    tdf#48140 Replace uno call from worksheethelper.cxx
    
    Change-Id: Ibf738d67af6536e9300e11f8d4fa3fe79ab7099b
    Reviewed-on: https://gerrit.libreoffice.org/31006
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/inc/viewsettings.hxx b/sc/source/filter/inc/viewsettings.hxx
index c7d3ec5..c7f343a 100644
--- a/sc/source/filter/inc/viewsettings.hxx
+++ b/sc/source/filter/inc/viewsettings.hxx
@@ -163,8 +163,7 @@ public:
                             const SheetViewModelRef& rxSheetView,
                             const css::uno::Any& rProperties );
     /** Stores the used area for a specific worksheet. */
-    void                setSheetUsedArea(
-                            const css::table::CellRangeAddress& rUsedArea );
+    void                setSheetUsedArea( const ScRange& rUsedArea );
 
     /** Converts all imported document view settings. */
     void                finalizeImport();
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index 9623059..6111a60 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -33,13 +33,10 @@ namespace com { namespace sun { namespace star {
     namespace awt { struct Rectangle; }
     namespace awt { struct Size; }
     namespace drawing { class XDrawPage; }
-    namespace sheet { class XSheetCellRanges; }
     namespace sheet { class XSpreadsheet; }
     namespace table { class XCell; }
     namespace table { class XCell2; }
     namespace table { class XCellRange; }
-    namespace table { class XTableColumns; }
-    namespace table { class XTableRows; }
 } } }
 
 namespace oox {
@@ -191,7 +188,7 @@ public:
     /** Returns the type of this sheet. */
     WorksheetType       getSheetType() const;
     /** Returns the index of the current sheet. */
-    sal_Int32           getSheetIndex() const;
+    SCTAB               getSheetIndex() const;
     /** Returns the XSpreadsheet interface of the current sheet. */
     const css::uno::Reference< css::sheet::XSpreadsheet >&
                         getSheet() const;
@@ -252,6 +249,7 @@ public:
     /** Extends the used area of this sheet by the passed cell position. */
     void                extendUsedArea( const ScAddress& rAddress );
     /** Extends the used area of this sheet by the passed cell range. */
+    void                extendUsedArea( const ScRange& rRange );
     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). */
     void                extendShapeBoundingBox( const css::awt::Rectangle& rShapeRect );
diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx
index 8a4dcaa..99f7c4a 100644
--- a/sc/source/filter/oox/viewsettings.cxx
+++ b/sc/source/filter/oox/viewsettings.cxx
@@ -533,9 +533,14 @@ void ViewSettings::setSheetViewSettings( sal_Int16 nSheet, const SheetViewModelR
     maSheetProps[ nSheet ] = rProperties;
 }
 
-void ViewSettings::setSheetUsedArea( const CellRangeAddress& rUsedArea )
-{
-    maSheetUsedAreas[ rUsedArea.Sheet ] = rUsedArea;
+void ViewSettings::setSheetUsedArea( const ScRange& rUsedArea )
+{
+    assert( rUsedArea.IsValid() );
+    assert( rUsedArea.aStart.Col() <= MAXCOLCOUNT );
+    assert( rUsedArea.aStart.Row() <= MAXROWCOUNT );
+    maSheetUsedAreas[ rUsedArea.aStart.Tab() ] = CellRangeAddress( rUsedArea.aStart.Tab(),
+                                                                   rUsedArea.aStart.Col(), rUsedArea.aStart.Row(),
+                                                                   rUsedArea.aEnd.Col(), rUsedArea.aEnd.Row() );
 }
 
 void ViewSettings::finalizeImport()
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 8cd46ed..73cc67c 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -133,7 +133,7 @@ public:
     /** Sets the VBA project storage used to import VBA source code and forms. */
     inline void         setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
     /** Sets the index of the current Calc sheet, if filter currently processes a sheet. */
-    inline void         setCurrentSheetIndex( sal_Int16 nSheet ) { mnCurrSheet = nSheet; }
+    inline void         setCurrentSheetIndex( SCTAB nSheet ) { mnCurrSheet = nSheet; }
 
     // document model ---------------------------------------------------------
 
@@ -676,7 +676,7 @@ void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg )
     mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
 }
 
-void WorkbookHelper::setCurrentSheetIndex( sal_Int16 nSheet )
+void WorkbookHelper::setCurrentSheetIndex( SCTAB nSheet )
 {
     mrBookGlob.setCurrentSheetIndex( nSheet );
 }
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 450283a..6d68ad4 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -29,7 +29,6 @@
 #include <com/sun/star/sheet/ValidationType.hpp>
 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
 #include <com/sun/star/sheet/XCellAddressable.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
 #include <com/sun/star/sheet/XSheetCondition2.hpp>
@@ -216,7 +215,7 @@ public:
     /** Returns the type of this sheet. */
     inline WorksheetType getSheetType() const { return meSheetType; }
     /** Returns the index of the current sheet. */
-    inline sal_Int32    getSheetIndex() const { return maUsedArea.Sheet; }
+    inline SCTAB        getSheetIndex() const { return maUsedArea.aStart.Tab(); }
     /** Returns the XSpreadsheet interface of the current sheet. */
     inline const Reference< XSpreadsheet >& getSheet() const { return mxSheet; }
 
@@ -244,9 +243,9 @@ public:
     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 awt::Point& rPosition ) const;
+    ScAddress                getCellAddressFromPosition( const awt::Point& rPosition ) const;
     /** Returns the cell range address that contains the passed rectangle in 1/100 mm. */
-    CellRangeAddress    getCellRangeFromRectangle( const awt::Rectangle& rRect ) const;
+    ScRange                  getCellRangeFromRectangle( const awt::Rectangle& rRect ) const;
 
     /** Returns the buffer for cell contents and cell formatting. */
     inline SheetDataBuffer& getSheetData() { return maSheetData; }
@@ -281,11 +280,10 @@ public:
     void                setVmlDrawingPath( const OUString& rVmlDrawingPath );
 
     /** 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 );
+    void                extendUsedArea( const ScRange& rRange );
     /** Extends the shape bounding box by the position and size of the passed rectangle. */
     void                extendShapeBoundingBox( const awt::Rectangle& rShapeRect );
 
@@ -365,14 +363,14 @@ private:
     void                finalizeDrawings();
 
     /** Update the row import progress bar */
-    void UpdateRowProgress( const CellRangeAddress& rUsedArea, sal_Int32 nRow );
+    void UpdateRowProgress( const ScRange& rUsedArea, SCROW nRow );
 
 private:
     typedef ::std::unique_ptr< VmlDrawing >       VmlDrawingPtr;
 
     const OUString      maSheetCellRanges;  /// Service name for a SheetCellRanges object.
     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.
+    ScRange             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.
     RowModel            maDefRowModel;      /// Default row formatting.
@@ -406,7 +404,7 @@ WorksheetGlobals::WorksheetGlobals( const WorkbookHelper& rHelper, const ISegmen
     WorkbookHelper( rHelper ),
     maSheetCellRanges( "com.sun.star.sheet.SheetCellRanges" ),
     mrMaxApiPos( rHelper.getAddressConverter().getMaxApiAddress() ),
-    maUsedArea( nSheet, SAL_MAX_INT32, SAL_MAX_INT32, -1, -1 ),
+    maUsedArea( SCCOL_MAX, SCROW_MAX, nSheet, -1, -1, nSheet ), // Set start address to largest possible value, and End Addreess to smallest
     maSheetData( *this ),
     maCondFormats( *this ),
     maComments( *this ),
@@ -422,7 +420,7 @@ WorksheetGlobals::WorksheetGlobals( const WorkbookHelper& rHelper, const ISegmen
 {
     mxSheet = getSheetFromDoc( nSheet );
     if( !mxSheet.is() )
-        maUsedArea.Sheet = -1;
+        maUsedArea.aStart.SetTab( -1 );
 
     // default column settings (width and hidden state may be updated later)
     maDefColModel.mfWidth = 8.5;
@@ -640,7 +638,7 @@ bool lclUpdateInterval( sal_Int32& rnBegAddr, sal_Int32& rnMidAddr, sal_Int32& r
 
 } // namespace
 
-CellAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPosition ) const
+ScAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPosition ) const
 {
     // starting cell address and its position in drawing layer (top-left edge)
     sal_Int32 nBegCol = 0;
@@ -673,27 +671,28 @@ CellAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPos
         or the last column/row of the sheet has been reached. */
     if( aMidPos.X > rPosition.X ) --nMidCol;
     if( aMidPos.Y > rPosition.Y ) --nMidRow;
-    return CellAddress( getSheetIndex(), nMidCol, nMidRow );
+    return ScAddress( nMidCol, nMidRow, getSheetIndex() );
 }
 
-CellRangeAddress WorksheetGlobals::getCellRangeFromRectangle( const awt::Rectangle& rRect ) const
+ScRange WorksheetGlobals::getCellRangeFromRectangle( const awt::Rectangle& rRect ) const
 {
-    CellAddress aStartAddr = getCellAddressFromPosition( awt::Point( rRect.X, rRect.Y ) );
+    ScAddress 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;
+    ScAddress aEndAddr = getCellAddressFromPosition( aBotRight );
+    bool bMultiCols = aStartAddr.Col() < aEndAddr.Col();
+    bool bMultiRows = aStartAddr.Row() < aEndAddr.Row();
     if( bMultiCols || bMultiRows )
     {
         /*  Reduce end position of the cell range to previous column or row, if
             the rectangle ends exactly between two columns or rows. */
-        awt::Point aEndPos = getCellPosition( aEndAddr.Column, aEndAddr.Row );
+        awt::Point aEndPos = getCellPosition( aEndAddr.Col(), aEndAddr.Row() );
         if( bMultiCols && (aBotRight.X <= aEndPos.X) )
-            --aEndAddr.Column;
+            aEndAddr.SetCol( aEndAddr.Col() - 1 );
         if( bMultiRows && (aBotRight.Y <= aEndPos.Y) )
-            --aEndAddr.Row;
+            aEndAddr.SetRow( aEndAddr.Row() - 1 );
     }
-    return CellRangeAddress( getSheetIndex(), aStartAddr.Column, aStartAddr.Row, aEndAddr.Column, aEndAddr.Row );
+    return ScRange( aStartAddr.Col(), aStartAddr.Row(), getSheetIndex(),
+                    aEndAddr.Col(), aEndAddr.Row(), getSheetIndex() );
 }
 
 void WorksheetGlobals::setPageBreak( const PageBreakModel& rModel, bool bRowBreak )
@@ -725,26 +724,24 @@ void WorksheetGlobals::setVmlDrawingPath( const OUString& rVmlDrawingPath )
     maVmlDrawingPath = rVmlDrawingPath;
 }
 
-void WorksheetGlobals::extendUsedArea( const CellAddress& rAddress )
+void WorksheetGlobals::extendUsedArea( const ScAddress& rAddress )
 {
-    maUsedArea.StartColumn = ::std::min( maUsedArea.StartColumn, rAddress.Column );
-    maUsedArea.StartRow    = ::std::min( maUsedArea.StartRow,    rAddress.Row );
-    maUsedArea.EndColumn   = ::std::max( maUsedArea.EndColumn,   rAddress.Column );
-    maUsedArea.EndRow      = ::std::max( maUsedArea.EndRow,      rAddress.Row );
+    maUsedArea.aStart.SetCol( ::std::min( maUsedArea.aStart.Col(), rAddress.Col() ) );
+    maUsedArea.aStart.SetRow( ::std::min( maUsedArea.aStart.Row(), rAddress.Row() ) );
+    maUsedArea.aEnd.SetCol( ::std::max( maUsedArea.aEnd.Col(), rAddress.Col() ) );
+    maUsedArea.aEnd.SetRow( ::std::max( maUsedArea.aEnd.Row(), rAddress.Row() ) );
 }
 
-void WorksheetGlobals::extendUsedArea( const ScAddress& rAddress )
+void WorksheetGlobals::extendUsedArea( const ScRange& rRange )
 {
-    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() ) );
+    extendUsedArea( rRange.aStart );
+    extendUsedArea( rRange.aEnd );
 }
 
-void WorksheetGlobals::extendUsedArea( const CellRangeAddress& rRange )
+void WorksheetHelper::extendUsedArea( const css::table::CellRangeAddress& rRange )
 {
-    extendUsedArea( CellAddress( rRange.Sheet, rRange.StartColumn, rRange.StartRow ) );
-    extendUsedArea( CellAddress( rRange.Sheet, rRange.EndColumn, rRange.EndRow ) );
+    extendUsedArea( ScAddress( rRange.StartColumn, rRange.StartRow, rRange.Sheet ) );
+    extendUsedArea( ScAddress( rRange.EndColumn, rRange.EndRow, rRange.Sheet ) );
 }
 
 void WorksheetGlobals::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
@@ -903,12 +900,12 @@ void WorksheetGlobals::setRowModel( const RowModel& rModel )
 }
 
 // This is called at a higher frequency inside the (threaded) inner loop.
-void WorksheetGlobals::UpdateRowProgress( const CellRangeAddress& rUsedArea, sal_Int32 nRow )
+void WorksheetGlobals::UpdateRowProgress( const ScRange& rUsedArea, SCROW nRow )
 {
-    if (!mxRowProgress || nRow < rUsedArea.StartRow || rUsedArea.EndRow < nRow)
+    if (!mxRowProgress || nRow < rUsedArea.aStart.Row() || rUsedArea.aEnd.Row() < nRow)
         return;
 
-    double fNewPos = static_cast<double>(nRow - rUsedArea.StartRow + 1.0) / (rUsedArea.EndRow - rUsedArea.StartRow + 1.0);
+    double fNewPos = static_cast<double>(nRow - rUsedArea.aStart.Row() + 1.0) / (rUsedArea.aEnd.Row() - rUsedArea.aStart.Row() + 1.0);
 
     if (mbFastRowProgress)
         mxRowProgress->setPosition(fNewPos);
@@ -1359,10 +1356,17 @@ void WorksheetGlobals::finalizeDrawings()
         extendUsedArea( getCellRangeFromRectangle( maShapeBoundingBox ) );
 
     // if no used area is set, default to A1
-    if( maUsedArea.StartColumn > maUsedArea.EndColumn )
-        maUsedArea.StartColumn = maUsedArea.EndColumn = 0;
-    if( maUsedArea.StartRow > maUsedArea.EndRow )
-        maUsedArea.StartRow = maUsedArea.EndRow = 0;
+    if( maUsedArea.aStart.Col() > maUsedArea.aEnd.Col() )
+    {
+        maUsedArea.aStart.SetCol( 0 );
+        maUsedArea.aEnd.SetCol( 0 );
+    }
+
+    if( maUsedArea.aStart.Row() > maUsedArea.aEnd.Row() )
+    {
+        maUsedArea.aStart.SetRow( 0 );
+        maUsedArea.aEnd.SetRow( 0 );
+    }
 
     /*  Register the used area of this sheet in global view settings. The
         global view settings will set the visible area if this document is an
@@ -1403,7 +1407,7 @@ WorksheetType WorksheetHelper::getSheetType() const
     return mrSheetGlob.getSheetType();
 }
 
-sal_Int32 WorksheetHelper::getSheetIndex() const
+SCTAB WorksheetHelper::getSheetIndex() const
 {
     return mrSheetGlob.getSheetIndex();
 }
@@ -1528,11 +1532,6 @@ void WorksheetHelper::extendUsedArea( const ScAddress& rAddress )
     mrSheetGlob.extendUsedArea( rAddress );
 }
 
-void WorksheetHelper::extendUsedArea( const CellRangeAddress& rRange )
-{
-    mrSheetGlob.extendUsedArea( rRange );
-}
-
 void WorksheetHelper::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
 {
     mrSheetGlob.extendShapeBoundingBox( rShapeRect );


More information about the Libreoffice-commits mailing list