summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-18 15:21:46 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-05-18 15:21:46 +0200
commit52bd6de2d9ccc7eb6591e258989dccf9c86703fc (patch)
treef8b2b4bf86e8dfa067d7924e23fb728438073146 /sc
parentfb66a6bffaf822bfb26f8a8ed2ce981979de19ce (diff)
rework ScPrintFuncCache to work with unlimited number of sheets
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/pfuncache.hxx4
-rw-r--r--sc/source/ui/view/pfuncache.cxx17
2 files changed, 14 insertions, 7 deletions
diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index b64e9753e43d..75d1d097f0cf 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 9359c5425cf9..25c90813136a 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;
}