[Libreoffice-commits] .: Branch 'feature/unlimited-number-of-sheets' - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Wed May 18 17:22:02 PDT 2011
sc/source/core/data/documen2.cxx | 14 ++++++++------
sc/source/core/data/markdata.cxx | 6 +++---
sc/source/ui/app/transobj.cxx | 6 +++---
sc/source/ui/view/gridwin.cxx | 9 ++++-----
sc/source/ui/view/tabvwshf.cxx | 11 +++++------
sc/source/ui/view/viewdata.cxx | 29 +++++++++++++++++++++++++----
sc/source/ui/view/viewfun3.cxx | 4 ++--
7 files changed, 50 insertions(+), 29 deletions(-)
New commits:
commit a25d5443d8c36a8abc210510fdb89515da337c41
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 19 02:21:03 2011 +0200
fix some bugs introduced with the last patches and rework some parts
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 950a9de..42cf6fe 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -790,12 +790,14 @@ sal_Bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos )//TODO:REWORK
ScTable* pSaveTab = pTab[nOldPos];
SCTAB i;
- for (i = nOldPos + 1; i < nTabCount; i++)
- pTab[i - 1] = pTab[i];
- pTab[i-1] = NULL;
- for (i = nTabCount - 1; i > nNewPos; i--)
- pTab[i] = pTab[i - 1];
- pTab[nNewPos] = pSaveTab;
+ pTab.erase(pTab.begin()+nOldPos);
+ pTab.insert(pTab.begin()+nNewPos, pSaveTab);
+// for (i = nOldPos + 1; i < nTabCount; i++)
+// pTab[i - 1] = pTab[i];
+// pTab[i-1] = NULL;
+// for (i = nTabCount - 1; i > nNewPos; i--)
+// pTab[i] = pTab[i - 1];
+// pTab[nNewPos] = pSaveTab;
for (i = 0; i < static_cast<SCTAB>(pTab.size()); i++)
if (pTab[i])
pTab[i]->UpdateMoveTab( nOldPos, nNewPos, i, *pProgress );
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 8871a71..34edaec 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -600,14 +600,14 @@ sal_Bool ScMarkData::HasAnyMultiMarks() const
return false; // nix
}
-void ScMarkData::InsertTab( SCTAB nTab )
+void ScMarkData::InsertTab( SCTAB nTab )//TODO:REWORK
{
maTabMarked.insert( nTab );
}
-void ScMarkData::DeleteTab( SCTAB nTab )
+void ScMarkData::DeleteTab( SCTAB nTab )//TODO:REWORK
{
- maTabMarked.erase( maTabMarked.find( nTab ) );
+ maTabMarked.erase( nTab );
}
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index b94987f..121ade1 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -160,7 +160,7 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDesc
SCTAB nTab1=0;
SCTAB nTab2=0;
sal_Bool bFirst = sal_True;
- for (SCTAB i=0; i<=MAXTAB; i++)
+ for (SCTAB i=0; i< pDoc->GetTableCount(); i++)
if (pDoc->HasTable(i))
{
if (bFirst)
@@ -766,10 +766,10 @@ void ScTransferObj::StripRefs( ScDocument* pDoc,
// In a clipboard doc the data don't have to be on the first sheet
SCTAB nSrcTab = 0;
- while (nSrcTab<MAXTAB && !pDoc->HasTable(nSrcTab))
+ while (nSrcTab<pDoc->GetTableCount() && !pDoc->HasTable(nSrcTab))
++nSrcTab;
SCTAB nDestTab = 0;
- while (nDestTab<MAXTAB && !pDestDoc->HasTable(nDestTab))
+ while (nDestTab<pDestDoc->GetTableCount() && !pDestDoc->HasTable(nDestTab))
++nDestTab;
if (!pDoc->HasTable(nSrcTab) || !pDestDoc->HasTable(nDestTab))
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index cd75842..e855a31 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3951,22 +3951,21 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
{
ScDocShell* pSrcShell = pTransObj->GetSourceDocShell();
- SCTAB nTabs[MAXTABCOUNT];
+ std::vector<SCTAB> nTabs;
ScMarkData aMark = pTransObj->GetSourceMarkData();
SCTAB nTabCount = pSourceDoc->GetTableCount();
- SCTAB nTabSelCount = 0;
for(SCTAB i=0; i<nTabCount; i++)
{
if(aMark.GetTableSelect(i))
{
- nTabs[nTabSelCount++]=i;
+ nTabs.push_back(i);
for(SCTAB j=i+1;j<nTabCount;j++)
{
if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j)))
{
- nTabs[nTabSelCount++]=j;
+ nTabs.push_back( j );
i=j;
}
else break;
@@ -3974,7 +3973,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
}
}
- pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, nThisTab );
+ pView->ImportTables( pSrcShell,static_cast<SCTAB>(nTabs.size()), &nTabs[0], bIsLink, nThisTab );
bDone = sal_True;
}
}
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 605d379..f33a562 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -252,21 +252,20 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
{
if (pDlg->GetTablesFromFile())
{
- SCTAB nTabs[MAXTABCOUNT];
- SCTAB nCount = 0;
+ std::vector<SCTAB> nTabs;
sal_uInt16 n = 0;
const String* pStr = pDlg->GetFirstTable( &n );
while ( pStr )
{
- nTabs[nCount++] = static_cast<SCTAB>(n);
+ nTabs.push_back( static_cast<SCTAB>(n) );
pStr = pDlg->GetNextTable( &n );
}
sal_Bool bLink = pDlg->GetTablesAsLink();
- if (nCount != 0)
+ if (0 < nTabs.size())
{
if(pDlg->IsTableBefore())
{
- ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
bLink,nTabNr );
}
else
@@ -282,7 +281,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
}
}
- ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), &nTabs[0],
bLink,nTabAfter );
}
}
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index c95bd68..575eb3c 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -333,7 +333,6 @@ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
aScrSize = Size( (long) ( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
(long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
pTabData.push_back( new ScViewDataTable() );
- for ( SCTAB i = 1; i <= MAXTAB; i++ )
pThisTab = pTabData[nTabNo];
for (sal_uInt16 j=0; j<4; j++)
{
@@ -461,6 +460,8 @@ void ScViewData::UpdateThis()
void ScViewData::InsertTab( SCTAB nTab )
{
+ while( nTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
pTabData.insert( pTabData.begin() + nTab, NULL );
CreateTabData( nTab );
@@ -488,6 +489,11 @@ void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
return;
}
+ if (nSrcTab >= static_cast<SCTAB>(pTabData.size()))
+ OSL_FAIL("pTabData out of bounds, FIX IT");
+
+ while( nDestTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
if ( pTabData[nSrcTab] )
pTabData.insert(pTabData.begin() + nDestTab, new ScViewDataTable( *pTabData[nSrcTab] ));
else
@@ -501,10 +507,23 @@ void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
{
if (nDestTab==SC_TAB_APPEND)
nDestTab = pDoc->GetTableCount() - 1;
+ ScViewDataTable* pTab;
+ if (nSrcTab < static_cast<SCTAB>(pTabData.size()))
+ {
+ pTab = pTabData[nSrcTab];
+ pTabData.erase( pTabData.begin() + nSrcTab );
+ }
+ else
+ pTab = NULL;
- ScViewDataTable* pTab = pTabData[nSrcTab];
- pTabData.erase( pTabData.begin() + nSrcTab );
- pTabData.insert( pTabData.begin() + nDestTab, pTab );
+ if (nDestTab < static_cast<SCTAB>(pTabData.size()))
+ pTabData.insert( pTabData.begin() + nDestTab, pTab );
+ else
+ {
+ while (nDestTab > static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
+ pTabData.push_back(pTab);
+ }
UpdateThis();
aMarkData.DeleteTab( nSrcTab );
@@ -1380,6 +1399,8 @@ void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCo
void ScViewData::CreateTabData( SCTAB nNewTab )
{
+ while(nNewTab >= static_cast<SCTAB>(pTabData.size()))
+ pTabData.push_back(NULL);
if (!pTabData[nNewTab])
{
pTabData[nNewTab] = new ScViewDataTable;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 43e73df..a4383c7 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1268,7 +1268,7 @@ sal_Bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
// #i68690# ExtendMerge for the clip doc must be called with the clipboard's sheet numbers.
// The same end column/row can be used for all calls because the clip doc doesn't contain
// content outside the clip area.
- for (SCTAB nClipTab=0; nClipTab<=MAXTAB; nClipTab++)
+ for (SCTAB nClipTab=0; nClipTab < pClipDoc->GetTableCount(); nClipTab++)
if ( pClipDoc->HasTable(nClipTab) )
if ( pClipDoc->ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nClipTab, false ) )
bClipOver = sal_True;
@@ -1604,7 +1604,7 @@ bool ScViewFunc::PasteMultiRangesFromClip(
// Determine the first and last selected sheet numbers.
SCTAB nTab1 = aMark.GetFirstSelected();
SCTAB nTab2 = nTab1;
- for (SCTAB i = nTab1+1; i <= MAXTAB; ++i)
+ for (SCTAB i = nTab1+1; i < aMark.GetLastSelected(); ++i)
if (aMark.GetTableSelect(i))
nTab2 = i;
More information about the Libreoffice-commits
mailing list