diff options
author | Juergen Funk <juergen.funk_ml@cib.de> | 2020-09-04 10:53:44 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-09-08 13:40:28 +0200 |
commit | 63bf8f042abe3c0f6989f6763d13f5389182b816 (patch) | |
tree | 7b8d28118a5d3ee10e7be72c65d328fed2a785f3 /vcl/source/window/printdlg.cxx | |
parent | f386cb407c5d780706e224aff9f80a79f36daf01 (diff) |
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@CIB.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'vcl/source/window/printdlg.cxx')
-rw-r--r-- | vcl/source/window/printdlg.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
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() |