tdf#126877 crash on inserting floating frame

regression from
    commit 5043421fdc
    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>
This commit is contained in:
Noel Grandin
2019-08-16 14:16:36 +02:00
parent 0b42faf3d0
commit 23f60bbf28

View File

@@ -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() )