[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sc/source
Armin Le Grand
alg at apache.org
Tue Feb 25 20:07:18 PST 2014
sc/source/ui/inc/printfun.hxx | 8 +-
sc/source/ui/view/printfun.cxx | 122 +++++++++++++++++++++++++++--------------
2 files changed, 87 insertions(+), 43 deletions(-)
New commits:
commit 51dac483c90f5d33fab5f449c0915917540ef547
Author: Armin Le Grand <alg at apache.org>
Date: Wed Feb 26 03:04:14 2014 +0000
i123672 Made data used in ScPrintFunc to prepare print preview dynamic
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 9c84556..b53ebe2 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -209,9 +209,11 @@ private:
SCCOL nEndCol;
SCROW nEndRow;
- SCCOL* pPageEndX; // Seitenaufteilung
- SCROW* pPageEndY;
- ScPageRowEntry* pPageRows;
+ // #123672# use dynamic mem to react on size changes
+ std::vector< SCCOL > maPageEndX;
+ std::vector< SCROW > maPageEndY;
+ std::vector< ScPageRowEntry> maPageRows;
+
size_t nPagesX;
size_t nPagesY;
size_t nTotalY;
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index b6e94ea..5e38f66 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -190,9 +190,6 @@ void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
// weil die EditEngine sonst unterschiedliche Texthoehen liefert
pDev->SetMapMode(MAP_PIXEL);
- pPageEndX = NULL;
- pPageEndY = NULL;
- pPageRows = NULL;
pBorderItem = NULL;
pBackgroundItem = NULL;
pShadowItem = NULL;
@@ -331,8 +328,25 @@ void ScPrintFunc::FillPageData()
rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab,
nEndCol, nEndRow, nPrintTab ) );
- rData.SetPagesX( nPagesX, pPageEndX );
- rData.SetPagesY( nTotalY, pPageEndY );
+ // #123672#
+ if(maPageEndX.empty())
+ {
+ OSL_ENSURE(false, "vector access error for maPageEndX (!)");
+ }
+ else
+ {
+ rData.SetPagesX( nPagesX, &maPageEndX[0]);
+ }
+
+ // #123672#
+ if(maPageEndY.empty())
+ {
+ OSL_ENSURE(false, "vector access error for maPageEndY (!)");
+ }
+ else
+ {
+ rData.SetPagesY( nTotalY, &maPageEndY[0]);
+ }
// Einstellungen
rData.SetTopDown( aTableParam.bTopDown );
@@ -350,9 +364,6 @@ ScPrintFunc::~ScPrintFunc()
}
aNotePosList.Clear();
- delete[] pPageEndX;
- delete[] pPageEndY;
- delete[] pPageRows;
delete pEditDefaults;
delete pEditEngine;
@@ -2491,7 +2502,10 @@ long ScPrintFunc::CountPages() // setzt auch nPagesX, n
CalcZoom(i);
if ( aTableParam.bSkipEmpty )
for (nY=0; nY<nPagesY; nY++)
- nPages += pPageRows[nY].CountVisible();
+ {
+ OSL_ENSURE(nY < maPageRows.size(), "vector access error for maPageRows (!)");
+ nPages += maPageRows[nY].CountVisible();
+ }
else
nPages += ((long) nPagesX) * nPagesY;
if ( pPageData )
@@ -2503,7 +2517,10 @@ long ScPrintFunc::CountPages() // setzt auch nPagesX, n
CalcZoom(RANGENO_NORANGE); // Zoom berechnen
if ( aTableParam.bSkipEmpty )
for (nY=0; nY<nPagesY; nY++)
- nPages += pPageRows[nY].CountVisible();
+ {
+ OSL_ENSURE(nY < maPageRows.size(), "vector access error for maPageRows (!)");
+ nPages += maPageRows[nY].CountVisible();
+ }
else
nPages += ((long) nPagesX) * nPagesY;
if ( pPageData )
@@ -2711,12 +2728,14 @@ long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges,
nX1 = nStartCol;
for (nCountX=0; nCountX<nPagesX; nCountX++)
{
- nX2 = pPageEndX[nCountX];
+ OSL_ENSURE(nCountX < maPageEndX.size(), "vector access error for maPageEndX (!)");
+ nX2 = maPageEndX[nCountX];
for (nCountY=0; nCountY<nPagesY; nCountY++)
{
- nY1 = pPageRows[nCountY].GetStartRow();
- nY2 = pPageRows[nCountY].GetEndRow();
- if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
+ OSL_ENSURE(nCountY < maPageRows.size(), "vector access error for maPageRows (!)");
+ nY1 = maPageRows[nCountY].GetStartRow();
+ nY2 = maPageRows[nCountY].GetEndRow();
+ if ( !aTableParam.bSkipEmpty || !maPageRows[nCountY].IsHidden(nCountX) )
{
if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
{
@@ -2734,13 +2753,15 @@ long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges,
{
for (nCountY=0; nCountY<nPagesY; nCountY++)
{
- nY1 = pPageRows[nCountY].GetStartRow();
- nY2 = pPageRows[nCountY].GetEndRow();
+ OSL_ENSURE(nCountY < maPageRows.size(), "vector access error for maPageRows (!)");
+ nY1 = maPageRows[nCountY].GetStartRow();
+ nY2 = maPageRows[nCountY].GetEndRow();
nX1 = nStartCol;
for (nCountX=0; nCountX<nPagesX; nCountX++)
{
- nX2 = pPageEndX[nCountX];
- if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
+ OSL_ENSURE(nCountX < maPageEndX.size(), "vector access error for maPageEndX (!)");
+ nX2 = maPageEndX[nCountX];
+ if ( !aTableParam.bSkipEmpty || !maPageRows[nCountY].IsHidden(nCountX) )
{
if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
{
@@ -2961,8 +2982,7 @@ void ScPrintFunc::ResetBreaks( SCTAB nTab ) // Breaks fuer Anzeige richt
pDoc->UpdatePageBreaks( nTab, NULL );
}
-void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry,
- SCCOL nStartCol, const SCCOL* pPageEndX )
+void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry, SCCOL nStartCol, const std::vector< SCCOL >& aPageEndX)
{
size_t nPagesX = rPageRowEntry.GetPagesX();
SCROW nStartRow = rPageRowEntry.GetStartRow();
@@ -2974,7 +2994,8 @@ void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowE
for (size_t i=0; i<nPagesX; i++)
{
- SCCOL nEndCol = pPageEndX[i];
+ OSL_ENSURE(i < aPageEndX.size(), "vector access error for maPageEndX (!)");
+ SCCOL nEndCol = aPageEndX[i];
if ( pDoc->IsPrintEmpty( nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow,
bLeftIsEmpty, &aTempRange, &aTempRect ) )
{
@@ -2990,10 +3011,11 @@ void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowE
void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
{
- if (!pPageEndX) pPageEndX = new SCCOL[MAXCOL+1];
- //performance impact
-// if (!pPageEndY) pPageEndY = new SCROW[MAXROW+1];
-// if (!pPageRows) pPageRows = new ScPageRowEntry[MAXROW+1]; //! vorher zaehlen !!!!
+ // #123672# use dynamic mem to react on size changes
+ if(maPageEndX.size() < MAXCOL+1)
+ {
+ maPageEndX.resize(MAXCOL+1, SCCOL());
+ }
pDoc->SetPageSize( nPrintTab, GetDocPageSize() );
if (aAreaParam.bPrintArea)
@@ -3002,10 +3024,24 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au
pDoc->UpdatePageBreaks( nPrintTab, &aRange );
}
else
+ {
pDoc->UpdatePageBreaks( nPrintTab, NULL ); // sonst wird das Ende markiert
- SCROW nRealCnt = nEndRow-nStartRow+1;
- if (!pPageEndY) pPageEndY = new SCROW[nRealCnt+1];
- if (!pPageRows) pPageRows = new ScPageRowEntry[nRealCnt+1]; //! vorher zaehlen !!!!
+ }
+
+ const SCROW nRealCnt = nEndRow-nStartRow+1;
+
+ // #123672# use dynamic mem to react on size changes
+ if(maPageEndY.size() < nRealCnt+1)
+ {
+ maPageEndY.resize(nRealCnt+1, SCROW());
+ }
+
+ // #123672# use dynamic mem to react on size changes
+ if(maPageRows.size() < nRealCnt+1)
+ {
+ maPageRows.resize(nRealCnt+1, ScPageRowEntry());
+ }
+
//
// Seiteneinteilung nach Umbruechen in Col/RowFlags
// Von mehreren Umbruechen in einem ausgeblendeten Bereich zaehlt nur einer.
@@ -3023,7 +3059,8 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au
bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
if ( i>nStartCol && bVisCol && bPageBreak )
{
- pPageEndX[nPagesX] = i-1;
+ OSL_ENSURE(nPagesX < maPageEndX.size(), "vector access error for maPageEndX (!)");
+ maPageEndX[nPagesX] = i-1;
++nPagesX;
bVisCol = false;
}
@@ -3032,7 +3069,8 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au
}
if (bVisCol) // auch am Ende keine leeren Seiten
{
- pPageEndX[nPagesX] = nEndCol;
+ OSL_ENSURE(nPagesX < maPageEndX.size(), "vector access error for maPageEndX (!)");
+ maPageEndX[nPagesX] = nEndCol;
++nPagesX;
}
@@ -3054,17 +3092,19 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au
if (nRow > nStartRow && bVisRow && bPageBreak )
{
- pPageEndY[nTotalY] = nRow-1;
+ OSL_ENSURE(nTotalY < maPageEndY.size(), "vector access error for maPageEndY (!)");
+ maPageEndY[nTotalY] = nRow-1;
++nTotalY;
if ( !aTableParam.bSkipEmpty ||
!pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) )
{
- pPageRows[nPagesY].SetStartRow( nPageStartRow );
- pPageRows[nPagesY].SetEndRow( nRow-1 );
- pPageRows[nPagesY].SetPagesX( nPagesX );
+ OSL_ENSURE(nPagesY < maPageRows.size(), "vector access error for maPageRows (!)");
+ maPageRows[nPagesY].SetStartRow( nPageStartRow );
+ maPageRows[nPagesY].SetEndRow( nRow-1 );
+ maPageRows[nPagesY].SetPagesX( nPagesX );
if (aTableParam.bSkipEmpty)
- lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
+ lcl_SetHidden( pDoc, nPrintTab, maPageRows[nPagesY], nStartCol, maPageEndX );
++nPagesY;
}
@@ -3093,17 +3133,19 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten au
if (bVisRow)
{
- pPageEndY[nTotalY] = nEndRow;
+ OSL_ENSURE(nTotalY < maPageEndY.size(), "vector access error for maPageEndY (!)");
+ maPageEndY[nTotalY] = nEndRow;
++nTotalY;
if ( !aTableParam.bSkipEmpty ||
!pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow ) )
{
- pPageRows[nPagesY].SetStartRow( nPageStartRow );
- pPageRows[nPagesY].SetEndRow( nEndRow );
- pPageRows[nPagesY].SetPagesX( nPagesX );
+ OSL_ENSURE(nPagesY < maPageRows.size(), "vector access error for maPageRows (!)");
+ maPageRows[nPagesY].SetStartRow( nPageStartRow );
+ maPageRows[nPagesY].SetEndRow( nEndRow );
+ maPageRows[nPagesY].SetPagesX( nPagesX );
if (aTableParam.bSkipEmpty)
- lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
+ lcl_SetHidden( pDoc, nPrintTab, maPageRows[nPagesY], nStartCol, maPageEndX );
++nPagesY;
}
}
More information about the Libreoffice-commits
mailing list