Bug 150600 - Macro recorder generates invalid code for MediaProperties' FilterData property: it is Array(Array(...)), must be array of PropertyValue
Summary: Macro recorder generates invalid code for MediaProperties' FilterData propert...
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: 2025-05-22 04:16 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.
Comment 7 QA Administrators 2025-05-22 03:13:03 UTC
Dear dainius.mazuika,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug