comphelper/source/container/embeddedobjectcontainer.cxx |   24 +++-
 include/comphelper/embeddedobjectcontainer.hxx          |   81 ++++++++++------
 2 files changed, 69 insertions(+), 36 deletions(-)

New commits:
commit 02db8e7392fd3c6da8d7a6684ba5291482afd84e
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 12 10:24:49 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Sep 12 20:58:10 2025 +0200

    pretty up EmbeddedObjectContainer a little
    
    Change-Id: I69f29310da41ccc7ae619529fd503bd5ce55d6bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190886
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx 
b/comphelper/source/container/embeddedobjectcontainer.cxx
index b21da5a3924a..9928e176bfca 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -360,7 +360,8 @@ uno::Reference<embed::XEmbeddedObject> 
EmbeddedObjectContainer::Get_Impl(
     return xObj;
 }
 
-uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::CreateEmbeddedObject( const uno::Sequence < sal_Int8 
>& rClassId,
+uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::CreateEmbeddedObject(
+            const uno::Sequence < sal_Int8 >& rClassId,
             const uno::Sequence < beans::PropertyValue >& rArgs, OUString& 
rNewName, OUString const* pBaseURL )
 {
     if ( rNewName.isEmpty() )
@@ -407,7 +408,8 @@ uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::CreateEmbedde
     return CreateEmbeddedObject( rClassId, uno::Sequence < 
beans::PropertyValue >(), rNewName, pBaseURL );
 }
 
-void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >& xObj, const OUString& rName )
+void EmbeddedObjectContainer::AddEmbeddedObject(
+            const css::uno::Reference < css::embed::XEmbeddedObject >& xObj, 
const OUString& rName )
 {
 #if OSL_DEBUG_LEVEL > 1
     SAL_WARN_IF( rName.isEmpty(), "comphelper.container", "Added object 
doesn't have a name!");
@@ -513,7 +515,9 @@ bool EmbeddedObjectContainer::StoreEmbeddedObject(
 
     return true;
 }
-bool EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < 
embed::XEmbeddedObject >& xObj, OUString& rName,
+bool EmbeddedObjectContainer::InsertEmbeddedObject(
+        const uno::Reference < embed::XEmbeddedObject >& xObj,
+        OUString& rName,
         OUString const* pTargetShellID )
 {
     // store it into the container storage
@@ -530,7 +534,8 @@ bool EmbeddedObjectContainer::InsertEmbeddedObject( const 
uno::Reference < embed
         return false;
 }
 
-uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < 
io::XInputStream >& xStm, OUString& rNewName )
+uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedObject(
+            const uno::Reference < io::XInputStream >& xStm, OUString& 
rNewName )
 {
     if ( rNewName.isEmpty() )
         rNewName = CreateUniqueObjectName();
@@ -590,7 +595,9 @@ uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbedde
     return xRet;
 }
 
-uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedObject( const css::uno::Sequence < 
css::beans::PropertyValue >& aMedium, OUString& rNewName, OUString const* 
pBaseURL )
+uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedObject(
+        const css::uno::Sequence < css::beans::PropertyValue >& aMedium,
+        OUString& rNewName, OUString const* pBaseURL )
 {
     if ( rNewName.isEmpty() )
         rNewName = CreateUniqueObjectName();
@@ -628,7 +635,9 @@ uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbedde
     return xObj;
 }
 
-uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedLink( const css::uno::Sequence < 
css::beans::PropertyValue >& aMedium, OUString& rNewName )
+uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::InsertEmbeddedLink(
+        const css::uno::Sequence < css::beans::PropertyValue >& aMedium,
+        OUString& rNewName )
 {
     if ( rNewName.isEmpty() )
         rNewName = CreateUniqueObjectName();
@@ -890,7 +899,8 @@ bool EmbeddedObjectContainer::MoveEmbeddedObject( const 
OUString& rName, Embedde
 }
 
 // #i119941, bKeepToTempStorage: use to specify whether store the removed 
object to temporary storage+
-bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < 
embed::XEmbeddedObject >& xObj, bool bKeepToTempStorage )
+bool EmbeddedObjectContainer::RemoveEmbeddedObject(
+        const uno::Reference < embed::XEmbeddedObject >& xObj, bool 
bKeepToTempStorage )
 {
     uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
     OUString aName;
diff --git a/include/comphelper/embeddedobjectcontainer.hxx 
b/include/comphelper/embeddedobjectcontainer.hxx
index a847f1e1b55d..ed3d0e1f9109 100644
--- a/include/comphelper/embeddedobjectcontainer.hxx
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -36,6 +36,7 @@ namespace com::sun::star::uno { class XInterface; }
 namespace comphelper
 {
     class EmbeddedObjectContainer;
+
     /** Helper interface to give access to some common object which replace 
the SfxObjectShell
     */
     class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
@@ -63,11 +64,14 @@ class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
 public:
     // add an embedded object to the container storage
     bool StoreEmbeddedObject(
-        const css::uno::Reference<css::embed::XEmbeddedObject>& xObj, 
OUString& rName, bool bCopy,
-        const OUString& rSrcShellID, const OUString& rDestShellID );
+        const css::uno::Reference<css::embed::XEmbeddedObject>& xObj,
+        OUString& rName,
+        bool bCopy,
+        const OUString& rSrcShellID,
+        const OUString& rDestShellID );
 
     // add an embedded object that has been imported from the container 
storage - should only be called by filters!
-    void                AddEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >&, const OUString& );
+    void                AddEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >&, const OUString& rName );
 
                         EmbeddedObjectContainer();
                         EmbeddedObjectContainer( const css::uno::Reference < 
css::embed::XStorage >& );
@@ -79,7 +83,7 @@ public:
     bool                CommitImageSubStorage();
     void                ReleaseImageSubStorage();
 
-    OUString     CreateUniqueObjectName();
+    OUString        CreateUniqueObjectName();
 
     // get a list of object names that have been added so far
     css::uno::Sequence < OUString > GetObjectNames() const;
@@ -90,42 +94,50 @@ public:
     // check existence of an object - either by identity or by name
     bool            HasEmbeddedObject( const OUString& );
     bool            HasEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >& ) const;
-    bool            HasInstantiatedEmbeddedObject( const OUString& );
+    bool            HasInstantiatedEmbeddedObject( const OUString& rName );
 
     // get the object name of an object - this is the persist name if the 
object has persistence
     OUString        GetEmbeddedObjectName( const css::uno::Reference < 
css::embed::XEmbeddedObject >& ) const;
 
     // retrieve an embedded object by name that either has been added already 
or is available in the container storage
-    css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const 
OUString&, OUString const* pBaseURL = nullptr);
+    css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const 
OUString& rName, OUString const* pBaseURL = nullptr);
 
     // create an object from a ClassId
-    css::uno::Reference < css::embed::XEmbeddedObject >
-                        CreateEmbeddedObject( const css::uno::Sequence < 
sal_Int8 >&, OUString&,
-                                              OUString const* pBaseURL = 
nullptr );
+    css::uno::Reference < css::embed::XEmbeddedObject > CreateEmbeddedObject(
+                        const css::uno::Sequence < sal_Int8 >& rClassId,
+                        OUString& rNewName,
+                        OUString const* pBaseURL = nullptr );
 
-    css::uno::Reference < css::embed::XEmbeddedObject >
-                        CreateEmbeddedObject( const css::uno::Sequence < 
sal_Int8 >&,
-                        const css::uno::Sequence < css::beans::PropertyValue 
>&, OUString&,
+    css::uno::Reference < css::embed::XEmbeddedObject > CreateEmbeddedObject(
+                        const css::uno::Sequence < sal_Int8 >& rClassId,
+                        const css::uno::Sequence < css::beans::PropertyValue 
>& rArgs,
+                        OUString& rNewName,
                         OUString const* pBaseURL = nullptr );
 
     // insert an embedded object into the container - objects persistent 
representation will be added to the storage
-    bool            InsertEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >&, OUString&,
-        OUString const* pTargetShellID = nullptr);
+    bool            InsertEmbeddedObject(
+                        const css::uno::Reference < 
css::embed::XEmbeddedObject >& xObj,
+                        OUString& rName,
+                        OUString const* pTargetShellID = nullptr);
 
     // load an embedded object from a MediaDescriptor and insert it into the 
container
     // a new object will be created from the new content and returned
-    css::uno::Reference < css::embed::XEmbeddedObject >
-                        InsertEmbeddedObject( const css::uno::Sequence < 
css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = 
nullptr);
+    css::uno::Reference < css::embed::XEmbeddedObject > InsertEmbeddedObject(
+                        const css::uno::Sequence < css::beans::PropertyValue 
>& aMedium,
+                        OUString& rName,
+                        OUString const* pBaseURL = nullptr);
 
     // create an embedded link based on a MediaDescriptor and insert it into 
the container
     // a new object will be created from the new content and returned
