sd/inc/strings.hrc | 2 + sd/source/ui/view/DocumentRenderer.cxx | 41 ++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 11 deletions(-)
New commits: commit 72d766134e374816e88451fa90c70656dde89581 Author: Mohamed Ali <mohmedali1462...@gmail.com> AuthorDate: Wed Nov 27 18:18:44 2024 +0200 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Mon Feb 17 10:07:29 2025 +0100 tdf#161195 Allow right-to-left brochure printing in Draw / Impress introduces support for Right-to-Left (RTL) brochure printing in LibreOffice Draw and Impress. The changes include modifications to the print layout logic to handle RTL text and ensure proper alignment and formatting. - Adjusted the brochure printing logic to correctly handle RTL page order. This ensures that pages are printed in the correct sequence for RTL languages, which is essential for creating readable brochures. - Modified the user interface to allow users to select RTL brochure printing. This includes adding new options in the print dialog. Change-Id: Ie0c5e6abebfdf4805c1b9d9d43bdf91f5d710aaf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177432 Reviewed-by: Hossein <hoss...@libreoffice.org> Tested-by: Jenkins diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc index 16174a94f76f..f408b5a01cc6 100644 --- a/sd/inc/strings.hrc +++ b/sd/inc/strings.hrc @@ -446,6 +446,8 @@ #define STR_IMPRESS_PRINT_UI_QUALITY NC_("STR_IMPRESS_PRINT_UI_QUALITY", "Color") #define STR_IMPRESS_PRINT_UI_PAGE_OPTIONS NC_("STR_IMPRESS_PRINT_UI_PAGE_OPTIONS", "~Size") #define STR_IMPRESS_PRINT_UI_BROCHURE NC_("STR_IMPRESS_PRINT_UI_BROCHURE", "Brochure") +#define STR_IMPRESS_PRINT_UI_LEFT_SCRIPT NC_("STR_IMPRESS_PRINT_UI_LEFT_SCRIPT", "Left-to-right script") +#define STR_IMPRESS_PRINT_UI_RIGHT_SCRIPT NC_("STR_IMPRESS_PRINT_UI_RIGHT_SCRIPT", "Right-to-left script") #define STR_IMPRESS_PRINT_UI_PAGE_SIDES NC_("STR_IMPRESS_PRINT_UI_PAGE_SIDES", "Page sides") #define STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE NC_("STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE", "Include") #define STR_IMPRESS_PRINT_UI_PAPER_TRAY NC_("STR_IMPRESS_PRINT_UI_PAPER_TRAY", "~Use only paper tray from printer preferences") diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 2b666dbc2b89..53b9737f5e8b 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -65,6 +65,9 @@ #include <xmloff/autolayout.hxx> #include <sfx2/objsh.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> + #include <officecfg/Office/Draw.hxx> #include <officecfg/Office/Impress.hxx> @@ -194,6 +197,11 @@ namespace { return GetBoolValue("PrintProspect", false); } + bool IsProspectRTL() const + { + return mrProperties.getIntValue( "PrintProspectRTL", 0 ) != 0; + } + bool IsPrinterPreferred(DocumentType eDocType) const { bool bIsDraw = eDocType == DocumentType::Draw; @@ -390,7 +398,7 @@ namespace { void ProcessResource() { - // load the writer PrinterOptions into the custom tab + // load the impress or draw PrinterOptions into the custom tab beans::PropertyValue aOptionsUIFile; aOptionsUIFile.Name = "OptionsUIFile"; if( mbImpress ) @@ -565,22 +573,29 @@ namespace { ) ); - vcl::PrinterOptionsHelper::UIControlOptions - aIncludeOpt( u"PrintProspect"_ustr , -1, false ); - aIncludeOpt.maGroupHint = "LayoutPage" ; - aHelpIds = { u".HelpID:vcl:PrintDialog:PrintProspectInclude:ListBox"_ustr }; - AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt( - u"brochureinclude"_ustr, + // check if either CJK or CTL is enabled + bool bRTL = SvtCJKOptions::IsCJKFontEnabled() || SvtCTLOptions::IsCTLFontEnabled(); + + if(bRTL) + { + uno::Sequence< OUString > aBRTLChoices{ SdResId(STR_IMPRESS_PRINT_UI_LEFT_SCRIPT), + SdResId(STR_IMPRESS_PRINT_UI_RIGHT_SCRIPT) }; + vcl::PrinterOptionsHelper::UIControlOptions + aIncludeOpt( u"PrintProspect"_ustr , -1, true ); + aIncludeOpt.maGroupHint = "LayoutPage" ; + aHelpIds = { u".HelpID:vcl:PrintDialog:PrintProspectRTL:ListBox"_ustr }; + AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt( + u"scriptdirection"_ustr, SdResId(STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE), aHelpIds, - u"PrintProspectInclude"_ustr , - CreateChoice(STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST, SAL_N_ELEMENTS(STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST)), + u"PrintProspectRTL"_ustr , + aBRTLChoices, 0, Sequence< sal_Bool >(), aIncludeOpt ) ); - + } // paper tray (on options page) vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt; aPaperTrayOpt.maGroupHint = "OptionsPageOptGroup" ; @@ -2368,6 +2383,8 @@ private: } } + bool bPrintBookletRTL = mpOptions->IsProspectRTL(); + for (sal_uInt32 nIndex=0, nCount=aPairVector.size(); @@ -2376,7 +2393,9 @@ private: { if ( CheckForFrontBackPages( nIndex ) ) { - const std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]); + std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]); + if( bPrintBookletRTL ) + std::swap(aPair.first, aPair.second); Point aSecondOffset (aOffset); if (rInfo.meOrientation == Orientation::Landscape) aSecondOffset.AdjustX( aAdjustedPrintSize.Width() / 2 );