diff --git a/sc/qa/uitest/calc_dialogs/printDialog.py b/sc/qa/uitest/calc_dialogs/printDialog.py index fd879b4b4362..cd359539cab1 100644 --- a/sc/qa/uitest/calc_dialogs/printDialog.py +++ b/sc/qa/uitest/calc_dialogs/printDialog.py @@ -40,4 +40,11 @@ class printDialog(UITestCase): xLandscapePageRange = xDialog.getChild("pagerange") self.assertEqual(get_state_as_dict(xLandscapePageRange)["Text"], "1") + # 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") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index e33b790d16af..ff58bf2ac173 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -685,6 +685,7 @@ #define STR_PRINTOPTUI_PRINTALLPAGES NC_("STR_PRINTOPTUI_PRINTALLPAGES", "~All Pages") #define STR_PRINTOPTUI_PRINTPAGES NC_("STR_PRINTOPTUI_PRINTPAGES", "Pa~ges:") #define STR_PRINTOPTUI_PRINTSELECTION NC_("STR_PRINTOPTUI_PRINTSELECTION", "~Selection") +#define STR_PRINTOPTUI_PRINTCURRENTPAGE NC_("STR_PRINTOPTUI_PRINTCURRENTPAGE", "Current ~Page") #define STR_PRINTOPTUI_PLACE_MARGINS NC_("STR_PRINTOPTUI_PLACE_MARGINS", "Place in margins") #define STR_FORMULA_CALC NC_("STR_FORMULA_CALC", "Functions") diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 940c3af70a3b..db01cdbffbfc 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -743,7 +743,7 @@ void SwDoc::CalculatePagesForPrinting( // 0 -> print all pages (default if aPageRange is empty) // 1 -> print range according to PageRange // 2 -> print selection - if (1 == nContent) + if (1 == nContent || 3 == nContent) aPageRange = rOptions.getStringValue( "PageRange" ); if (2 == nContent) diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx index 4cc427af5b7e..ddcbf759143a 100644 --- a/sw/source/core/view/printdata.cxx +++ b/sw/source/core/view/printdata.cxx @@ -272,12 +272,15 @@ SwPrintUIOptions::SwPrintUIOptions( static constexpr OUString aPrintRangeName( u"PrintContent"_ustr ); uno::Sequence< OUString > aChoices{ SwResId( STR_PRINTOPTUI_PRINTALLPAGES ), SwResId( STR_PRINTOPTUI_PRINTPAGES ), - SwResId( STR_PRINTOPTUI_PRINTSELECTION ) }; - uno::Sequence< sal_Bool > aChoicesDisabled{ false, false, !bHasSelection }; + SwResId( STR_PRINTOPTUI_PRINTSELECTION ), + SwResId( STR_PRINTOPTUI_PRINTCURRENTPAGE ) }; + uno::Sequence< sal_Bool > aChoicesDisabled{ false, false, !bHasSelection, false }; uno::Sequence< OUString > aHelpIds{ u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0"_ustr, u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1"_ustr, - u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2"_ustr }; - uno::Sequence< OUString > aWidgetIds{ u"rbAllPages"_ustr, u"rbRangePages"_ustr, u"rbRangeSelection"_ustr }; + u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2"_ustr, + u".HelpID:vcl:PrintDialog:PrintContent:RadioButton:3"_ustr + }; + uno::Sequence< OUString > aWidgetIds{ u"rbAllPages"_ustr, u"rbRangePages"_ustr, u"rbRangeSelection"_ustr, u"rbCurrentPage"_ustr }; m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(), aHelpIds, aPrintRangeName, aChoices, 0 /* always default to 'All pages' */, diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 682971d3676e..ece2d5b7a6e6 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -2591,6 +2591,11 @@ SwDoc * SwXTextDocument::GetRenderDoc( uno::Reference< frame::XModel > xModel; rSelection >>= xModel; + const bool bPrintCurrentPage = m_pPrintUIOptions && m_pPrintUIOptions->getIntValue("PrintContent", 0) == 3; + + if (bPrintCurrentPage) + return m_pDocShell->GetDoc(); + if (xModel == m_pDocShell->GetModel()) pDoc = m_pDocShell->GetDoc(); else diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 3787f5fb4c45..3db74784fc2b 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -190,6 +190,7 @@ namespace vcl OUString maPageStr; OUString maNoPageStr; OUString maNoPreviewStr; + sal_Int32 mnInitialPage; sal_Int32 mnCurPage; sal_Int32 mnCachedPages; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a02c99e48e4f..2599f2a860bd 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -580,12 +580,22 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, std::shared_ptrgetValue(u"PageRange"_ustr); + if (pPageRange && pPageRange->Value.hasValue()) + { + OUString aPageRange; + pPageRange->Value >>= aPageRange; + mnInitialPage = aPageRange.toInt32(); + } + // save printbutton text, gets exchanged occasionally with print to file maPrintText = mxOKButton->get_label(); @@ -1150,18 +1160,51 @@ void PrintDialog::preparePreview( bool i_bMayUseCache ) void PrintDialog::updatePageRange(sal_Int32 nPages) { - if (nPages > 0 && !mxPageRangesRadioButton->get_active()) + if (nPages <= 0) + return; + + PropertyValue* pContentVal = maPController->getValue(u"PrintContent"_ustr); + sal_Int32 nContent = -1; + if (pContentVal) + 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; + } + + OUString sRange; + + if (nContent == 3) + { + // Current page: preserve the document page selected when + // the print dialog was opened. + sRange = OUString::number(mnInitialPage); + } + else if (nContent == 0) + { + // All pages OUStringBuffer aBuf(32); aBuf.append("1"); if (nPages > 1) - { aBuf.append("-" + OUString::number(nPages)); - } - OUString sRange = aBuf.makeStringAndClear(); - mxPageRangeEdit->set_text(sRange); - maPController->setValue(u"PageRange"_ustr, Any(sRange)); + sRange = aBuf.makeStringAndClear(); } + else + { + return; + } + + mxPageRangeEdit->set_text(sRange); + maPController->setValue(u"PageRange"_ustr, Any(sRange)); } void PrintDialog::updatePageSize(int nOrientation) @@ -2365,6 +2408,15 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, weld::Toggleable&, i_rBtn, void ) sal_Int32 nVal = it->second; pVal->Value <<= nVal; + if (pVal->Name == "PrintContent" && nVal == 3) + { + PropertyValue* pPageRange = maPController->getValue(u"PageRange"_ustr); + if (pPageRange) + { + pPageRange->Value <<= OUString::number(mnInitialPage); + } + } + updateOrientationBox(); checkOptionalControlDependencies(); diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui index 5ffa739789f9..5e9e21b6bb8c 100644 --- a/vcl/uiconfig/ui/printdialog.ui +++ b/vcl/uiconfig/ui/printdialog.ui @@ -546,48 +546,6 @@ 0 - - - _Pages: - True - True - False - start - 2 - 2 - True - True - rbAllPages - - - Prints only the pages or slides that you specify in the Pages box. - - - - - 0 - 1 - - - - - True - True - True - True - True - e.g.: 1, 3-5, 7, 9 - - - To print a range of pages, use a format like 3-6. To print single pages, use a format like 7;9;11. You can print a combination of page ranges and single pages, by using a format like 3-6;8;10;12. - - - - - 1 - 1 - - _Selection @@ -609,6 +567,69 @@ 0 + + + _Current page + True + False + start + 2 + True + True + rbAllPages + + + Prints only the current page. + + + + + 0 + 1 + + + + + _Pages: + True + True + False + start + 2 + 2 + True + True + rbAllPages + + + Prints only the pages or slides that you specify in the Pages box. + + + + + 0 + 2 + + + + + True + True + True + True + True + e.g.: 1, 3-5, 7, 9 + + + To print a range of pages, use a format like 3-6. To print single pages, use a format like 7;9;11. You can print a combination of page ranges and single pages, by using a format like 3-6;8;10;12. + + + + + 1 + 2 + + True @@ -621,7 +642,7 @@ 0 - 2 + 3 @@ -643,7 +664,7 @@ 1 - 2 + 3