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