include/svx/xmleohlp.hxx                                |    9 -
 include/unotools/streamwrap.hxx                         |    7 
 include/xmloff/xmlgrhlp.hxx                             |   32 +--
 include/xmloff/xmlimp.hxx                               |    3 
 offapi/com/sun/star/document/XGraphicStorageHandler.idl |    6 
 reportdesign/source/core/api/ReportDefinition.cxx       |    2 
 sc/source/filter/xml/xmlwrap.cxx                        |    2 
 sc/source/ui/unoobj/servuno.cxx                         |    2 
 sd/source/filter/xml/sdxmlwrp.cxx                       |    2 
 sd/source/ui/unoidl/unomodel.cxx                        |    2 
 solenv/bin/native-code.py                               |    4 
 solenv/clang-format/excludelist                         |    4 
 svx/CppunitTest_svx_core.mk                             |    1 
 svx/Library_svxcore.mk                                  |    1 
 svx/qa/unit/core.cxx                                    |    2 
 svx/source/unodraw/unomod.cxx                           |    2 
 svx/source/xml/xmleohlp.cxx                             |  112 +++++++-----
 svx/source/xml/xmlexport.cxx                            |    2 
 svx/source/xml/xmlxtexp.cxx                             |    2 
 svx/source/xml/xmlxtimp.cxx                             |    2 
 svx/util/svxcore.component                              |   10 -
 sw/source/filter/xml/swxml.cxx                          |    2 
 sw/source/filter/xml/wrtxml.cxx                         |    2 
 sw/source/filter/xml/xmlexp.cxx                         |    2 
 sw/source/filter/xml/xmlimp.cxx                         |    2 
 xmloff/Library_xo.mk                                    |    1 
 xmloff/qa/unit/draw.cxx                                 |   45 ++---
 xmloff/source/core/xmlgrhlp.cxx                         |  141 +++++++---------
 xmloff/source/core/xmlimp.cxx                           |    5 
 xmloff/source/draw/ximpshap.cxx                         |    2 
 xmloff/util/xo.component                                |   10 +
 31 files changed, 228 insertions(+), 193 deletions(-)

New commits:
commit 2a98176566712c95718eea1435ae974ac6aa35b8
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Oct 30 13:33:12 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Oct 31 10:04:42 2025 +0100

    move GraphicImportHelper/GraphicExportHelper into xmloff
    
    Change-Id: If0e9d7b2d9fee0ff4307f35ae82074031b0b0015
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193210
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/include/svx/xmleohlp.hxx b/include/svx/xmleohlp.hxx
index 55682f16c51a..59c604fbc980 100644
--- a/include/svx/xmleohlp.hxx
+++ b/include/svx/xmleohlp.hxx
@@ -112,13 +112,12 @@ public:
     // XNameAccess
     virtual css::uno::Type SAL_CALL getElementType(  ) override;
     virtual sal_Bool SAL_CALL hasElements(  ) override;
-
-
-    static void splitObjectURL(const OUString& aURLNoPar,
-        OUString& rContainerStorageName,
-        OUString& rObjectStorageName);
 };
 
+namespace svx {
+    SVXCORE_DLLPUBLIC void 
DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& xModel);
+}
+
 #endif // INCLUDED_SVX_XMLEOHLP_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx
index 5eddbd6ffcff..b25e8ce23157 100644
--- a/include/unotools/streamwrap.hxx
+++ b/include/unotools/streamwrap.hxx
@@ -99,7 +99,12 @@ public:
 
 //= OOutputStreamWrapper
 