-    css::uno::Reference < css::embed::XEmbeddedObject >
-                        InsertEmbeddedLink( const css::uno::Sequence < 
css::beans::PropertyValue >&, OUString& );
+    css::uno::Reference < css::embed::XEmbeddedObject > InsertEmbeddedLink(
+                        const css::uno::Sequence < css::beans::PropertyValue 
>& aMedium,
+                        OUString& rNewName);
 
     // create an object from a stream that contains its persistent 
representation and insert it as usual (usually called from clipboard)
     // a new object will be created from the new content and returned
-    css::uno::Reference < css::embed::XEmbeddedObject >
-                        InsertEmbeddedObject( const css::uno::Reference < 
css::io::XInputStream >&, OUString& );
+    css::uno::Reference < css::embed::XEmbeddedObject > InsertEmbeddedObject(
+                        const css::uno::Reference < css::io::XInputStream >& 
xStm,
+                        OUString& rNewName);
 
     // copy an embedded object into the storage, open the new copy and return 
it
     css::uno::Reference <css::embed::XEmbeddedObject> CopyAndGetEmbeddedObject(
@@ -135,25 +147,34 @@ public:
     // remove an embedded object from the container and from the storage; if 
object can't be closed
     // #i119941, bKeepToTempStorage: use to specify whether store the removed 
object to temporary storage+
     void            RemoveEmbeddedObject( const OUString& rName, bool 
bKeepToTempStorage = true);
-    bool            RemoveEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true);
+    bool            RemoveEmbeddedObject(
+                        const css::uno::Reference < 
css::embed::XEmbeddedObject >& xObj,
+                        bool bKeepToTempStorage = true);
 
     // close and remove an embedded object from the container without removing 
it from the storage
-    void            CloseEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >& );
+    void            CloseEmbeddedObject( const css::uno::Reference < 
css::embed::XEmbeddedObject >& xObj );
 
     // move an embedded object to another container (keep the persistent name)
     bool            MoveEmbeddedObject( const OUString& rName, 
EmbeddedObjectContainer& );
 
     // get the stored graphical representation for the object
-    css::uno::Reference < css::io::XInputStream > GetGraphicStream( const 
css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* 
pMediaType=nullptr );
+    css::uno::Reference < css::io::XInputStream > GetGraphicStream(
+                    const css::uno::Reference < css::embed::XEmbeddedObject >&,
+                    OUString* pMediaType=nullptr );
 
     // get the stored graphical representation by the object name
     css::uno::Reference < css::io::XInputStream > GetGraphicStream( const 
OUString& aName, OUString* pMediaType=nullptr );
 
     // add a graphical representation for an object
-    bool            InsertGraphicStream( const css::uno::Reference < 
css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& 
rMediaType );
+    bool            InsertGraphicStream(
+                    const css::uno::Reference < css::io::XInputStream >& 
rStream,
+                    const OUString& rObjectName, const OUString& rMediaType );
 
     // try to add a graphical representation for an object in optimized way ( 
might fail )
-    bool            InsertGraphicStreamDirectly( const css::uno::Reference < 
css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& 
rMediaType );
+    bool            InsertGraphicStreamDirectly(
+                    const css::uno::Reference < css::io::XInputStream >& 
rStream,
+                    const OUString& rObjectName,
+                    const OUString& rMediaType );
 
     // remove a graphical representation for an object
     void            RemoveGraphicStream( const OUString& rObjectName );
@@ -177,11 +198,13 @@ public:
 
     /** call setPersistentEntry for each embedded object in the container
     *
-    * \param _xStorage The storage where to store the objects.
-    * \param _bClearModifiedFlag If <TRUE/> then the modified flag will be set 
to <FALSE/> otherwise nothing happen.
-    *  eturn <FALSE/> if no error occurred, otherwise <TRUE/>.
+    * @param _xStorage The storage where to store the objects.
+    * @param _bClearModifiedFlag If <TRUE/> then the modified flag will be set 
to <FALSE/> otherwise nothing happen.
+    * @return <FALSE/> if no error occurred, otherwise <TRUE/>.
     */
-    bool             SetPersistentEntries(const css::uno::Reference< 
css::embed::XStorage >& _xStorage,bool _bClearModifiedFlag = true);
+    bool             SetPersistentEntries(
+                        const css::uno::Reference< css::embed::XStorage >& 
_xStorage,
+                        bool _bClearModifiedFlag = true);
 
     // if DisableActiveContent configuration option is set, this always 
returns false
     bool getUserAllowsLinkUpdate() const;

Reply via email to