diff options
-rw-r--r-- | embeddedobj/source/commonembedding/specialobject.cxx | 9 | ||||
-rw-r--r-- | embeddedobj/source/inc/specialobject.hxx | 6 | ||||
-rw-r--r-- | sw/inc/ndole.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/ole/ndole.cxx | 89 |
4 files changed, 97 insertions, 11 deletions
diff --git a/embeddedobj/source/commonembedding/specialobject.cxx b/embeddedobj/source/commonembedding/specialobject.cxx index 809ffce1f2c4..3dc1eb7e47ef 100644 --- a/embeddedobj/source/commonembedding/specialobject.cxx +++ b/embeddedobj/source/commonembedding/specialobject.cxx @@ -48,6 +48,7 @@ uno::Any SAL_CALL OSpecialEmbeddedObject::queryInterface( const uno::Type& rType uno::Any aReturn = ::cppu::queryInterface( rType, static_cast< embed::XEmbeddedObject* >( this ), static_cast< embed::XInplaceObject* >( this ), + static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ), static_cast< embed::XVisualObject* >( this ), static_cast< embed::XClassifiedObject* >( this ), static_cast< embed::XComponentSupplier* >( this ), @@ -163,6 +164,14 @@ void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID ) OCommonEmbeddedObject::doVerb( nVerbID ); } +void SAL_CALL OSpecialEmbeddedObject::reload( + const uno::Sequence< beans::PropertyValue >&, + const uno::Sequence< beans::PropertyValue >&) +{ + // Allow IFrames to reload their content + SetInplaceActiveState(); +} + OUString SAL_CALL OSpecialEmbeddedObject::getImplementationName() { return "com.sun.star.comp.embed.OSpecialEmbeddedObject"; diff --git a/embeddedobj/source/inc/specialobject.hxx b/embeddedobj/source/inc/specialobject.hxx index 48d1d872a2a2..9ec0d7d86465 100644 --- a/embeddedobj/source/inc/specialobject.hxx +++ b/embeddedobj/source/inc/specialobject.hxx @@ -48,6 +48,12 @@ public: virtual void SAL_CALL doVerb( sal_Int32 nVerbID ) override; +// XCommonEmbedPersist + + virtual void SAL_CALL reload( + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; + // XServiceInfo OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx index acac9307e496..5caa29ab43bf 100644 --- a/sw/inc/ndole.hxx +++ b/sw/inc/ndole.hxx @@ -28,7 +28,7 @@ class SwGrfFormatColl; class SwDoc; class SwOLENode; class SwOLEListener_Impl; -class SwEmbedObjectLink; +namespace sfx2 { class SvBaseLink; } class DeflateData; class SW_DLLPUBLIC SwOLEObj @@ -94,7 +94,7 @@ class SW_DLLPUBLIC SwOLENode final: public SwNoTextNode bool mbOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify (e.g. copied). Is not persistent. */ - SwEmbedObjectLink* mpObjectLink; + sfx2::SvBaseLink* mpObjectLink; OUString maLinkURL; SwOLENode( SwNode& rWhere, diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 831dcaef6faf..de94986797f3 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -149,6 +149,8 @@ void SAL_CALL SwOLEListener_Impl::disposing( const lang::EventObject& ) // TODO/LATER: actually SwEmbedObjectLink should be used here, but because different objects are used to control // embedded object different link objects with the same functionality had to be implemented +namespace { + class SwEmbedObjectLink : public sfx2::SvBaseLink { SwOLENode* m_pOleNode; @@ -211,6 +213,44 @@ void SwEmbedObjectLink::Closed() SvBaseLink::Closed(); } +class SwIFrameLink : public sfx2::SvBaseLink +{ + SwOLENode* m_pOleNode; + +public: + explicit SwIFrameLink(SwOLENode* pNode) + : ::sfx2::SvBaseLink(::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB) + , m_pOleNode(pNode) + { + SetSynchron( false ); + } + + ::sfx2::SvBaseLink::UpdateResult DataChanged( + const OUString&, const uno::Any& ) + { + uno::Reference<embed::XEmbeddedObject> xObject = m_pOleNode->GetOLEObj().GetOleRef(); + uno::Reference<embed::XCommonEmbedPersist> xPersObj(xObject, uno::UNO_QUERY); + if (xPersObj.is()) + { + // let the IFrameObject reload the link + try + { + xPersObj->reload(uno::Sequence<beans::PropertyValue>(), uno::Sequence<beans::PropertyValue>()); + } + catch (const uno::Exception&) + { + } + + m_pOleNode->SetChanged(); + } + + return SUCCESS; + } + +}; + +} + SwOLENode::SwOLENode( SwNode& rWhere, const svt::EmbeddedObjectRef& xObj, SwGrfFormatColl *pGrfColl, @@ -609,18 +649,49 @@ void SwOLENode::CheckFileLink_Impl() try { - uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW ); - if ( xLinkSupport->isLink() ) + uno::Reference<embed::XEmbeddedObject> xObject = maOLEObj.m_xOLERef.GetObject(); + if (!xObject) + return; + + bool bIFrame = false; + + OUString aLinkURL; + uno::Reference<embed::XLinkageSupport> xLinkSupport(xObject, uno::UNO_QUERY); + if (xLinkSupport) + { + if (xLinkSupport->isLink()) + aLinkURL = xLinkSupport->getLinkURL(); + } + else + { + // get IFrame (Floating Frames) listed and updatable from the + // manage links dialog + SvGlobalName aClassId(xObject->getClassID()); + if (aClassId == SvGlobalName(SO3_IFRAME_CLASSID)) + { + uno::Reference<beans::XPropertySet> xSet(xObject->getComponent(), uno::UNO_QUERY); + if (xSet.is()) + xSet->getPropertyValue("FrameURL") >>= aLinkURL; + bIFrame = true; + } + } + + if (!aLinkURL.isEmpty()) // this is a file link so the model link manager should handle it { - const OUString aLinkURL = xLinkSupport->getLinkURL(); - if ( !aLinkURL.isEmpty() ) + SwEmbedObjectLink* pEmbedObjectLink = nullptr; + if (!bIFrame) + { + pEmbedObjectLink = new SwEmbedObjectLink(this); + mpObjectLink = pEmbedObjectLink; + } + else { - // this is a file link so the model link manager should handle it - mpObjectLink = new SwEmbedObjectLink( this ); - maLinkURL = aLinkURL; - GetDoc().getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); - mpObjectLink->Connect(); + mpObjectLink = new SwIFrameLink(this); } + maLinkURL = aLinkURL; + GetDoc().getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); + if (pEmbedObjectLink) + pEmbedObjectLink->Connect(); } } catch( uno::Exception& ) |