[Libreoffice-commits] .: Branch 'feature/unlimited-number-of-sheets' - 2 commits - sc/inc sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Tue May 17 07:38:30 PDT 2011


 sc/inc/address.hxx               |    2 +-
 sc/inc/markdata.hxx              |    1 +
 sc/source/core/data/documen2.cxx |   12 +++++++-----
 sc/source/core/data/documen9.cxx |    6 +++---
 sc/source/core/data/document.cxx |   33 ++++++++++++++++++++++++++-------
 sc/source/core/data/markdata.cxx |   14 ++++++++++++--
 6 files changed, 50 insertions(+), 18 deletions(-)

New commits:
commit d6dfdfe4a12037eeee8be006d1283d425bcd2909
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue May 17 16:35:15 2011 +0200

    fix bugs that were inserted with the last patches
    
    calc starts now

diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 2f31b9a..865907a 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -85,6 +85,7 @@ public:
     void		SelectOneTable( SCTAB nTab );
     SCTAB		GetSelectCount() const;
     SCTAB		GetFirstSelected() const;
+    SCTAB       GetLastSelected() const;
 
     void		SetMarkNegative( sal_Bool bFlag )	{ bMarkIsNeg = bFlag; }
     sal_Bool		IsMarkNegative() const			{ return bMarkIsNeg;  }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index b8a5f81..950a9de 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -744,11 +744,11 @@ sal_Bool ScDocument::GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRo
     return false;
 }
 
