filter/source/svg/svgfilter.cxx |   33 ++++++++++++++++++++-------------
 sfx2/source/doc/objstor.cxx     |   13 +++++++++++++
 2 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit b152ca62b9fdb4a667440ae20e96612dcc12191e
Author:     Mike Kaganski <[email protected]>
AuthorDate: Tue Dec 2 17:17:22 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Dec 4 20:35:08 2025 +0100

    tdf#168054: Export all ODG pages to SVG from command line by default
    
    Regression from commit 58ba249df589b0c9f91667f2938bfa18d2a1ce61, which
    fixed obtaining controller, including command line scenario. Before it,
    no controller was found, and mSelectedPages was empty after a call to
    fillDrawImpressSelectedPages. Now the document's controller is found,
    and that puts the first page as the selection into mSelectedPages.
    
    This change uses ConversionRequestOrigin property, added to medium in
    DispatchWatcher::executeDispatchRequests, to detect that the export
    is initiated from command line. In that case, it is assumed that all
    pages should be exported.
    
    I don't really know why the behavior restored in this change is wanted.
    The result is all pages' objects overlapped. Even though SVG markup
    has the pages in separate 'g' elements, it doesn't look reasonable to
    have this result by default. Yet, as it was a pre-existing behavior,
    let's keep it this way for now.
    
    Change-Id: I6d6923e627df4282c61342210ee7d762ea08e2b5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195003
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 56e1d3b4a2e9..f4407aad9563 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -423,19 +423,26 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< 
PropertyValue >& rDescripto
         bool bPageProvided = comphelper::LibreOfficeKit::isActive();
         sal_Int32 nPageToExport = -1;
 
-        for( const PropertyValue& rProp : rDescriptor )
+        comphelper::SequenceAsHashMap args(rDescriptor);
+        if (args.contains(u"ConversionRequestOrigin"_ustr))
         {
-            if (rProp.Name == "SelectionOnly")
-            {
-                // #i124608# extract single selection wanted from dialog 
return values
-                rProp.Value >>= bSelectionOnly;
-                bPageProvided = false;
-            }
-            else if (rProp.Name == "PagePos")
-            {
-                rProp.Value >>= nPageToExport;
+            // when invoked from command line, default to exporting everything 
(-1)
+            if (args[u"ConversionRequestOrigin"_ustr] == u"CommandLine"_ustr)
                 bPageProvided = true;
-            }
+        }
+
+        if (args.contains(u"PagePos"_ustr))
+        {
+            args[u"PagePos"_ustr] >>= nPageToExport;
+            bPageProvided = true;
+        }
+
+        if (args.contains(u"SelectionOnly"_ustr))
+        {
+            // #i124608# extract single selection wanted from dialog return 
values
+            args[u"SelectionOnly"_ustr] >>= bSelectionOnly;
+            if (bSelectionOnly)
+                bPageProvided = false;
         }
 
         uno::Reference<frame::XController > xController;
@@ -461,12 +468,12 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< 
PropertyValue >& rDescripto
 
                     for (sal_Int32 i = 0; i < nDPCount; ++i)
                     {
-                        if( nPageToExport != -1 && nPageToExport == i )
+                        if (nPageToExport == i)
                         {
                             uno::Reference< drawing::XDrawPage > xDrawPage( 
xDrawPages->getByIndex( i ), uno::UNO_QUERY );
                             mSelectedPages.push_back(xDrawPage);
                         }
-                        else
+                        else if (nPageToExport == -1)
                         {
                             uno::Reference< drawing::XDrawPage > xDrawPage( 
xDrawPages->getByIndex( i ), uno::UNO_QUERY );
                             Reference< XPropertySet > xPropSet( xDrawPage, 
UNO_QUERY );
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index c6a9ed3dc871..9c23ef5fd8b1 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2837,6 +2837,7 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium )
         bool bHasFilterName = false;
         bool bIsRedactMode = false;
         bool bIsPreview = false;
+        std::optional<OUString> oConversionRequestOrigin;
         sal_Int32 nEnd = aOldArgs.getLength();
 
         for ( sal_Int32 i = 0; i < nEnd; i++ )
@@ -2859,6 +2860,11 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium )
         {
             if( rMediumArgs[i].Name == "IsPreview" )
                 rMediumArgs[i].Value >>= bIsPreview;
+            else if (rMediumArgs[i].Name == "ConversionRequestOrigin")
+            {
+                if (OUString s; rMediumArgs[i].Value >>= s)
+                    oConversionRequestOrigin = s;
+            }
         }
 
         // FIXME: Handle this inside TransformItems()
@@ -2913,6 +2919,13 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium )
             pArgs[nEnd-1].Name = "IsPreview";
             pArgs[nEnd-1].Value <<= bIsPreview;
         }
+        if (oConversionRequestOrigin)
+        {
+            aArgs.realloc( ++nEnd );
+            auto pArgs = aArgs.getArray();
+            pArgs[nEnd-1].Name = u"ConversionRequestOrigin"_ustr;
+            pArgs[nEnd-1].Value <<= *oConversionRequestOrigin;
+        }
 
         return xFilter->filter( aArgs );
         }

Reply via email to