[Libreoffice-commits] core.git: embeddedobj/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 10 20:02:39 UTC 2021


 embeddedobj/source/commonembedding/miscobj.cxx       |   46 +++++++++++++++++++
 embeddedobj/source/commonembedding/specialobject.cxx |   18 +++++++
 embeddedobj/source/general/dummyobject.cxx           |   16 ++++++
 embeddedobj/source/inc/commonembobj.hxx              |   12 ++++
 embeddedobj/source/inc/dummyobject.hxx               |    8 ++-
 embeddedobj/source/inc/oleembobj.hxx                 |    9 +++
 embeddedobj/source/inc/specialobject.hxx             |    5 ++
 embeddedobj/source/msole/olemisc.cxx                 |   16 ++++++
 8 files changed, 128 insertions(+), 2 deletions(-)

New commits:
commit 15a524a1ed2bf464b0b727e628bb5af9685f49b9
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Aug 10 16:37:15 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Aug 10 22:02:00 2021 +0200

    embeddedobj: implement XServiceInfo in the various embedded obj implementations
    
    This gives UNO clients a reliable way to detect e.g.
    OSpecialEmbeddedObject, where it's expected that double-clicking on the
    object doesn't do anything.
    
    Change-Id: I595453490b157b64214cd7359da1e3a3c959191d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120274
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index 8d2cb7332a40..9427e0639b92 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -38,6 +38,7 @@
 
 #include <vcl/svapp.hxx>
 #include <tools/diagnose_ex.h>
+#include <cppuhelper/supportsservice.hxx>
 
 #include "persistence.hxx"
 
@@ -400,6 +401,16 @@ uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType
         void* p = static_cast<embed::XEmbedPersist2*>(this);
         return uno::Any(&p, rType);
     }
+    else if (rType == cppu::UnoType<lang::XServiceInfo>::get())
+    {
+        void* p = static_cast<lang::XServiceInfo*>(this);
+        return uno::Any(&p, rType);
+    }
+    else if (rType == cppu::UnoType<lang::XTypeProvider>::get())
+    {
+        void* p = static_cast<lang::XTypeProvider*>(this);
+        return uno::Any(&p, rType);
+    }
     else
         aReturn = ::cppu::queryInterface(
                     rType,
@@ -643,4 +654,39 @@ void SAL_CALL OCommonEmbeddedObject::removeEventListener( const uno::Reference<
                                                 xListener );
 }
 
