1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski #include "precompiled_embeddedobj.hxx"
25*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EmbedStates.hpp>
26*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EmbedVerbs.hpp>
27*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EmbedUpdateModes.hpp>
28*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XEmbeddedClient.hpp>
29*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XInplaceClient.hpp>
30*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XWindowSupplier.hpp>
31*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/StateChangeInProgressException.hpp>
32*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EmbedStates.hpp>
33*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/Aspects.hpp>
34*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EmbedMapUnits.hpp>
35*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/EntryInitModes.hpp>
36*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
37*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/DisposedException.hpp>
38*b1cdbd2cSJim Jagielski
39*b1cdbd2cSJim Jagielski #include <cppuhelper/interfacecontainer.h>
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim Jagielski #include <dummyobject.hxx>
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski
44*b1cdbd2cSJim Jagielski using namespace ::com::sun::star;
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski //----------------------------------------------
CheckInit()47*b1cdbd2cSJim Jagielski void ODummyEmbeddedObject::CheckInit()
48*b1cdbd2cSJim Jagielski {
49*b1cdbd2cSJim Jagielski if ( m_bDisposed )
50*b1cdbd2cSJim Jagielski throw lang::DisposedException();
51*b1cdbd2cSJim Jagielski
52*b1cdbd2cSJim Jagielski if ( m_nObjectState == -1 )
53*b1cdbd2cSJim Jagielski throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
54*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
55*b1cdbd2cSJim Jagielski }
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim Jagielski //----------------------------------------------
PostEvent_Impl(const::rtl::OUString & aEventName,const uno::Reference<uno::XInterface> &)58*b1cdbd2cSJim Jagielski void ODummyEmbeddedObject::PostEvent_Impl( const ::rtl::OUString& aEventName,
59*b1cdbd2cSJim Jagielski const uno::Reference< uno::XInterface >& /*xSource*/ )
60*b1cdbd2cSJim Jagielski {
61*b1cdbd2cSJim Jagielski if ( m_pInterfaceContainer )
62*b1cdbd2cSJim Jagielski {
63*b1cdbd2cSJim Jagielski ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
64*b1cdbd2cSJim Jagielski ::getCppuType((const uno::Reference< document::XEventListener >*)0) );
65*b1cdbd2cSJim Jagielski if( pIC )
66*b1cdbd2cSJim Jagielski {
67*b1cdbd2cSJim Jagielski document::EventObject aEvent;
68*b1cdbd2cSJim Jagielski aEvent.EventName = aEventName;
69*b1cdbd2cSJim Jagielski aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) );
70*b1cdbd2cSJim Jagielski // For now all the events are sent as object events
71*b1cdbd2cSJim Jagielski // aEvent.Source = ( xSource.is() ? xSource
72*b1cdbd2cSJim Jagielski // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
73*b1cdbd2cSJim Jagielski ::cppu::OInterfaceIteratorHelper aIt( *pIC );
74*b1cdbd2cSJim Jagielski while( aIt.hasMoreElements() )
75*b1cdbd2cSJim Jagielski {
76*b1cdbd2cSJim Jagielski try
77*b1cdbd2cSJim Jagielski {
78*b1cdbd2cSJim Jagielski ((document::XEventListener *)aIt.next())->notifyEvent( aEvent );
79*b1cdbd2cSJim Jagielski }
80*b1cdbd2cSJim Jagielski catch( uno::RuntimeException& )
81*b1cdbd2cSJim Jagielski {
82*b1cdbd2cSJim Jagielski aIt.remove();
83*b1cdbd2cSJim Jagielski }
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski // the listener could dispose the object.
86*b1cdbd2cSJim Jagielski if ( m_bDisposed )
87*b1cdbd2cSJim Jagielski return;
88*b1cdbd2cSJim Jagielski }
89*b1cdbd2cSJim Jagielski }
90*b1cdbd2cSJim Jagielski }
91*b1cdbd2cSJim Jagielski }
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski //----------------------------------------------
~ODummyEmbeddedObject()94*b1cdbd2cSJim Jagielski ODummyEmbeddedObject::~ODummyEmbeddedObject()
95*b1cdbd2cSJim Jagielski {
96*b1cdbd2cSJim Jagielski }
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski //----------------------------------------------
changeState(sal_Int32 nNewState)99*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::changeState( sal_Int32 nNewState )
100*b1cdbd2cSJim Jagielski throw ( embed::UnreachableStateException,
101*b1cdbd2cSJim Jagielski embed::WrongStateException,
102*b1cdbd2cSJim Jagielski uno::Exception,
103*b1cdbd2cSJim Jagielski uno::RuntimeException )
104*b1cdbd2cSJim Jagielski {
105*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
106*b1cdbd2cSJim Jagielski CheckInit();
107*b1cdbd2cSJim Jagielski
108*b1cdbd2cSJim Jagielski if ( nNewState == embed::EmbedStates::LOADED )
109*b1cdbd2cSJim Jagielski return;
110*b1cdbd2cSJim Jagielski
111*b1cdbd2cSJim Jagielski throw embed::UnreachableStateException();
112*b1cdbd2cSJim Jagielski }
113*b1cdbd2cSJim Jagielski
114*b1cdbd2cSJim Jagielski //----------------------------------------------
getReachableStates()115*b1cdbd2cSJim Jagielski uno::Sequence< sal_Int32 > SAL_CALL ODummyEmbeddedObject::getReachableStates()
116*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
117*b1cdbd2cSJim Jagielski uno::RuntimeException )
118*b1cdbd2cSJim Jagielski {
119*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
120*b1cdbd2cSJim Jagielski CheckInit();
121*b1cdbd2cSJim Jagielski
122*b1cdbd2cSJim Jagielski uno::Sequence< sal_Int32 > aResult( 1 );
123*b1cdbd2cSJim Jagielski aResult[0] = embed::EmbedStates::LOADED;
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski return aResult;
126*b1cdbd2cSJim Jagielski }
127*b1cdbd2cSJim Jagielski
128*b1cdbd2cSJim Jagielski //----------------------------------------------
getCurrentState()129*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState()
130*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
131*b1cdbd2cSJim Jagielski uno::RuntimeException )
132*b1cdbd2cSJim Jagielski {
133*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
134*b1cdbd2cSJim Jagielski CheckInit();
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski return m_nObjectState;
137*b1cdbd2cSJim Jagielski }
138*b1cdbd2cSJim Jagielski
139*b1cdbd2cSJim Jagielski //----------------------------------------------
doVerb(sal_Int32)140*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::doVerb( sal_Int32 )
141*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
142*b1cdbd2cSJim Jagielski embed::WrongStateException,
143*b1cdbd2cSJim Jagielski embed::UnreachableStateException,
144*b1cdbd2cSJim Jagielski uno::Exception,
145*b1cdbd2cSJim Jagielski uno::RuntimeException )
146*b1cdbd2cSJim Jagielski {
147*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
148*b1cdbd2cSJim Jagielski CheckInit();
149*b1cdbd2cSJim Jagielski
150*b1cdbd2cSJim Jagielski // no supported verbs
151*b1cdbd2cSJim Jagielski }
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski //----------------------------------------------
getSupportedVerbs()154*b1cdbd2cSJim Jagielski uno::Sequence< embed::VerbDescriptor > SAL_CALL ODummyEmbeddedObject::getSupportedVerbs()
155*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
156*b1cdbd2cSJim Jagielski uno::RuntimeException )
157*b1cdbd2cSJim Jagielski {
158*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
159*b1cdbd2cSJim Jagielski CheckInit();
160*b1cdbd2cSJim Jagielski
161*b1cdbd2cSJim Jagielski return uno::Sequence< embed::VerbDescriptor >();
162*b1cdbd2cSJim Jagielski }
163*b1cdbd2cSJim Jagielski
164*b1cdbd2cSJim Jagielski //----------------------------------------------
setClientSite(const uno::Reference<embed::XEmbeddedClient> & xClient)165*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setClientSite(
166*b1cdbd2cSJim Jagielski const uno::Reference< embed::XEmbeddedClient >& xClient )
167*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
168*b1cdbd2cSJim Jagielski uno::RuntimeException )
169*b1cdbd2cSJim Jagielski {
170*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
171*b1cdbd2cSJim Jagielski CheckInit();
172*b1cdbd2cSJim Jagielski
173*b1cdbd2cSJim Jagielski m_xClientSite = xClient;
174*b1cdbd2cSJim Jagielski }
175*b1cdbd2cSJim Jagielski
176*b1cdbd2cSJim Jagielski //----------------------------------------------
getClientSite()177*b1cdbd2cSJim Jagielski uno::Reference< embed::XEmbeddedClient > SAL_CALL ODummyEmbeddedObject::getClientSite()
178*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
179*b1cdbd2cSJim Jagielski uno::RuntimeException )
180*b1cdbd2cSJim Jagielski {
181*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
182*b1cdbd2cSJim Jagielski CheckInit();
183*b1cdbd2cSJim Jagielski
184*b1cdbd2cSJim Jagielski return m_xClientSite;
185*b1cdbd2cSJim Jagielski }
186*b1cdbd2cSJim Jagielski
187*b1cdbd2cSJim Jagielski //----------------------------------------------
update()188*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::update()
189*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
190*b1cdbd2cSJim Jagielski uno::Exception,
191*b1cdbd2cSJim Jagielski uno::RuntimeException )
192*b1cdbd2cSJim Jagielski {
193*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
194*b1cdbd2cSJim Jagielski CheckInit();
195*b1cdbd2cSJim Jagielski }
196*b1cdbd2cSJim Jagielski
197*b1cdbd2cSJim Jagielski //----------------------------------------------
setUpdateMode(sal_Int32)198*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setUpdateMode( sal_Int32 )
199*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
200*b1cdbd2cSJim Jagielski uno::RuntimeException )
201*b1cdbd2cSJim Jagielski {
202*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
203*b1cdbd2cSJim Jagielski CheckInit();
204*b1cdbd2cSJim Jagielski }
205*b1cdbd2cSJim Jagielski
206*b1cdbd2cSJim Jagielski //----------------------------------------------
getStatus(sal_Int64)207*b1cdbd2cSJim Jagielski sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 )
208*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
209*b1cdbd2cSJim Jagielski uno::RuntimeException )
210*b1cdbd2cSJim Jagielski {
211*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
212*b1cdbd2cSJim Jagielski CheckInit();
213*b1cdbd2cSJim Jagielski
214*b1cdbd2cSJim Jagielski return 0;
215*b1cdbd2cSJim Jagielski }
216*b1cdbd2cSJim Jagielski
217*b1cdbd2cSJim Jagielski //----------------------------------------------
setContainerName(const::rtl::OUString &)218*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setContainerName( const ::rtl::OUString& )
219*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
220*b1cdbd2cSJim Jagielski {
221*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
222*b1cdbd2cSJim Jagielski CheckInit();
223*b1cdbd2cSJim Jagielski }
224*b1cdbd2cSJim Jagielski
225*b1cdbd2cSJim Jagielski //----------------------------------------------
setVisualAreaSize(sal_Int64 nAspect,const awt::Size & aSize)226*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
227*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
228*b1cdbd2cSJim Jagielski embed::WrongStateException,
229*b1cdbd2cSJim Jagielski uno::Exception,
230*b1cdbd2cSJim Jagielski uno::RuntimeException )
231*b1cdbd2cSJim Jagielski {
232*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
233*b1cdbd2cSJim Jagielski CheckInit();
234*b1cdbd2cSJim Jagielski
235*b1cdbd2cSJim Jagielski OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
236*b1cdbd2cSJim Jagielski if ( nAspect == embed::Aspects::MSOLE_ICON )
237*b1cdbd2cSJim Jagielski // no representation can be retrieved
238*b1cdbd2cSJim Jagielski throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
239*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
240*b1cdbd2cSJim Jagielski
241*b1cdbd2cSJim Jagielski m_nCachedAspect = nAspect;
242*b1cdbd2cSJim Jagielski m_aCachedSize = aSize;
243*b1cdbd2cSJim Jagielski m_bHasCachedSize = sal_True;
244*b1cdbd2cSJim Jagielski }
245*b1cdbd2cSJim Jagielski
246*b1cdbd2cSJim Jagielski //----------------------------------------------
getVisualAreaSize(sal_Int64 nAspect)247*b1cdbd2cSJim Jagielski awt::Size SAL_CALL ODummyEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
248*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
249*b1cdbd2cSJim Jagielski embed::WrongStateException,
250*b1cdbd2cSJim Jagielski uno::Exception,
251*b1cdbd2cSJim Jagielski uno::RuntimeException )
252*b1cdbd2cSJim Jagielski {
253*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
254*b1cdbd2cSJim Jagielski CheckInit();
255*b1cdbd2cSJim Jagielski
256*b1cdbd2cSJim Jagielski OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
257*b1cdbd2cSJim Jagielski if ( nAspect == embed::Aspects::MSOLE_ICON )
258*b1cdbd2cSJim Jagielski // no representation can be retrieved
259*b1cdbd2cSJim Jagielski throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
260*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
261*b1cdbd2cSJim Jagielski
262*b1cdbd2cSJim Jagielski if ( !m_bHasCachedSize || m_nCachedAspect != nAspect )
263*b1cdbd2cSJim Jagielski throw embed::NoVisualAreaSizeException(
264*b1cdbd2cSJim Jagielski ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No size available!\n" ) ),
265*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
266*b1cdbd2cSJim Jagielski
267*b1cdbd2cSJim Jagielski return m_aCachedSize;
268*b1cdbd2cSJim Jagielski }
269*b1cdbd2cSJim Jagielski
270*b1cdbd2cSJim Jagielski //----------------------------------------------
getMapUnit(sal_Int64 nAspect)271*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect )
272*b1cdbd2cSJim Jagielski throw ( uno::Exception,
273*b1cdbd2cSJim Jagielski uno::RuntimeException)
274*b1cdbd2cSJim Jagielski {
275*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
276*b1cdbd2cSJim Jagielski CheckInit();
277*b1cdbd2cSJim Jagielski
278*b1cdbd2cSJim Jagielski OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
279*b1cdbd2cSJim Jagielski if ( nAspect == embed::Aspects::MSOLE_ICON )
280*b1cdbd2cSJim Jagielski // no representation can be retrieved
281*b1cdbd2cSJim Jagielski throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
282*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
283*b1cdbd2cSJim Jagielski
284*b1cdbd2cSJim Jagielski return embed::EmbedMapUnits::ONE_100TH_MM;
285*b1cdbd2cSJim Jagielski }
286*b1cdbd2cSJim Jagielski
287*b1cdbd2cSJim Jagielski //----------------------------------------------
getPreferredVisualRepresentation(sal_Int64)288*b1cdbd2cSJim Jagielski embed::VisualRepresentation SAL_CALL ODummyEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 )
289*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
290*b1cdbd2cSJim Jagielski embed::WrongStateException,
291*b1cdbd2cSJim Jagielski uno::Exception,
292*b1cdbd2cSJim Jagielski uno::RuntimeException )
293*b1cdbd2cSJim Jagielski {
294*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
295*b1cdbd2cSJim Jagielski CheckInit();
296*b1cdbd2cSJim Jagielski
297*b1cdbd2cSJim Jagielski // no representation can be retrieved
298*b1cdbd2cSJim Jagielski throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ),
299*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
300*b1cdbd2cSJim Jagielski }
301*b1cdbd2cSJim Jagielski
302*b1cdbd2cSJim Jagielski //----------------------------------------------
setPersistentEntry(const uno::Reference<embed::XStorage> & xStorage,const::rtl::OUString & sEntName,sal_Int32 nEntryConnectionMode,const uno::Sequence<beans::PropertyValue> &,const uno::Sequence<beans::PropertyValue> &)303*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setPersistentEntry(
304*b1cdbd2cSJim Jagielski const uno::Reference< embed::XStorage >& xStorage,
305*b1cdbd2cSJim Jagielski const ::rtl::OUString& sEntName,
306*b1cdbd2cSJim Jagielski sal_Int32 nEntryConnectionMode,
307*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lArguments */,
308*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
309*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
310*b1cdbd2cSJim Jagielski embed::WrongStateException,
311*b1cdbd2cSJim Jagielski io::IOException,
312*b1cdbd2cSJim Jagielski uno::Exception,
313*b1cdbd2cSJim Jagielski uno::RuntimeException )
314*b1cdbd2cSJim Jagielski {
315*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
316*b1cdbd2cSJim Jagielski if ( m_bDisposed )
317*b1cdbd2cSJim Jagielski throw lang::DisposedException(); // TODO
318*b1cdbd2cSJim Jagielski
319*b1cdbd2cSJim Jagielski if ( !xStorage.is() )
320*b1cdbd2cSJim Jagielski throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
321*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
322*b1cdbd2cSJim Jagielski 1 );
323*b1cdbd2cSJim Jagielski
324*b1cdbd2cSJim Jagielski if ( !sEntName.getLength() )
325*b1cdbd2cSJim Jagielski throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
326*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
327*b1cdbd2cSJim Jagielski 2 );
328*b1cdbd2cSJim Jagielski
329*b1cdbd2cSJim Jagielski if ( ( m_nObjectState != -1 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
330*b1cdbd2cSJim Jagielski && ( m_nObjectState == -1 || nEntryConnectionMode != embed::EntryInitModes::NO_INIT ) )
331*b1cdbd2cSJim Jagielski {
332*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
333*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "Can't change persistant representation of activated object!\n" ),
334*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
335*b1cdbd2cSJim Jagielski }
336*b1cdbd2cSJim Jagielski
337*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
338*b1cdbd2cSJim Jagielski {
339*b1cdbd2cSJim Jagielski if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
340*b1cdbd2cSJim Jagielski saveCompleted( ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) ) );
341*b1cdbd2cSJim Jagielski else
342*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
343*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
344*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
345*b1cdbd2cSJim Jagielski }
346*b1cdbd2cSJim Jagielski
347*b1cdbd2cSJim Jagielski if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
348*b1cdbd2cSJim Jagielski || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
349*b1cdbd2cSJim Jagielski {
350*b1cdbd2cSJim Jagielski if ( xStorage->hasByName( sEntName ) )
351*b1cdbd2cSJim Jagielski
352*b1cdbd2cSJim Jagielski {
353*b1cdbd2cSJim Jagielski m_xParentStorage = xStorage;
354*b1cdbd2cSJim Jagielski m_aEntryName = sEntName;
355*b1cdbd2cSJim Jagielski m_nObjectState = embed::EmbedStates::LOADED;
356*b1cdbd2cSJim Jagielski }
357*b1cdbd2cSJim Jagielski else
358*b1cdbd2cSJim Jagielski throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong entry is provided!\n" ),
359*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
360*b1cdbd2cSJim Jagielski 2 );
361*b1cdbd2cSJim Jagielski
362*b1cdbd2cSJim Jagielski }
363*b1cdbd2cSJim Jagielski else
364*b1cdbd2cSJim Jagielski throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Wrong connection mode is provided!\n" ),
365*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
366*b1cdbd2cSJim Jagielski 3 );
367*b1cdbd2cSJim Jagielski }
368*b1cdbd2cSJim Jagielski
369*b1cdbd2cSJim Jagielski //------------------------------------------------------
storeToEntry(const uno::Reference<embed::XStorage> & xStorage,const::rtl::OUString & sEntName,const uno::Sequence<beans::PropertyValue> &,const uno::Sequence<beans::PropertyValue> &)370*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::storeToEntry( const uno::Reference< embed::XStorage >& xStorage,
371*b1cdbd2cSJim Jagielski const ::rtl::OUString& sEntName,
372*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lArguments */,
373*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
374*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
375*b1cdbd2cSJim Jagielski embed::WrongStateException,
376*b1cdbd2cSJim Jagielski io::IOException,
377*b1cdbd2cSJim Jagielski uno::Exception,
378*b1cdbd2cSJim Jagielski uno::RuntimeException )
379*b1cdbd2cSJim Jagielski {
380*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
381*b1cdbd2cSJim Jagielski CheckInit();
382*b1cdbd2cSJim Jagielski
383*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
384*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
385*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
386*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
387*b1cdbd2cSJim Jagielski
388*b1cdbd2cSJim Jagielski m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
389*b1cdbd2cSJim Jagielski }
390*b1cdbd2cSJim Jagielski
391*b1cdbd2cSJim Jagielski //------------------------------------------------------
storeAsEntry(const uno::Reference<embed::XStorage> & xStorage,const::rtl::OUString & sEntName,const uno::Sequence<beans::PropertyValue> &,const uno::Sequence<beans::PropertyValue> &)392*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::storeAsEntry( const uno::Reference< embed::XStorage >& xStorage,
393*b1cdbd2cSJim Jagielski const ::rtl::OUString& sEntName,
394*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lArguments */,
395*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
396*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
397*b1cdbd2cSJim Jagielski embed::WrongStateException,
398*b1cdbd2cSJim Jagielski io::IOException,
399*b1cdbd2cSJim Jagielski uno::Exception,
400*b1cdbd2cSJim Jagielski uno::RuntimeException )
401*b1cdbd2cSJim Jagielski {
402*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
403*b1cdbd2cSJim Jagielski CheckInit();
404*b1cdbd2cSJim Jagielski
405*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
406*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
407*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
408*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
409*b1cdbd2cSJim Jagielski
410*b1cdbd2cSJim Jagielski PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAs" ),
411*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) );
412*b1cdbd2cSJim Jagielski
413*b1cdbd2cSJim Jagielski m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
414*b1cdbd2cSJim Jagielski
415*b1cdbd2cSJim Jagielski m_bWaitSaveCompleted = sal_True;
416*b1cdbd2cSJim Jagielski m_xNewParentStorage = xStorage;
417*b1cdbd2cSJim Jagielski m_aNewEntryName = sEntName;
418*b1cdbd2cSJim Jagielski }
419*b1cdbd2cSJim Jagielski
420*b1cdbd2cSJim Jagielski //------------------------------------------------------
saveCompleted(sal_Bool bUseNew)421*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew )
422*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
423*b1cdbd2cSJim Jagielski uno::Exception,
424*b1cdbd2cSJim Jagielski uno::RuntimeException )
425*b1cdbd2cSJim Jagielski {
426*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
427*b1cdbd2cSJim Jagielski CheckInit();
428*b1cdbd2cSJim Jagielski
429*b1cdbd2cSJim Jagielski // it is allowed to call saveCompleted( false ) for nonstored objects
430*b1cdbd2cSJim Jagielski if ( !m_bWaitSaveCompleted && !bUseNew )
431*b1cdbd2cSJim Jagielski return;
432*b1cdbd2cSJim Jagielski
433*b1cdbd2cSJim Jagielski OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" );
434*b1cdbd2cSJim Jagielski if ( !m_bWaitSaveCompleted )
435*b1cdbd2cSJim Jagielski throw io::IOException(); // TODO: illegal call
436*b1cdbd2cSJim Jagielski
437*b1cdbd2cSJim Jagielski OSL_ENSURE( m_xNewParentStorage.is() , "Internal object information is broken!\n" );
438*b1cdbd2cSJim Jagielski if ( !m_xNewParentStorage.is() )
439*b1cdbd2cSJim Jagielski throw uno::RuntimeException(); // TODO: broken internal information
440*b1cdbd2cSJim Jagielski
441*b1cdbd2cSJim Jagielski if ( bUseNew )
442*b1cdbd2cSJim Jagielski {
443*b1cdbd2cSJim Jagielski m_xParentStorage = m_xNewParentStorage;
444*b1cdbd2cSJim Jagielski m_aEntryName = m_aNewEntryName;
445*b1cdbd2cSJim Jagielski
446*b1cdbd2cSJim Jagielski PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAsDone" ),
447*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( this ) ) );
448*b1cdbd2cSJim Jagielski }
449*b1cdbd2cSJim Jagielski
450*b1cdbd2cSJim Jagielski m_xNewParentStorage = uno::Reference< embed::XStorage >();
451*b1cdbd2cSJim Jagielski m_aNewEntryName = ::rtl::OUString();
452*b1cdbd2cSJim Jagielski m_bWaitSaveCompleted = sal_False;
453*b1cdbd2cSJim Jagielski }
454*b1cdbd2cSJim Jagielski
455*b1cdbd2cSJim Jagielski //------------------------------------------------------
hasEntry()456*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL ODummyEmbeddedObject::hasEntry()
457*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
458*b1cdbd2cSJim Jagielski uno::RuntimeException )
459*b1cdbd2cSJim Jagielski {
460*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
461*b1cdbd2cSJim Jagielski CheckInit();
462*b1cdbd2cSJim Jagielski
463*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
464*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
465*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
466*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
467*b1cdbd2cSJim Jagielski
468*b1cdbd2cSJim Jagielski if ( m_aEntryName.getLength() )
469*b1cdbd2cSJim Jagielski return sal_True;
470*b1cdbd2cSJim Jagielski
471*b1cdbd2cSJim Jagielski return sal_False;
472*b1cdbd2cSJim Jagielski }
473*b1cdbd2cSJim Jagielski
474*b1cdbd2cSJim Jagielski //------------------------------------------------------
getEntryName()475*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getEntryName()
476*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
477*b1cdbd2cSJim Jagielski uno::RuntimeException )
478*b1cdbd2cSJim Jagielski {
479*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
480*b1cdbd2cSJim Jagielski CheckInit();
481*b1cdbd2cSJim Jagielski
482*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
483*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
484*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
485*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
486*b1cdbd2cSJim Jagielski
487*b1cdbd2cSJim Jagielski return m_aEntryName;
488*b1cdbd2cSJim Jagielski }
489*b1cdbd2cSJim Jagielski
490*b1cdbd2cSJim Jagielski //------------------------------------------------------
storeOwn()491*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::storeOwn()
492*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
493*b1cdbd2cSJim Jagielski io::IOException,
494*b1cdbd2cSJim Jagielski uno::Exception,
495*b1cdbd2cSJim Jagielski uno::RuntimeException )
496*b1cdbd2cSJim Jagielski {
497*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
498*b1cdbd2cSJim Jagielski CheckInit();
499*b1cdbd2cSJim Jagielski
500*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
501*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
502*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
503*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
504*b1cdbd2cSJim Jagielski
505*b1cdbd2cSJim Jagielski // the object can not be activated or changed
506*b1cdbd2cSJim Jagielski return;
507*b1cdbd2cSJim Jagielski }
508*b1cdbd2cSJim Jagielski
509*b1cdbd2cSJim Jagielski //------------------------------------------------------
isReadonly()510*b1cdbd2cSJim Jagielski sal_Bool SAL_CALL ODummyEmbeddedObject::isReadonly()
511*b1cdbd2cSJim Jagielski throw ( embed::WrongStateException,
512*b1cdbd2cSJim Jagielski uno::RuntimeException )
513*b1cdbd2cSJim Jagielski {
514*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
515*b1cdbd2cSJim Jagielski CheckInit();
516*b1cdbd2cSJim Jagielski
517*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
518*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
519*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
520*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
521*b1cdbd2cSJim Jagielski
522*b1cdbd2cSJim Jagielski // this object can not be changed
523*b1cdbd2cSJim Jagielski return sal_True;
524*b1cdbd2cSJim Jagielski }
525*b1cdbd2cSJim Jagielski
526*b1cdbd2cSJim Jagielski //------------------------------------------------------
reload(const uno::Sequence<beans::PropertyValue> &,const uno::Sequence<beans::PropertyValue> &)527*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::reload(
528*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lArguments */,
529*b1cdbd2cSJim Jagielski const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
530*b1cdbd2cSJim Jagielski throw ( lang::IllegalArgumentException,
531*b1cdbd2cSJim Jagielski embed::WrongStateException,
532*b1cdbd2cSJim Jagielski io::IOException,
533*b1cdbd2cSJim Jagielski uno::Exception,
534*b1cdbd2cSJim Jagielski uno::RuntimeException )
535*b1cdbd2cSJim Jagielski {
536*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
537*b1cdbd2cSJim Jagielski CheckInit();
538*b1cdbd2cSJim Jagielski
539*b1cdbd2cSJim Jagielski if ( m_bWaitSaveCompleted )
540*b1cdbd2cSJim Jagielski throw embed::WrongStateException(
541*b1cdbd2cSJim Jagielski ::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
542*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
543*b1cdbd2cSJim Jagielski
544*b1cdbd2cSJim Jagielski // nothing to reload
545*b1cdbd2cSJim Jagielski }
546*b1cdbd2cSJim Jagielski
547*b1cdbd2cSJim Jagielski //------------------------------------------------------
getClassID()548*b1cdbd2cSJim Jagielski uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID()
549*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
550*b1cdbd2cSJim Jagielski {
551*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
552*b1cdbd2cSJim Jagielski CheckInit();
553*b1cdbd2cSJim Jagielski
554*b1cdbd2cSJim Jagielski // currently the class ID is empty
555*b1cdbd2cSJim Jagielski // TODO/LATER: should a special class ID be used in this case?
556*b1cdbd2cSJim Jagielski return uno::Sequence< sal_Int8 >();
557*b1cdbd2cSJim Jagielski }
558*b1cdbd2cSJim Jagielski
559*b1cdbd2cSJim Jagielski //------------------------------------------------------
getClassName()560*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL ODummyEmbeddedObject::getClassName()
561*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
562*b1cdbd2cSJim Jagielski {
563*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
564*b1cdbd2cSJim Jagielski if ( m_bDisposed )
565*b1cdbd2cSJim Jagielski throw lang::DisposedException(); // TODO
566*b1cdbd2cSJim Jagielski
567*b1cdbd2cSJim Jagielski return ::rtl::OUString();
568*b1cdbd2cSJim Jagielski }
569*b1cdbd2cSJim Jagielski
570*b1cdbd2cSJim Jagielski //------------------------------------------------------
setClassInfo(const uno::Sequence<sal_Int8> &,const::rtl::OUString &)571*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::setClassInfo(
572*b1cdbd2cSJim Jagielski const uno::Sequence< sal_Int8 >& /*aClassID*/, const ::rtl::OUString& /*aClassName*/ )
573*b1cdbd2cSJim Jagielski throw ( lang::NoSupportException,
574*b1cdbd2cSJim Jagielski uno::RuntimeException )
575*b1cdbd2cSJim Jagielski {
576*b1cdbd2cSJim Jagielski throw lang::NoSupportException();
577*b1cdbd2cSJim Jagielski }
578*b1cdbd2cSJim Jagielski
579*b1cdbd2cSJim Jagielski //------------------------------------------------------
getComponent()580*b1cdbd2cSJim Jagielski uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent()
581*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
582*b1cdbd2cSJim Jagielski {
583*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
584*b1cdbd2cSJim Jagielski CheckInit();
585*b1cdbd2cSJim Jagielski
586*b1cdbd2cSJim Jagielski return uno::Reference< util::XCloseable >();
587*b1cdbd2cSJim Jagielski }
588*b1cdbd2cSJim Jagielski
589*b1cdbd2cSJim Jagielski //----------------------------------------------
addStateChangeListener(const uno::Reference<embed::XStateChangeListener> & xListener)590*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
591*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
592*b1cdbd2cSJim Jagielski {
593*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
594*b1cdbd2cSJim Jagielski if ( m_bDisposed )
595*b1cdbd2cSJim Jagielski return;
596*b1cdbd2cSJim Jagielski
597*b1cdbd2cSJim Jagielski if ( !m_pInterfaceContainer )
598*b1cdbd2cSJim Jagielski m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
599*b1cdbd2cSJim Jagielski
600*b1cdbd2cSJim Jagielski m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
601*b1cdbd2cSJim Jagielski xListener );
602*b1cdbd2cSJim Jagielski }
603*b1cdbd2cSJim Jagielski
604*b1cdbd2cSJim Jagielski //----------------------------------------------
removeStateChangeListener(const uno::Reference<embed::XStateChangeListener> & xListener)605*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener(
606*b1cdbd2cSJim Jagielski const uno::Reference< embed::XStateChangeListener >& xListener )
607*b1cdbd2cSJim Jagielski throw (uno::RuntimeException)
608*b1cdbd2cSJim Jagielski {
609*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
610*b1cdbd2cSJim Jagielski if ( m_pInterfaceContainer )
611*b1cdbd2cSJim Jagielski m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
612*b1cdbd2cSJim Jagielski xListener );
613*b1cdbd2cSJim Jagielski }
614*b1cdbd2cSJim Jagielski
615*b1cdbd2cSJim Jagielski //----------------------------------------------
close(sal_Bool bDeliverOwnership)616*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership )
617*b1cdbd2cSJim Jagielski throw ( util::CloseVetoException,
618*b1cdbd2cSJim Jagielski uno::RuntimeException )
619*b1cdbd2cSJim Jagielski {
620*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
621*b1cdbd2cSJim Jagielski if ( m_bDisposed )
622*b1cdbd2cSJim Jagielski throw lang::DisposedException(); // TODO
623*b1cdbd2cSJim Jagielski
624*b1cdbd2cSJim Jagielski uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
625*b1cdbd2cSJim Jagielski lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
626*b1cdbd2cSJim Jagielski
627*b1cdbd2cSJim Jagielski if ( m_pInterfaceContainer )
628*b1cdbd2cSJim Jagielski {
629*b1cdbd2cSJim Jagielski ::cppu::OInterfaceContainerHelper* pContainer =
630*b1cdbd2cSJim Jagielski m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
631*b1cdbd2cSJim Jagielski if ( pContainer != NULL )
632*b1cdbd2cSJim Jagielski {
633*b1cdbd2cSJim Jagielski ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
634*b1cdbd2cSJim Jagielski while (pIterator.hasMoreElements())
635*b1cdbd2cSJim Jagielski {
636*b1cdbd2cSJim Jagielski try
637*b1cdbd2cSJim Jagielski {
638*b1cdbd2cSJim Jagielski ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
639*b1cdbd2cSJim Jagielski }
640*b1cdbd2cSJim Jagielski catch( uno::RuntimeException& )
641*b1cdbd2cSJim Jagielski {
642*b1cdbd2cSJim Jagielski pIterator.remove();
643*b1cdbd2cSJim Jagielski }
644*b1cdbd2cSJim Jagielski }
645*b1cdbd2cSJim Jagielski }
646*b1cdbd2cSJim Jagielski
647*b1cdbd2cSJim Jagielski pContainer = m_pInterfaceContainer->getContainer(
648*b1cdbd2cSJim Jagielski ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
649*b1cdbd2cSJim Jagielski if ( pContainer != NULL )
650*b1cdbd2cSJim Jagielski {
651*b1cdbd2cSJim Jagielski ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
652*b1cdbd2cSJim Jagielski while (pCloseIterator.hasMoreElements())
653*b1cdbd2cSJim Jagielski {
654*b1cdbd2cSJim Jagielski try
655*b1cdbd2cSJim Jagielski {
656*b1cdbd2cSJim Jagielski ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
657*b1cdbd2cSJim Jagielski }
658*b1cdbd2cSJim Jagielski catch( uno::RuntimeException& )
659*b1cdbd2cSJim Jagielski {
660*b1cdbd2cSJim Jagielski pCloseIterator.remove();
661*b1cdbd2cSJim Jagielski }
662*b1cdbd2cSJim Jagielski }
663*b1cdbd2cSJim Jagielski }
664*b1cdbd2cSJim Jagielski
665*b1cdbd2cSJim Jagielski m_pInterfaceContainer->disposeAndClear( aSource );
666*b1cdbd2cSJim Jagielski }
667*b1cdbd2cSJim Jagielski
668*b1cdbd2cSJim Jagielski m_bDisposed = sal_True; // the object is disposed now for outside
669*b1cdbd2cSJim Jagielski }
670*b1cdbd2cSJim Jagielski
671*b1cdbd2cSJim Jagielski //----------------------------------------------
addCloseListener(const uno::Reference<util::XCloseListener> & xListener)672*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
673*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
674*b1cdbd2cSJim Jagielski {
675*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
676*b1cdbd2cSJim Jagielski if ( m_bDisposed )
677*b1cdbd2cSJim Jagielski return;
678*b1cdbd2cSJim Jagielski
679*b1cdbd2cSJim Jagielski if ( !m_pInterfaceContainer )
680*b1cdbd2cSJim Jagielski m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
681*b1cdbd2cSJim Jagielski
682*b1cdbd2cSJim Jagielski m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
683*b1cdbd2cSJim Jagielski }
684*b1cdbd2cSJim Jagielski
685*b1cdbd2cSJim Jagielski //----------------------------------------------
removeCloseListener(const uno::Reference<util::XCloseListener> & xListener)686*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
687*b1cdbd2cSJim Jagielski throw (uno::RuntimeException)
688*b1cdbd2cSJim Jagielski {
689*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
690*b1cdbd2cSJim Jagielski if ( m_pInterfaceContainer )
691*b1cdbd2cSJim Jagielski m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
692*b1cdbd2cSJim Jagielski xListener );
693*b1cdbd2cSJim Jagielski }
694*b1cdbd2cSJim Jagielski
695*b1cdbd2cSJim Jagielski //------------------------------------------------------
addEventListener(const uno::Reference<document::XEventListener> & xListener)696*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
697*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
698*b1cdbd2cSJim Jagielski {
699*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
700*b1cdbd2cSJim Jagielski if ( m_bDisposed )
701*b1cdbd2cSJim Jagielski return;
702*b1cdbd2cSJim Jagielski
703*b1cdbd2cSJim Jagielski if ( !m_pInterfaceContainer )
704*b1cdbd2cSJim Jagielski m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
705*b1cdbd2cSJim Jagielski
706*b1cdbd2cSJim Jagielski m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
707*b1cdbd2cSJim Jagielski }
708*b1cdbd2cSJim Jagielski
709*b1cdbd2cSJim Jagielski //------------------------------------------------------
removeEventListener(const uno::Reference<document::XEventListener> & xListener)710*b1cdbd2cSJim Jagielski void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
711*b1cdbd2cSJim Jagielski throw ( uno::RuntimeException )
712*b1cdbd2cSJim Jagielski {
713*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex );
714*b1cdbd2cSJim Jagielski if ( m_pInterfaceContainer )
715*b1cdbd2cSJim Jagielski m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
716*b1cdbd2cSJim Jagielski xListener );
717*b1cdbd2cSJim Jagielski }
718*b1cdbd2cSJim Jagielski
719