vcl/source/window/printdlg.cxx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
New commits: commit 72c1c84e14ffc8127f24930066220e7c7b28a970 Author: Juergen Funk <juergen.funk...@cib.de> AuthorDate: Fri Sep 4 10:53:44 2020 +0200 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Thu Sep 10 12:11:11 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.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 diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 7d340559806a..1515b8b74264 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -2159,6 +2159,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") @@ -2176,15 +2185,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() @@ -2203,11 +2214,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() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits