1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: embedobj.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_embeddedobj.hxx"
33 #include <com/sun/star/embed/EmbedStates.hpp>
34 #include <com/sun/star/embed/EmbedVerbs.hpp>
35 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
36 #include <com/sun/star/embed/XEmbeddedClient.hpp>
37 #include <com/sun/star/embed/XInplaceClient.hpp>
38 #include <com/sun/star/embed/XWindowSupplier.hpp>
39 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
40 #include <com/sun/star/embed/Aspects.hpp>
42 #include <com/sun/star/awt/XWindowPeer.hpp>
43 #include <com/sun/star/util/XCloseBroadcaster.hpp>
44 #include <com/sun/star/util/XCloseable.hpp>
45 #include <com/sun/star/util/XModifiable.hpp>
46 #include <com/sun/star/frame/XFrame.hpp>
47 #include <com/sun/star/frame/XComponentLoader.hpp>
48 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
49 #include <com/sun/star/frame/XModuleManager.hpp>
50 #include <com/sun/star/lang/DisposedException.hpp>
52 #include <com/sun/star/embed/EmbedMisc.hpp>
54 #include <rtl/logfile.hxx>
56 #include <targetstatecontrol.hxx>
58 #include "commonembobj.hxx"
59 #include "intercept.hxx"
62 using namespace ::com::sun::star
;
64 awt::Rectangle
GetRectangleInterception( const awt::Rectangle
& aRect1
, const awt::Rectangle
& aRect2
)
66 awt::Rectangle aResult
;
68 OSL_ENSURE( aRect1
.Width
>= 0 && aRect2
.Width
>= 0 && aRect1
.Height
>= 0 && aRect2
.Height
>= 0,
69 "Offset must not be less then zero!" );
71 aResult
.X
= aRect1
.X
> aRect2
.X
? aRect1
.X
: aRect2
.X
;
72 aResult
.Y
= aRect1
.Y
> aRect2
.Y
? aRect1
.Y
: aRect2
.Y
;
74 sal_Int32 nRight1
= aRect1
.X
+ aRect1
.Width
;
75 sal_Int32 nBottom1
= aRect1
.Y
+ aRect1
.Height
;
76 sal_Int32 nRight2
= aRect2
.X
+ aRect2
.Width
;
77 sal_Int32 nBottom2
= aRect2
.Y
+ aRect2
.Height
;
78 aResult
.Width
= ( nRight1
< nRight2
? nRight1
: nRight2
) - aResult
.X
;
79 aResult
.Height
= ( nBottom1
< nBottom2
? nBottom1
: nBottom2
) - aResult
.Y
;
84 //----------------------------------------------
85 sal_Int32
OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb
)
87 for ( sal_Int32 nInd
= 0; nInd
< m_aVerbTable
.getLength(); nInd
++ )
88 if ( m_aVerbTable
[nInd
][0] == nVerb
)
89 return m_aVerbTable
[nInd
][1];
91 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
94 //----------------------------------------------
95 void OCommonEmbeddedObject::Deactivate()
97 uno::Reference
< util::XModifiable
> xModif( m_pDocHolder
->GetComponent(), uno::UNO_QUERY
);
98 //MBA if ( !xModif.is() )
99 //MBA throw uno::RuntimeException();
101 // no need to lock for the initialization
102 uno::Reference
< embed::XEmbeddedClient
> xClientSite
= m_xClientSite
;
103 if ( !xClientSite
.is() )
104 throw embed::WrongStateException(); //TODO: client site is not set!
106 // store document if it is modified
107 if ( xModif
.is() && xModif
->isModified() )
110 xClientSite
->saveObject();
112 catch( embed::ObjectSaveVetoException
& )
115 catch( uno::Exception
& e
)
117 throw embed::StorageWrappedTargetException(
118 ::rtl::OUString::createFromAscii( "The client could not store the object!" ),
119 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >( this ) ),
124 m_pDocHolder
->CloseFrame();
126 xClientSite
->visibilityChanged( sal_False
);
129 //----------------------------------------------
130 void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange
, sal_Int32 nOldState
, sal_Int32 nNewState
,::osl::ResettableMutexGuard
& rGuard
)
132 if ( m_pInterfaceContainer
)
134 ::cppu::OInterfaceContainerHelper
* pContainer
= m_pInterfaceContainer
->getContainer(
135 ::getCppuType( ( const uno::Reference
< embed::XStateChangeListener
>*) NULL
) );
136 if ( pContainer
!= NULL
)
138 lang::EventObject
aSource( static_cast< ::cppu::OWeakObject
* >( this ) );
139 ::cppu::OInterfaceIteratorHelper
pIterator(*pContainer
);
141 // should be locked after the method is finished successfully
144 while (pIterator
.hasMoreElements())
149 ((embed::XStateChangeListener
*)pIterator
.next())->changingState( aSource
, nOldState
, nNewState
);
151 ((embed::XStateChangeListener
*)pIterator
.next())->stateChanged( aSource
, nOldState
, nNewState
);
153 catch( uno::Exception
& )
155 // even if the listener complains ignore it for now
167 //----------------------------------------------
168 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState
)
170 // TODO: may be needs interaction handler to detect wherether the object state
171 // can be changed even after errors
173 if ( m_nObjectState
== embed::EmbedStates::LOADED
)
175 if ( nNextState
== embed::EmbedStates::RUNNING
)
177 // after the object reaches the running state the cloned size is not necessary any more
178 m_bHasClonedSize
= sal_False
;
182 m_pDocHolder
->SetComponent( LoadLink_Impl(), m_bReadOnly
);
186 uno::Reference
< embed::XEmbedPersist
> xPersist( static_cast < embed::XClassifiedObject
* > (this), uno::UNO_QUERY
);
189 // in case embedded object is in loaded state the contents must
190 // be stored in the related storage and the storage
191 // must be created already
192 if ( !m_xObjectStorage
.is() )
193 throw io::IOException(); //TODO: access denied
195 m_pDocHolder
->SetComponent( LoadDocumentFromStorage_Impl( m_xObjectStorage
), m_bReadOnly
);
199 // objects without persistence will be initialized internally
200 uno::Sequence
< uno::Any
> aArgs(1);
201 aArgs
[0] <<= uno::Reference
< embed::XEmbeddedObject
>( this );
202 uno::Reference
< util::XCloseable
> xDocument(
203 m_xFactory
->createInstanceWithArguments( GetDocumentServiceName(), aArgs
), uno::UNO_QUERY
);
205 uno::Reference
< container::XChild
> xChild( xDocument
, uno::UNO_QUERY
);
207 xChild
->setParent( m_xParent
);
209 m_pDocHolder
->SetComponent( xDocument
, m_bReadOnly
);
213 if ( !m_pDocHolder
->GetComponent().is() )
214 throw embed::UnreachableStateException(); //TODO: can't open document
216 m_nObjectState
= nNextState
;
220 OSL_ENSURE( sal_False
, "Unacceptable state switch!\n" );
221 throw uno::RuntimeException(); // TODO
224 else if ( m_nObjectState
== embed::EmbedStates::RUNNING
)
226 if ( nNextState
== embed::EmbedStates::LOADED
)
228 m_nClonedMapUnit
= m_pDocHolder
->GetMapUnit( embed::Aspects::MSOLE_CONTENT
);
229 m_bHasClonedSize
= m_pDocHolder
->GetExtent( embed::Aspects::MSOLE_CONTENT
, &m_aClonedSize
);
231 // actually frame should not exist at this point
232 m_pDocHolder
->CloseDocument( sal_False
, sal_False
);
234 m_nObjectState
= nNextState
;
238 if ( nNextState
== embed::EmbedStates::INPLACE_ACTIVE
)
240 if ( !m_xClientSite
.is() )
241 throw embed::WrongStateException(); //TODO: client site is not set!
243 uno::Reference
< embed::XInplaceClient
> xInplaceClient( m_xClientSite
, uno::UNO_QUERY
);
244 if ( xInplaceClient
.is() && xInplaceClient
->canInplaceActivate() )
246 xInplaceClient
->activatingInplace();
248 uno::Reference
< embed::XWindowSupplier
> xClientWindowSupplier( xInplaceClient
, uno::UNO_QUERY
);
249 if ( !xClientWindowSupplier
.is() )
250 throw uno::RuntimeException(); // TODO: the inplace client implementation must support XWinSupp
252 m_xClientWindow
= xClientWindowSupplier
->getWindow();
253 m_aOwnRectangle
= xInplaceClient
->getPlacement();
254 m_aClipRectangle
= xInplaceClient
->getClipRectangle();
255 awt::Rectangle aRectangleToShow
= GetRectangleInterception( m_aOwnRectangle
, m_aClipRectangle
);
257 // create own window based on the client window
258 // place and resize the window according to the rectangles
259 uno::Reference
< awt::XWindowPeer
> xClientWindowPeer( m_xClientWindow
, uno::UNO_QUERY
);
260 if ( !xClientWindowPeer
.is() )
261 throw uno::RuntimeException(); // TODO: the container window must support the interface
263 // dispatch provider may not be provided
264 uno::Reference
< frame::XDispatchProvider
> xContainerDP
= xInplaceClient
->getInplaceDispatchProvider();
265 sal_Bool bOk
= m_pDocHolder
->ShowInplace( xClientWindowPeer
, aRectangleToShow
, xContainerDP
);
266 m_nObjectState
= nNextState
;
269 SwitchStateTo_Impl( embed::EmbedStates::RUNNING
);
270 throw embed::WrongStateException(); //TODO: can't activate inplace
274 throw embed::WrongStateException(); //TODO: can't activate inplace
276 else if ( nNextState
== embed::EmbedStates::ACTIVE
)
278 if ( !m_xClientSite
.is() )
279 throw embed::WrongStateException(); //TODO: client site is not set!
281 // create frame and load document in the frame
282 m_pDocHolder
->Show();
284 m_xClientSite
->visibilityChanged( sal_True
);
285 m_nObjectState
= nNextState
;
289 OSL_ENSURE( sal_False
, "Unacceptable state switch!\n" );
290 throw uno::RuntimeException(); // TODO
294 else if ( m_nObjectState
== embed::EmbedStates::INPLACE_ACTIVE
)
296 if ( nNextState
== embed::EmbedStates::RUNNING
)
298 uno::Reference
< embed::XInplaceClient
> xInplaceClient( m_xClientSite
, uno::UNO_QUERY
);
299 if ( !xInplaceClient
.is() )
300 throw uno::RuntimeException();
302 m_xClientSite
->visibilityChanged( sal_True
);
304 xInplaceClient
->deactivatedInplace();
306 m_nObjectState
= nNextState
;
308 else if ( nNextState
== embed::EmbedStates::UI_ACTIVE
)
310 if ( !(m_nMiscStatus
& embed::EmbedMisc::MS_EMBED_NOUIACTIVATE
) )
312 uno::Reference
< embed::XInplaceClient
> xInplaceClient( m_xClientSite
, uno::UNO_QUERY_THROW
);
314 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xContainerLM
=
315 xInplaceClient
->getLayoutManager();
316 if ( xContainerLM
.is() )
318 // dispatch provider may not be provided
319 uno::Reference
< frame::XDispatchProvider
> xContainerDP
= xInplaceClient
->getInplaceDispatchProvider();
321 // get the container module name
322 ::rtl::OUString aModuleName
;
325 uno::Reference
< embed::XComponentSupplier
> xCompSupl( m_xClientSite
, uno::UNO_QUERY_THROW
);
326 uno::Reference
< uno::XInterface
> xContDoc( xCompSupl
->getComponent(), uno::UNO_QUERY_THROW
);
328 uno::Reference
< frame::XModuleManager
> xManager(
329 m_xFactory
->createInstance(
330 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
331 uno::UNO_QUERY_THROW
);
333 aModuleName
= xManager
->identify( xContDoc
);
335 catch( uno::Exception
& )
338 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
339 // the container. Locking the LM will prevent flicker.
340 xContainerLM
->lock();
341 xInplaceClient
->activatingUI();
342 sal_Bool bOk
= m_pDocHolder
->ShowUI( xContainerLM
, xContainerDP
, aModuleName
);
343 xContainerLM
->unlock();
347 m_nObjectState
= nNextState
;
348 m_pDocHolder
->ResizeHatchWindow();
352 xInplaceClient
->deactivatedUI();
353 throw embed::WrongStateException(); //TODO: can't activate UI
357 throw embed::WrongStateException(); //TODO: can't activate UI
362 OSL_ENSURE( sal_False
, "Unacceptable state switch!\n" );
363 throw uno::RuntimeException(); // TODO
366 else if ( m_nObjectState
== embed::EmbedStates::ACTIVE
)
368 if ( nNextState
== embed::EmbedStates::RUNNING
)
371 m_nObjectState
= nNextState
;
375 OSL_ENSURE( sal_False
, "Unacceptable state switch!\n" );
376 throw uno::RuntimeException(); // TODO
379 else if ( m_nObjectState
== embed::EmbedStates::UI_ACTIVE
)
381 if ( nNextState
== embed::EmbedStates::INPLACE_ACTIVE
)
383 uno::Reference
< embed::XInplaceClient
> xInplaceClient( m_xClientSite
, uno::UNO_QUERY_THROW
);
384 uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xContainerLM
=
385 xInplaceClient
->getLayoutManager();
387 sal_Bool bOk
= sal_False
;
388 if ( xContainerLM
.is() )
389 bOk
= m_pDocHolder
->HideUI( xContainerLM
);
393 m_nObjectState
= nNextState
;
394 m_pDocHolder
->ResizeHatchWindow();
395 xInplaceClient
->deactivatedUI();
398 throw embed::WrongStateException(); //TODO: can't activate UI
402 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is in unacceptable state!\n" ),
403 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
406 //----------------------------------------------
407 uno::Sequence
< sal_Int32
> OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState
)
409 sal_Int32 nCurInd
= 0;
410 for ( nCurInd
= 0; nCurInd
< m_aAcceptedStates
.getLength(); nCurInd
++ )
411 if ( m_aAcceptedStates
[nCurInd
] == m_nObjectState
)
414 if ( nCurInd
== m_aAcceptedStates
.getLength() )
415 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is in unacceptable state!\n" ),
416 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
418 sal_Int32 nDestInd
= 0;
419 for ( nDestInd
= 0; nDestInd
< m_aAcceptedStates
.getLength(); nDestInd
++ )
420 if ( m_aAcceptedStates
[nDestInd
] == nNewState
)
423 if ( nDestInd
== m_aAcceptedStates
.getLength() )
424 throw embed::UnreachableStateException(
425 ::rtl::OUString::createFromAscii( "The state either not reachable, or the object allows the state only as an intermediate one!\n" ),
426 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ),
430 return m_pIntermediateStatesSeqs
[nCurInd
][nDestInd
];
433 //----------------------------------------------
434 void SAL_CALL
OCommonEmbeddedObject::changeState( sal_Int32 nNewState
)
435 throw ( embed::UnreachableStateException
,
436 embed::WrongStateException
,
438 uno::RuntimeException
)
440 RTL_LOGFILE_CONTEXT( aLog
, "embeddedobj (mv76033) OCommonEmbeddedObject::changeState" );
442 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >( this ), uno::UNO_QUERY
);
444 ::osl::ResettableMutexGuard
aGuard( m_aMutex
);
446 throw lang::DisposedException(); // TODO
448 if ( m_nObjectState
== -1 )
449 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
450 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
452 sal_Int32 nOldState
= m_nObjectState
;
454 if ( m_nTargetState
!= -1 )
456 // means that the object is currently trying to reach the target state
457 throw embed::StateChangeInProgressException( ::rtl::OUString(),
458 uno::Reference
< uno::XInterface
>(),
463 TargetStateControl_Impl
aControl( m_nTargetState
, nNewState
);
465 // in case the object is already in requested state
466 if ( m_nObjectState
== nNewState
)
468 // if active object is activated again, bring it's window to top
469 if ( m_nObjectState
== embed::EmbedStates::ACTIVE
)
470 m_pDocHolder
->Show();
475 // retrieve sequence of states that should be passed to reach desired state
476 uno::Sequence
< sal_Int32
> aIntermediateStates
= GetIntermediateStatesSequence_Impl( nNewState
);
478 // notify listeners that the object is going to change the state
479 StateChangeNotification_Impl( sal_True
, nOldState
, nNewState
,aGuard
);
482 for ( sal_Int32 nInd
= 0; nInd
< aIntermediateStates
.getLength(); nInd
++ )
483 SwitchStateTo_Impl( aIntermediateStates
[nInd
] );
485 SwitchStateTo_Impl( nNewState
);
487 catch( uno::Exception
& )
489 if ( nOldState
!= m_nObjectState
)
490 // notify listeners that the object has changed the state
491 StateChangeNotification_Impl( sal_False
, nOldState
, m_nObjectState
,aGuard
);
497 // notify listeners that the object has changed the state
498 StateChangeNotification_Impl( sal_False
, nOldState
, nNewState
,aGuard
);
502 //----------------------------------------------
503 uno::Sequence
< sal_Int32
> SAL_CALL
OCommonEmbeddedObject::getReachableStates()
504 throw ( embed::WrongStateException
,
505 uno::RuntimeException
)
507 ::osl::MutexGuard
aGuard( m_aMutex
);
509 throw lang::DisposedException(); // TODO
511 if ( m_nObjectState
== -1 )
512 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
513 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
515 return m_aAcceptedStates
;
518 //----------------------------------------------
519 sal_Int32 SAL_CALL
OCommonEmbeddedObject::getCurrentState()
520 throw ( embed::WrongStateException
,
521 uno::RuntimeException
)
523 ::osl::MutexGuard
aGuard( m_aMutex
);
525 throw lang::DisposedException(); // TODO
527 if ( m_nObjectState
== -1 )
528 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
529 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
531 return m_nObjectState
;
534 //----------------------------------------------
535 void SAL_CALL
OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID
)
536 throw ( lang::IllegalArgumentException
,
537 embed::WrongStateException
,
538 embed::UnreachableStateException
,
540 uno::RuntimeException
)
542 RTL_LOGFILE_CONTEXT( aLog
, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" );
544 ::osl::MutexGuard
aGuard( m_aMutex
);
546 throw lang::DisposedException(); // TODO
548 if ( m_nObjectState
== -1 )
549 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
550 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
552 // for internal documents this call is just a duplicate of changeState
553 sal_Int32 nNewState
= -1;
556 nNewState
= ConvertVerbToState_Impl( nVerbID
);
558 catch( uno::Exception
& )
561 if ( nNewState
== -1 )
563 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container
564 // TODO/LATER: check if the verb is a supported one and if it is produce related operation
567 changeState( nNewState
);
570 //----------------------------------------------
571 uno::Sequence
< embed::VerbDescriptor
> SAL_CALL
OCommonEmbeddedObject::getSupportedVerbs()
572 throw ( embed::WrongStateException
,
573 uno::RuntimeException
)
575 ::osl::MutexGuard
aGuard( m_aMutex
);
577 throw lang::DisposedException(); // TODO
579 if ( m_nObjectState
== -1 )
580 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
581 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
583 return m_aObjectVerbs
;
586 //----------------------------------------------
587 void SAL_CALL
OCommonEmbeddedObject::setClientSite(
588 const uno::Reference
< embed::XEmbeddedClient
>& xClient
)
589 throw ( embed::WrongStateException
,
590 uno::RuntimeException
)
592 ::osl::MutexGuard
aGuard( m_aMutex
);
594 throw lang::DisposedException(); // TODO
596 if ( m_xClientSite
!= xClient
)
598 if ( m_nObjectState
!= embed::EmbedStates::LOADED
&& m_nObjectState
!= embed::EmbedStates::RUNNING
)
599 throw embed::WrongStateException(
600 ::rtl::OUString::createFromAscii( "The client site can not be set currently!\n" ),
601 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
603 m_xClientSite
= xClient
;
607 //----------------------------------------------
608 uno::Reference
< embed::XEmbeddedClient
> SAL_CALL
OCommonEmbeddedObject::getClientSite()
609 throw ( embed::WrongStateException
,
610 uno::RuntimeException
)
612 ::osl::MutexGuard
aGuard( m_aMutex
);
614 throw lang::DisposedException(); // TODO
616 if ( m_nObjectState
== -1 )
617 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
618 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
620 return m_xClientSite
;
623 //----------------------------------------------
624 void SAL_CALL
OCommonEmbeddedObject::update()
625 throw ( embed::WrongStateException
,
627 uno::RuntimeException
)
629 ::osl::MutexGuard
aGuard( m_aMutex
);
631 throw lang::DisposedException(); // TODO
633 if ( m_nObjectState
== -1 )
634 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
635 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
637 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ),
638 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
641 //----------------------------------------------
642 void SAL_CALL
OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode
)
643 throw ( embed::WrongStateException
,
644 uno::RuntimeException
)
646 ::osl::MutexGuard
aGuard( m_aMutex
);
648 throw lang::DisposedException(); // TODO
650 if ( m_nObjectState
== -1 )
651 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ),
652 uno::Reference
< uno::XInterface
>( static_cast< ::cppu::OWeakObject
* >(this) ) );
654 OSL_ENSURE( nMode
== embed::EmbedUpdateModes::ALWAYS_UPDATE
655 || nMode
== embed::EmbedUpdateModes::EXPLICIT_UPDATE
,
656 "Unknown update mode!\n" );
657 m_nUpdateMode
= nMode
;
660 //----------------------------------------------
661 sal_Int64 SAL_CALL
OCommonEmbeddedObject::getStatus( sal_Int64
)
662 throw ( embed::WrongStateException
,
663 uno::RuntimeException
)
665 ::osl::MutexGuard
aGuard( m_aMutex
);
667 throw lang::DisposedException(); // TODO
669 return m_nMiscStatus
;
672 //----------------------------------------------
673 void SAL_CALL
OCommonEmbeddedObject::setContainerName( const ::rtl::OUString
& sName
)
674 throw ( uno::RuntimeException
)
676 ::osl::MutexGuard
aGuard( m_aMutex
);
678 throw lang::DisposedException(); // TODO
680 m_aContainerName
= sName
;
683 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> SAL_CALL
OCommonEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException
)
688 void SAL_CALL
OCommonEmbeddedObject::setParent( const com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>& xParent
) throw (::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
)
691 if ( m_nObjectState
!= -1 && m_nObjectState
!= embed::EmbedStates::LOADED
)
693 uno::Reference
< container::XChild
> xChild( m_pDocHolder
->GetComponent(), uno::UNO_QUERY
);
695 xChild
->setParent( xParent
);