filter/source/pdf/pdfexport.cxx |   30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 24d4540088f7b45716e87db3fcf0817518d61fe1
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Oct 30 08:41:54 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Oct 30 14:26:49 2023 +0100

    Allow passing Math-specific options to PDF export
    
    The options present in the Math' Print dialog:
    * Contents:
      - Title;
      - Formula text;
      - Borders;
    * Size:
      - Original size;
      - Fit to page;
      - Scaling N%
    
    were previously not handled in math_pdf_Export. This change makes
    them handled, similar to handling of other modules' options.
    
    The final handling of them happens in SmDocShell::Impl_Print.
    
      TitleRow (boolean; default = true)
      FormulaText (boolean; default = true)
      Border (boolean; default = true)
      PrintFormat (long: 0 - original size; 1 - fit to page; 2 - scaling to 
PrintScale; default = 0)
      PrintScale (unsigned short; default = 100)
    
    They are also available in command line, as implemented in commit
    0c3b8792b712e939d2ad524d554f96616b4844be (PDF export: allow setting
    filter data keys from the cmdline, 2022-01-24), using JSON syntax.
    
    TODO: make these options available in Math' PDF export dialog.
    Change-Id: I4fcc609e943823a5325a4840988a96c9d5ab3223
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158637
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index a8f3cda62224..7d07f8182bdc 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -450,7 +450,11 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
             OUString aOpenPassword, aPermissionPassword;
             Reference< beans::XMaterialHolder > xEnc;
             Sequence< beans::NamedValue > aPreparedPermissionPassword;
-
+            std::optional<PropertyValue> oMathTitleRow;
+            std::optional<PropertyValue> oMathFormulaText;
+            std::optional<PropertyValue> oMathBorder;
+            std::optional<PropertyValue> oMathPrintFormat;
+            std::optional<PropertyValue> oMathPrintScale;
 
             // getting the string for the creator
             OUString aCreator;
@@ -674,6 +678,17 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
                 // Redaction & bitmap related stuff
                 else if ( rProp.Name == "IsRedactMode" )
                     rProp.Value >>= mbIsRedactMode;
+                // Math-specific render options
+                else if (rProp.Name == "TitleRow")
+                    oMathTitleRow = rProp;
+                else if (rProp.Name == "FormulaText")
+                    oMathFormulaText = rProp;
+                else if (rProp.Name == "Border")
+                    oMathBorder = rProp;
+                else if (rProp.Name == "PrintFormat")
+                    oMathPrintFormat = rProp;
+                else if (rProp.Name == "PrintScale")
+                    oMathPrintScale = rProp;
             }
 
             if (!aSignCertificate.is() && 
!aSignCertificateSubjectName.isEmpty())
@@ -981,7 +996,7 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
                 aPDFExtOutDevData.SetIsReduceImageResolution( 
mbReduceImageResolution );
                 aPDFExtOutDevData.SetIsExportNamedDestinations( 
bExportBmkToDest );
 
-                Sequence< PropertyValue > aRenderOptions{
+                std::vector<PropertyValue> aRenderOptionsVector{
                     comphelper::makePropertyValue("RenderDevice", 
uno::Reference<awt::XDevice>(xDevice)),
                     comphelper::makePropertyValue("ExportNotesPages", false),
                     comphelper::makePropertyValue("IsFirstPage", true),
@@ -992,6 +1007,17 @@ bool PDFExport::Export( const OUString& rFile, const 
Sequence< PropertyValue >&
                     comphelper::makePropertyValue("SinglePageSheets", 
bSinglePageSheets),
                     comphelper::makePropertyValue("ExportNotesInMargin", 
bExportNotesInMargin)
                 };
+                if (oMathTitleRow)
+                    aRenderOptionsVector.push_back(*oMathTitleRow);
+                if (oMathFormulaText)
+                    aRenderOptionsVector.push_back(*oMathFormulaText);
+                if (oMathBorder)
+                    aRenderOptionsVector.push_back(*oMathBorder);
+                if (oMathPrintFormat)
+                    aRenderOptionsVector.push_back(*oMathPrintFormat);
+                if (oMathPrintScale)
+                    aRenderOptionsVector.push_back(*oMathPrintScale);
+                Sequence aRenderOptions = 
comphelper::containerToSequence(aRenderOptionsVector);
                 Any& rExportNotesValue = aRenderOptions.getArray()[ 1 ].Value;
 
                 if( !aPageRange.isEmpty() || !aSelection.hasValue() )

Reply via email to