1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <commonembobj.hxx> 32*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedVerbs.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/embed/EmbedUpdateModes.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/embed/XInplaceClient.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 42*cdf0e10cSrcweir #include <comphelper/mimeconfighelper.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "closepreventer.hxx" 45*cdf0e10cSrcweir #include "intercept.hxx" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::com::sun::star; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > GetValuableArgs_Impl( const uno::Sequence< beans::PropertyValue >& aMedDescr, 51*cdf0e10cSrcweir sal_Bool bCanUseDocumentBaseURL ); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir //------------------------------------------------------ 54*cdf0e10cSrcweir OCommonEmbeddedObject::OCommonEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, 55*cdf0e10cSrcweir const uno::Sequence< beans::NamedValue >& aObjProps ) 56*cdf0e10cSrcweir : m_pDocHolder( NULL ) 57*cdf0e10cSrcweir , m_pInterfaceContainer( NULL ) 58*cdf0e10cSrcweir , m_bReadOnly( sal_False ) 59*cdf0e10cSrcweir , m_bDisposed( sal_False ) 60*cdf0e10cSrcweir , m_bClosed( sal_False ) 61*cdf0e10cSrcweir , m_nObjectState( -1 ) 62*cdf0e10cSrcweir , m_nTargetState( -1 ) 63*cdf0e10cSrcweir , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE ) 64*cdf0e10cSrcweir , m_xFactory( xFactory ) 65*cdf0e10cSrcweir , m_nMiscStatus( 0 ) 66*cdf0e10cSrcweir , m_bEmbeddedScriptSupport( sal_True ) 67*cdf0e10cSrcweir , m_bDocumentRecoverySupport( sal_True ) 68*cdf0e10cSrcweir , m_bWaitSaveCompleted( sal_False ) 69*cdf0e10cSrcweir , m_bIsLink( sal_False ) 70*cdf0e10cSrcweir , m_bLinkHasPassword( sal_False ) 71*cdf0e10cSrcweir , m_bHasClonedSize( sal_False ) 72*cdf0e10cSrcweir , m_nClonedMapUnit( 0 ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir CommonInit_Impl( aObjProps ); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //------------------------------------------------------ 78*cdf0e10cSrcweir OCommonEmbeddedObject::OCommonEmbeddedObject( 79*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xFactory, 80*cdf0e10cSrcweir const uno::Sequence< beans::NamedValue >& aObjProps, 81*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& aMediaDescr, 82*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& aObjectDescr ) 83*cdf0e10cSrcweir : m_pDocHolder( NULL ) 84*cdf0e10cSrcweir , m_pInterfaceContainer( NULL ) 85*cdf0e10cSrcweir , m_bReadOnly( sal_False ) 86*cdf0e10cSrcweir , m_bDisposed( sal_False ) 87*cdf0e10cSrcweir , m_bClosed( sal_False ) 88*cdf0e10cSrcweir , m_nObjectState( embed::EmbedStates::LOADED ) 89*cdf0e10cSrcweir , m_nTargetState( -1 ) 90*cdf0e10cSrcweir , m_nUpdateMode ( embed::EmbedUpdateModes::ALWAYS_UPDATE ) 91*cdf0e10cSrcweir , m_xFactory( xFactory ) 92*cdf0e10cSrcweir , m_nMiscStatus( 0 ) 93*cdf0e10cSrcweir , m_bEmbeddedScriptSupport( sal_True ) 94*cdf0e10cSrcweir , m_bDocumentRecoverySupport( sal_True ) 95*cdf0e10cSrcweir , m_bWaitSaveCompleted( sal_False ) 96*cdf0e10cSrcweir , m_bIsLink( sal_True ) 97*cdf0e10cSrcweir , m_bLinkHasPassword( sal_False ) 98*cdf0e10cSrcweir , m_bHasClonedSize( sal_False ) 99*cdf0e10cSrcweir , m_nClonedMapUnit( 0 ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir // linked object has no own persistence so it is in loaded state starting from creation 102*cdf0e10cSrcweir LinkInit_Impl( aObjProps, aMediaDescr, aObjectDescr ); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir //------------------------------------------------------ 106*cdf0e10cSrcweir void OCommonEmbeddedObject::CommonInit_Impl( const uno::Sequence< beans::NamedValue >& aObjectProps ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir OSL_ENSURE( m_xFactory.is(), "No ServiceFactory is provided!\n" ); 109*cdf0e10cSrcweir if ( !m_xFactory.is() ) 110*cdf0e10cSrcweir throw uno::RuntimeException(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir m_pDocHolder = new DocumentHolder( m_xFactory, this ); 113*cdf0e10cSrcweir m_pDocHolder->acquire(); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // parse configuration entries 116*cdf0e10cSrcweir // TODO/LATER: in future UI names can be also provided here 117*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aObjectProps.getLength(); nInd++ ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir if ( aObjectProps[nInd].Name.equalsAscii( "ClassID" ) ) 120*cdf0e10cSrcweir aObjectProps[nInd].Value >>= m_aClassID; 121*cdf0e10cSrcweir else if ( aObjectProps[nInd].Name.equalsAscii( "ObjectDocumentServiceName" ) ) 122*cdf0e10cSrcweir aObjectProps[nInd].Value >>= m_aDocServiceName; 123*cdf0e10cSrcweir else if ( aObjectProps[nInd].Name.equalsAscii( "ObjectDocumentFilterName" ) ) 124*cdf0e10cSrcweir aObjectProps[nInd].Value >>= m_aPresetFilterName; 125*cdf0e10cSrcweir else if ( aObjectProps[nInd].Name.equalsAscii( "ObjectMiscStatus" ) ) 126*cdf0e10cSrcweir aObjectProps[nInd].Value >>= m_nMiscStatus; 127*cdf0e10cSrcweir else if ( aObjectProps[nInd].Name.equalsAscii( "ObjectVerbs" ) ) 128*cdf0e10cSrcweir aObjectProps[nInd].Value >>= m_aObjectVerbs; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if ( m_aClassID.getLength() != 16 /*|| !m_aDocServiceName.getLength()*/ ) 132*cdf0e10cSrcweir throw uno::RuntimeException(); // something goes really wrong 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // accepted states 135*cdf0e10cSrcweir m_aAcceptedStates.realloc( NUM_SUPPORTED_STATES ); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir m_aAcceptedStates[0] = embed::EmbedStates::LOADED; 138*cdf0e10cSrcweir m_aAcceptedStates[1] = embed::EmbedStates::RUNNING; 139*cdf0e10cSrcweir m_aAcceptedStates[2] = embed::EmbedStates::INPLACE_ACTIVE; 140*cdf0e10cSrcweir m_aAcceptedStates[3] = embed::EmbedStates::UI_ACTIVE; 141*cdf0e10cSrcweir m_aAcceptedStates[4] = embed::EmbedStates::ACTIVE; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // intermediate states 145*cdf0e10cSrcweir // In the following table the first index points to starting state, 146*cdf0e10cSrcweir // the second one to the target state, and the sequence referenced by 147*cdf0e10cSrcweir // first two indexes contains intermediate states, that should be 148*cdf0e10cSrcweir // passed by object to reach the target state. 149*cdf0e10cSrcweir // If the sequence is empty that means that indirect switch from start 150*cdf0e10cSrcweir // state to the target state is forbidden, only if direct switch is possible 151*cdf0e10cSrcweir // the state can be reached. 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][2].realloc( 1 ); 154*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][2][0] = embed::EmbedStates::RUNNING; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][3].realloc( 2 ); 157*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][3][0] = embed::EmbedStates::RUNNING; 158*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][3][1] = embed::EmbedStates::INPLACE_ACTIVE; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][4].realloc( 1 ); 161*cdf0e10cSrcweir m_pIntermediateStatesSeqs[0][4][0] = embed::EmbedStates::RUNNING; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir m_pIntermediateStatesSeqs[1][3].realloc( 1 ); 164*cdf0e10cSrcweir m_pIntermediateStatesSeqs[1][3][0] = embed::EmbedStates::INPLACE_ACTIVE; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir m_pIntermediateStatesSeqs[2][0].realloc( 1 ); 167*cdf0e10cSrcweir m_pIntermediateStatesSeqs[2][0][0] = embed::EmbedStates::RUNNING; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir m_pIntermediateStatesSeqs[3][0].realloc( 2 ); 170*cdf0e10cSrcweir m_pIntermediateStatesSeqs[3][0][0] = embed::EmbedStates::INPLACE_ACTIVE; 171*cdf0e10cSrcweir m_pIntermediateStatesSeqs[3][0][1] = embed::EmbedStates::RUNNING; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir m_pIntermediateStatesSeqs[3][1].realloc( 1 ); 174*cdf0e10cSrcweir m_pIntermediateStatesSeqs[3][1][0] = embed::EmbedStates::INPLACE_ACTIVE; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir m_pIntermediateStatesSeqs[4][0].realloc( 1 ); 177*cdf0e10cSrcweir m_pIntermediateStatesSeqs[4][0][0] = embed::EmbedStates::RUNNING; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // verbs table 180*cdf0e10cSrcweir sal_Int32 nVerbTableSize = 0; 181*cdf0e10cSrcweir for ( sal_Int32 nVerbInd = 0; nVerbInd < m_aObjectVerbs.getLength(); nVerbInd++ ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_PRIMARY ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 186*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 187*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 188*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_SHOW ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 193*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 194*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 195*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 200*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 201*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 202*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::ACTIVE; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_IPACTIVATE ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 207*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 208*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 209*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::INPLACE_ACTIVE; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_UIACTIVATE ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 214*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 215*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 216*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::UI_ACTIVE; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir else if ( m_aObjectVerbs[nVerbInd].VerbID == embed::EmbedVerbs::MS_OLEVERB_HIDE ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir m_aVerbTable.realloc( ++nVerbTableSize ); 221*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1].realloc( 2 ); 222*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][0] = m_aObjectVerbs[nVerbInd].VerbID; 223*cdf0e10cSrcweir m_aVerbTable[nVerbTableSize - 1][1] = embed::EmbedStates::RUNNING; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir //------------------------------------------------------ 229*cdf0e10cSrcweir void OCommonEmbeddedObject::LinkInit_Impl( 230*cdf0e10cSrcweir const uno::Sequence< beans::NamedValue >& aObjectProps, 231*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& aMediaDescr, 232*cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& aObjectDescr ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir // setPersistance has no effect on own links, so the complete initialization must be done here 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aMediaDescr.getLength(); nInd++ ) 237*cdf0e10cSrcweir if ( aMediaDescr[nInd].Name.equalsAscii( "URL" ) ) 238*cdf0e10cSrcweir aMediaDescr[nInd].Value >>= m_aLinkURL; 239*cdf0e10cSrcweir else if ( aMediaDescr[nInd].Name.equalsAscii( "FilterName" ) ) 240*cdf0e10cSrcweir aMediaDescr[nInd].Value >>= m_aLinkFilterName; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir OSL_ENSURE( m_aLinkURL.getLength() && m_aLinkFilterName.getLength(), "Filter and URL must be provided!\n" ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir m_bReadOnly = sal_True; 245*cdf0e10cSrcweir if ( m_aLinkFilterName.getLength() ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir ::comphelper::MimeConfigurationHelper aHelper( m_xFactory ); 248*cdf0e10cSrcweir ::rtl::OUString aExportFilterName = aHelper.GetExportFilterFromImportFilter( m_aLinkFilterName ); 249*cdf0e10cSrcweir m_bReadOnly = !( aExportFilterName.equals( m_aLinkFilterName ) ); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir m_aDocMediaDescriptor = GetValuableArgs_Impl( aMediaDescr, sal_False ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir uno::Reference< frame::XDispatchProviderInterceptor > xDispatchInterceptor; 255*cdf0e10cSrcweir for ( sal_Int32 nObjInd = 0; nObjInd < aObjectDescr.getLength(); nObjInd++ ) 256*cdf0e10cSrcweir if ( aObjectDescr[nObjInd].Name.equalsAscii( "OutplaceDispatchInterceptor" ) ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir aObjectDescr[nObjInd].Value >>= xDispatchInterceptor; 259*cdf0e10cSrcweir break; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir else if ( aObjectDescr[nObjInd].Name.equalsAscii( "Parent" ) ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir aObjectDescr[nObjInd].Value >>= m_xParent; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir CommonInit_Impl( aObjectProps ); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir if ( xDispatchInterceptor.is() ) 269*cdf0e10cSrcweir m_pDocHolder->SetOutplaceDispatchInterceptor( xDispatchInterceptor ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir //------------------------------------------------------ 273*cdf0e10cSrcweir OCommonEmbeddedObject::~OCommonEmbeddedObject() 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir if ( m_pInterfaceContainer || m_pDocHolder ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir m_refCount++; 278*cdf0e10cSrcweir try { 279*cdf0e10cSrcweir lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir m_pInterfaceContainer->disposeAndClear( aSource ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir delete m_pInterfaceContainer; 286*cdf0e10cSrcweir m_pInterfaceContainer = NULL; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir } catch( uno::Exception& ) {} 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir try { 291*cdf0e10cSrcweir if ( m_pDocHolder ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir m_pDocHolder->CloseFrame(); 294*cdf0e10cSrcweir try { 295*cdf0e10cSrcweir m_pDocHolder->CloseDocument( sal_True, sal_True ); 296*cdf0e10cSrcweir } catch ( uno::Exception& ) {} 297*cdf0e10cSrcweir m_pDocHolder->FreeOffice(); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir m_pDocHolder->release(); 300*cdf0e10cSrcweir m_pDocHolder = NULL; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir } catch( uno::Exception& ) {} 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir //------------------------------------------------------ 307*cdf0e10cSrcweir void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle& aRect ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir // the method is called in case object is inplace active and the object window was resized 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir OSL_ENSURE( m_xClientSite.is(), "The client site must be set for inplace active object!\n" ); 312*cdf0e10cSrcweir if ( m_xClientSite.is() ) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir OSL_ENSURE( xInplaceClient.is(), "The client site must support XInplaceClient to allow inplace activation!\n" ); 317*cdf0e10cSrcweir if ( xInplaceClient.is() ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir try { 320*cdf0e10cSrcweir xInplaceClient->changedPlacement( aRect ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir catch( uno::Exception& ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir OSL_ENSURE( sal_False, "Exception on request to resize!\n" ); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir //------------------------------------------------------ 331*cdf0e10cSrcweir void OCommonEmbeddedObject::PostEvent_Impl( const ::rtl::OUString& aEventName, 332*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& /*xSource*/ ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( 337*cdf0e10cSrcweir ::getCppuType((const uno::Reference< document::XEventListener >*)0) ); 338*cdf0e10cSrcweir if( pIC ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir document::EventObject aEvent; 341*cdf0e10cSrcweir aEvent.EventName = aEventName; 342*cdf0e10cSrcweir aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ); 343*cdf0e10cSrcweir // For now all the events are sent as object events 344*cdf0e10cSrcweir // aEvent.Source = ( xSource.is() ? xSource 345*cdf0e10cSrcweir // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); 346*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIt( *pIC ); 347*cdf0e10cSrcweir while( aIt.hasMoreElements() ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir try 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir ((document::XEventListener *)aIt.next())->notifyEvent( aEvent ); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir catch( uno::RuntimeException& ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir aIt.remove(); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // the listener could dispose the object. 359*cdf0e10cSrcweir if ( m_bDisposed ) 360*cdf0e10cSrcweir return; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir //------------------------------------------------------ 367*cdf0e10cSrcweir uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType ) 368*cdf0e10cSrcweir throw( uno::RuntimeException ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir uno::Any aReturn; 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir if ( rType == ::getCppuType( (uno::Reference< embed::XEmbeddedObject > const *)0 )) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir void * p = static_cast< embed::XEmbeddedObject * >( this ); 375*cdf0e10cSrcweir return uno::Any( &p, rType ); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir else 378*cdf0e10cSrcweir aReturn <<= ::cppu::queryInterface( 379*cdf0e10cSrcweir rType, 380*cdf0e10cSrcweir static_cast< embed::XInplaceObject* >( this ), 381*cdf0e10cSrcweir static_cast< embed::XVisualObject* >( this ), 382*cdf0e10cSrcweir static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ), 383*cdf0e10cSrcweir static_cast< embed::XEmbedPersist* >( this ), 384*cdf0e10cSrcweir static_cast< embed::XLinkageSupport* >( this ), 385*cdf0e10cSrcweir static_cast< embed::XStateChangeBroadcaster* >( this ), 386*cdf0e10cSrcweir static_cast< embed::XClassifiedObject* >( this ), 387*cdf0e10cSrcweir static_cast< embed::XComponentSupplier* >( this ), 388*cdf0e10cSrcweir static_cast< util::XCloseable* >( this ), 389*cdf0e10cSrcweir static_cast< container::XChild* >( this ), 390*cdf0e10cSrcweir static_cast< chart2::XDefaultSizeTransmitter* >( this ), 391*cdf0e10cSrcweir static_cast< document::XEventBroadcaster* >( this ) ); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir if ( aReturn.hasValue() ) 394*cdf0e10cSrcweir return aReturn; 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir return ::cppu::OWeakObject::queryInterface( rType ) ; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir //------------------------------------------------------ 401*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::acquire() 402*cdf0e10cSrcweir throw() 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir ::cppu::OWeakObject::acquire() ; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir //------------------------------------------------------ 408*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::release() 409*cdf0e10cSrcweir throw() 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir ::cppu::OWeakObject::release() ; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir //------------------------------------------------------ 415*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL OCommonEmbeddedObject::getTypes() 416*cdf0e10cSrcweir throw( uno::RuntimeException ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir static ::cppu::OTypeCollection* pTypeCollection = NULL; 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if ( !pTypeCollection ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 423*cdf0e10cSrcweir if ( !pTypeCollection ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir if ( m_bIsLink ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir static ::cppu::OTypeCollection aTypeCollection( 428*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ), 429*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ), 430*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ), 431*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XCommonEmbedPersist >*)NULL ), 432*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< container::XChild >*)NULL ), 433*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XLinkageSupport >*)NULL ) ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir pTypeCollection = &aTypeCollection ; 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir else 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir static ::cppu::OTypeCollection aTypeCollection( 440*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ), 441*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ), 442*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ), 443*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XCommonEmbedPersist >*)NULL ), 444*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< container::XChild >*)NULL ), 445*cdf0e10cSrcweir ::getCppuType( (const uno::Reference< embed::XEmbedPersist >*)NULL ) ); 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir pTypeCollection = &aTypeCollection ; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir return pTypeCollection->getTypes() ; 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir //------------------------------------------------------ 457*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getImplementationId() 458*cdf0e10cSrcweir throw( uno::RuntimeException ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir static ::cppu::OImplementationId* pID = NULL ; 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if ( !pID ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ; 465*cdf0e10cSrcweir if ( !pID ) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir static ::cppu::OImplementationId aID( sal_False ) ; 468*cdf0e10cSrcweir pID = &aID ; 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir return pID->getImplementationId() ; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir //------------------------------------------------------ 476*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL OCommonEmbeddedObject::getClassID() 477*cdf0e10cSrcweir throw ( uno::RuntimeException ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir if ( m_bDisposed ) 480*cdf0e10cSrcweir throw lang::DisposedException(); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir return m_aClassID; 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir //------------------------------------------------------ 486*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OCommonEmbeddedObject::getClassName() 487*cdf0e10cSrcweir throw ( uno::RuntimeException ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir if ( m_bDisposed ) 490*cdf0e10cSrcweir throw lang::DisposedException(); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir return m_aClassName; 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir //------------------------------------------------------ 496*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::setClassInfo( 497*cdf0e10cSrcweir const uno::Sequence< sal_Int8 >& /*aClassID*/, const ::rtl::OUString& /*aClassName*/ ) 498*cdf0e10cSrcweir throw ( lang::NoSupportException, 499*cdf0e10cSrcweir uno::RuntimeException ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir // the object class info can not be changed explicitly 502*cdf0e10cSrcweir throw lang::NoSupportException(); //TODO: 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir //------------------------------------------------------ 506*cdf0e10cSrcweir uno::Reference< util::XCloseable > SAL_CALL OCommonEmbeddedObject::getComponent() 507*cdf0e10cSrcweir throw ( uno::RuntimeException ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 510*cdf0e10cSrcweir if ( m_bDisposed ) 511*cdf0e10cSrcweir throw lang::DisposedException(); // TODO 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // add an exception 514*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir // the object is still not loaded 517*cdf0e10cSrcweir throw uno::RuntimeException( ::rtl::OUString::createFromAscii( "Can't store object without persistence!\n" ), 518*cdf0e10cSrcweir uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir // if ( m_bWaitSaveCompleted ) 522*cdf0e10cSrcweir // throw embed::WrongStateException( 523*cdf0e10cSrcweir // ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ), 524*cdf0e10cSrcweir // uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir return uno::Reference< util::XCloseable >( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir //---------------------------------------------- 530*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener ) 531*cdf0e10cSrcweir throw ( uno::RuntimeException ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 534*cdf0e10cSrcweir if ( m_bDisposed ) 535*cdf0e10cSrcweir throw lang::DisposedException(); // TODO 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir if ( !m_pInterfaceContainer ) 538*cdf0e10cSrcweir m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ), 541*cdf0e10cSrcweir xListener ); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir //---------------------------------------------- 545*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::removeStateChangeListener( 546*cdf0e10cSrcweir const uno::Reference< embed::XStateChangeListener >& xListener ) 547*cdf0e10cSrcweir throw (uno::RuntimeException) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 550*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 551*cdf0e10cSrcweir m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ), 552*cdf0e10cSrcweir xListener ); 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir //---------------------------------------------- 556*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership ) 557*cdf0e10cSrcweir throw ( util::CloseVetoException, 558*cdf0e10cSrcweir uno::RuntimeException ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 561*cdf0e10cSrcweir if ( m_bClosed ) 562*cdf0e10cSrcweir throw lang::DisposedException(); // TODO 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) ); 565*cdf0e10cSrcweir lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = 570*cdf0e10cSrcweir m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) ); 571*cdf0e10cSrcweir if ( pContainer != NULL ) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 574*cdf0e10cSrcweir while (pIterator.hasMoreElements()) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir try 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership ); 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir catch( uno::RuntimeException& ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir pIterator.remove(); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir pContainer = m_pInterfaceContainer->getContainer( 588*cdf0e10cSrcweir ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) ); 589*cdf0e10cSrcweir if ( pContainer != NULL ) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer); 592*cdf0e10cSrcweir while (pCloseIterator.hasMoreElements()) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir try 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource ); 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir catch( uno::RuntimeException& ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir pCloseIterator.remove(); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir m_pInterfaceContainer->disposeAndClear( aSource ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir m_bDisposed = sal_True; // the object is disposed now for outside 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir // it is possible that the document can not be closed, in this case if the argument is false 611*cdf0e10cSrcweir // the exception will be thrown otherwise in addition to exception the object must register itself 612*cdf0e10cSrcweir // as termination listener and listen for document events 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir if ( m_pDocHolder ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir m_pDocHolder->CloseFrame(); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir try { 619*cdf0e10cSrcweir m_pDocHolder->CloseDocument( bDeliverOwnership, bDeliverOwnership ); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir catch( uno::Exception& ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir if ( bDeliverOwnership ) 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir m_pDocHolder->release(); 626*cdf0e10cSrcweir m_pDocHolder = NULL; 627*cdf0e10cSrcweir m_bClosed = sal_True; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir throw; 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir m_pDocHolder->FreeOffice(); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir m_pDocHolder->release(); 636*cdf0e10cSrcweir m_pDocHolder = NULL; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir // TODO: for now the storage will be disposed by the object, but after the document 640*cdf0e10cSrcweir // will use the storage, the storage will be disposed by the document and recreated by the object 641*cdf0e10cSrcweir if ( m_xObjectStorage.is() ) 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir uno::Reference< lang::XComponent > xComp( m_xObjectStorage, uno::UNO_QUERY ); 644*cdf0e10cSrcweir OSL_ENSURE( xComp.is(), "Storage does not support XComponent!\n" ); 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir if ( xComp.is() ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir try { 649*cdf0e10cSrcweir xComp->dispose(); 650*cdf0e10cSrcweir } catch ( uno::Exception& ) {} 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir m_xObjectStorage.clear(); 654*cdf0e10cSrcweir m_xRecoveryStorage.clear(); 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir m_bClosed = sal_True; // the closing succeeded 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir //---------------------------------------------- 661*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener ) 662*cdf0e10cSrcweir throw ( uno::RuntimeException ) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 665*cdf0e10cSrcweir if ( m_bDisposed ) 666*cdf0e10cSrcweir throw lang::DisposedException(); // TODO 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir if ( !m_pInterfaceContainer ) 669*cdf0e10cSrcweir m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener ); 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir //---------------------------------------------- 675*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener ) 676*cdf0e10cSrcweir throw (uno::RuntimeException) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 679*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 680*cdf0e10cSrcweir m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), 681*cdf0e10cSrcweir xListener ); 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir //------------------------------------------------------ 685*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener ) 686*cdf0e10cSrcweir throw ( uno::RuntimeException ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 689*cdf0e10cSrcweir if ( m_bDisposed ) 690*cdf0e10cSrcweir throw lang::DisposedException(); // TODO 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir if ( !m_pInterfaceContainer ) 693*cdf0e10cSrcweir m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener ); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir //------------------------------------------------------ 699*cdf0e10cSrcweir void SAL_CALL OCommonEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener ) 700*cdf0e10cSrcweir throw ( uno::RuntimeException ) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 703*cdf0e10cSrcweir if ( m_pInterfaceContainer ) 704*cdf0e10cSrcweir m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), 705*cdf0e10cSrcweir xListener ); 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708