+OUString SAL_CALL OCommonEmbeddedObject::getImplementationName()
+{
+    return "com.sun.star.comp.embed.OCommonEmbeddedObject";
+}
+
+sal_Bool SAL_CALL OCommonEmbeddedObject::supportsService(const OUString& ServiceName)
+{
+    return cppu::supportsService(this, ServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL OCommonEmbeddedObject::getSupportedServiceNames()
+{
+    return { "com.sun.star.comp.embed.OCommonEmbeddedObject" };
+}
+
+uno::Sequence<uno::Type> SAL_CALL OCommonEmbeddedObject::getTypes()
+{
+    static const uno::Sequence<uno::Type> aTypes{
+        cppu::UnoType<embed::XEmbeddedObject>::get(),
+        cppu::UnoType<embed::XEmbedPersist2>::get(),
+        cppu::UnoType<embed::XLinkageSupport>::get(),
+        cppu::UnoType<embed::XInplaceObject>::get(),
+        cppu::UnoType<container::XChild>::get(),
+        cppu::UnoType<chart2::XDefaultSizeTransmitter>::get(),
+        cppu::UnoType<lang::XServiceInfo>::get(),
+        cppu::UnoType<lang::XTypeProvider>::get(),
+    };
+    return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL OCommonEmbeddedObject::getImplementationId()
+{
+    return uno::Sequence<sal_Int8>();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/commonembedding/specialobject.cxx b/embeddedobj/source/commonembedding/specialobject.cxx
index 683fe0aab3f2..809ffce1f2c4 100644
--- a/embeddedobj/source/commonembedding/specialobject.cxx
+++ b/embeddedobj/source/commonembedding/specialobject.cxx
@@ -28,6 +28,7 @@
 
 #include <cppuhelper/queryinterface.hxx>
 #include <osl/diagnose.h>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <specialobject.hxx>
 
@@ -51,6 +52,8 @@ uno::Any SAL_CALL OSpecialEmbeddedObject::queryInterface( const uno::Type& rType
                                         static_cast< embed::XClassifiedObject* >( this ),
                                         static_cast< embed::XComponentSupplier* >( this ),
                                         static_cast< util::XCloseable* >( this ),
+                                        static_cast< lang::XServiceInfo* >( this ),
+                                        static_cast< lang::XTypeProvider* >( this ),
                                         static_cast< document::XEventBroadcaster* >( this ) );
     if ( aReturn.hasValue() )
         return aReturn;
@@ -160,4 +163,19 @@ void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
         OCommonEmbeddedObject::doVerb( nVerbID );
 }
 
+OUString SAL_CALL OSpecialEmbeddedObject::getImplementationName()
+{
+    return "com.sun.star.comp.embed.OSpecialEmbeddedObject";
+}
+
+sal_Bool SAL_CALL OSpecialEmbeddedObject::supportsService(const OUString& ServiceName)
+{
+    return cppu::supportsService(this, ServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL OSpecialEmbeddedObject::getSupportedServiceNames()
+{
+    return { "com.sun.star.comp.embed.OSpecialEmbeddedObject" };
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/general/dummyobject.cxx b/embeddedobj/source/general/dummyobject.cxx
index 8bd43fc488ae..d37d74c524d3 100644
--- a/embeddedobj/source/general/dummyobject.cxx
+++ b/embeddedobj/source/general/dummyobject.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/lang/NoSupportException.hpp>
 
 #include <comphelper/multicontainer2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <dummyobject.hxx>
 
 
@@ -621,4 +622,19 @@ void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< d
                                                 xListener );
 }
 
+OUString SAL_CALL ODummyEmbeddedObject::getImplementationName()
+{
+    return "com.sun.star.comp.embed.ODummyEmbeddedObject";
+}
+
+sal_Bool SAL_CALL ODummyEmbeddedObject::supportsService(const OUString& ServiceName)
+{
+    return cppu::supportsService(this, ServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL ODummyEmbeddedObject::getSupportedServiceNames()
+{
+    return { "com.sun.star.comp.embed.ODummyEmbeddedObject" };
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 4b087ccc7601..fab8ccbc717e 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -33,6 +33,7 @@
 #include <com/sun/star/util/XCloseable.hpp>
 #include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp>
 #include <com/sun/star/io/XTempFile.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <cppuhelper/weak.hxx>
 #include <rtl/ref.hxx>
 #include <map>
@@ -79,6 +80,8 @@ class OCommonEmbeddedObject : public css::embed::XEmbeddedObject
                             , public css::embed::XInplaceObject
                             , public css::container::XChild
                             , public css::chart2::XDefaultSizeTransmitter
+                            , public css::lang::XServiceInfo
+                            , public css::lang::XTypeProvider
                             , public ::cppu::OWeakObject
 {
 protected:
@@ -399,6 +402,15 @@ public:
     // XDefaultSizeTransmitter
     //#i103460# charts do not necessarily have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method
     virtual void SAL_CALL setDefaultSize( const css::awt::Size& rSize_100TH_MM ) override;
+
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+    css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+    // XTypeProvider
+    css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
+    css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/inc/dummyobject.hxx b/embeddedobj/source/inc/dummyobject.hxx
index cc7355668dd6..64ee7deeb5e8 100644
--- a/embeddedobj/source/inc/dummyobject.hxx
+++ b/embeddedobj/source/inc/dummyobject.hxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <comphelper/multicontainer2.hxx>
 
@@ -49,7 +50,8 @@ namespace com::sun::star {
  */
 class ODummyEmbeddedObject : public ::cppu::WeakImplHelper
                         < css::embed::XEmbeddedObject
-                        , css::embed::XEmbedPersist >
+                        , css::embed::XEmbedPersist
+                        , css::lang::XServiceInfo >
 {
     ::osl::Mutex    m_aMutex;
     std::unique_ptr<comphelper::OMultiTypeInterfaceContainerHelper2>
@@ -194,6 +196,10 @@ public:
     virtual void SAL_CALL removeEventListener(
                 const css::uno::Reference< css::document::XEventListener >& Listener ) override;
 
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+    css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx
index d0884871deb4..e456f2fc31a4 100644
--- a/embeddedobj/source/inc/oleembobj.hxx
+++ b/embeddedobj/source/inc/oleembobj.hxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/util/XCloseListener.hpp>
 #include <com/sun/star/io/XActiveDataStreamer.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <rtl/ref.hxx>
@@ -114,7 +115,8 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper
                         , css::embed::XInplaceObject
                         , css::container::XChild
                         , css::io::XActiveDataStreamer
-                        , css::lang::XInitialization >
+                        , css::lang::XInitialization
+                        , css::lang::XServiceInfo >
 {
     friend class OleComponent;
 
@@ -444,6 +446,11 @@ public:
 
     // XInitialization
     void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override;
+
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+    css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/inc/specialobject.hxx b/embeddedobj/source/inc/specialobject.hxx
index 5c467b97a379..48d1d872a2a2 100644
--- a/embeddedobj/source/inc/specialobject.hxx
+++ b/embeddedobj/source/inc/specialobject.hxx
@@ -47,6 +47,11 @@ public:
     virtual void SAL_CALL changeState( sal_Int32 nNewState ) override;
 
     virtual void SAL_CALL doVerb( sal_Int32 nVerbID ) override;
+
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+    css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx
index a4045f34b4f2..e2be05d1e2b9 100644
--- a/embeddedobj/source/msole/olemisc.cxx
+++ b/embeddedobj/source/msole/olemisc.cxx
@@ -30,6 +30,7 @@
 
 #include <comphelper/multicontainer2.hxx>
 #include <comphelper/sequenceashashmap.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <oleembobj.hxx>
 #include "olepersist.hxx"
@@ -682,4 +683,19 @@ void OleEmbeddedObject::initialize(const uno::Sequence<uno::Any>& rArguments)
     }
 }
 
+OUString SAL_CALL OleEmbeddedObject::getImplementationName()
+{
+    return "com.sun.star.comp.embed.OleEmbeddedObject";
+}
+
+sal_Bool SAL_CALL OleEmbeddedObject::supportsService(const OUString& ServiceName)
+{
+    return cppu::supportsService(this, ServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL OleEmbeddedObject::getSupportedServiceNames()
+{
+    return { "com.sun.star.comp.embed.OleEmbeddedObject" };
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list