[Libreoffice-commits] core.git: vcl/source

Juergen Funk (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 8 11:41:22 UTC 2020


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

New commits:
commit 63bf8f042abe3c0f6989f6763d13f5389182b816
Author:     Juergen Funk <juergen.funk_ml at cib.de>
AuthorDate: Fri Sep 4 10:53:44 2020 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Sep 8 13:40:28 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()
    
    Change-Id: I66576e339de814922512b68167e6c0a9b1025378
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102031
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index d964390ef062..c210525b17f3 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -2164,6 +2164,15 @@ void PrintDialog::previewLast()
     ActivateHdl(*mxPageEdit);
 }
 
+
+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(weld::Window* i_pParent, int i_nMax)
     : GenericDialogController(i_pParent, "vcl/ui/printprogressdialog.ui", "PrintProgressDialog")
@@ -2181,15 +2190,17 @@ PrintProgressDialog::PrintProgressDialog(weld::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( maStr.replaceFirst( "%p", OUString::number( mnMax * 10 ) ) );
-    aNewText = aNewText.replaceFirst( "%n", OUString::number( mnMax * 10 ) );
-    mxText->set_label( aNewText );
+    mxText->set_label(getNewLabel(maStr, mnMax * 10, mnMax * 10));
     mxText->set_size_request(mxText->get_preferred_size().Width(), -1);
 
     //Pick a useful max width
     mxProgress->set_size_request(mxProgress->get_approximate_digit_width() * 25, -1);
 
     mxButton->connect_clicked( LINK( this, PrintProgressDialog, ClickHdl ) );
+
+    // after this patch f7157f04fab298423e2c4f6a7e5f8e361164b15f, we have seen the calc Max string (sometimes) look above
+    // now init to the right start vaules
+    mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
 }
 
 PrintProgressDialog::~PrintProgressDialog()
@@ -2208,11 +2219,10 @@ void PrintProgressDialog::setProgress( int i_nCurrent )
     if( mnMax < 1 )
         mnMax = 1;
 
-    mxProgress->set_percentage(mnCur*100/mnMax);
+    mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
 
-    OUString aNewText( maStr.replaceFirst( "%p", OUString::number( mnCur ) ) );
-    aNewText = aNewText.replaceFirst( "%n", OUString::number( mnMax ) );
-    mxText->set_label( aNewText );
+    // here view the dialog, with the right label
+    mxProgress->set_percentage(mnCur*100/mnMax);
 }
 
 void PrintProgressDialog::tick()


More information about the Libreoffice-commits mailing list