-class UNOTOOLS_DLLPUBLIC OOutputStreamWrapper : public 
cppu::WeakImplHelper<css::io::XOutputStream>
+// avoid LNK2005 duplicate WeakImplHelper definitions with MSVC
+class SAL_DLLPUBLIC_TEMPLATE OOutputStreamWrapper_Base : public 
cppu::WeakImplHelper<css::io::XOutputStream>
+{
+};
+
+class UNOTOOLS_DLLPUBLIC OOutputStreamWrapper : public 
OOutputStreamWrapper_Base
 {
 public:
     OOutputStreamWrapper(SvStream& _rStream);
diff --git a/include/svx/xmlgrhlp.hxx b/include/xmloff/xmlgrhlp.hxx
similarity index 89%
rename from include/svx/xmlgrhlp.hxx
rename to include/xmloff/xmlgrhlp.hxx
index 1057b1ad18fd..c4fe893baef5 100644
--- a/include/svx/xmlgrhlp.hxx
+++ b/include/xmloff/xmlgrhlp.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_SVX_XMLGRHLP_HXX
-#define INCLUDED_SVX_XMLGRHLP_HXX
+#pragma once
 
 #include <comphelper/compbase.hxx>
 #include <vcl/graph.hxx>
@@ -32,7 +31,7 @@
 #include <com/sun/star/document/XGraphicStorageHandler.hpp>
 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
-#include <svx/svxdllapi.h>
+#include <xmloff/dllapi.h>
 
 enum class SvXMLGraphicHelperMode
 {
@@ -45,7 +44,7 @@ struct SvxGraphicHelperStream_Impl
     css::uno::Reference < css::io::XStream > xStream;
 };
 
-class SVXCORE_DLLPUBLIC SvXMLGraphicHelper final :
+class XMLOFF_DLLPUBLIC SvXMLGraphicHelper final :
         public 
comphelper::WeakComponentImplHelper<css::document::XGraphicObjectResolver,
                                             
css::document::XGraphicStorageHandler,
                                             
css::document::XBinaryStreamResolver>
@@ -63,16 +62,16 @@ private:
     SvXMLGraphicHelperMode      meCreateMode;
     OUString                    maOutputMimeType;
 
-    SVX_DLLPRIVATE static bool          ImplGetStreamNames( const OUString& 
rURLStr,
+    SAL_DLLPRIVATE static bool          ImplGetStreamNames( const OUString& 
rURLStr,
                                                     OUString& 
rPictureStorageName,
                                                     OUString& 
rPictureStreamName );
-    SVX_DLLPRIVATE css::uno::Reference < css::embed::XStorage >
+    SAL_DLLPRIVATE css::uno::Reference < css::embed::XStorage >
                                             ImplGetGraphicStorage( const 
OUString& rPictureStorageName );
-    SVX_DLLPRIVATE SvxGraphicHelperStream_Impl
+    SAL_DLLPRIVATE SvxGraphicHelperStream_Impl
                                             ImplGetGraphicStream( const 
OUString& rPictureStorageName,
                                                       const OUString& 
rPictureStreamName );
-    SVX_DLLPRIVATE static OUString      ImplGetGraphicMimeType( 
std::u16string_view rFileName );
-    SVX_DLLPRIVATE Graphic ImplReadGraphic(const OUString& rPictureStorageName,
+    SAL_DLLPRIVATE static OUString      ImplGetGraphicMimeType( 
std::u16string_view rFileName );
+    SAL_DLLPRIVATE Graphic ImplReadGraphic(const OUString& rPictureStorageName,
                                            const OUString& rPictureStreamName,
                                            sal_Int32 nPage = -1);
 
@@ -82,7 +81,7 @@ private:
                                       SvXMLGraphicHelperMode eCreateMode,
                                       const OUString& rGraphicMimeType = 
OUString() );
 
-    SVX_DLLPRIVATE OUString 
implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
+    SAL_DLLPRIVATE OUString 
implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
                                             OUString & rOutMimeType,
                                             std::u16string_view rRequestName);
 
@@ -94,6 +93,10 @@ public:
     static rtl::Reference<SvXMLGraphicHelper>  Create( SvXMLGraphicHelperMode 
eCreateMode,
                                         const OUString& rMimeType = OUString() 
);
 
+    static void splitObjectURL(const OUString& aURLNoPar,
+        OUString& rContainerStorageName,
+        OUString& rObjectStorageName);
+
 public:
 
     // XGraphicObjectResolver
@@ -128,10 +131,4 @@ public:
     virtual OUString SAL_CALL resolveOutputStream( const css::uno::Reference< 
css::io::XOutputStream >& rxBinaryStream ) override;
 };
 
-namespace svx {
-    SVXCORE_DLLPUBLIC void 
DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& xModel);
-}
-
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx 
b/reportdesign/source/core/api/ReportDefinition.cxx
index 5e5de10606b0..0d636d1af7fe 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -110,7 +110,7 @@
 #include <svx/svdlayer.hxx>
 #include <svx/unofill.hxx>
 #include <svx/xmleohlp.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <comphelper/diagnose_ex.hxx>
 #include <vcl/svapp.hxx>
 
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index f6e9d7ef466b..9dc4e7d4a125 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -30,7 +30,7 @@
 #include <comphelper/propertysequence.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/strings.hrc>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <svtools/sfxecode.hxx>
 #include <sfx2/frame.hxx>
 #include <svl/itemset.hxx>
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index d06af2e78b5d..38a8682af63f 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -51,7 +51,7 @@
 
 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
 #include <svx/xmleohlp.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
 #include <com/sun/star/document/XCodeNameQuery.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx 
b/sd/source/filter/xml/sdxmlwrp.cxx
index caf15884c10f..9131299b1e2a 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -37,7 +37,7 @@
 #include <unotools/streamwrap.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/strings.hrc>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <xmloff/xmlexp.hxx>
 
 #include <DrawDocShell.hxx>
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index b51403690386..772d41f64c2b 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -124,7 +124,7 @@
 
 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
 #include <svx/xmleohlp.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <DrawDocShell.hxx>
 #include <ViewShellBase.hxx>
 #include "UnoDocumentSettings.hxx"
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index cb4cfa0ec732..3092230ab415 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -390,8 +390,6 @@ core_constructor_list = [
     "com_sun_star_comp_svx_ColorToolBoxControl_get_implementation",
     "com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation",
     "com_sun_star_comp_svx_FrameToolBoxControl_get_implementation",
-    "com_sun_star_comp_Svx_GraphicExportHelper_get_implementation",
-    "com_sun_star_comp_Svx_GraphicImportHelper_get_implementation",
     "com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation",
     "com_sun_star_comp_svx_LineStyleToolBoxControl_get_implementation",
     "com_sun_star_comp_svx_StyleToolBoxControl_get_implementation",
@@ -539,6 +537,8 @@ core_constructor_list = [
     
"com_sun_star_comp_Writer_XMLOasisAutotextEventsExporter_get_implementation",
     "com_sun_star_comp_Writer_XMLAutotextEventsExporter_get_implementation",
     
"com_sun_star_comp_Writer_XMLOasisAutotextEventsImporter_get_implementation",
+    "com_sun_star_comp_Svx_GraphicExportHelper_get_implementation",
+    "com_sun_star_comp_Svx_GraphicImportHelper_get_implementation",
 # xmlscript/util/xmlscript.component
     "com_sun_star_comp_xml_input_SaxDocumentHandler_get_implementation",
     "com_sun_star_comp_xmlscript_XMLBasicExporter",
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index fa5814104418..560c937ce265 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -5854,7 +5854,6 @@ include/svx/xlntrit.hxx
 include/svx/xlnwtit.hxx
 include/svx/xmleohlp.hxx
 include/svx/xmlexchg.hxx
-include/svx/xmlgrhlp.hxx
 include/svx/xmlsecctrl.hxx
 include/svx/xoutbmp.hxx
 include/svx/xpoly.hxx
@@ -6282,6 +6281,7 @@ include/xmloff/xmlerror.hxx
 include/xmloff/xmlevent.hxx
 include/xmloff/xmlexp.hxx
 include/xmloff/xmlexppr.hxx
+include/xmloff/xmlgrhlp.hxx
 include/xmloff/xmlictxt.hxx
 include/xmloff/xmlimp.hxx
 include/xmloff/xmlimppr.hxx
@@ -11654,7 +11654,6 @@ svx/source/unogallery/unogaltheme.hxx
 svx/source/unogallery/unogalthemeprovider.cxx
 svx/source/xml/xmleohlp.cxx
 svx/source/xml/xmlexport.cxx
-svx/source/xml/xmlgrhlp.cxx
 svx/source/xml/xmlxtexp.cxx
 svx/source/xml/xmlxtimp.cxx
 svx/source/xoutdev/_xoutbmp.cxx
@@ -15199,6 +15198,7 @@ 
xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
 xmloff/source/core/xmlcnimp.cxx
 xmloff/source/core/xmlerror.cxx
 xmloff/source/core/xmlexp.cxx
+xmloff/source/core/xmlgrhlp.cxx
 xmloff/source/core/xmlictxt.cxx
 xmloff/source/core/xmlimp.cxx
 xmloff/source/core/xmlmultiimagehelper.cxx
diff --git a/svx/CppunitTest_svx_core.mk b/svx/CppunitTest_svx_core.mk
index 1a0a5c25dde2..2c4d97e29c66 100644
--- a/svx/CppunitTest_svx_core.mk
+++ b/svx/CppunitTest_svx_core.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svx_core, \
     unotest \
     utl \
     vcl \
+    xo \
 ))
 
 $(eval $(call gb_CppunitTest_use_sdk_api,svx_core))
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index cf48f318363a..ad98cd64917f 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -468,7 +468,6 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/unodraw/XPropertyTable \
     svx/source/xml/xmleohlp \
     svx/source/xml/xmlexport \
-    svx/source/xml/xmlgrhlp \
     svx/source/xml/xmlxtexp \
     svx/source/xml/xmlxtimp \
     svx/source/xoutdev/xattr \
diff --git a/svx/qa/unit/core.cxx b/svx/qa/unit/core.cxx
index 6349397c7d33..705b46a71b5b 100644
--- a/svx/qa/unit/core.cxx
+++ b/svx/qa/unit/core.cxx
@@ -14,7 +14,7 @@
 #include <comphelper/storagehelper.hxx>
 
 #include <svx/graphichelper.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <unotools/tempfile.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
 
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
index 85240ef6da47..2f0c533b6c5c 100644
--- a/svx/source/unodraw/unomod.cxx
+++ b/svx/source/unodraw/unomod.cxx
@@ -48,7 +48,7 @@
 #include <svx/svdpage.hxx>
 #include <svx/SvxXTextColumns.hxx>
 #include <svx/unoshape.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 
 #include <com/sun/star/text/textfield/Type.hpp>
 
diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx
index e3164e4b838c..5802daaecb19 100644
--- a/svx/source/xml/xmleohlp.cxx
+++ b/svx/source/xml/xmleohlp.cxx
@@ -27,6 +27,8 @@
 #include <com/sun/star/embed/EmbedStates.hpp>
 #include <com/sun/star/embed/Aspects.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
 #include <osl/diagnose.h>
 #include <sot/storage.hxx>
 #include <tools/debug.hxx>
@@ -36,6 +38,7 @@
 
 #include <svtools/embedhlp.hxx>
 #include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/diagnose_ex.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/embeddedobjectcontainer.hxx>
@@ -44,6 +47,7 @@
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <svx/xmleohlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <map>
 #include <memory>
 #include <mutex>
@@ -143,48 +147,6 @@ void 
SvXMLEmbeddedObjectHelper::disposing(std::unique_lock<std::mutex>&)
     }
 }
 
