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

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Wed May 18 07:02:15 PDT 2011


 sc/source/ui/inc/pfuncache.hxx  |    4 ++--
 sc/source/ui/inc/preview.hxx    |    6 ++++--
 sc/source/ui/view/pfuncache.cxx |   17 ++++++++++++-----
 sc/source/ui/view/preview.cxx   |   22 +++++++++++++++++-----
 4 files changed, 35 insertions(+), 14 deletions(-)

New commits:
commit 99f6389550f9c8c09840b4655e8a2f0c0c2af5f8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed May 18 15:55:20 2011 +0200

    rework ScPreview to work with unlimited number of sheets

diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index 8bdd74e..9d4000b 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -32,6 +32,8 @@
 #include <vcl/window.hxx>
 #include "printfun.hxx"		// ScPrintState
 
+#include <vector>
+
 class ScDocShell;
 class ScPreviewShell;
 class FmFormView;
@@ -48,8 +50,8 @@ private:
     sal_Bool			bValid;				// folgende Werte gueltig
     SCTAB			nTabCount;
     SCTAB			nTabsTested;		// fuer wieviele Tabellen ist nPages gueltig?
-    long			nPages[MAXTABCOUNT];
-    long			nFirstAttr[MAXTABCOUNT];
+    std::vector<long>       nPages;
+    std::vector<long>       nFirstAttr;
     SCTAB			nTab;				// Tabelle
     long			nTabPage;			// Seite von Tabelle
     long			nTabStart;			// erste Seite der Tabelle (wirklich)
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 5db2797..0c46da9 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -82,7 +82,7 @@
 
 #define SC_PREVIEW_SHADOWSIZE	2
 
-long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
+long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, std::vector<long>& nPages )
 {
     long nDisplayStart = 0;
     for (SCTAB i=0; i<nTab; i++)
@@ -90,7 +90,7 @@ long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
         if ( pDoc->NeedPageResetAfterTab(i) )
             nDisplayStart = 0;
         else
-            nDisplayStart += pPages[i];
+            nDisplayStart += nPages[i];
     }
     return nDisplayStart;
 }
@@ -102,6 +102,8 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
     nZoom( 100 ),
     bValid( false ),
     nTabsTested( 0 ),
+    nPages(),
+    nFirstAttr(),
     nTab( 0 ),
     nTabStart( 0 ),
     nDisplayStart( 0 ),
@@ -191,10 +193,10 @@ void ScPreview::TestLastPage()
         if (nTotalPages)
         {
             nPageNo = nTotalPages - 1;
-            nTab = nTabCount - 1;
+            nTab = static_cast<SCTAB>(nPages.size()) -1;
             while (nTab > 0 && !nPages[nTab])		// letzte nicht leere Tabelle
                 --nTab;
-            DBG_ASSERT(nPages[nTab],"alle Tabellen leer?");
+            DBG_ASSERT(0 < static_cast<SCTAB>(nPages.size()),"alle Tabellen leer?");
             nTabPage = nPages[nTab] - 1;
             nTabStart = 0;
             for (sal_uInt16 i=0; i<nTab; i++)
@@ -246,8 +248,16 @@ void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
     ScMarkData aMarkData;
     aMarkData.SelectTable( nCurTab, true );
 
+    while (nStart > static_cast<SCTAB>(nPages.size()))
+        nPages.push_back(0);
+    while (nStart > static_cast<SCTAB>(nFirstAttr.size()))
+        nFirstAttr.push_back(0);
     for (SCTAB i=nStart; i<nAnz; i++)
     {
+        if ( i == static_cast<SCTAB>(nPages.size()))
+            nPages.push_back(0);
+        if ( i == static_cast<SCTAB>(nFirstAttr.size()))
+            nFirstAttr.push_back(0);
         if (!aOptions.GetAllSheets() && !aMarkData.GetTableSelect( i )) {
             nPages[i] = 0;
             nFirstAttr[i] = 0;
@@ -309,7 +319,7 @@ void ScPreview::RecalcPages()					// nur nPageNo geaendert
     if (!bDone)
     {
         long nPartPages = 0;
-        for (SCTAB i=0; i<nTabsTested; i++)
+        for (SCTAB i=0; i<nTabsTested && nTab < static_cast<SCTAB>(nPages.size()); i++)
         {
             long nThisStart = nPartPages;
             nPartPages += nPages[i];
@@ -807,6 +817,8 @@ void ScPreview::SetPageNo( long nPage )
 
 long ScPreview::GetFirstPage(SCTAB nTabP)
 {
+    if (nTabP >= static_cast<SCTAB>(nPages.size()) )
+        OSL_FAIL("nPages out ouf bounds, FIX IT");
     SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount();
     if (nTabP >= nDocTabCount)
         nTabP = nDocTabCount-1;
commit fb4c94edbd82e310416fe30e59dc4da52c0000d6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed May 18 15:21:46 2011 +0200

    rework ScPrintFuncCache to work with unlimited number of sheets

diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index 4076d2c..2f65368 100644
--- a/sc/source/ui/inc/pfuncache.hxx
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -100,8 +100,8 @@ class ScPrintFuncCache
     ScPrintSelectionStatus	aSelection;
     ScDocShell*				pDocSh;
     long					nTotalPages;
-    long					nPages[MAXTABCOUNT];
-    long					nFirstAttr[MAXTABCOUNT];
+    std::vector<long>       nPages;
+    std::vector<long>       nFirstAttr;
     std::vector<ScPrintPageLocation> aLocations;
     bool                    bLocInitialized;
 
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
index e3e59ac..3653bb4 100644
--- a/sc/source/ui/view/pfuncache.cxx
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -48,6 +48,8 @@ ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
     aSelection( rStatus ),
     pDocSh( pD ),
     nTotalPages( 0 ),
+    nPages(),
+    nFirstAttr(),
     bLocInitialized( false )
 {
     //	page count uses the stored cell widths for the printer anyway,
@@ -77,12 +79,12 @@ ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
 
             ScPrintFunc aFunc( pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange, &aSelection.GetOptions() );
             nThisTab = aFunc.GetTotalPages();
-            nFirstAttr[nTab] = aFunc.GetFirstPageNo();			// from page style or previous sheet
+            nFirstAttr.push_back( aFunc.GetFirstPageNo() );			// from page style or previous sheet
         }
         else
-            nFirstAttr[nTab] = nAttrPage;
+            nFirstAttr.push_back( nAttrPage );
 
-        nPages[nTab] = nThisTab;
+        nPages.push_back( nThisTab );
         nTotalPages += nThisTab;
     }
 }
@@ -175,7 +177,7 @@ SCTAB ScPrintFuncCache::GetTabForPage( long nPage ) const
 long ScPrintFuncCache::GetTabStart( SCTAB nTab ) const
 {
     long nRet = 0;
-    for ( SCTAB i=0; i<nTab; i++ )
+    for ( SCTAB i=0; i<nTab&& i < static_cast<SCTAB>(nPages.size()); i++ )
         nRet += nPages[i];
     return nRet;
 }
@@ -191,7 +193,12 @@ long ScPrintFuncCache::GetDisplayStart( SCTAB nTab ) const
         if ( pDoc->NeedPageResetAfterTab(i) )
             nDisplayStart = 0;
         else
-            nDisplayStart += nPages[i];
+        {
+            if ( i < static_cast<SCTAB>(nPages.size()) )
+                nDisplayStart += nPages[i];
+            else
+                OSL_FAIL("nPages out of bounds, FIX IT!");
+        }
     }
     return nDisplayStart;
 }


More information about the Libreoffice-commits mailing list