summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-16 14:16:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-16 19:35:43 +0200
commit23f60bbf283414bae6f649992c18253c9d0ac2ab (patch)
tree998dfefdbda6158627930b579790d0107400b813 /embeddedobj
parent0b42faf3d09cb4e63feebcd056c7c014c657d404 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/commonembedding/embedobj.cxx31
1 files changed, 25 insertions, 6 deletions
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() )