-void SvXMLEmbeddedObjectHelper::splitObjectURL(const OUString& _aURLNoPar,
-    OUString& rContainerStorageName,
-    OUString& rObjectStorageName)
-{
-    DBG_ASSERT(_aURLNoPar.isEmpty() || '#' != _aURLNoPar[0], "invalid object 
URL" );
-    OUString aURLNoPar = _aURLNoPar;
-
-    sal_Int32 _nPos = aURLNoPar.lastIndexOf( '/' );
-    if( -1 == _nPos )
-    {
-        rContainerStorageName.clear();
-        rObjectStorageName = aURLNoPar;
-    }
-    else
-    {
-        //eliminate 'superfluous' slashes at start and end
-        //#i103076# load objects with all allowed xlink:href syntaxes
-        {
-            //eliminate './' at start
-            sal_Int32 nStart = 0;
-            sal_Int32 nCount = aURLNoPar.getLength();
-            if( aURLNoPar.startsWith( "./" ) )
-            {
-                nStart = 2;
-                nCount -= 2;
-            }
-
-            //eliminate '/' at end
-            sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' );
-            if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) )
-                nCount--;
-
-            aURLNoPar = aURLNoPar.copy( nStart, nCount );
-        }
-
-        _nPos = aURLNoPar.lastIndexOf( '/' );
-        if( _nPos >= 0 )
-            rContainerStorageName = aURLNoPar.copy( 0, _nPos );
-        rObjectStorageName = aURLNoPar.copy( _nPos+1 );
-    }
-}
-
 bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames(
         const OUString& rURLStr,
         OUString& rContainerStorageName,
@@ -283,7 +245,7 @@ bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames(
     }
     else
     {
-        splitObjectURL(aURLNoPar, rContainerStorageName, rObjectStorageName);
+        SvXMLGraphicHelper::splitObjectURL(aURLNoPar, rContainerStorageName, 
rObjectStorageName);
     }
 
     if( -1 != rContainerStorageName.indexOf( '/' ) )
@@ -716,4 +678,68 @@ sal_Bool SAL_CALL SvXMLEmbeddedObjectHelper::hasElements()
     }
 }
 
+namespace svx {
+
+    void DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& 
xModel)
+    {
+        uno::Reference<lang::XMultiServiceFactory> const xModelFactory(xModel, 
uno::UNO_QUERY);
+        assert(xModelFactory.is());
+        try
+        {
+            uno::Reference<util::XCancellable> const xGradient(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.GradientTable"_ustr),
+                uno::UNO_QUERY );
+            if (xGradient.is())
+            {
+                xGradient->cancel();
+            }
+
+            uno::Reference<util::XCancellable> const xHatch(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.HatchTable"_ustr),
+                uno::UNO_QUERY );
+            if (xHatch.is())
+            {
+                xHatch->cancel();
+            }
+
+            uno::Reference<util::XCancellable> const xBitmap(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.BitmapTable"_ustr),
+                uno::UNO_QUERY );
+            if (xBitmap.is())
+            {
+                xBitmap->cancel();
+            }
+
+            uno::Reference<util::XCancellable> const xTransGradient(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.TransparencyGradientTable"_ustr),
+                uno::UNO_QUERY );
+            if (xTransGradient.is())
+            {
+                xTransGradient->cancel();
+            }
+
+            uno::Reference<util::XCancellable> const xMarker(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.MarkerTable"_ustr),
+                uno::UNO_QUERY );
+            if (xMarker.is())
+            {
+                xMarker->cancel();
+            }
+
+            uno::Reference<util::XCancellable> const xDashes(
+                
xModelFactory->createInstance(u"com.sun.star.drawing.DashTable"_ustr),
+                uno::UNO_QUERY );
+            if (xDashes.is())
+            {
+                xDashes->cancel();
+            }
+        }
+        catch (const Exception&)
+        {
+            TOOLS_WARN_EXCEPTION("svx", "dropUnusedNamedItems(): exception 
during clearing of unused named items");
+        }
+    }
+
+} // namespace svx
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlexport.cxx b/svx/source/xml/xmlexport.cxx
index 53babc43fad8..73ffdee3811f 100644
--- a/svx/source/xml/xmlexport.cxx
+++ b/svx/source/xml/xmlexport.cxx
@@ -30,7 +30,7 @@
 #include <comphelper/processfactory.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/xmleohlp.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 
 #include <svx/unomodel.hxx>
 
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index d06afda8208b..e0adf8d3cdc3 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -48,7 +48,7 @@
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #include <comphelper/processfactory.hxx>
 #include <unotools/streamwrap.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 
 #include <xmlxtexp.hxx>
 
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index a2d97359fe9a..9d3858ab901c 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -44,7 +44,7 @@
 #include <xmloff/ImageStyle.hxx>
 #include <xmloff/MarkerStyle.hxx>
 #include <xmloff/xmlictxt.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 
 #include <xmlxtimp.hxx>
 #include <comphelper/sequence.hxx>
diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component
index d218e1292b5a..b8059e341977 100644
--- a/svx/util/svxcore.component
+++ b/svx/util/svxcore.component
@@ -75,16 +75,6 @@
       
constructor="com_sun_star_comp_svx_LineStyleToolBoxControl_get_implementation">
     <service name="com.sun.star.frame.ToolbarController"/>
   </implementation>
-  <implementation name="com.sun.star.comp.Svx.GraphicExportHelper"
-      
constructor="com_sun_star_comp_Svx_GraphicExportHelper_get_implementation">
-    <service name="com.sun.star.document.BinaryStreamResolver"/>
-    <service name="com.sun.star.document.GraphicStorageHandler"/>
-  </implementation>
-  <implementation name="com.sun.star.comp.Svx.GraphicImportHelper"
-      
constructor="com_sun_star_comp_Svx_GraphicImportHelper_get_implementation">
-    <service name="com.sun.star.document.BinaryStreamResolver"/>
-    <service name="com.sun.star.document.GraphicStorageHandler"/>
-  </implementation>
   <implementation name="com.sun.star.comp.graphic.PrimitiveFactory2D"
       
constructor="com_sun_star_comp_graphic_PrimitiveFactory2D_get_implementation">
     <service name="com.sun.star.graphic.PrimitiveFactory2D"/>
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index ca9e78e2b058..c0578a062f40 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -41,7 +41,7 @@
 #include <svl/stritem.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/strings.hrc>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <svx/xmleohlp.hxx>
 #include <comphelper/fileformat.h>
 #include <comphelper/genericpropertyset.hxx>
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 2f5e049ea581..f44305fe2cd6 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -36,7 +36,7 @@
 #include <vcl/errinf.hxx>
 #include <osl/diagnose.h>
 #include <sal/log.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <svx/xmleohlp.hxx>
 #include <svl/stritem.hxx>
 #include <sfx2/frame.hxx>
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 07d011f0e05a..ca6996f9168d 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -30,7 +30,7 @@
 #include <sax/tools/converter.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/xmleohlp.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <editeng/eeitem.hxx>
 #include <svx/svddef.hxx>
 #include <tools/UnitConversion.hxx>
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 7e6820e3cf66..1708019f791a 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -59,7 +59,7 @@
 #include <swdll.hxx>
 #include <xmloff/DocumentSettingsContext.hxx>
 #include <docsh.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <svx/xmleohlp.hxx>
 #include <sfx2/printer.hxx>
 #include <sfx2/sfxmodelfactory.hxx>
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 2bad53c2130a..535e71a00124 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
     xmloff/source/core/xmlcnimp \
     xmloff/source/core/xmlerror \
     xmloff/source/core/xmlexp \
+    xmloff/source/core/xmlgrhlp \
     xmloff/source/core/xmlictxt \
     xmloff/source/core/xmlimp \
     xmloff/source/core/xmltkmap \
diff --git a/svx/source/xml/xmlgrhlp.cxx b/xmloff/source/core/xmlgrhlp.cxx
similarity index 94%
rename from svx/source/xml/xmlgrhlp.cxx
rename to xmloff/source/core/xmlgrhlp.cxx
index 3497265f765d..312c6795e3bb 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/xmloff/source/core/xmlgrhlp.cxx
@@ -26,8 +26,6 @@
 #include <com/sun/star/io/NotConnectedException.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/util/XCancellable.hpp>
 #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
 #include <comphelper/fileformat.h>
 #include <comphelper/graphicmimetype.hxx>
@@ -43,12 +41,13 @@
 #include <vcl/filter/SvmWriter.hxx>
 #include <vcl/gfxlink.hxx>
 #include <vcl/metaact.hxx>
+#include <tools/debug.hxx>
 #include <tools/zcodec.hxx>
 #include <comphelper/diagnose_ex.hxx>
 
 #include <vcl/GraphicObject.hxx>
 #include <vcl/graphicfilter.hxx>
-#include <svx/xmlgrhlp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <svx/xmleohlp.hxx>
 
 #include <algorithm>
@@ -376,6 +375,48 @@ SvXMLGraphicHelper::~SvXMLGraphicHelper()
 {
 }
 
+void SvXMLGraphicHelper::splitObjectURL(const OUString& _aURLNoPar,
+    OUString& rContainerStorageName,
+    OUString& rObjectStorageName)
+{
+    DBG_ASSERT(_aURLNoPar.isEmpty() || '#' != _aURLNoPar[0], "invalid object 
URL" );
+    OUString aURLNoPar = _aURLNoPar;
+
+    sal_Int32 _nPos = aURLNoPar.lastIndexOf( '/' );
+    if( -1 == _nPos )
+    {
+        rContainerStorageName.clear();
+        rObjectStorageName = aURLNoPar;
+    }
+    else
+    {
+        //eliminate 'superfluous' slashes at start and end
+        //#i103076# load objects with all allowed xlink:href syntaxes
+        {
+            //eliminate './' at start
+            sal_Int32 nStart = 0;
+            sal_Int32 nCount = aURLNoPar.getLength();
+            if( aURLNoPar.startsWith( "./" ) )
+            {
+                nStart = 2;
+                nCount -= 2;
+            }
+
+            //eliminate '/' at end
+            sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' );
+            if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) )
+                nCount--;
+
+            aURLNoPar = aURLNoPar.copy( nStart, nCount );
+        }
+
+        _nPos = aURLNoPar.lastIndexOf( '/' );
+        if( _nPos >= 0 )
+            rContainerStorageName = aURLNoPar.copy( 0, _nPos );
+        rObjectStorageName = aURLNoPar.copy( _nPos+1 );
+    }
+}
+
 bool SvXMLGraphicHelper::ImplGetStreamNames( const OUString& rURLStr,
                                                  OUString& rPictureStorageName,
                                                  OUString& rPictureStreamName )
@@ -391,7 +432,7 @@ bool SvXMLGraphicHelper::ImplGetStreamNames( const 
OUString& rURLStr,
         rPictureStreamName = aURLStr;
     }
     else
-        SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, 
rPictureStorageName, rPictureStreamName);
+        SvXMLGraphicHelper::splitObjectURL(aURLStr, rPictureStorageName, 
rPictureStreamName);
 
     SAL_WARN_IF(rPictureStreamName.isEmpty(), "svx", 
"SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
 
@@ -1176,68 +1217,4 @@ 
com_sun_star_comp_Svx_GraphicExportHelper_get_implementation(
     return cppu::acquire(new 
SvXMLGraphicImportExportHelper(SvXMLGraphicHelperMode::Write));
 }
 
-namespace svx {
-
-    void DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& 
xModel)
-    {
-        uno::Reference<lang::XMultiServiceFactory> const xModelFactory(xModel, 
uno::UNO_QUERY);
-        assert(xModelFactory.is());
-        try
-        {
-            uno::Reference<util::XCancellable> const xGradient(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.GradientTable"_ustr),
-                uno::UNO_QUERY );
-            if (xGradient.is())
-            {
-                xGradient->cancel();
-            }
-
-            uno::Reference<util::XCancellable> const xHatch(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.HatchTable"_ustr),
-                uno::UNO_QUERY );
-            if (xHatch.is())
-            {
-                xHatch->cancel();
-            }
-
-            uno::Reference<util::XCancellable> const xBitmap(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.BitmapTable"_ustr),
-                uno::UNO_QUERY );
-            if (xBitmap.is())
-            {
-                xBitmap->cancel();
-            }
-
-            uno::Reference<util::XCancellable> const xTransGradient(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.TransparencyGradientTable"_ustr),
-                uno::UNO_QUERY );
-            if (xTransGradient.is())
-            {
-                xTransGradient->cancel();
-            }
-
-            uno::Reference<util::XCancellable> const xMarker(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.MarkerTable"_ustr),
-                uno::UNO_QUERY );
-            if (xMarker.is())
-            {
-                xMarker->cancel();
-            }
-
-            uno::Reference<util::XCancellable> const xDashes(
-                
xModelFactory->createInstance(u"com.sun.star.drawing.DashTable"_ustr),
-                uno::UNO_QUERY );
-            if (xDashes.is())
-            {
-                xDashes->cancel();
-            }
-        }
-        catch (const Exception&)
-        {
-            TOOLS_WARN_EXCEPTION("svx", "dropUnusedNamedItems(): exception 
during clearing of unused named items");
-        }
-    }
-
-} // namespace svx
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/util/xo.component b/xmloff/util/xo.component
index 7bd198ce17d3..ef06443f8a6e 100644
--- a/xmloff/util/xo.component
+++ b/xmloff/util/xo.component
@@ -229,4 +229,14 @@
       constructor="com_sun_star_comp_Xmloff_AnimationsImport">
     <service name="com.sun.star.comp.Xmloff.AnimationsImport"/>
   </implementation>
+  <implementation name="com.sun.star.comp.Svx.GraphicExportHelper"
+      
constructor="com_sun_star_comp_Svx_GraphicExportHelper_get_implementation">
+    <service name="com.sun.star.document.BinaryStreamResolver"/>
+    <service name="com.sun.star.document.GraphicStorageHandler"/>
+  </implementation>
+  <implementation name="com.sun.star.comp.Svx.GraphicImportHelper"
+      
constructor="com_sun_star_comp_Svx_GraphicImportHelper_get_implementation">
+    <service name="com.sun.star.document.BinaryStreamResolver"/>
+    <service name="com.sun.star.document.GraphicStorageHandler"/>
+  </implementation>
 </component>
commit cf6edbd0b327ca8aa660b00d5165e63174f1dc17
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Oct 29 13:14:41 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Oct 31 10:04:34 2025 +0100

    [API CHANGE] sd pdfium: apply page number when loading pdf pages from fodg
    
    this is the same concept/ideas as
    
    a12bd4fedfc3f269f1dbb5fea36b607facd1261d
        [API CHANGE] sd pdfium: add page number when saving/loading pdf pages 
as images
    
    but extended to support fodg where the problem of showing the first page
    of the pdf for all images remained.
    
    Change-Id: I5a180037634f71104800e09bec400316b56ab1f2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193156
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/svx/xmlgrhlp.hxx b/include/svx/xmlgrhlp.hxx
index 6e84eb340e56..1057b1ad18fd 100644
--- a/include/svx/xmlgrhlp.hxx
+++ b/include/svx/xmlgrhlp.hxx
@@ -110,6 +110,9 @@ public:
     virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
         
loadGraphicFromOutputStream(css::uno::Reference<css::io::XOutputStream> const & 
rxOutputStream) override;
 
+    virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
+        
loadGraphicFromOutputStreamAtPage(css::uno::Reference<css::io::XOutputStream> 
const & rxOutputStream, sal_Int32 nPage) override;
+
     virtual OUString SAL_CALL
         saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & 
rxGraphic) override;
 
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 2a0660272250..6a3d4e57d9c7 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -409,7 +409,8 @@ public:
 
     css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString 
const& rURL,
                                                                  sal_Int32 
nPageNum = -1);
-    css::uno::Reference<css::graphic::XGraphic> 
loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & 
rxOutputStream);
+    css::uno::Reference<css::graphic::XGraphic> 
loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & 
rxOutputStream,
+                                                                      
sal_Int32 nPageNum = -1);
 
     css::uno::Reference< css::io::XOutputStream > 
GetStreamForGraphicObjectURLFromBase64() const;
 
diff --git a/offapi/com/sun/star/document/XGraphicStorageHandler.idl 
b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
index 7390b189394f..c440e1e9351b 100644
--- a/offapi/com/sun/star/document/XGraphicStorageHandler.idl
+++ b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
@@ -21,7 +21,7 @@ interface XGraphicStorageHandler : 
com::sun::star::uno::XInterface
     */
     com::sun::star::graphic::XGraphic loadGraphic([in] string aURL);
 
-    /** load a specific page from a graphic defined by the URL from the storage
+    /** load a specific page of a graphic defined by the URL from the storage
     */
     com::sun::star::graphic::XGraphic loadGraphicAtPage([in] string aURL, [in] 
long nPage);
 
@@ -29,6 +29,10 @@ interface XGraphicStorageHandler : 
com::sun::star::uno::XInterface
     */
     com::sun::star::graphic::XGraphic loadGraphicFromOutputStream([in] 
com::sun::star::io::XOutputStream xOutputStream);
 
+    /** load a specific page of a graphic from the output stream
+    */
+    com::sun::star::graphic::XGraphic loadGraphicFromOutputStreamAtPage([in] 
com::sun::star::io::XOutputStream xOutputStream, [in] long nPage);
+
     /** save the graphic to the storage and return the URL reference to
         its location inside the storage
     */
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 11f2ecc1effe..3497265f765d 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -237,7 +237,7 @@ public:
 
     bool                            Exists() const { return mxStmWrapper.is(); 
}
     const GraphicObject&            GetGraphicObject();
-    Graphic GetGraphic();
+    Graphic GetGraphic(sal_Int32 nPageNum = -1);
 };
 
 SvXMLGraphicOutputStream::SvXMLGraphicOutputStream()
@@ -283,7 +283,7 @@ void SAL_CALL SvXMLGraphicOutputStream::closeOutput()
     mbClosed = true;
 }
 
-Graphic SvXMLGraphicOutputStream::GetGraphic()
+Graphic SvXMLGraphicOutputStream::GetGraphic(sal_Int32 nPageNum)
 {
     Graphic aGraphic;
 
@@ -292,7 +292,8 @@ Graphic SvXMLGraphicOutputStream::GetGraphic()
         mpOStm->Seek( 0 );
         sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
         sal_uInt16 nDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
-        GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, u"", 
*mpOStm ,nFormat,&nDeterminedFormat);
+        GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, u"", 
*mpOStm ,nFormat,&nDeterminedFormat,
+                GraphicFilterImportFlags::NONE, nPageNum);
 
         if (nDeterminedFormat == GRFILTER_FORMAT_DONTKNOW)
         {
@@ -332,7 +333,8 @@ Graphic SvXMLGraphicOutputStream::GetGraphic()
                         if (nStreamLen_ > 0)
                         {
                             aDest.Seek(0);
-                            GraphicFilter::GetGraphicFilter().ImportGraphic( 
aGraphic, u"", aDest ,nFormat,&nDeterminedFormat );
+                            GraphicFilter::GetGraphicFilter().ImportGraphic( 
aGraphic, u"", aDest ,nFormat,&nDeterminedFormat,
+                                    GraphicFilterImportFlags::NONE, nPageNum);
                         }
                     }
                 }
@@ -619,7 +621,7 @@ uno::Reference<graphic::XGraphic>
     return xGraphic;
 }
 
-uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream>
 const & rxOutputStream)
+uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOutputStreamAtPage(uno::Reference<io::XOutputStream>
 const & rxOutputStream, sal_Int32 nPageNum)
 {
     std::unique_lock aGuard(m_aMutex);
 
@@ -627,16 +629,20 @@ uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOu
 
     if ((SvXMLGraphicHelperMode::Read == meCreateMode) && rxOutputStream.is())
     {
-
         SvXMLGraphicOutputStream* pGraphicOutputStream = 
static_cast<SvXMLGraphicOutputStream*>(rxOutputStream.get());
         if (pGraphicOutputStream)
         {
-            xGraphic = pGraphicOutputStream->GetGraphic().GetXGraphic();
+            xGraphic = 
pGraphicOutputStream->GetGraphic(nPageNum).GetXGraphic();
         }
     }
     return xGraphic;
 }
 
+uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream>
 const & rxOutputStream)
+{
+    return loadGraphicFromOutputStreamAtPage(rxOutputStream, -1);
+}
+
 OUString SAL_CALL 
SvXMLGraphicHelper::saveGraphicByName(css::uno::Reference<css::graphic::XGraphic>
 const & rxGraphic,
                                                         OUString & 
rOutSavedMimeType, OUString const & rRequestName)
 {
@@ -999,6 +1005,9 @@ protected:
     virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
         
loadGraphicFromOutputStream(css::uno::Reference<css::io::XOutputStream> const & 
rxOutputStream) override;
 
+    virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
+        
loadGraphicFromOutputStreamAtPage(css::uno::Reference<css::io::XOutputStream> 
const & rxOutputStream, sal_Int32 nPage) override;
+
     virtual OUString SAL_CALL
         saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & 
rxGraphic) override;
 
@@ -1071,6 +1080,11 @@ uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicImportExportHelper::loadG
     return m_xXMLGraphicHelper->loadGraphicFromOutputStream(rxOutputStream);
 }
 
+uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicImportExportHelper::loadGraphicFromOutputStreamAtPage(uno::Reference<io::XOutputStream>
 const & rxOutputStream, sal_Int32 nPage)
+{
+    return 
m_xXMLGraphicHelper->loadGraphicFromOutputStreamAtPage(rxOutputStream, nPage);
+}
+
 OUString SAL_CALL 
SvXMLGraphicImportExportHelper::saveGraphic(css::uno::Reference<css::graphic::XGraphic>
 const & rxGraphic)
 {
     return m_xXMLGraphicHelper->saveGraphic(rxGraphic);
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index 41019fbeb204..0ba4132fb4e4 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -1107,26 +1107,33 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testPdfExportAsOdg)
     });
 
     loadFromFile(u"two-pages.pdf");
-    // save and reload as odg
-    saveAndReload("draw8");
 
-    // Check that the graphic in the second page of the document is the second 
page of the pdf
-    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
-                                                                   
uno::UNO_QUERY_THROW);
-    CPPUNIT_ASSERT(xDrawPagesSupplier.is());
-    uno::Reference<drawing::XDrawPages> 
xDrawPages(xDrawPagesSupplier->getDrawPages());
-    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(1), 
uno::UNO_QUERY_THROW);
-    uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
-    CPPUNIT_ASSERT(xImage.is());
-    uno::Reference<beans::XPropertySet> xShapeProps(xImage, uno::UNO_QUERY);
-    uno::Reference<graphic::XGraphic> xGraphic;
-    CPPUNIT_ASSERT(xShapeProps->getPropertyValue("Graphic") >>= xGraphic);
-
-    Graphic aGraphic(xGraphic);
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 1
-    // - Actual  : -1
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getPageNumber());
+    OUString formats[] = { "draw8", "OpenDocument Drawing Flat XML" };
+    // save and reload as odg and fodg
+    for (const OUString& format : formats)
+    {
+        setImportFilterName(format);
+        saveAndReload(format);
+
+        // Check that the graphic in the second page of the document is the 
second page of the pdf
+        uno::Reference<drawing::XDrawPagesSupplier> 
xDrawPagesSupplier(mxComponent,
+                                                                       
uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT(xDrawPagesSupplier.is());
+        uno::Reference<drawing::XDrawPages> 
xDrawPages(xDrawPagesSupplier->getDrawPages());
+        uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(1),
+                                                     uno::UNO_QUERY_THROW);
+        uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT(xImage.is());
+        uno::Reference<beans::XPropertySet> xShapeProps(xImage, 
uno::UNO_QUERY);
+        uno::Reference<graphic::XGraphic> xGraphic;
+        CPPUNIT_ASSERT(xShapeProps->getPropertyValue("Graphic") >>= xGraphic);
+
+        Graphic aGraphic(xGraphic);
+        // Without the accompanying fix in place, this test would have failed 
with:
+        // - Expected: 1
+        // - Actual  : -1
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aGraphic.getPageNumber());
+    }
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 36aae86dc200..d783b0fc6601 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1362,13 +1362,14 @@ uno::Reference<graphic::XGraphic> 
SvXMLImport::loadGraphicByURL(OUString const&
     return xGraphic;
 }
 
-uno::Reference<graphic::XGraphic> 
SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream> const & 
rxOutputStream)
+uno::Reference<graphic::XGraphic> 
SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream> const & 
rxOutputStream,
+                                                                     sal_Int32 
nPageNum)
 {
     uno::Reference<graphic::XGraphic> xGraphic;
 
     if (mxGraphicStorageHandler.is())
     {
-        xGraphic = 
mxGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
+        xGraphic = 
mxGraphicStorageHandler->loadGraphicFromOutputStreamAtPage(rxOutputStream, 
nPageNum);
     }
 
     return xGraphic;
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 26b4d7f1e95b..9e9a0ff55024 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -2462,7 +2462,7 @@ void 
SdXMLGraphicObjectShapeContext::endFastElement(sal_Int32 nElement)
 {
     if (mxBase64Stream.is())
     {
-        uno::Reference<graphic::XGraphic> 
xGraphic(GetImport().loadGraphicFromBase64(mxBase64Stream));
+        uno::Reference<graphic::XGraphic> 
xGraphic(GetImport().loadGraphicFromBase64(mxBase64Stream, mnPage));
         if (xGraphic.is())
         {
             uno::Reference<beans::XPropertySet> xProperties(mxShape, 
uno::UNO_QUERY);

Reply via email to