Bug 150600 - MaxImageResolution is ignored in macro
Summary: MaxImageResolution is ignored in macro
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.5.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2022-08-25 09:42 UTC by dainius.mazuika
Modified: 2023-05-22 05:22 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dainius.mazuika 2022-08-25 09:42:43 UTC
Description:
When exporting odt to PDF using macro, DPI numeric parameter is ignored. Last used image resolution, set via Writer GUI is used.

Array("MaxImageResolution",0,300..)<- Number 300 is ignored in this example.

Steps to Reproduce:
1. Have an odt document with images, record macro which does File -> Export as -> Export as PDF with "Reduce Image resolution" checkbox set and DPI value is set to 150 and later to 300;
2. Macro recorder will generate these functions (for 150 and 300 DPI setting).

[The only difference is in DPI numeric value, as it should be
Array("MaxImageResolution",0,150, ...
and
Array("MaxImageResolution",0,300, ...
]

**************************************************************************************************
a) for 150DPI resolution:
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///D:/150.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "writer_pdf_Export"
args1(2).Name = "FilterData"
args1(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,87,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,150,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFUACompliance",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ViewPDFAfterExport",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportPlaceholders",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Watermark",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPasswords",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPermissionPassword",0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureLocation",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureReason",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureContactInfo",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignaturePassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureCertificate",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureTSA",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseReferenceXObject",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE))

dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())
end sub

**************************************************************************************************

b) For 300DPI resolution:

sub Macro1
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///D:/300.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "writer_pdf_Export"
args1(2).Name = "FilterData"
args1(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,87,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFUACompliance",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ViewPDFAfterExport",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportPlaceholders",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Watermark",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPasswords",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PreparedPermissionPassword",0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureLocation",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureReason",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureContactInfo",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignaturePassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureCertificate",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SignatureTSA",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseReferenceXObject",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE))

dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())
end sub

******************************************************************************

3. Run sub 1 (with 150 DPI setting);
4. Run sub 2 (with 300 DPI setting):
5. Identical output files are created (the same size). In this case, both 300 DPI files are created, because macro was recorded via GUI dialog, where 300 DPI vas set in the gui.

Actual Results:
Two identical size pdf's are created when running both macros

Expected Results:
1. Run macro with 150 DPI (a. variant in steps to reproduce) -> Expect to get small pdf, with 150DPI images;
2. Run macro with 300 DPI (b. variant in steps to reproduce) -> Expect to get larger pdf, with 150DPI images;


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.3.5.2 (x64) / LibreOffice Community
Build ID: 184fe81b8c8c30d8b5082578aee2fed2ea847c01
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL
Comment 1 Andreas Heinisch 2022-09-01 10:13:16 UTC
Confirmed in:
Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 4044dbbbbdd6a151fa400a270ea685447e654c7b
CPU threads: 16; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL
Comment 2 Mike Kaganski 2023-05-21 11:56:44 UTC
Why do you expect that you can pass an array of arrays as args to executeDispatch? You need to prepare an array of *PropertyValue* struct, and array(array(a,b,c,d)) is not the correct way to do it.

Hence, the array("MaxImageResolution", 0, 150, 0) will not be copied to a PropertyValue structure in PDFFilter::implExport.

IMO, NOTABUG.
Comment 3 Mike Kaganski 2023-05-21 12:22:37 UTC
For comparison, this works fine:


function PropertyValue(n, v)
  dim result as new com.sun.star.beans.PropertyValue
  result.Name = n
  result.Value = v
  PropertyValue = result
end function

sub Main2
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
args1 = Array(PropertyValue("URL", "file:///D:/150.pdf"),_
              PropertyValue("FilterName", "writer_pdf_Export"),_
              PropertyValue("FilterData", Array(PropertyValue("UseLosslessCompression", false),_
                                                PropertyValue("Quality", 87,),_
                                                PropertyValue("ReduceImageResolution", true),_
                                                PropertyValue("MaxImageResolution", 150),_
                                                PropertyValue("UseTaggedPDF", false),_
                                                PropertyValue("SelectPdfVersion", 0),_
                                                PropertyValue("PDFUACompliance", false),_
                                                PropertyValue("ExportNotes", false),_
                                                PropertyValue("ViewPDFAfterExport", true),_
                                                PropertyValue("ExportBookmarks", false),_
                                                PropertyValue("OpenBookmarkLevels", -1),_
                                                PropertyValue("UseTransitionEffects", true),_
                                                PropertyValue("IsSkipEmptyPages", true),_
                                                PropertyValue("ExportPlaceholders", false),_
                                                PropertyValue("IsAddStream", false),_
                                                PropertyValue("ExportFormFields", false),_
                                                PropertyValue("FormsType", 0),_
                                                PropertyValue("AllowDuplicateFieldNames", false),_
                                                PropertyValue("HideViewerToolbar", false),_
                                                PropertyValue("HideViewerMenubar", false),_
                                                PropertyValue("HideViewerWindowControls", false),_
                                                PropertyValue("ResizeWindowToInitialPage", false),_
                                                PropertyValue("CenterWindow", false),_
                                                PropertyValue("OpenInFullScreenMode", false),_
                                                PropertyValue("DisplayPDFDocumentTitle", true),_
                                                PropertyValue("InitialView", 0),_
                                                PropertyValue("Magnification", 1),_
                                                PropertyValue("Zoom", 100),_
                                                PropertyValue("PageLayout", 2),_
                                                PropertyValue("FirstPageOnLeft", false),_
                                                PropertyValue("InitialPage", 1),_
                                                PropertyValue("Printing", 2),_
                                                PropertyValue("Changes", 4),_
                                                PropertyValue("EnableCopyingOfContent", true),_
                                                PropertyValue("EnableTextAccessForAccessibilityTools", true),_
                                                PropertyValue("ExportLinksRelativeFsys", true),_
                                                PropertyValue("PDFViewSelection", 0),_
                                                PropertyValue("ConvertOOoTargetToPDFTarget", false),_
                                                PropertyValue("ExportBookmarksToPDFDestination", false),_
                                                PropertyValue("SignPDF", false),_
                                                PropertyValue("_OkButtonString", ""),_
                                                PropertyValue("Watermark", ""),_
                                                PropertyValue("EncryptFile", false),_
                                                PropertyValue("PreparedPasswords", Empty),_
                                                PropertyValue("RestrictPermissions", false),_
                                                PropertyValue("PreparedPermissionPassword", Array()),_
                                                PropertyValue("SignatureLocation", ""),_
                                                PropertyValue("SignatureReason", ""),_
                                                PropertyValue("SignatureContactInfo", ""),_
                                                PropertyValue("SignaturePassword", ""),_
                                                PropertyValue("SignatureCertificate", Empty),_
                                                PropertyValue("SignatureTSA", ""),_
                                                PropertyValue("UseReferenceXObject", false))))

dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())
end sub
Comment 4 Mike Kaganski 2023-05-21 12:38:11 UTC
(In reply to Mike Kaganski from comment #2)
> Why do you expect that you can pass an array of arrays as args to
> executeDispatch?

Sorry for a thinko; what I meant was that you need to prepare an array of PropertyValue as *FilterData*.
Comment 5 dainius.mazuika 2023-05-21 13:54:08 UTC
Aš I Remember the problem is that two macros, generated by macro recorder are not working as expected. Not using libre extensively anymore, but will try to recheck original usage scenario.
Comment 6 Mike Kaganski 2023-05-22 05:22:36 UTC
So, the issue is that macro recorder creates non-working code? The relevant step is #1 from comment 0.

If the recorder generates these Array(Array(...)) for FilterData, it is definitely a bug.