embeddedobj/source/commonembedding/embedobj.cxx | 31 +++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-)
New commits: commit 23f60bbf283414bae6f649992c18253c9d0ac2ab Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Aug 16 14:16:36 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 16 19:35:43 2019 +0200 tdf#126877 crash on inserting floating frame regression from commit 5043421fdc527d18d18121ec5fe2d4e009c8191a Date: Fri Jul 19 14:05:10 2019 +0200 loplugin:referencecasting in embeddedobj OSpecialEmbeddedObject is playing games and effectively "unimplementing" an interface it's superclass implements by doing custom stuff in OSpecialEmbeddedObject::queryInterface. So lets rather implement this in a more direct and obvious way. Change-Id: I341b8e0b6acafac80cbd55f745811b73d2593585 Reviewed-on: https://gerrit.libreoffice.org/77580 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index a34020d354e1..3370c273dc6a 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -50,6 +50,7 @@ #include <commonembobj.hxx> #include <intercept.hxx> #include "embedobj.hxx" +#include <specialobject.hxx> using namespace ::com::sun::star; @@ -174,13 +175,31 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) } else { - // in case embedded object is in loaded state the contents must - // be stored in the related storage and the storage - // must be created already - if ( !m_xObjectStorage.is() ) - throw io::IOException(); //TODO: access denied + if ( !dynamic_cast<OSpecialEmbeddedObject*>(this) ) + { + // in case embedded object is in loaded state the contents must + // be stored in the related storage and the storage + // must be created already + if ( !m_xObjectStorage.is() ) + throw io::IOException(); //TODO: access denied - m_xDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly ); + m_xDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly ); + } + else + { + // objects without persistence will be initialized internally + uno::Sequence < uno::Any > aArgs(1); + aArgs[0] <<= uno::Reference < embed::XEmbeddedObject >( this ); + uno::Reference< util::XCloseable > xDocument( + m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( GetDocumentServiceName(), aArgs, m_xContext), + uno::UNO_QUERY ); + + uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); + if ( xChild.is() ) + xChild->setParent( m_xParent ); + + m_xDocHolder->SetComponent( xDocument, m_bReadOnly ); + } } if ( !m_xDocHolder->GetComponent().is() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits