summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-01-20 23:44:52 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-01-20 23:44:52 -0500
commitb6734b453ec636aff3cb14535da24865c9d66d9a (patch)
treea1ae7a9504df071067cc55c50a0d5e5d7ba53da8
parent792321095f149b21fa8cb61583817d5cf73a5f32 (diff)
Fixed incorrect page number in page preview mode. (fdo#33155)
When the window is large enough to show several 'Page X' strings, the page number was not properly incremented. This commit fixes it.
-rw-r--r--sc/source/ui/view/gridwin4.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 657f75177..ac296c880 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1072,7 +1072,9 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
nPageNo += ((long)nColPos)*nRowBreaks+nRowPos;
else
nPageNo += ((long)nRowPos)*nColBreaks+nColPos;
- aPageStr.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPageNo));
+
+ String aThisPageStr = aPageStr; // Don't modify the original string.
+ aThisPageStr.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPageNo));
if ( pEditEng )
{
@@ -1081,7 +1083,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
- pEditEng->SetText( aPageStr );
+ pEditEng->SetText( aThisPageStr );
Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
// 40% of width or 60% of height
@@ -1103,7 +1105,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
// find right font size for DrawText
aFont.SetSize( Size( 0,100 ) );
pContentDev->SetFont( aFont );
- Size aSize100( pContentDev->GetTextWidth( aPageStr ), pContentDev->GetTextHeight() );
+ Size aSize100( pContentDev->GetTextWidth( aThisPageStr ), pContentDev->GetTextHeight() );
// 40% of width or 60% of height
long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
@@ -1112,10 +1114,10 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
pContentDev->SetFont( aFont );
// centered output with DrawText
- Size aTextSize( pContentDev->GetTextWidth( aPageStr ), pContentDev->GetTextHeight() );
+ Size aTextSize( pContentDev->GetTextWidth( aThisPageStr ), pContentDev->GetTextHeight() );
Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
(aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
- pContentDev->DrawText( aPos, aPageStr );
+ pContentDev->DrawText( aPos, aThisPageStr );
}
}
nPrStartX = nPrEndX + 1;