[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Jan 20 20:46:20 PST 2011


 sc/source/ui/view/gridwin4.cxx |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit b6734b453ec636aff3cb14535da24865c9d66d9a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jan 20 23:44:52 2011 -0500

    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.

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 657f751..ac296c8 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;


More information about the Libreoffice-commits mailing list