Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi

I converted the SV PTRARR to std::deque in sw component.
Could you please check and push this path?
This and later contributions is licensed under MPL 1.1 / GPL v3+ / LGPL v3+.

Best Regards
Bartosz





From a0291c115fa588b7e0d2faeb0df38c7a8f694004 Mon Sep 17 00:00:00 2001
From: Bartosz Kosiorek <gang65@poczta.onet.pl>
Date: Sat, 24 Mar 2012 23:01:06 +0100
Subject: [PATCH] Convert SV_PTRARRAY to ::std::deque

---
 sw/inc/crsrsh.hxx                |    1 -
 sw/inc/tblsel.hxx                |    3 ++-
 sw/source/core/crsr/trvltbl.cxx  |    2 +-
 sw/source/core/frmedt/fetab.cxx  |   14 +++++++-------
 sw/source/core/frmedt/tblsel.cxx |   33 +++++++++++++++------------------
 5 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index fba2e68..0c07972 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -69,7 +69,6 @@ class SwTxtINetFmt;
 class SwFmtINetFmt;
 class SwTxtAttr;
 class SwTableBox;
-class SwCellFrms;
 class SwTOXMark;
 class SwRedline;
 class IBlockCursor;
diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx
index 5ecc65b..5725956 100644
--- a/sw/inc/tblsel.hxx
+++ b/sw/inc/tblsel.hxx
@@ -34,6 +34,7 @@
 #include "swdllapi.h"
 
 #include <map>
+#include <deque>
 
 class SwCrsrShell;
 class SwCursor;
@@ -49,7 +50,7 @@ class SwTable;
 class SwUndoTblMerge;
 class SwCellFrm;
 
-SV_DECL_PTRARR( SwCellFrms, SwCellFrm*, 16 )
+typedef ::std::deque< SwCellFrm* > SwCellFrms;
 
 
 class SwSelBoxes : private std::map<sal_uLong, SwTableBox*>
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index cae5aa8..44a2b95 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -217,7 +217,7 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple )
                    static_cast<const SwCellFrm*>(pEndFrm),
                    aBoxes, bSelectUp ? 0 : &aCells, eType );
 
-        if( aBoxes.empty() || ( !bSelectUp && 4 != aCells.Count() ) )
+        if( aBoxes.empty() || ( !bSelectUp && 4 != aCells.size() ) )
             return sal_False;
 
         if ( bSelectUp )
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 3d3a1ae..9da85cd 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -2345,12 +2345,12 @@ sal_Bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& 
rFml
     for( SwSelBoxes::reverse_iterator it = aBoxes.rbegin(); it != aBoxes.rend(); ++it )
     {
         SwTableBox* pBox = it->second;
-        sal_uInt16 i;
-        for( i = 0; i < rCells.Count(); ++i )
-            if( rCells[ i ]->GetTabBox() == pBox )
+        SwCellFrms::iterator iC;
+        for( iC = rCells.begin(); iC != rCells.end(); ++iC )
+            if( (*iC)->GetTabBox() == pBox )
                 break;      // found
 
-        if( i == rCells.Count() )
+        if( iC == rCells.end() )
             return sal_False;
     }
 
