filter/source/graphic/GraphicExportFilter.cxx |   24 ++++++++++++++++++++++++
 filter/source/graphic/GraphicExportFilter.hxx |    1 +
 include/sal/log-areas.dox                     |    1 +
 3 files changed, 26 insertions(+)

New commits:
commit 323598a6845bd8b4046689816a7d535385c23a19
Author:     Oscar Megía López <[email protected]>
AuthorDate: Mon Jun 9 10:44:12 2025 +0200
Commit:     Mike Kaganski <[email protected]>
CommitDate: Tue Jun 17 08:37:11 2025 +0200

    tdf#157668 Upgrade to pass options to --convert-to
    
    The user can now pass the available options
    for each graphic type to export.
    
    For example:
    
    $ instdir/program/soffice --convert-to 'jpg:calc_jpg_Export:\
    {"PixelWidth":{"type":"long","value":"1280"},\
     "PixelHeight":{"type":"long","value":"1024"},\
     "Quality":{"type":"long","value":"8"}}' --outdir /tmp Calc.ods
    
    Change-Id: I77211805f4fd726da7d5fb0818ac422c3e9b6c96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186287
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/filter/source/graphic/GraphicExportFilter.cxx 
b/filter/source/graphic/GraphicExportFilter.cxx
index fce0571ae9ee..f07d7fbf80e6 100644
--- a/filter/source/graphic/GraphicExportFilter.cxx
+++ b/filter/source/graphic/GraphicExportFilter.cxx
@@ -29,6 +29,10 @@
 #include <vcl/graphicfilter.hxx>
 #include <svl/outstrm.hxx>
 #include <svtools/DocumentToGraphicRenderer.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
+#include <boost/property_tree/json_parser/error.hpp>
+#include <vcl/glyphitemcache.hxx>
 
 using namespace css;
 
@@ -80,6 +84,10 @@ void GraphicExportFilter::gatherProperties( const 
uno::Sequence< beans::Property
         {
             rProperty.Value >>= maFilterDataSequence;
         }
+        else if ( rProperty.Name == "FilterOptions" )
+        {
+            rProperty.Value >>= maFilterOptions;
+        }
         else if ( rProperty.Name == "OutputStream" )
         {
             rProperty.Value >>= mxOutputStream;
@@ -90,6 +98,22 @@ void GraphicExportFilter::gatherProperties( const 
uno::Sequence< beans::Property
         }
     }
 
+    if (!maFilterDataSequence.hasElements() && maFilterOptions.startsWith("{"))
+    {
+        try
+        {
+            // Allow setting filter data keys from the cmdline.
+            std::vector<beans::PropertyValue> aData
+                = comphelper::JsonToPropertyValues(maFilterOptions.toUtf8());
+            maFilterDataSequence = comphelper::containerToSequence(aData);
+        }
+        catch (const boost::property_tree::json_parser::json_parser_error& e)
+        {
+            // This wasn't a valid json; maybe came from import filter
+            SAL_WARN("filter.graphic", "error parsing FilterOptions: " << 
e.message());
+        }
+    }
+
     for (const beans::PropertyValue& rProp : maFilterDataSequence)
     {
         if ( rProp.Name == "PixelWidth" )
diff --git a/filter/source/graphic/GraphicExportFilter.hxx 
b/filter/source/graphic/GraphicExportFilter.hxx
index c78b25d70a89..078217acb357 100644
--- a/filter/source/graphic/GraphicExportFilter.hxx
+++ b/filter/source/graphic/GraphicExportFilter.hxx
@@ -45,6 +45,7 @@ class GraphicExportFilter :
     css::uno::Sequence< css::beans::PropertyValue >     maFilterDataSequence;
 
     OUString    maFilterExtension;
+    OUString    maFilterOptions;
     sal_Int32   mnTargetWidth;
     sal_Int32   mnTargetHeight;
     bool        mbSelectionOnly;
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index cfa4a2e9ee45..984cf9c92041 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -245,6 +245,7 @@ certain functionality.
 @li @c filter.xmlfa
 @li @c filter.xmlfd
 @li @c filter.xslt - xslt import/export
+@li @c filter.graphic
 
 @section oox
 

Reply via email to