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 1135 : void ODummyEmbeddedObject::CheckInit_WrongState()
42 : {
43 1135 : if ( m_bDisposed )
44 0 : throw lang::DisposedException();
45 :
46 1135 : if ( m_nObjectState == -1 )
47 : throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
48 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
49 1135 : }
50 :
51 196 : void ODummyEmbeddedObject::CheckInit_Runtime()
52 : {
53 196 : if ( m_bDisposed )
54 0 : throw lang::DisposedException();
55 :
56 196 : if ( m_nObjectState == -1 )
57 : throw uno::RuntimeException( OUString( "The object has no persistence!\n" ),
58 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
59 196 : }
60 62 : void ODummyEmbeddedObject::PostEvent_Impl( const OUString& aEventName )
61 : {
62 62 : if ( m_pInterfaceContainer )
63 : {
64 : ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
65 62 : ::getCppuType((const uno::Reference< document::XEventListener >*)0) );
66 62 : if( pIC )
67 : {
68 62 : document::EventObject aEvent;
69 62 : aEvent.EventName = aEventName;
70 62 : 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 124 : ::cppu::OInterfaceIteratorHelper aIt( *pIC );
75 180 : while( aIt.hasMoreElements() )
76 : {
77 : try
78 : {
79 56 : ((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 56 : if ( m_bDisposed )
88 62 : return;
89 62 : }
90 : }
91 : }
92 : }
93 :
94 :
95 126 : ODummyEmbeddedObject::~ODummyEmbeddedObject()
96 : {
97 126 : }
98 :
99 :
100 60 : 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 60 : ::osl::MutexGuard aGuard( m_aMutex );
107 60 : CheckInit_WrongState();
108 :
109 60 : if ( nNewState == embed::EmbedStates::LOADED )
110 108 : return;
111 :
112 6 : 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 782 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState()
131 : throw ( embed::WrongStateException,
132 : uno::RuntimeException, std::exception )
133 : {
134 782 : ::osl::MutexGuard aGuard( m_aMutex );
135 782 : CheckInit_WrongState();
136 :
137 782 : 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 4 : void SAL_CALL ODummyEmbeddedObject::setClientSite(
167 : const uno::Reference< embed::XEmbeddedClient >& xClient )
168 : throw ( embed::WrongStateException,
169 : uno::RuntimeException, std::exception )
170 : {
171 4 : ::osl::MutexGuard aGuard( m_aMutex );
172 4 : CheckInit_WrongState();
173 :
174 4 : m_xClientSite = xClient;
175 4 : }
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 94 : sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 )
209 : throw ( embed::WrongStateException,
210 : uno::RuntimeException, std::exception )
211 : {
212 94 : ::osl::MutexGuard aGuard( m_aMutex );
213 94 : CheckInit_WrongState();
214 :
215 94 : 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 8 : 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 8 : ::osl::MutexGuard aGuard( m_aMutex );
234 8 : CheckInit_WrongState();
235 :
236 : OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
237 8 : if ( nAspect == embed::Aspects::MSOLE_ICON )
238 : // no representation can be retrieved
239 : throw embed::WrongStateException( OUString( "Illegal call!\n" ),
240 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
241 :
242 8 : m_nCachedAspect = nAspect;
243 8 : m_aCachedSize = aSize;
244 8 : m_bHasCachedSize = sal_True;
245 8 : }
246 :
247 :
248 19 : 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 19 : ::osl::MutexGuard aGuard( m_aMutex );
255 19 : CheckInit_WrongState();
256 :
257 : OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
258 19 : if ( nAspect == embed::Aspects::MSOLE_ICON )
259 : // no representation can be retrieved
260 : throw embed::WrongStateException( OUString( "Illegal call!\n" ),
261 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
262 :
263 19 : if ( !m_bHasCachedSize || m_nCachedAspect != nAspect )
264 : throw embed::NoVisualAreaSizeException(
265 : OUString( "No size available!\n" ),
266 13 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
267 :
268 19 : return m_aCachedSize;
269 : }
270 :
271 :
272 22 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect )
273 : throw ( uno::Exception,
274 : uno::RuntimeException, std::exception)
275 : {
276 22 : ::osl::MutexGuard aGuard( m_aMutex );
277 22 : CheckInit_Runtime();
278 :
279 : OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
280 22 : if ( nAspect == embed::Aspects::MSOLE_ICON )
281 : // no representation can be retrieved
282 : throw embed::WrongStateException( OUString( "Illegal call!\n" ),
283 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
284 :
285 22 : 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( OUString( "Illegal call!\n" ),
300 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
301 : }
302 :
303 :
304 63 : 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 63 : ::osl::MutexGuard aGuard( m_aMutex );
317 63 : if ( m_bDisposed )
318 0 : throw lang::DisposedException(); // TODO
319 :
320 63 : if ( !xStorage.is() )
321 : throw lang::IllegalArgumentException( OUString( "No parent storage is provided!\n" ),
322 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
323 0 : 1 );
324 :
325 63 : if ( sEntName.isEmpty() )
326 : throw lang::IllegalArgumentException( OUString( "Empty element name is provided!\n" ),
327 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
328 0 : 2 );
329 :
330 63 : 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 : OUString( "Can't change persistent representation of activated object!\n" ),
335 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
336 : }
337 :
338 63 : 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 : OUString( "The object waits for saveCompleted() call!\n" ),
345 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
346 : }
347 :
348 63 : if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
349 0 : || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
350 : {
351 126 : if ( xStorage->hasByName( sEntName ) )
352 :
353 : {
354 63 : m_xParentStorage = xStorage;
355 63 : m_aEntryName = sEntName;
356 63 : m_nObjectState = embed::EmbedStates::LOADED;
357 : }
358 : else
359 : throw lang::IllegalArgumentException( OUString( "Wrong entry is provided!\n" ),
360 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
361 0 : 2 );
362 :
363 : }
364 : else
365 : throw lang::IllegalArgumentException( OUString( "Wrong connection mode is provided!\n" ),
366 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
367 0 : 3 );
368 63 : }
369 :
370 :
371 31 : 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 31 : ::osl::MutexGuard aGuard( m_aMutex );
382 31 : CheckInit_WrongState();
383 :
384 31 : if ( m_bWaitSaveCompleted )
385 : throw embed::WrongStateException(
386 : OUString( "The object waits for saveCompleted() call!\n" ),
387 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
388 :
389 31 : m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
390 31 : }
391 :
392 :
393 34 : 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 34 : ::osl::MutexGuard aGuard( m_aMutex );
404 34 : CheckInit_WrongState();
405 :
406 34 : if ( m_bWaitSaveCompleted )
407 : throw embed::WrongStateException(
408 : OUString( "The object waits for saveCompleted() call!\n" ),
409 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
410 :
411 34 : PostEvent_Impl( OUString( "OnSaveAs" ) );
412 :
413 34 : m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
414 :
415 34 : m_bWaitSaveCompleted = sal_True;
416 34 : m_xNewParentStorage = xStorage;
417 34 : m_aNewEntryName = sEntName;
418 34 : }
419 :
420 :
421 41 : void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew )
422 : throw ( embed::WrongStateException,
423 : uno::Exception,
424 : uno::RuntimeException, std::exception )
425 : {
426 41 : ::osl::MutexGuard aGuard( m_aMutex );
427 41 : CheckInit_WrongState();
428 :
429 : // it is allowed to call saveCompleted( false ) for nonstored objects
430 41 : if ( !m_bWaitSaveCompleted && !bUseNew )
431 48 : return;
432 :
433 : OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" );
434 34 : 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 34 : if ( !m_xNewParentStorage.is() )
439 0 : throw uno::RuntimeException(); // TODO: broken internal information
440 :
441 34 : if ( bUseNew )
442 : {
443 28 : m_xParentStorage = m_xNewParentStorage;
444 28 : m_aEntryName = m_aNewEntryName;
445 :
446 28 : PostEvent_Impl( OUString( "OnSaveAsDone" ) );
447 : }
448 :
449 34 : m_xNewParentStorage = uno::Reference< embed::XStorage >();
450 34 : m_aNewEntryName = OUString();
451 34 : m_bWaitSaveCompleted = sal_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 : OUString( "The object waits for saveCompleted() call!\n" ),
465 0 : uno::Reference< uno::XInterface >( 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 62 : OUString SAL_CALL ODummyEmbeddedObject::getEntryName()
475 : throw ( embed::WrongStateException,
476 : uno::RuntimeException, std::exception )
477 : {
478 62 : ::osl::MutexGuard aGuard( m_aMutex );
479 62 : CheckInit_WrongState();
480 :
481 62 : if ( m_bWaitSaveCompleted )
482 : throw embed::WrongStateException(
483 : OUString( "The object waits for saveCompleted() call!\n" ),
484 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
485 :
486 62 : 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 : OUString( "The object waits for saveCompleted() call!\n" ),
502 0 : uno::Reference< uno::XInterface >( 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 : OUString( "The object waits for saveCompleted() call!\n" ),
519 0 : uno::Reference< uno::XInterface >( 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 : OUString( "The object waits for saveCompleted() call!\n" ),
541 0 : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
542 :
543 : // nothing to reload
544 0 : }
545 :
546 :
547 146 : uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID()
548 : throw ( uno::RuntimeException, std::exception )
549 : {
550 146 : ::osl::MutexGuard aGuard( m_aMutex );
551 146 : CheckInit_Runtime();
552 :
553 : // currently the class ID is empty
554 : // TODO/LATER: should a special class ID be used in this case?
555 146 : 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 28 : uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent()
580 : throw ( uno::RuntimeException, std::exception )
581 : {
582 28 : ::osl::MutexGuard aGuard( m_aMutex );
583 28 : CheckInit_Runtime();
584 :
585 28 : return uno::Reference< util::XCloseable >();
586 : }
587 :
588 :
589 135 : void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
590 : throw ( uno::RuntimeException, std::exception )
591 : {
592 135 : ::osl::MutexGuard aGuard( m_aMutex );
593 135 : if ( m_bDisposed )
594 135 : return;
595 :
596 135 : if ( !m_pInterfaceContainer )
597 63 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
598 :
599 135 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
600 270 : xListener );
601 : }
602 :
603 :
604 135 : void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener(
605 : const uno::Reference< embed::XStateChangeListener >& xListener )
606 : throw (uno::RuntimeException, std::exception)
607 : {
608 135 : ::osl::MutexGuard aGuard( m_aMutex );
609 135 : if ( m_pInterfaceContainer )
610 135 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
611 270 : xListener );
612 135 : }
613 :
614 :
615 42 : void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership )
616 : throw ( util::CloseVetoException,
617 : uno::RuntimeException, std::exception )
618 : {
619 42 : ::osl::MutexGuard aGuard( m_aMutex );
620 42 : if ( m_bDisposed )
621 0 : throw lang::DisposedException(); // TODO
622 :
623 84 : uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
624 84 : lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
625 :
626 42 : if ( m_pInterfaceContainer )
627 : {
628 : ::cppu::OInterfaceContainerHelper* pContainer =
629 42 : m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
630 42 : if ( pContainer != NULL )
631 : {
632 42 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
633 84 : while (pIterator.hasMoreElements())
634 : {
635 : try
636 : {
637 4 : ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
638 : }
639 0 : catch( const uno::RuntimeException& )
640 : {
641 0 : pIterator.remove();
642 : }
643 42 : }
644 : }
645 :
646 : pContainer = m_pInterfaceContainer->getContainer(
647 38 : ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
648 38 : if ( pContainer != NULL )
649 : {
650 38 : ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
651 76 : while (pCloseIterator.hasMoreElements())
652 : {
653 : try
654 : {
655 0 : ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
656 : }
657 0 : catch( const uno::RuntimeException& )
658 : {
659 0 : pCloseIterator.remove();
660 : }
661 38 : }
662 : }
663 :
664 38 : m_pInterfaceContainer->disposeAndClear( aSource );
665 : }
666 :
667 80 : m_bDisposed = sal_True; // the object is disposed now for outside
668 38 : }
669 :
670 :
671 72 : void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
672 : throw ( uno::RuntimeException, std::exception )
673 : {
674 72 : ::osl::MutexGuard aGuard( m_aMutex );
675 72 : if ( m_bDisposed )
676 72 : return;
677 :
678 72 : if ( !m_pInterfaceContainer )
679 0 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
680 :
681 72 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
682 : }
683 :
684 :
685 72 : void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
686 : throw (uno::RuntimeException, std::exception)
687 : {
688 72 : ::osl::MutexGuard aGuard( m_aMutex );
689 72 : if ( m_pInterfaceContainer )
690 72 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
691 144 : xListener );
692 72 : }
693 :
694 :
695 76 : void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
696 : throw ( uno::RuntimeException, std::exception )
697 : {
698 76 : ::osl::MutexGuard aGuard( m_aMutex );
699 76 : if ( m_bDisposed )
700 76 : return;
701 :
702 76 : if ( !m_pInterfaceContainer )
703 0 : m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
704 :
705 76 : m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
706 : }
707 :
708 :
709 76 : void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
710 : throw ( uno::RuntimeException, std::exception )
711 : {
712 76 : ::osl::MutexGuard aGuard( m_aMutex );
713 76 : if ( m_pInterfaceContainer )
714 76 : m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
715 152 : xListener );
716 76 : }
717 :
718 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|