vcl/source/window/printdlg.cxx |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

New commits:
commit edc33e9d0f05f3717a5f450c60d5f538fdb89c6e
Author:     Juergen Funk <juergen.funk...@cib.de>
AuthorDate: Fri Sep 4 10:53:44 2020 +0200
Commit:     Juergen Funk <juergen.funk...@cib.de>
CommitDate: Wed Sep 16 11:34:35 2020 +0200

    tdf#127932 fix wrong page number in print progress
    
    - in ctor, reset start pages to non-inflated value after size
      calculation
    - update label, _then_ progress in setProgress()
    
    trac#33592
    
    Change-Id: I66576e339de814922512b68167e6c0a9b1025378
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102031
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    (cherry picked from commit 63bf8f042abe3c0f6989f6763d13f5389182b816)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102281
    Tested-by: Jenkins
    (cherry picked from commit 72c1c84e14ffc8127f24930066220e7c7b28a970)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102832
    Tested-by: Juergen Funk <juergen.funk...@cib.de>
    Reviewed-by: Juergen Funk <juergen.funk...@cib.de>

diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index b59bfc17dfe3..c4cf4977b41a 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -1972,6 +1972,15 @@ void PrintDialog::previewBackward()
     mpPageEdit->Down();
 }
 
+
+static OUString getNewLabel(const OUString& aLabel, int i_nCurr, int i_nMax)
+{
+    OUString aNewText( aLabel.replaceFirst( "%p", OUString::number( i_nCurr ) 
) );
+    aNewText = aNewText.replaceFirst( "%n", OUString::number( i_nMax ) );
+
+    return aNewText;
+}
+
 // PrintProgressDialog
 
 PrintProgressDialog::PrintProgressDialog(vcl::Window* i_pParent, int i_nMax)
@@ -1991,9 +2000,7 @@ PrintProgressDialog::PrintProgressDialog(vcl::Window* 
i_pParent, int i_nMax)
 
     //just multiply largest value by 10 and take the width of that string as
     //the max size we will want
-    OUString aNewText( searchAndReplace( maStr, "%p", 2, OUString::number( 
mnMax * 10 ) ) );
-    aNewText = searchAndReplace( aNewText, "%n", 2, OUString::number( mnMax * 
10 ) );
-    mpText->SetText( aNewText );
+    mpText->SetText( getNewLabel(maStr, mnMax * 10, mnMax * 10) );
     mpText->set_width_request(mpText->get_preferred_size().Width());
 
     //Pick a useful max width
@@ -2001,6 +2008,7 @@ PrintProgressDialog::PrintProgressDialog(vcl::Window* 
i_pParent, int i_nMax)
 
     mpButton->SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) );
 
+    mpText->SetText( getNewLabel(maStr, mnMax, mnMax) );
 }
 
 PrintProgressDialog::~PrintProgressDialog()
@@ -2029,11 +2037,9 @@ void PrintProgressDialog::setProgress( int i_nCurrent )
     if( mnMax < 1 )
         mnMax = 1;
 
-    mpProgress->SetValue(mnCur*100/mnMax);
+    mpText->SetText( getNewLabel(maStr, mnCur, mnMax) );
 
-    OUString aNewText( searchAndReplace( maStr, "%p", 2, OUString::number( 
mnCur ) ) );
-    aNewText = searchAndReplace( aNewText, "%n", 2, OUString::number( mnMax ) 
);
-    mpText->SetText( aNewText );
+    mpProgress->SetValue(mnCur*100/mnMax);
 }
 
 void PrintProgressDialog::tick()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to