-sal_Bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos )
+sal_Bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos )//TODO:REWORK
 {
     if (nOldPos == nNewPos) return false;
     sal_Bool bValid = false;
-    if (VALIDTAB(nOldPos))
+    if (VALIDTAB(nOldPos) && nOldPos < static_cast<SCTAB>(pTab.size()))
     {
         if (pTab[nOldPos])
         {
@@ -760,7 +760,7 @@ sal_Bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos )
                 SetNoListening( sal_True );
                 ScProgress* pProgress = new ScProgress( GetDocumentShell(),
                     ScGlobal::GetRscString(STR_UNDO_MOVE_TAB), GetCodeCount() );
-                if (nNewPos == SC_TAB_APPEND)
+                if (nNewPos = SC_TAB_APPEND || nNewPos >= static_cast<SCTAB>(pTab.size()))
                     nNewPos = nTabCount-1;
 
                 //	Referenz-Updaterei
@@ -824,7 +824,8 @@ sal_Bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos )
 
 sal_Bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyMarked )
 {
-    if (SC_TAB_APPEND == nNewPos ) nNewPos = static_cast<SCTAB>(pTab.size());
+    if (SC_TAB_APPEND == nNewPos  || nNewPos >= static_cast<SCTAB>(pTab.size()))
+        nNewPos = static_cast<SCTAB>(pTab.size());
     String aName;
     GetName(nOldPos, aName);
 
@@ -848,7 +849,7 @@ sal_Bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pO
     {
         if (nNewPos >= static_cast<SCTAB>(pTab.size()))
         {
-            pTab.push_back( new ScTable(this, nMaxTableNumber, aName) );
+            pTab.push_back( new ScTable(this, static_cast<SCTAB>(pTab.size()), aName) );
         }
         else
         {
@@ -876,6 +877,7 @@ sal_Bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pO
                 for (TableContainer::iterator it = pTab.begin(); it != pTab.end(); ++it)
                     if (*it && it != (pTab.begin() + nOldPos))
                         (*it)->UpdateInsertTab(nNewPos);
+                pTab.push_back(NULL);
                 for (i = static_cast<SCTAB>(pTab.size())-1; i > nNewPos; i--)
                     pTab[i] = pTab[i - 1];
                 if (nNewPos <= nOldPos)
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index a5a853d..a9928ab 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -154,14 +154,14 @@ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
 
         SCTAB nDrawPages = 0;
         SCTAB nTab;
-        for (nTab=0; nTab< static_cast<SCTAB>(pTab.size()); nTab++)
+        for (nTab=0; nTab < static_cast<SCTAB>(pTab.size()); nTab++)
             if (pTab[nTab])
                 nDrawPages = nTab + 1;			// needed number of pages
 
-        for (nTab=0; nTab<nDrawPages; nTab++)
+        for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(pTab.size()); nTab++)
         {
             pDrawLayer->ScAddPage( nTab );		// always add page, with or without the table
-            if (nTab < static_cast<SCTAB>(pTab.size()) && pTab[nTab])
+            if (pTab[nTab])
             {
                 String aTabName;
                 pTab[nTab]->GetName(aTabName);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9f28517..527cc09 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -361,7 +361,7 @@ sal_Bool ScDocument::InsertTab( SCTAB nPos, const String& rName,
         }
         else
         {
-            if (VALIDTAB(nPos) && (nPos < nTabCount))
+            if (VALIDTAB(nPos) && (nPos < nTabCount))//TODO:REWORK
             {
                 ScRange aRange( 0,0,nPos, MAXCOL,MAXROW,MAXTAB );
                 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
@@ -384,6 +384,7 @@ sal_Bool ScDocument::InsertTab( SCTAB nPos, const String& rName,
                     if (pTab[i])
                         pTab[i]->UpdateInsertTab(nPos);
 
+                pTab.push_back(NULL);
                 for (i = nTabCount; i > nPos; i--)
                 {
                     pTab[i] = pTab[i - 1];
@@ -1402,7 +1403,7 @@ void ScDocument::DeleteAreaTab( const ScRange& rRange, sal_uInt16 nDelFlag )
 }
 
 
-void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSelection,//TODO:REWORK
+void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSelection,
                                 sal_Bool bColInfo, sal_Bool bRowInfo )
 {
     if (bIsUndo)
@@ -1412,11 +1413,21 @@ void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSe
         xPoolHelper = pSrcDoc->xPoolHelper;
 
         String aString;
-        for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++)
+        for (SCTAB nTab = 0; nTab < rTabSelection.GetLastSelected(); nTab++)
             if ( rTabSelection.GetTableSelect( nTab ) )
             {
-                pTab[nTab] = new ScTable(this, nTab, aString, bColInfo, bRowInfo);
-                nMaxTableNumber = nTab + 1;
+                ScTable* pTable = new ScTable(this, nTab, aString, bColInfo, bRowInfo);
+                if (nTab < static_cast<SCTAB>(pTab.size()))
+                    pTab[nTab] = pTable;
+                else
+                    pTab.push_back(pTable);
+            }
+            else
+            {
+                if (nTab < static_cast<SCTAB>(pTab.size()))
+                    pTab[nTab]=NULL;
+                else
+                    pTab.push_back(NULL);
             }
     }
     else
@@ -1426,7 +1437,7 @@ void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, const ScMarkData& rTabSe
 }
 
 
-void ScDocument::InitUndo( ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,//TODO:REWORK
+void ScDocument::InitUndo( ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,
                                 sal_Bool bColInfo, sal_Bool bRowInfo )
 {
     if (bIsUndo)
@@ -1436,8 +1447,16 @@ void ScDocument::InitUndo( ScDocument* pSrcDoc, SCTAB nTab1, SCTAB nTab2,//TODO:
         xPoolHelper = pSrcDoc->xPoolHelper;
 
         String aString;
+        while ( nTab1 > static_cast<SCTAB>(pTab.size()))
+            pTab.push_back(NULL);
         for (SCTAB nTab = nTab1; nTab <= nTab2; nTab++)
-            pTab[nTab] = new ScTable(this, nTab, aString, bColInfo, bRowInfo);
+        {
+            ScTable* pTable = new ScTable(this, nTab, aString, bColInfo, bRowInfo);
+            if (nTab < static_cast<SCTAB>(pTab.size()))
+                pTab[nTab] = pTable;
+            else
+                pTab.push_back(pTable);
+        }
 
         nMaxTableNumber = nTab2 + 1;
     }
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 0a6b820..8871a71 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -44,7 +44,8 @@
 //------------------------------------------------------------------------
 
 ScMarkData::ScMarkData() :
-    pMultiSel( NULL )
+    pMultiSel( NULL ),
+    maTabMarked()
 {
     ResetMark();
 }
@@ -193,7 +194,7 @@ void ScMarkData::SelectTable( SCTAB nTab, bool bNew )
     }
     else
     {
-        maTabMarked.erase( maTabMarked.find( nTab ) );
+        maTabMarked.erase( nTab );
     }
 }
 
@@ -222,6 +223,15 @@ SCTAB ScMarkData::GetFirstSelected() const
     return 0;
 }
 
+SCTAB ScMarkData::GetLastSelected() const
+{
+    if (maTabMarked.size() > 0)
+        return (*maTabMarked.rbegin());
+
+    OSL_FAIL("GetLastSelected: keine markiert");
+    return 0;
+}
+
 void ScMarkData::MarkToMulti()
 {
     if ( bMarked && !bMarking )
commit f7240f67b73f500f933fdd6ef27fe04b5bbb4590
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue May 17 16:34:24 2011 +0200

    increase table limit to 10000 for now

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index d83caf7..ddc38f4 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -91,7 +91,7 @@ const SCSIZE   SCSIZE_MAX   = ::std::numeric_limits<SCSIZE>::max();
 // Count values
 const SCROW       MAXROWCOUNT    = MAXROWCOUNT_DEFINE;
 const SCCOL       MAXCOLCOUNT    = MAXCOLCOUNT_DEFINE;
-const SCTAB       MAXTABCOUNT    = 1024;
+const SCTAB       MAXTABCOUNT    = 10000;
 const SCCOLROW    MAXCOLROWCOUNT = MAXROWCOUNT;
 // Maximum values
 const SCROW       MAXROW         = MAXROWCOUNT - 1;


More information about the Libreoffice-commits mailing list