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