@@ -2371,7 +2371,7 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
     if( ::GetAutoSumSel( *this, aCells ))
     {
         sal_uInt16 nW = 0, nInsPos = 0;
-        for( sal_uInt16 n = aCells.Count(); n; )
+        for( size_t n = aCells.size(); n; )
         {
             SwCellFrm* pCFrm = aCells[ --n ];
             sal_uInt16 nBoxW = pCFrm->GetTabBox()->IsFormulaOrValueBox();
@@ -2393,7 +2393,7 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                 {
                     nW = RES_BOXATR_VALUE;
                     // restore previous spaces!
-                    for( sal_uInt16 i = aCells.Count(); n+1 < i; )
+                    for( size_t i = aCells.size(); n+1 < i; )
                     {
                         String sTmp( String::CreateFromAscii(
                                 RTL_CONSTASCII_STRINGPARAM( "|<" )) );
@@ -2431,7 +2431,7 @@ sal_Bool SwFEShell::GetAutoSum( String& rFml ) const
                         nW = RES_BOXATR_VALUE;
                         rFml.Erase( nInsPos );
                         // restore previous spaces!
-                        for( sal_uInt16 i = aCells.Count(); n+1 < i; )
+                        for( size_t i = aCells.size(); n+1 < i; )
                         {
                             String sTmp( String::CreateFromAscii(
                                     RTL_CONSTASCII_STRINGPARAM( "|<" )) );
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 2a4123e..c6a8b64 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -74,9 +74,6 @@
 #undef      DEL_EMPTY_BOXES_AT_START_AND_END
 #define     DEL_ALL_EMPTY_BOXES
 
-
-SV_IMPL_PTRARR( SwCellFrms, SwCellFrm* )
-
 struct _CmpLPt
 {
     Point aPos;
@@ -358,7 +355,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
                                        aTopLeft.X() <  aCurrentTopLeft.X() ) )
                                 {
                                     aCurrentTopLeft = aTopLeft;
-                                    pCurrentTopLeftFrm = static_cast<const SwCellFrm*>( pCell );
+                                    pCurrentTopLeftFrm = static_cast< const SwCellFrm* >( pCell );
                                 }
 
                                 if ( aTopRight.Y() < aCurrentTopRight.Y() ||
@@ -366,7 +363,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
                                        aTopRight.X() >  aCurrentTopRight.X() ) )
                                 {
                                     aCurrentTopRight = aTopRight;
-                                    pCurrentTopRightFrm = static_cast<const SwCellFrm*>( pCell );
+                                    pCurrentTopRightFrm = static_cast< const SwCellFrm* >( pCell );
                                 }
 
                                 if ( aBottomLeft.Y() > aCurrentBottomLeft.Y() ||
@@ -374,7 +371,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
                                        aBottomLeft.X() <  aCurrentBottomLeft.X() ) )
                                 {
                                     aCurrentBottomLeft = aBottomLeft;
-                                    pCurrentBottomLeftFrm = static_cast<const SwCellFrm*>( pCell );
+                                    pCurrentBottomLeftFrm = static_cast< const SwCellFrm* >( pCell 
);
                                 }
 
                                 if ( aBottomRight.Y() > aCurrentBottomRight.Y() ||
@@ -382,7 +379,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
                                        aBottomRight.X() >  aCurrentBottomRight.X() ) )
                                 {
                                     aCurrentBottomRight = aBottomRight;
-                                    pCurrentBottomRightFrm = static_cast<const SwCellFrm*>( pCell 
);
+                                    pCurrentBottomRightFrm = static_cast< const SwCellFrm* >( 
pCell );
                                 }
 
                             }
@@ -403,11 +400,11 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd,
 
         if ( pCells )
         {
-            pCells->Remove( 0, pCells->Count() );
-            pCells->Insert( pCurrentTopLeftFrm, 0 );
-            pCells->Insert( pCurrentTopRightFrm, 1 );
-            pCells->Insert( pCurrentBottomLeftFrm, 2 );
-            pCells->Insert( pCurrentBottomRightFrm, 3 );
+            pCells->clear();
+            pCells->push_back( const_cast< SwCellFrm* >(pCurrentTopLeftFrm) );
+            pCells->push_back( const_cast< SwCellFrm* >(pCurrentTopRightFrm) );
+            pCells->push_back( const_cast< SwCellFrm* >(pCurrentBottomLeftFrm) );
+            pCells->push_back( const_cast< SwCellFrm* >(pCurrentBottomRightFrm) );
         }
 
         if( bTblIsValid )
@@ -773,7 +770,7 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
                     if( pCell == pSttCell )
                     {
                         sal_uInt16 nWhichId = 0;
-                        for( sal_uInt16 n = rBoxes.Count(); n; )
+                        for( size_t n = rBoxes.size(); n; )
                             if( USHRT_MAX != ( nWhichId = rBoxes[ --n ]
                                 ->GetTabBox()->IsFormulaOrValueBox() ))
                                 break;
@@ -800,7 +797,7 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
                 }
 
                 if( pUpperCell )
-                    rBoxes.Insert( pUpperCell, rBoxes.Count() );
+                    rBoxes.push_back( const_cast< SwCellFrm* >(pUpperCell) );
             }
             if( bFound )
             {
@@ -817,7 +814,7 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
     {
         bFound = sal_False;
 
-        rBoxes.Remove( 0, rBoxes.Count() );
+        rBoxes.clear();
         aUnions.DeleteAndDestroy( 0, aUnions.Count() );
         ::MakeSelUnions( aUnions, pStart, pEnd, nsSwTblSearchType::TBLSEARCH_ROW );
 
@@ -842,7 +839,7 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
                         if( pCell == pSttCell )
                         {
                             sal_uInt16 nWhichId = 0;
-                            for( sal_uInt16 n = rBoxes.Count(); n; )
+                            for( size_t n = rBoxes.size(); n; )
                                 if( USHRT_MAX != ( nWhichId = rBoxes[ --n ]
                                     ->GetTabBox()->IsFormulaOrValueBox() ))
                                     break;
@@ -857,8 +854,8 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes )
                         OSL_ENSURE( pCell->IsCellFrm(), "Frame without cell" );
                         if( ::IsFrmInTblSel( pUnion->GetUnion(), pCell ) )
                         {
-                            const SwCellFrm* pC = (SwCellFrm*)pCell;
-                            rBoxes.Insert( pC, rBoxes.Count() );
+                            SwCellFrm* pC = (SwCellFrm*)pCell;
+                            rBoxes.push_back( pC );
                         }
                         if( pCell->GetNext() )
                         {
-- 
1.7.5.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.