[Libreoffice-commits] .: 2 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Dec 14 15:58:33 PST 2010
sc/source/ui/docshell/docsh5.cxx | 22 +++++++------
sc/source/ui/inc/undotab.hxx | 15 ++++----
sc/source/ui/undo/undotab.cxx | 66 +++++++++++++++------------------------
sc/source/ui/view/viewfun2.cxx | 28 +++++++---------
4 files changed, 59 insertions(+), 72 deletions(-)
New commits:
commit b2f3c59bc4a6dafe4ae4ee4997b53bcff5df84c0
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Dec 14 18:57:04 2010 -0500
Replaced SvShorts with std::vector<SCTAB>.
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 59c7e4b..edb92cd 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -69,6 +69,9 @@
#include <basic/sbstar.hxx>
#include <basic/basmgr.hxx>
+#include <memory>
+#include <vector>
+
// defined in docfunc.cxx
void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource );
@@ -78,6 +81,9 @@ using com::sun::star::container::XNameContainer;
using com::sun::star::uno::Reference;
using com::sun::star::uno::UNO_QUERY;
+using ::std::auto_ptr;
+using ::std::vector;
+
// ---------------------------------------------------------------------------
//
@@ -934,12 +940,10 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
if (bRecord)
{
- SvShorts aSrcList;
- SvShorts aDestList;
- aSrcList.Insert(nSrcTab,0);
- aDestList.Insert(nDestTab,0);
+ auto_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
+ auto_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
GetUndoManager()->AddUndoAction(
- new ScUndoCopyTab( this, aSrcList, aDestList ) );
+ new ScUndoCopyTab(this, pSrcList.release(), pDestList.release()));
}
BOOL bVbaEnabled = aDocument.IsInVBAMode();
@@ -996,12 +1000,10 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec
return FALSE;
else if (bRecord)
{
- SvShorts aSrcList;
- SvShorts aDestList;
- aSrcList.Insert(nSrcTab,0);
- aDestList.Insert(nDestTab,0);
+ auto_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
+ auto_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
GetUndoManager()->AddUndoAction(
- new ScUndoMoveTab( this, aSrcList, aDestList ) );
+ new ScUndoMoveTab(this, pSrcList.release(), pDestList.release()));
}
Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 5d46136..bf43322 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -184,7 +184,8 @@ public:
TYPEINFO();
ScUndoMoveTab(
ScDocShell* pNewDocShell,
- const SvShorts &aOldTab, const SvShorts &aNewTab,
+ ::std::vector<SCTAB>* pOldTabs,
+ ::std::vector<SCTAB>* pNewTabs,
::std::vector< ::rtl::OUString>* pOldNames = NULL,
::std::vector< ::rtl::OUString>* pNewNames = NULL );
@@ -198,10 +199,10 @@ public:
virtual String GetComment() const;
private:
+ ::boost::shared_ptr< ::std::vector<SCTAB> > mpOldTabs;
+ ::boost::shared_ptr< ::std::vector<SCTAB> > mpNewTabs;
::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpOldNames;
::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpNewNames;
- SvShorts theOldTabs;
- SvShorts theNewTabs;
void DoChange( BOOL bUndo ) const;
};
@@ -213,8 +214,8 @@ public:
TYPEINFO();
ScUndoCopyTab(
ScDocShell* pNewDocShell,
- const SvShorts &aOldTab,
- const SvShorts &aNewTab,
+ ::std::vector<SCTAB>* pOldTabs,
+ ::std::vector<SCTAB>* pNewTabs,
::std::vector< ::rtl::OUString>* pNewNames = NULL );
virtual ~ScUndoCopyTab();
@@ -227,10 +228,10 @@ public:
virtual String GetComment() const;
private:
+ ::boost::shared_ptr< ::std::vector<SCTAB> > mpOldTabs;
+ ::boost::shared_ptr< ::std::vector<SCTAB> > mpNewTabs;
::boost::shared_ptr< ::std::vector< ::rtl::OUString> > mpNewNames;
SdrUndoAction* pDrawUndo;
- SvShorts theOldTabs;
- SvShorts theNewTabs;
void DoChange() const;
};
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 65c7f67..3c1ba2b 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -547,31 +547,23 @@ BOOL ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
//
ScUndoMoveTab::ScUndoMoveTab(
- ScDocShell* pNewDocShell, const SvShorts &aOldTab, const SvShorts &aNewTab,
+ ScDocShell* pNewDocShell, vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs,
vector<OUString>* pOldNames, vector<OUString>* pNewNames) :
ScSimpleUndo( pNewDocShell ),
+ mpOldTabs(pOldTabs), mpNewTabs(pNewTabs),
mpOldNames(pOldNames), mpNewNames(pNewNames)
{
- int i;
- for(i=0;i<aOldTab.Count();i++)
- theOldTabs.Insert(aOldTab[sal::static_int_cast<USHORT>(i)],theOldTabs.Count());
-
- for(i=0;i<aNewTab.Count();i++)
- theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
-
- if (mpOldNames && theOldTabs.Count() != mpOldNames->size())
+ if (mpOldNames && mpOldTabs->size() != mpOldNames->size())
// The sizes differ. Something is wrong.
mpOldNames.reset();
- if (mpNewNames && theNewTabs.Count() != mpNewNames->size())
+ if (mpNewNames && mpNewTabs->size() != mpNewNames->size())
// The sizes differ. Something is wrong.
mpNewNames.reset();
}
ScUndoMoveTab::~ScUndoMoveTab()
{
- theNewTabs.Remove(0,theNewTabs.Count());
- theOldTabs.Remove(0,theOldTabs.Count());
}
String ScUndoMoveTab::GetComment() const
@@ -586,10 +578,10 @@ void ScUndoMoveTab::DoChange( BOOL bUndo ) const
if (bUndo) // UnDo
{
- for(int i=theNewTabs.Count()-1;i>=0;i--)
+ for (size_t i = mpNewTabs->size(); i > 0; --i)
{
- SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
- SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nDestTab = (*mpNewTabs)[i-1];
+ SCTAB nOldTab = (*mpOldTabs)[i-1];
if (nDestTab > MAXTAB) // angehaengt ?
nDestTab = pDoc->GetTableCount() - 1;
@@ -598,18 +590,18 @@ void ScUndoMoveTab::DoChange( BOOL bUndo ) const
pViewShell->SetTabNo( nOldTab, TRUE );
if (mpOldNames)
{
- const OUString& rOldName = (*mpOldNames)[i];
+ const OUString& rOldName = (*mpOldNames)[i-1];
pDoc->RenameTab(nOldTab, rOldName);
}
}
}
else
{
- for(int i=0;i<theNewTabs.Count();i++)
+ for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i)
{
- SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
- SCTAB nNewTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
- SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nDestTab = (*mpNewTabs)[i];
+ SCTAB nNewTab = nDestTab;
+ SCTAB nOldTab = (*mpOldTabs)[i];
if (nDestTab > MAXTAB) // angehaengt ?
nDestTab = pDoc->GetTableCount() - 1;
@@ -658,22 +650,18 @@ BOOL ScUndoMoveTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
//
ScUndoCopyTab::ScUndoCopyTab(
- ScDocShell* pNewDocShell, const SvShorts &aOldTab, const SvShorts &aNewTab,
+ ScDocShell* pNewDocShell,
+ vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs,
vector<OUString>* pNewNames) :
ScSimpleUndo( pNewDocShell ),
+ mpOldTabs(pOldTabs),
+ mpNewTabs(pNewTabs),
mpNewNames(pNewNames),
pDrawUndo( NULL )
{
pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
- int i;
- for(i=0;i<aOldTab.Count();i++)
- theOldTabs.Insert(aOldTab[sal::static_int_cast<USHORT>(i)],theOldTabs.Count());
-
- for(i=0;i<aNewTab.Count();i++)
- theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
-
- if (mpNewNames && theNewTabs.Count() != mpNewNames->size())
+ if (mpNewNames && mpNewTabs->size() != mpNewNames->size())
// The sizes differ. Something is wrong.
mpNewNames.reset();
}
@@ -693,7 +681,7 @@ void ScUndoCopyTab::DoChange() const
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
if (pViewShell)
- pViewShell->SetTabNo(theOldTabs[0],TRUE);
+ pViewShell->SetTabNo((*mpOldTabs)[0],TRUE);
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator
@@ -708,10 +696,10 @@ void ScUndoCopyTab::Undo()
DoSdrUndoAction( pDrawUndo, pDoc ); // before the sheets are deleted
- int i;
- for(i=theNewTabs.Count()-1;i>=0;i--)
+ vector<SCTAB>::const_reverse_iterator itr, itrEnd = mpNewTabs->rend();
+ for (itr = mpNewTabs->rbegin(); itr != itrEnd; ++itr)
{
- SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nDestTab = *itr;
if (nDestTab > MAXTAB) // append?
nDestTab = pDoc->GetTableCount() - 1;
@@ -723,9 +711,9 @@ void ScUndoCopyTab::Undo()
// ScTablesHint broadcasts after all sheets have been deleted,
// so sheets and draw pages are in sync!
- for(i=theNewTabs.Count()-1;i>=0;i--)
+ for (itr = mpNewTabs->rbegin(); itr != itrEnd; ++itr)
{
- SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nDestTab = *itr;
if (nDestTab > MAXTAB) // append?
nDestTab = pDoc->GetTableCount() - 1;
@@ -741,11 +729,11 @@ void ScUndoCopyTab::Redo()
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nDestTab = 0;
- for(int i=0;i<theNewTabs.Count();i++)
+ for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i)
{
- nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
- SCTAB nNewTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
- SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ nDestTab = (*mpNewTabs)[i];
+ SCTAB nNewTab = nDestTab;
+ SCTAB nOldTab = (*mpOldTabs)[i];
if (nDestTab > MAXTAB) // angehaengt ?
nDestTab = pDoc->GetTableCount() - 1;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index e78eec4..5c07a40 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2756,10 +2756,12 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
// Move or copy within the same document.
SCTAB nTabCount = pDoc->GetTableCount();
- SvShorts TheTabs;
- SvShorts TheDestTabs;
+ auto_ptr< vector<SCTAB> > pSrcTabs(new vector<SCTAB>);
+ auto_ptr< vector<SCTAB> > pDestTabs(new vector<SCTAB>);
auto_ptr< vector<OUString> > pTabNames(new vector<OUString>);
auto_ptr< vector<OUString> > pDestNames(NULL);
+ pSrcTabs->reserve(nTabCount);
+ pDestTabs->reserve(nTabCount);
pTabNames->reserve(nTabCount);
String aDestName;
@@ -2819,7 +2821,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
pDoc->SetVisible(nDestTab1,bVisible );
}
- TheTabs.Insert(nMovTab,TheTabs.Count());
+ pSrcTabs->push_back(nMovTab);
if(!bCopy)
{
@@ -2829,18 +2831,18 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
}
}
- TheDestTabs.Insert(nDestTab1,TheDestTabs.Count());
+ pDestTabs->push_back(nDestTab1);
}
// Rename must be done after all sheets have been moved.
if (bRename)
{
pDestNames.reset(new vector<OUString>);
- size_t n = TheDestTabs.Count();
+ size_t n = pDestTabs->size();
pDestNames->reserve(n);
for (size_t j = 0; j < n; ++j)
{
- SCTAB nRenameTab = static_cast<SCTAB>(TheDestTabs[j]);
+ SCTAB nRenameTab = (*pDestTabs)[j];
String aTabName = *pNewTabName;
pDoc->CreateValidTabName( aTabName );
pDestNames->push_back(aTabName);
@@ -2858,13 +2860,14 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
if (bCopy)
{
pDocShell->GetUndoManager()->AddUndoAction(
- new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs, pDestNames.release()));
+ new ScUndoCopyTab(
+ pDocShell, pSrcTabs.release(), pDestTabs.release(), pDestNames.release()));
}
else
{
pDocShell->GetUndoManager()->AddUndoAction(
new ScUndoMoveTab(
- pDocShell, TheTabs, TheDestTabs, pTabNames.release(), pDestNames.release()));
+ pDocShell, pSrcTabs.release(), pDestTabs.release(), pTabNames.release(), pDestNames.release()));
}
}
commit f534c96b2c69306d5888f87c88cb8e5b081c8263
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Dec 14 18:13:46 2010 -0500
Removed unused code.
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 8b923c7..e78eec4 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2716,13 +2716,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
default:
break;
}
- //pDestShell->GetUndoManager()->Clear(); //! Undo implementieren !!!
-/*
- String sName;
- pDestDoc->GetName(nDestTab, sName);
- pDestShell->GetUndoManager()->AddUndoAction(
- new ScUndoInsertTab( pDestShell, nDestTab, TRUE, sName ) );
-*/
+
if (!bCopy)
{
if(nTabCount!=nTabSelCount)
@@ -2738,7 +2732,6 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy, const
pDestDoc->UpdateChartListenerCollection();
pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.Count())); // alte erste Tabelle
-//? pDestDoc->SelectTable(0, TRUE); // neue erste Tabelle selektieren
if (pDestViewSh)
pDestViewSh->TabChanged(); // Pages auf dem Drawing-Layer
pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
More information about the Libreoffice-commits
mailing list