Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / embeddedobj / source / commonembedding / embedobj.cxx
blob337b01beb12d4e7b1629a07774ed0c7368e620e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/embed/EmbedStates.hpp>
30 #include <com/sun/star/embed/EmbedVerbs.hpp>
31 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
32 #include <com/sun/star/embed/XEmbeddedClient.hpp>
33 #include <com/sun/star/embed/XInplaceClient.hpp>
34 #include <com/sun/star/embed/XWindowSupplier.hpp>
35 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
36 #include <com/sun/star/embed/Aspects.hpp>
38 #include <com/sun/star/awt/XWindowPeer.hpp>
39 #include <com/sun/star/util/XCloseBroadcaster.hpp>
40 #include <com/sun/star/util/XCloseable.hpp>
41 #include <com/sun/star/util/XModifiable.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/frame/XComponentLoader.hpp>
44 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
45 #include <com/sun/star/frame/XModuleManager.hpp>
46 #include <com/sun/star/lang/DisposedException.hpp>
48 #include <com/sun/star/embed/EmbedMisc.hpp>
50 #include <rtl/logfile.hxx>
52 #include <targetstatecontrol.hxx>
54 #include "commonembobj.hxx"
55 #include "intercept.hxx"
58 using namespace ::com::sun::star;
60 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
62 awt::Rectangle aResult;
64 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
65 "Offset must not be less then zero!" );
67 aResult.X = aRect1.X > aRect2.X ? aRect1.X : aRect2.X;
68 aResult.Y = aRect1.Y > aRect2.Y ? aRect1.Y : aRect2.Y;
70 sal_Int32 nRight1 = aRect1.X + aRect1.Width;
71 sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
72 sal_Int32 nRight2 = aRect2.X + aRect2.Width;
73 sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
74 aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X;
75 aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y;
77 return aResult;
80 //----------------------------------------------
81 sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb )
83 for ( sal_Int32 nInd = 0; nInd < m_aVerbTable.getLength(); nInd++ )
84 if ( m_aVerbTable[nInd][0] == nVerb )
85 return m_aVerbTable[nInd][1];
87 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
90 //----------------------------------------------
91 void OCommonEmbeddedObject::Deactivate()
93 uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
95 // no need to lock for the initialization
96 uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite;
97 if ( !xClientSite.is() )
98 throw embed::WrongStateException(); //TODO: client site is not set!
100 // store document if it is modified
101 if ( xModif.is() && xModif->isModified() )
103 try {
104 xClientSite->saveObject();
106 catch( const embed::ObjectSaveVetoException& )
109 catch( const uno::Exception& e )
111 throw embed::StorageWrappedTargetException(
112 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The client could not store the object!" )),
113 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ),
114 uno::makeAny( e ) );
118 m_pDocHolder->CloseFrame();
120 xClientSite->visibilityChanged( sal_False );
123 //----------------------------------------------
124 void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
126 if ( m_pInterfaceContainer )
128 ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer(
129 ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) );
130 if ( pContainer != NULL )
132 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
133 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
135 // should be locked after the method is finished successfully
136 rGuard.clear();
138 while (pIterator.hasMoreElements())
142 if ( bBeforeChange )
143 ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState );
144 else
145 ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState );
147 catch( const uno::Exception& )
149 // even if the listener complains ignore it for now
152 if ( m_bDisposed )
153 return;
156 rGuard.reset();
161 //----------------------------------------------
162 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
164 // TODO: may be needs interaction handler to detect wherether the object state
165 // can be changed even after errors
167 if ( m_nObjectState == embed::EmbedStates::LOADED )
169 if ( nNextState == embed::EmbedStates::RUNNING )
171 // after the object reaches the running state the cloned size is not necessary any more
172 m_bHasClonedSize = sal_False;
174 if ( m_bIsLink )
176 m_pDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
178 else
180 uno::Reference < embed::XEmbedPersist > xPersist( static_cast < embed::XClassifiedObject* > (this), uno::UNO_QUERY );
181 if ( xPersist.is() )
183 // in case embedded object is in loaded state the contents must
184 // be stored in the related storage and the storage
185 // must be created already
186 if ( !m_xObjectStorage.is() )
187 throw io::IOException(); //TODO: access denied
189 m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly );
191 else
193 // objects without persistence will be initialized internally
194 uno::Sequence < uno::Any > aArgs(1);
195 aArgs[0] <<= uno::Reference < embed::XEmbeddedObject >( this );
196 uno::Reference< util::XCloseable > xDocument(
197 m_xFactory->createInstanceWithArguments( GetDocumentServiceName(), aArgs ), uno::UNO_QUERY );
199 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
200 if ( xChild.is() )
201 xChild->setParent( m_xParent );
203 m_pDocHolder->SetComponent( xDocument, m_bReadOnly );
207 if ( !m_pDocHolder->GetComponent().is() )
208 throw embed::UnreachableStateException(); //TODO: can't open document
210 m_nObjectState = nNextState;
212 else
214 OSL_FAIL( "Unacceptable state switch!\n" );
215 throw uno::RuntimeException(); // TODO
218 else if ( m_nObjectState == embed::EmbedStates::RUNNING )
220 if ( nNextState == embed::EmbedStates::LOADED )
222 m_nClonedMapUnit = m_pDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
223 m_bHasClonedSize = m_pDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
225 // actually frame should not exist at this point
226 m_pDocHolder->CloseDocument( sal_False, sal_False );
228 m_nObjectState = nNextState;
230 else
232 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
234 if ( !m_xClientSite.is() )
235 throw embed::WrongStateException(
236 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "client site not set, yet" ) ),
237 *this
240 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
241 if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() )
243 xInplaceClient->activatingInplace();
245 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY );
246 if ( !xClientWindowSupplier.is() )
247 throw uno::RuntimeException(); // TODO: the inplace client implementation must support XWinSupp
249 m_xClientWindow = xClientWindowSupplier->getWindow();
250 m_aOwnRectangle = xInplaceClient->getPlacement();
251 m_aClipRectangle = xInplaceClient->getClipRectangle();
252 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
254 // create own window based on the client window
255 // place and resize the window according to the rectangles
256 uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY );
257 if ( !xClientWindowPeer.is() )
258 throw uno::RuntimeException(); // TODO: the container window must support the interface
260 // dispatch provider may not be provided
261 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
262 sal_Bool bOk = m_pDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
263 m_nObjectState = nNextState;
264 if ( !bOk )
266 SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
267 throw embed::WrongStateException(); //TODO: can't activate inplace
270 else
271 throw embed::WrongStateException(); //TODO: can't activate inplace
273 else if ( nNextState == embed::EmbedStates::ACTIVE )
275 if ( !m_xClientSite.is() )
276 throw embed::WrongStateException(); //TODO: client site is not set!
278 // create frame and load document in the frame
279 m_pDocHolder->Show();
281 m_xClientSite->visibilityChanged( sal_True );
282 m_nObjectState = nNextState;
284 else
286 OSL_FAIL( "Unacceptable state switch!\n" );
287 throw uno::RuntimeException(); // TODO
291 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
293 if ( nNextState == embed::EmbedStates::RUNNING )
295 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
296 if ( !xInplaceClient.is() )
297 throw uno::RuntimeException();
299 m_xClientSite->visibilityChanged( sal_True );
301 xInplaceClient->deactivatedInplace();
302 Deactivate();
303 m_nObjectState = nNextState;
305 else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
307 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
309 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
310 // TODO:
311 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
312 xInplaceClient->getLayoutManager();
313 if ( xContainerLM.is() )
315 // dispatch provider may not be provided
316 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
318 // get the container module name
319 ::rtl::OUString aModuleName;
322 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
323 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
325 uno::Reference< frame::XModuleManager > xManager(
326 m_xFactory->createInstance(
327 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ),
328 uno::UNO_QUERY_THROW );
330 aModuleName = xManager->identify( xContDoc );
332 catch( const uno::Exception& )
335 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
336 // the container. Locking the LM will prevent flicker.
337 xContainerLM->lock();
338 xInplaceClient->activatingUI();
339 sal_Bool bOk = m_pDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
340 xContainerLM->unlock();
342 if ( bOk )
344 m_nObjectState = nNextState;
345 m_pDocHolder->ResizeHatchWindow();
347 else
349 xInplaceClient->deactivatedUI();
350 throw embed::WrongStateException(); //TODO: can't activate UI
353 else
354 throw embed::WrongStateException(); //TODO: can't activate UI
357 else
359 OSL_FAIL( "Unacceptable state switch!\n" );
360 throw uno::RuntimeException(); // TODO
363 else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
365 if ( nNextState == embed::EmbedStates::RUNNING )
367 Deactivate();
368 m_nObjectState = nNextState;
370 else
372 OSL_FAIL( "Unacceptable state switch!\n" );
373 throw uno::RuntimeException(); // TODO
376 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
378 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
380 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
381 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
382 xInplaceClient->getLayoutManager();
384 sal_Bool bOk = sal_False;
385 if ( xContainerLM.is() )
386 bOk = m_pDocHolder->HideUI( xContainerLM );
388 if ( bOk )
390 m_nObjectState = nNextState;
391 m_pDocHolder->ResizeHatchWindow();
392 xInplaceClient->deactivatedUI();
394 else
395 throw embed::WrongStateException(); //TODO: can't activate UI
398 else
399 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object is in unacceptable state!\n" )),
400 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
403 //----------------------------------------------
404 uno::Sequence< sal_Int32 > OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
406 sal_Int32 nCurInd = 0;
407 for ( nCurInd = 0; nCurInd < m_aAcceptedStates.getLength(); nCurInd++ )
408 if ( m_aAcceptedStates[nCurInd] == m_nObjectState )
409 break;
411 if ( nCurInd == m_aAcceptedStates.getLength() )
412 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object is in unacceptable state!\n" )),
413 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
415 sal_Int32 nDestInd = 0;
416 for ( nDestInd = 0; nDestInd < m_aAcceptedStates.getLength(); nDestInd++ )
417 if ( m_aAcceptedStates[nDestInd] == nNewState )
418 break;
420 if ( nDestInd == m_aAcceptedStates.getLength() )
421 throw embed::UnreachableStateException(
422 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The state either not reachable, or the object allows the state only as an intermediate one!\n" )),
423 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
424 m_nObjectState,
425 nNewState );
427 return m_pIntermediateStatesSeqs[nCurInd][nDestInd];
430 //----------------------------------------------
431 void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
432 throw ( embed::UnreachableStateException,
433 embed::WrongStateException,
434 uno::Exception,
435 uno::RuntimeException )
437 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::changeState" );
439 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY);
441 ::osl::ResettableMutexGuard aGuard( m_aMutex );
442 if ( m_bDisposed )
443 throw lang::DisposedException(); // TODO
445 if ( m_nObjectState == -1 )
446 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
447 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
449 sal_Int32 nOldState = m_nObjectState;
451 if ( m_nTargetState != -1 )
453 // means that the object is currently trying to reach the target state
454 throw embed::StateChangeInProgressException( ::rtl::OUString(),
455 uno::Reference< uno::XInterface >(),
456 m_nTargetState );
458 else
460 TargetStateControl_Impl aControl( m_nTargetState, nNewState );
462 // in case the object is already in requested state
463 if ( m_nObjectState == nNewState )
465 // if active object is activated again, bring it's window to top
466 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
467 m_pDocHolder->Show();
469 return;
472 // retrieve sequence of states that should be passed to reach desired state
473 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
475 // notify listeners that the object is going to change the state
476 StateChangeNotification_Impl( sal_True, nOldState, nNewState,aGuard );
478 try {
479 for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ )
480 SwitchStateTo_Impl( aIntermediateStates[nInd] );
482 SwitchStateTo_Impl( nNewState );
484 catch( const uno::Exception& )
486 if ( nOldState != m_nObjectState )
487 // notify listeners that the object has changed the state
488 StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState, aGuard );
490 throw;
494 // notify listeners that the object has changed the state
495 StateChangeNotification_Impl( sal_False, nOldState, nNewState, aGuard );
497 // let the object window be shown
498 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
499 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ) );
503 //----------------------------------------------
504 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
505 throw ( embed::WrongStateException,
506 uno::RuntimeException )
508 if ( m_bDisposed )
509 throw lang::DisposedException(); // TODO
511 if ( m_nObjectState == -1 )
512 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "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 if ( m_bDisposed )
524 throw lang::DisposedException(); // TODO
526 if ( m_nObjectState == -1 )
527 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
528 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
530 return m_nObjectState;
533 //----------------------------------------------
534 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
535 throw ( lang::IllegalArgumentException,
536 embed::WrongStateException,
537 embed::UnreachableStateException,
538 uno::Exception,
539 uno::RuntimeException )
541 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" );
543 ::osl::ResettableMutexGuard aGuard( m_aMutex );
544 if ( m_bDisposed )
545 throw lang::DisposedException(); // TODO
547 if ( m_nObjectState == -1 )
548 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
549 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
551 // for internal documents this call is just a duplicate of changeState
552 sal_Int32 nNewState = -1;
555 nNewState = ConvertVerbToState_Impl( nVerbID );
557 catch( const uno::Exception& )
560 if ( nNewState == -1 )
562 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container
563 // TODO/LATER: check if the verb is a supported one and if it is produce related operation
565 else
567 aGuard.clear();
568 changeState( nNewState );
572 //----------------------------------------------
573 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
574 throw ( embed::WrongStateException,
575 uno::RuntimeException )
577 if ( m_bDisposed )
578 throw lang::DisposedException(); // TODO
580 if ( m_nObjectState == -1 )
581 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
582 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
584 return m_aObjectVerbs;
587 //----------------------------------------------
588 void SAL_CALL OCommonEmbeddedObject::setClientSite(
589 const uno::Reference< embed::XEmbeddedClient >& xClient )
590 throw ( embed::WrongStateException,
591 uno::RuntimeException )
593 ::osl::MutexGuard aGuard( m_aMutex );
594 if ( m_bDisposed )
595 throw lang::DisposedException(); // TODO
597 if ( m_xClientSite != xClient)
599 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
600 throw embed::WrongStateException(
601 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The client site can not be set currently!\n" )),
602 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
604 m_xClientSite = xClient;
608 //----------------------------------------------
609 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
610 throw ( embed::WrongStateException,
611 uno::RuntimeException )
613 if ( m_bDisposed )
614 throw lang::DisposedException(); // TODO
616 if ( m_nObjectState == -1 )
617 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "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,
626 uno::Exception,
627 uno::RuntimeException )
629 ::osl::MutexGuard aGuard( m_aMutex );
630 if ( m_bDisposed )
631 throw lang::DisposedException(); // TODO
633 if ( m_nObjectState == -1 )
634 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "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" ) ) );
640 //----------------------------------------------
641 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
642 throw ( embed::WrongStateException,
643 uno::RuntimeException )
645 ::osl::MutexGuard aGuard( m_aMutex );
646 if ( m_bDisposed )
647 throw lang::DisposedException(); // TODO
649 if ( m_nObjectState == -1 )
650 throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
651 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
653 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
654 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
655 "Unknown update mode!\n" );
656 m_nUpdateMode = nMode;
659 //----------------------------------------------
660 sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 )
661 throw ( embed::WrongStateException,
662 uno::RuntimeException )
664 if ( m_bDisposed )
665 throw lang::DisposedException(); // TODO
667 return m_nMiscStatus;
670 //----------------------------------------------
671 void SAL_CALL OCommonEmbeddedObject::setContainerName( const ::rtl::OUString& sName )
672 throw ( uno::RuntimeException )
674 ::osl::MutexGuard aGuard( m_aMutex );
675 if ( m_bDisposed )
676 throw lang::DisposedException(); // TODO
678 m_aContainerName = sName;
681 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException)
683 return m_xParent;
686 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)
688 m_xParent = xParent;
689 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
691 uno::Reference < container::XChild > xChild( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
692 if ( xChild.is() )
693 xChild->setParent( xParent );
697 // XDefaultSizeTransmitter
698 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException)
700 //#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method
701 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM;
704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */