include/xmloff/xmlgrhlp.hxx                             |   13 +++-----
 offapi/com/sun/star/document/XGraphicStorageHandler.idl |    8 -----
 xmloff/source/core/xmlexp.cxx                           |    6 +--
 xmloff/source/core/xmlgrhlp.cxx                         |   25 ++--------------
 xmloff/source/core/xmlimp.cxx                           |   16 ++++++----
 5 files changed, 22 insertions(+), 46 deletions(-)

New commits:
commit 6db1f0cfc3595ab675179c88b90147ddc13bc07c
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Oct 30 14:01:31 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Oct 31 10:04:51 2025 +0100

    [API CHANGE] remove loadGraphicAtPage and loadGraphicFromOutputStreamAtPage
    
    Change-Id: If53896987ea29ad09c82bdedd3a3028bffdff031
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193211
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/xmloff/xmlgrhlp.hxx b/include/xmloff/xmlgrhlp.hxx
index c4fe893baef5..4c2e9f21f799 100644
--- a/include/xmloff/xmlgrhlp.hxx
+++ b/include/xmloff/xmlgrhlp.hxx
@@ -106,16 +106,9 @@ public:
     virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
         loadGraphic(OUString const & aURL) override;
 
-    // XGraphicStorageHandler
-    virtual css::uno::Reference<css::graphic::XGraphic>
-        SAL_CALL loadGraphicAtPage(OUString const& aURL, sal_Int32 nPage) 
override;
-
     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;
 
@@ -129,6 +122,12 @@ public:
     virtual css::uno::Reference< css::io::XInputStream > SAL_CALL 
getInputStream( const OUString& rURL ) override;
     virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL 
createOutputStream(  ) override;
     virtual OUString SAL_CALL resolveOutputStream( const css::uno::Reference< 
css::io::XOutputStream >& rxBinaryStream ) override;
+
+    css::uno::Reference<css::graphic::XGraphic>
+        loadGraphicAtPage(OUString const& aURL, sal_Int32 nPage);
+
+    css::uno::Reference<css::graphic::XGraphic>
+        
loadGraphicFromOutputStreamAtPage(css::uno::Reference<css::io::XOutputStream> 
const & rxOutputStream, sal_Int32 nPage);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/document/XGraphicStorageHandler.idl 
b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
index c440e1e9351b..b36379890243 100644
--- a/offapi/com/sun/star/document/XGraphicStorageHandler.idl
+++ b/offapi/com/sun/star/document/XGraphicStorageHandler.idl
@@ -21,18 +21,10 @@ interface XGraphicStorageHandler : 
com::sun::star::uno::XInterface
     */
     com::sun::star::graphic::XGraphic loadGraphic([in] string aURL);
 
-    /** 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);
-
     /** load a graphic from the output stream
     */
     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/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index ed48ebd132d4..ed5a39326cbb 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -52,6 +52,7 @@
 #include <xmloff/xmlnamespace.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlexp.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <xmloff/xmlnumfe.hxx>
 #include <xmloff/xmlmetae.hxx>
 #include <xmloff/XMLSettingsExportContext.hxx>
@@ -1270,10 +1271,7 @@ ErrCode SvXMLExport::exportDoc( enum 
::xmloff::token::XMLTokenEnum eClass )
             {
                 if (!mxGraphicStorageHandler.is())
                 {
-                    mxGraphicStorageHandler.set(
-                        
getComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext(
-                        u"com.sun.star.comp.Svx.GraphicExportHelper"_ustr, 
uno::Sequence<uno::Any>(), getComponentContext()),
-                        uno::UNO_QUERY );
+                    mxGraphicStorageHandler = 
SvXMLGraphicHelper::Create(nullptr, SvXMLGraphicHelperMode::Write);
                     bOwnGraphicResolver = mxGraphicStorageHandler.is();
                 }
 
diff --git a/xmloff/source/core/xmlgrhlp.cxx b/xmloff/source/core/xmlgrhlp.cxx
index 312c6795e3bb..0b8834b5b0c4 100644
--- a/xmloff/source/core/xmlgrhlp.cxx
+++ b/xmloff/source/core/xmlgrhlp.cxx
@@ -614,9 +614,8 @@ uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphic(OUStr
     return loadGraphicAtPage(rURL, -1);
 }
 
-// XGraphicStorageHandler
 uno::Reference<graphic::XGraphic>
-    SAL_CALL SvXMLGraphicHelper::loadGraphicAtPage(OUString const& rURL, 
sal_Int32 nPage)
+    SvXMLGraphicHelper::loadGraphicAtPage(OUString const& rURL, sal_Int32 
nPage)
 {
     std::unique_lock aGuard(m_aMutex);
 
@@ -662,7 +661,7 @@ uno::Reference<graphic::XGraphic>
     return xGraphic;
 }
 
-uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOutputStreamAtPage(uno::Reference<io::XOutputStream>
 const & rxOutputStream, sal_Int32 nPageNum)
+uno::Reference<graphic::XGraphic> 
SvXMLGraphicHelper::loadGraphicFromOutputStreamAtPage(uno::Reference<io::XOutputStream>
 const & rxOutputStream, sal_Int32 nPageNum)
 {
     std::unique_lock aGuard(m_aMutex);
 
@@ -679,7 +678,8 @@ uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOu
     return xGraphic;
 }
 
-uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream>
 const & rxOutputStream)
+// XGraphicStorageHandler
+uno::Reference<graphic::XGraphic> 
SvXMLGraphicHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream>
 const & rxOutputStream)
 {
     return loadGraphicFromOutputStreamAtPage(rxOutputStream, -1);
 }
@@ -1040,15 +1040,9 @@ protected:
         loadGraphic(const OUString& aURL) override;
 
     // ____ XGraphicStorageHandler ____
-    virtual css::uno::Reference<css::graphic::XGraphic>
-        SAL_CALL loadGraphicAtPage(const OUString& aURL, sal_Int32 nPage) 
override;
-
     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;
 
@@ -1110,22 +1104,11 @@ uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicImportExportHelper::loadG
 }
 
 // ____ XGraphicStorageHandler ____
-uno::Reference<graphic::XGraphic> SAL_CALL
-SvXMLGraphicImportExportHelper::loadGraphicAtPage(OUString const& rURL, 
sal_Int32 nPage)
-{
-    return m_xXMLGraphicHelper->loadGraphicAtPage(rURL, nPage);
-}
-
 uno::Reference<graphic::XGraphic> SAL_CALL 
SvXMLGraphicImportExportHelper::loadGraphicFromOutputStream(uno::Reference<io::XOutputStream>
 const & rxOutputStream)
 {
     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/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index d783b0fc6601..497e92890bc7 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -31,6 +31,7 @@
 #include <vcl/graph.hxx>
 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
 #include <xmloff/namespacemap.hxx>
+#include <xmloff/xmlgrhlp.hxx>
 #include <xmloff/xmluconv.hxx>
 #include <xmloff/xmlnamespace.hxx>
 #include <xmloff/xmltoken.hxx>
@@ -608,10 +609,7 @@ void SAL_CALL SvXMLImport::startDocument()
         if (!mxGraphicStorageHandler.is())
         {
             // #99870# Import... instead of Export...
-            mxGraphicStorageHandler.set(
-                
GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext(
-                u"com.sun.star.comp.Svx.GraphicImportHelper"_ustr, 
uno::Sequence<uno::Any>(), GetComponentContext()),
-                uno::UNO_QUERY );
+            mxGraphicStorageHandler = SvXMLGraphicHelper::Create(nullptr, 
SvXMLGraphicHelperMode::Read);
             mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is();
         }
 
@@ -1331,7 +1329,10 @@ uno::Reference<graphic::XGraphic> 
SvXMLImport::loadGraphicByURL(OUString const&
         {
             if (IsPackageURL(rURL))
             {
-                xGraphic = mxGraphicStorageHandler->loadGraphicAtPage(rURL, 
nPageNum);
+                if (SvXMLGraphicHelper* pGraphicStorageHandler = 
dynamic_cast<SvXMLGraphicHelper*>(mxGraphicStorageHandler.get()))
+                    xGraphic = pGraphicStorageHandler->loadGraphicAtPage(rURL, 
nPageNum);
+                else
+                    xGraphic = mxGraphicStorageHandler->loadGraphic(rURL);
             }
             else
             {
@@ -1369,7 +1370,10 @@ uno::Reference<graphic::XGraphic> 
SvXMLImport::loadGraphicFromBase64(uno::Refere
 
     if (mxGraphicStorageHandler.is())
     {
-        xGraphic = 
mxGraphicStorageHandler->loadGraphicFromOutputStreamAtPage(rxOutputStream, 
nPageNum);
+        if (SvXMLGraphicHelper* pGraphicStorageHandler= 
dynamic_cast<SvXMLGraphicHelper*>(mxGraphicStorageHandler.get()))
+            xGraphic = 
pGraphicStorageHandler->loadGraphicFromOutputStreamAtPage(rxOutputStream, 
nPageNum);
+        else
+            xGraphic = 
mxGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
     }
 
     return xGraphic;

Reply via email to