diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-04-13 11:31:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-04-13 16:44:49 +0200 |
commit | 183e34a3f8c429c0698951e24c17844e416a3825 (patch) | |
tree | 2ffb0deae0c81845c1acc4b0ce1aa309a6a88b51 /embeddedobj | |
parent | f24b1ebec698fd1f956530d48a50985a99659172 (diff) |
extract a OCommonEmbeddedObject::SetInplaceActiveState for reuse
no behaviour change intended
Change-Id: Ia1d12aa5c9afdc1347f6d4364bc6a0b7f41ee168
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150341
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/commonembedding/embedobj.cxx | 60 | ||||
-rw-r--r-- | embeddedobj/source/inc/commonembobj.hxx | 3 |
2 files changed, 35 insertions, 28 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 0b1cb5785dac..ef627941921e 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -216,6 +216,37 @@ void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sa rGuard.reset(); } +void OCommonEmbeddedObject::SetInplaceActiveState() +{ + if ( !m_xClientSite.is() ) + throw embed::WrongStateException( "client site not set, yet", *this ); + + uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); + if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() ) + throw embed::WrongStateException(); //TODO: can't activate inplace + xInplaceClient->activatingInplace(); + + uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW ); + + m_xClientWindow = xClientWindowSupplier->getWindow(); + m_aOwnRectangle = xInplaceClient->getPlacement(); + m_aClipRectangle = xInplaceClient->getClipRectangle(); + awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle ); + + // create own window based on the client window + // place and resize the window according to the rectangles + uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW ); + + // dispatch provider may not be provided + uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); + bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP ); + m_nObjectState = embed::EmbedStates::INPLACE_ACTIVE; + if ( !bOk ) + { + SwitchStateTo_Impl( embed::EmbedStates::RUNNING ); + throw embed::WrongStateException(); //TODO: can't activate inplace + } +} void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) { @@ -289,34 +320,7 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) { if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) { - if ( !m_xClientSite.is() ) - throw embed::WrongStateException( "client site not set, yet", *this ); - - uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); - if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() ) - throw embed::WrongStateException(); //TODO: can't activate inplace - xInplaceClient->activatingInplace(); - - uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW ); - - m_xClientWindow = xClientWindowSupplier->getWindow(); - m_aOwnRectangle = xInplaceClient->getPlacement(); - m_aClipRectangle = xInplaceClient->getClipRectangle(); - awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle ); - - // create own window based on the client window - // place and resize the window according to the rectangles - uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW ); - - // dispatch provider may not be provided - uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); - bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP ); - m_nObjectState = nNextState; - if ( !bOk ) - { - SwitchStateTo_Impl( embed::EmbedStates::RUNNING ); - throw embed::WrongStateException(); //TODO: can't activate inplace - } + SetInplaceActiveState(); } else if ( nNextState == embed::EmbedStates::ACTIVE ) { diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx index 64ce9ae0f9f5..bbd2de63ec70 100644 --- a/embeddedobj/source/inc/commonembobj.hxx +++ b/embeddedobj/source/inc/commonembobj.hxx @@ -254,6 +254,9 @@ private: int ShowMsgDialog(TranslateId Msg, const OUString& sFileName); +protected: + void SetInplaceActiveState(); + public: OCommonEmbeddedObject( css::uno::Reference< css::uno::XComponentContext > xContext, |