diff --git a/sc/qa/uitest/calc_dialogs/printDialog.py b/sc/qa/uitest/calc_dialogs/printDialog.py index cd359539cab1..0057ebf52e2f 100644 --- a/sc/qa/uitest/calc_dialogs/printDialog.py +++ b/sc/qa/uitest/calc_dialogs/printDialog.py @@ -7,7 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, select_by_text +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, select_by_text, mkPropertyValues class printDialog(UITestCase): def test_printDialog(self): @@ -22,11 +22,11 @@ class printDialog(UITestCase): xPortraiTotalNumberPages = xDialog.getChild("totalnumpages") self.assertEqual(get_state_as_dict(xPortraiTotalNumberPages)["Text"], "/ 2") - xPortraiPageRange = xDialog.getChild("pagerange") - self.assertEqual(get_state_as_dict(xPortraiPageRange)["Text"], "1-2") + xPageRange = xDialog.getChild("pagerange") + self.assertEqual(get_state_as_dict(xPageRange)["Text"], "") - xpageorientationbox = xDialog.getChild("pageorientationbox") - select_by_text(xpageorientationbox, "Landscape") + xPageOrientationBox = xDialog.getChild("pageorientationbox") + select_by_text(xPageOrientationBox, "Landscape") # Without the fix in place, this test would have failed with # Expected: "/ 1" @@ -34,17 +34,19 @@ class printDialog(UITestCase): xLandscapeTotalNumberPages = xDialog.getChild("totalnumpages") self.assertEqual(get_state_as_dict(xLandscapeTotalNumberPages)["Text"], "/ 1") - # Without the fix in place, this test would have failed with - # Expected: "1" - # Actual : "1-2" - xLandscapePageRange = xDialog.getChild("pagerange") - self.assertEqual(get_state_as_dict(xLandscapePageRange)["Text"], "1") + # Page range is empty by default and must not be populated automatically + self.assertEqual(get_state_as_dict(xPageRange)["Text"], "") - # check that when reselecting Portrait, the range is again 1-2 - # Expected: "1-2" - # Actual : "1" - select_by_text(xpageorientationbox, "Portrait") - xPortraitPageRange = xDialog.getChild("pagerange") - self.assertEqual(get_state_as_dict(xPortraitPageRange)["Text"], "1-2") + select_by_text(xPageOrientationBox, "Portrait") + # Page range must remain empty when the number of pages changes. + self.assertEqual(get_state_as_dict(xPageRange)["Text"], "") + + # User enters a page range. + xPageRange.executeAction("TYPE", mkPropertyValues({"TEXT": "2-3"})) + + select_by_text(xPageOrientationBox, "Landscape") + select_by_text(xPageOrientationBox, "Portrait") + + self.assertEqual(get_state_as_dict(xPageRange)["Text"], "2-3") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 3db74784fc2b..6d60f4321e38 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -224,6 +224,9 @@ namespace vcl Idle maUpdatePreviewIdle; DECL_LINK(updatePreviewIdle, Timer*, void); + Timer maPageRangeUpdateTimer; + DECL_LINK(PageRangeUpdateTimerHdl, Timer*, void); + DECL_LINK(ClickOKCancelHdl, weld::Button&, void); DECL_LINK(ClickForwardHdl, weld::Button&, void); DECL_LINK(ClickBackwardHdl, weld::Button&, void); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index acafaaa1c7bf..d45aedb6125e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -586,6 +586,7 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, std::shared_ptrgetValue(u"PageRange"_ustr); @@ -663,6 +664,10 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, std::shared_ptrgetMultipage() ); // setup optional UI options set by application @@ -1031,6 +1036,12 @@ IMPL_LINK_NOARG(PrintDialog, updatePreviewIdle, Timer*, void) preparePreview(std::exchange(mbUseCacheForPreview, true)); } +IMPL_LINK_NOARG(PrintDialog, PageRangeUpdateTimerHdl, Timer*, void) +{ + schedulePreviewUpdate(false); +} + + void PrintDialog::preparePreview( bool i_bMayUseCache ) { VclPtr aPrt( maPController->getPrinter() ); @@ -1169,17 +1180,7 @@ void PrintDialog::updatePageRange(sal_Int32 nPages) pContentVal->Value >>= nContent; if (nContent == 1) - { - OUString sRange; - if (nPages == 1) - sRange = u"1"_ustr; - else - sRange = u"1-"_ustr + OUString::number(nPages); - - mxPageRangeEdit->set_text(sRange); - maPController->setValue(u"PageRange"_ustr, Any(sRange)); - return; - } + return; // User-controlled page range OUString sRange; @@ -1203,7 +1204,6 @@ void PrintDialog::updatePageRange(sal_Int32 nPages) return; } - mxPageRangeEdit->set_text(sRange); maPController->setValue(u"PageRange"_ustr, Any(sRange)); } @@ -1899,7 +1899,10 @@ void PrintDialog::setupOptionalUI() PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aCurVal; - xField->set_text( aCurVal ); + if (aPropertyName != "PageRange") + { + xField->set_text( aCurVal ); + } xField->connect_changed( LINK( this, PrintDialog, UIOption_EntryModifyHdl ) ); xField->show(); @@ -2495,8 +2498,11 @@ IMPL_LINK(PrintDialog, UIOption_EntryModifyHdl, weld::TextWidget&, i_rBox, void) checkOptionalControlDependencies(); - // update preview and page settings - schedulePreviewUpdate(false); + if (pVal->Name == "PageRange") + maPageRangeUpdateTimer.Start(); + else + schedulePreviewUpdate(false); + } }