[PATCH] Replace SvShorts with std::vector
Nigel Hawkins
n.hawkins at gmx.com
Thu Jan 27 05:52:52 PST 2011
---
sc/source/ui/docshell/docfunc.cxx | 21 ++++++++++---------
sc/source/ui/inc/undotab.hxx | 8 +++---
sc/source/ui/inc/viewfunc.hxx | 3 +-
sc/source/ui/undo/undotab.cxx | 41 ++++++++++++++++++-------------------
sc/source/ui/view/tabvwshf.cxx | 10 +++++---
sc/source/ui/view/viewfun2.cxx | 37 ++++++++++++++++-----------------
6 files changed, 61 insertions(+), 59 deletions(-)
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 85e31a5..0fe04f7 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -105,6 +105,7 @@
#include <basic/basmgr.hxx>
#include <boost/scoped_ptr.hpp>
#include <set>
+#include <vector>
using namespace com::sun::star;
using ::com::sun::star::uno::Sequence;
@@ -2625,8 +2626,8 @@ uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, St
uno::Reference< uno::XInterface > xDocModuleApiObject;
if ( xSF.is() )
{
- xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );
- xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );
+ xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );
+ xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );
}
return xDocModuleApiObject;
@@ -2661,7 +2662,7 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String
// if the Module with codename exists then find a new name
sal_Int32 nNum = 0;
String genModuleName;
- if ( sModuleName.Len() )
+ if ( sModuleName.Len() )
genModuleName = sModuleName;
else
{
@@ -2670,7 +2671,7 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String
}
while( xLib->hasByName( genModuleName ) )
genModuleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Sheet")) + rtl::OUString::valueOf( ++nNum );
-
+
uno::Any aSourceAny;
rtl::OUString sTmpSource = sSource;
if ( sTmpSource.getLength() == 0 )
@@ -2728,7 +2729,7 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL
// Strange loop, also basic is loaded too early ( InsertTable )
- // is called via the xml import for sheets in described in odf
+ // is called via the xml import for sheets in described in odf
BOOL bInsertDocModule = false;
if( !rDocShell.GetDocument()->IsImportingXML() )
@@ -2833,8 +2834,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ )
{
if (bRecord)
{
- SvShorts theTabs;
- theTabs.Insert(nTab,theTabs.Count());
+ vector<SCTAB> theTabs;
+ theTabs.push_back(nTab);
rDocShell.GetUndoManager()->AddUndoAction(
new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
}
@@ -3295,8 +3296,8 @@ BOOL ScDocFunc::InsertPageBreak( BOOL bColumn, const ScAddress& rPos,
if (nPos == 0)
return FALSE; // erste Spalte / Zeile
- ScBreakType nBreak = bColumn ?
- pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) :
+ ScBreakType nBreak = bColumn ?
+ pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) :
pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
if (nBreak & BREAK_MANUAL)
return true;
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index bf43322..26eb8a2 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -130,7 +130,7 @@ public:
TYPEINFO();
ScUndoDeleteTab(
ScDocShell* pNewDocShell,
- const SvShorts &theTabs, //SCTAB nNewTab,
+ const std::vector<SCTAB> &theTabs, //SCTAB nNewTab,
ScDocument* pUndoDocument,
ScRefUndoData* pRefData );
virtual ~ScUndoDeleteTab();
@@ -143,7 +143,7 @@ public:
virtual String GetComment() const;
private:
- SvShorts theTabs;
+ std::vector<SCTAB> theTabs;
ULONG nStartChangeAction;
ULONG nEndChangeAction;
@@ -406,7 +406,7 @@ private:
class ScUndoTabProtect : public ScSimpleUndo
{
public:
- ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
+ ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
::std::auto_ptr<ScTableProtection> pProtectSettings);
virtual ~ScUndoTabProtect();
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 98107ea..b07bf00 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -46,6 +46,7 @@
#endif
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/Aspects.hpp>
+#include <vector>
class ScPatternAttr;
class ScAutoFormatData;
@@ -269,7 +270,7 @@ public:
BOOL AppendTable( const String& rName, BOOL bRecord = TRUE );
BOOL DeleteTable( SCTAB nTabNr, BOOL bRecord = TRUE );
- BOOL DeleteTables(const SvShorts &TheTabs, BOOL bRecord = TRUE );
+ BOOL DeleteTables(const std::vector<SCTAB>& TheTabs, BOOL bRecord = TRUE );
BOOL RenameTable( const String& rName, SCTAB nTabNr );
void MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const String* pNewTabName = NULL );
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 3c1ba2b..17b6900 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -57,6 +57,8 @@
#include "drwlayer.hxx"
#include "scresid.hxx"
+#include <vector>
+
extern BOOL bDrawIsInUndo; //! irgendwo als Member !!!
using namespace com::sun::star;
@@ -252,14 +254,13 @@ void ScUndoInsertTables::Undo()
pDocShell->SetInUndo( TRUE ); //! BeginUndo
bDrawIsInUndo = TRUE;
- SvShorts TheTabs;
- for(int i=0;i<pNameList->Count();i++)
+ vector<SCTAB> TheTabs;
+ for(int i=0; i<pNameList->Count(); i++)
{
- TheTabs.Insert( sal::static_int_cast<short>(nTab+i), TheTabs.Count() );
+ TheTabs.push_back(i);
}
-
pViewShell->DeleteTables( TheTabs, FALSE );
- TheTabs.Remove(0,TheTabs.Count());
+ TheTabs.clear();
bDrawIsInUndo = FALSE;
pDocShell->SetInUndo( FALSE ); //! EndUndo
@@ -309,19 +310,17 @@ BOOL ScUndoInsertTables::CanRepeat(SfxRepeatTarget& rTarget) const
// Tabelle loeschen
//
-ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell,const SvShorts &aTab, //SCTAB nNewTab,
+ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell, const vector<SCTAB> &aTab, //SCTAB nNewTab,
ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST )
{
- for(int i=0;i<aTab.Count();i++)
- theTabs.Insert(aTab[sal::static_int_cast<USHORT>(i)],theTabs.Count());
-
- SetChangeTrack();
+ theTabs.insert(theTabs.end(), aTab.begin(), aTab.end() );
+ SetChangeTrack();
}
ScUndoDeleteTab::~ScUndoDeleteTab()
{
- theTabs.Remove(0,theTabs.Count());
+ theTabs.clear();
}
String ScUndoDeleteTab::GetComment() const
@@ -338,10 +337,10 @@ void ScUndoDeleteTab::SetChangeTrack()
nStartChangeAction = pChangeTrack->GetActionMax() + 1;
nEndChangeAction = 0;
ScRange aRange( 0, 0, 0, MAXCOL, MAXROW, 0 );
- for ( int i = 0; i < theTabs.Count(); i++ )
+ for ( unsigned int i = 0; i < theTabs.size(); i++ )
{
- aRange.aStart.SetTab( theTabs[sal::static_int_cast<USHORT>(i)] );
- aRange.aEnd.SetTab( theTabs[sal::static_int_cast<USHORT>(i)] );
+ aRange.aStart.SetTab( theTabs[i] );
+ aRange.aEnd.SetTab( theTabs[i] );
pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc,
nTmpChangeAction, nEndChangeAction, (short) i );
}
@@ -361,15 +360,15 @@ SCTAB lcl_GetVisibleTabBefore( ScDocument& rDoc, SCTAB nTab )
void ScUndoDeleteTab::Undo()
{
BeginUndo();
- int i=0;
+ unsigned int i=0;
ScDocument* pDoc = pDocShell->GetDocument();
BOOL bLink = FALSE;
String aName;
- for(i=0;i<theTabs.Count();i++)
+ for(i=0; i<theTabs.size(); ++i)
{
- SCTAB nTab = theTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nTab = theTabs[i];
pRefUndoDoc->GetName( nTab, aName );
bDrawIsInUndo = TRUE;
@@ -425,9 +424,9 @@ void ScUndoDeleteTab::Undo()
if ( pChangeTrack )
pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
- for(i=0;i<theTabs.Count();i++)
+ for(i=0; i<theTabs.size(); ++i)
{
- pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[sal::static_int_cast<USHORT>(i)]) );
+ pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[i]) );
}
SfxApplication* pSfxApp = SFX_APP(); // Navigator
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
@@ -794,7 +793,7 @@ BOOL ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
// Tab Bg Color
//
-ScUndoTabColor::ScUndoTabColor(
+ScUndoTabColor::ScUndoTabColor(
ScDocShell* pNewDocShell, SCTAB nT, const Color& aOTabBgColor, const Color& aNTabBgColor) :
ScSimpleUndo( pNewDocShell )
{
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 06d77ac..feff623 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -59,6 +59,8 @@
#include "tabbgcolor.hxx"
#include "tabbgcolordlg.hxx"
+#include <vector>
+
using ::boost::scoped_ptr;
using namespace com::sun::star;
@@ -634,12 +636,12 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
SCTAB nFirstTab=0;
BOOL bTabFlag=FALSE;
ScMarkData& rMark = pViewData->GetMarkData();
- SvShorts TheTabs;
+ std::vector<SCTAB> TheTabs;
for(SCTAB i=0;i<nTabCount;i++)
{
if(rMark.GetTableSelect(i) &&!pDoc->IsTabProtected(i))
{
- TheTabs.Insert(i,TheTabs.Count());
+ TheTabs.push_back(i);
bTabFlag=TRUE;
if(nNewTab==i) nNewTab++;
}
@@ -649,7 +651,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
pViewData->SetTabNo(nNewTab);
DeleteTables(TheTabs);
- TheTabs.Remove(0,TheTabs.Count());
+ TheTabs.clear();
rReq.Done();
}
}
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 130eb17..232e37f 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -2195,13 +2195,12 @@ BOOL ScViewFunc::DeleteTable( SCTAB nTab, BOOL bRecord )
return bSuccess;
}
-BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
+BOOL ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, BOOL bRecord )
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : FALSE;
SCTAB nNewTab = TheTabs[0];
- int i;
WaitObject aWait( GetFrameWin() );
if (bRecord && !pDoc->IsUndoEnabled())
bRecord = FALSE;
@@ -2220,9 +2219,9 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
SCTAB nCount = pDoc->GetTableCount();
String aOldName;
- for(i=0;i<TheTabs.Count();i++)
+ for(unsigned int i=0; i<TheTabs.size(); ++i)
{
- SCTAB nTab = TheTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nTab = TheTabs[i];
if (i==0)
pUndoDoc->InitUndo( pDoc, nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags
else
@@ -2270,11 +2269,11 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
BOOL bDelDone = FALSE;
- for(i=TheTabs.Count()-1;i>=0;i--)
+ for(int i=TheTabs.size()-1; i>=0; --i)
{
String sCodeName;
- BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast<USHORT>(i)], sCodeName );
- if (pDoc->DeleteTab( TheTabs[sal::static_int_cast<USHORT>(i)], pUndoDoc ))
+ BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[i], sCodeName );
+ if (pDoc->DeleteTab( TheTabs[i], pUndoDoc ))
{
bDelDone = TRUE;
if( bVbaEnabled )
@@ -2284,7 +2283,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
VBA_DeleteModule( *pDocSh, sCodeName );
}
}
- pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
+ pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[i] ) );
}
}
if (bRecord)
@@ -2615,21 +2614,21 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
SCTAB nTabCount = pDoc->GetTableCount();
SCTAB nTabSelCount = rMark.GetSelectCount();
- SvShorts TheTabs;
+ vector<SCTAB> TheTabs;
- for(SCTAB i=0;i<nTabCount;i++)
+ for(SCTAB i=0; i<nTabCount; i++)
{
if(rMark.GetTableSelect(i))
{
String aTabName;
pDoc->GetName( i, aTabName);
- TheTabs.Insert(i,TheTabs.Count());
+ TheTabs.push_back(i);
for(SCTAB j=i+1;j<nTabCount;j++)
{
if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
{
pDoc->GetName( j, aTabName);
- TheTabs.Insert(j,TheTabs.Count());
+ TheTabs.push_back(j);
i=j;
}
else break;
@@ -2649,7 +2648,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
if(nDestTab==SC_TAB_APPEND)
nDestTab=pDestDoc->GetTableCount();
SCTAB nDestTab1=nDestTab;
- for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
+ for( USHORT j=0; j<TheTabs.size(); j++, nDestTab1++ )
{ // #63304# insert sheets first and update all references
String aName;
if (bRename)
@@ -2667,9 +2666,9 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
if ( nErrVal > 0 )
{
nDestTab1 = nDestTab;
- for(USHORT i=0;i<TheTabs.Count();i++)
+ for(USHORT i=0; i<TheTabs.size();i++)
{
- nErrVal = pDestShell->TransferTab( *pDocShell, static_cast<SCTAB>(TheTabs[i]), static_cast<SCTAB>(nDestTab1), FALSE, FALSE );
+ nErrVal = pDestShell->TransferTab( *pDocShell, TheTabs[i], static_cast<SCTAB>(nDestTab1), FALSE, FALSE );
nDestTab1++;
}
}
@@ -2679,7 +2678,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
pDestDoc->GetName(nDestTab, sName);
pDestShell->GetUndoManager()->AddUndoAction(
new ScUndoImportTab( pDestShell, nDestTab,
- static_cast<SCTAB>(TheTabs.Count()), FALSE));
+ static_cast<SCTAB>(TheTabs.size()), FALSE));
}
else
@@ -2726,7 +2725,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
pDestDoc->UpdateChartListenerCollection();
- pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.Count())); // alte erste Tabelle
+ pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.size())); // alte erste Tabelle
if (pDestViewSh)
pDestViewSh->TabChanged(); // Pages auf dem Drawing-Layer
pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
@@ -2741,7 +2740,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
pDestShell->PostPaintGridAll();
}
- TheTabs.Remove(0,TheTabs.Count());
+ TheTabs.clear();
pDestShell->SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
--
1.7.0.4
--=-aYNAAJTUfh4tqmotxrdT
Content-Disposition: attachment; filename="0002-Remove-SvShorts.patch"
Content-Type: text/x-patch; name="0002-Remove-SvShorts.patch"; charset="UTF-8"
Content-Transfer-Encoding: 7bit
More information about the LibreOffice
mailing list