bump product version to 4.1.6.2
[LibreOffice.git] / embeddedobj / source / commonembedding / embedobj.cxx
blob24a7850427cac881c4e1183456e275b669c0b84d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 #include <com/sun/star/awt/XWindowPeer.hpp>
30 #include <com/sun/star/util/XCloseBroadcaster.hpp>
31 #include <com/sun/star/util/XCloseable.hpp>
32 #include <com/sun/star/util/XModifiable.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
34 #include <com/sun/star/frame/XComponentLoader.hpp>
35 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
36 #include <com/sun/star/frame/ModuleManager.hpp>
37 #include <com/sun/star/lang/DisposedException.hpp>
39 #include <com/sun/star/embed/EmbedMisc.hpp>
40 #include <comphelper/processfactory.hxx>
42 #include <rtl/logfile.hxx>
43 #include <vcl/svapp.hxx>
45 #include <targetstatecontrol.hxx>
47 #include "commonembobj.hxx"
48 #include "intercept.hxx"
51 using namespace ::com::sun::star;
53 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
55 awt::Rectangle aResult;
57 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
58 "Offset must not be less then zero!" );
60 aResult.X = aRect1.X > aRect2.X ? aRect1.X : aRect2.X;
61 aResult.Y = aRect1.Y > aRect2.Y ? aRect1.Y : aRect2.Y;
63 sal_Int32 nRight1 = aRect1.X + aRect1.Width;
64 sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
65 sal_Int32 nRight2 = aRect2.X + aRect2.Width;
66 sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
67 aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X;
68 aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y;
70 return aResult;
73 //----------------------------------------------
74 sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb )
76 for ( sal_Int32 nInd = 0; nInd < m_aVerbTable.getLength(); nInd++ )
77 if ( m_aVerbTable[nInd][0] == nVerb )
78 return m_aVerbTable[nInd][1];
80 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
83 //----------------------------------------------
84 void OCommonEmbeddedObject::Deactivate()
86 uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
88 // no need to lock for the initialization
89 uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite;
90 if ( !xClientSite.is() )
91 throw embed::WrongStateException(); //TODO: client site is not set!
93 // store document if it is modified
94 if ( xModif.is() && xModif->isModified() )
96 try {
97 xClientSite->saveObject();
99 catch( const embed::ObjectSaveVetoException& )
102 catch( const uno::Exception& e )
104 throw embed::StorageWrappedTargetException(
105 OUString( "The client could not store the object!" ),
106 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ),
107 uno::makeAny( e ) );
111 m_pDocHolder->CloseFrame();
113 xClientSite->visibilityChanged( sal_False );
116 //----------------------------------------------
117 void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
119 if ( m_pInterfaceContainer )
121 ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer(
122 ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) );
123 if ( pContainer != NULL )
125 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
126 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
128 // should be locked after the method is finished successfully
129 rGuard.clear();
131 while (pIterator.hasMoreElements())
135 if ( bBeforeChange )
136 ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState );
137 else
138 ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState );
140 catch( const uno::Exception& )
142 // even if the listener complains ignore it for now
145 if ( m_bDisposed )
146 return;
149 rGuard.reset();
154 //----------------------------------------------
155 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
157 // TODO: may be needs interaction handler to detect wherether the object state
158 // can be changed even after errors
160 if ( m_nObjectState == embed::EmbedStates::LOADED )
162 if ( nNextState == embed::EmbedStates::RUNNING )
164 // after the object reaches the running state the cloned size is not necessary any more
165 m_bHasClonedSize = sal_False;
167 if ( m_bIsLink )
169 m_pDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
171 else
173 uno::Reference < embed::XEmbedPersist > xPersist( static_cast < embed::XClassifiedObject* > (this), uno::UNO_QUERY );
174 if ( xPersist.is() )
176 // in case embedded object is in loaded state the contents must
177 // be stored in the related storage and the storage
178 // must be created already
179 if ( !m_xObjectStorage.is() )
180 throw io::IOException(); //TODO: access denied
182 m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly );
184 else
186 // objects without persistence will be initialized internally
187 uno::Sequence < uno::Any > aArgs(1);
188 aArgs[0] <<= uno::Reference < embed::XEmbeddedObject >( this );
189 uno::Reference< util::XCloseable > xDocument(
190 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( GetDocumentServiceName(), aArgs, m_xContext),
191 uno::UNO_QUERY );
193 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
194 if ( xChild.is() )
195 xChild->setParent( m_xParent );
197 m_pDocHolder->SetComponent( xDocument, m_bReadOnly );
201 if ( !m_pDocHolder->GetComponent().is() )
202 throw embed::UnreachableStateException(); //TODO: can't open document
204 m_nObjectState = nNextState;
206 else
208 OSL_FAIL( "Unacceptable state switch!\n" );
209 throw uno::RuntimeException(); // TODO
212 else if ( m_nObjectState == embed::EmbedStates::RUNNING )
214 if ( nNextState == embed::EmbedStates::LOADED )
216 m_nClonedMapUnit = m_pDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
217 m_bHasClonedSize = m_pDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
219 // actually frame should not exist at this point
220 m_pDocHolder->CloseDocument( sal_False, sal_False );
222 m_nObjectState = nNextState;
224 else
226 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
228 if ( !m_xClientSite.is() )
229 throw embed::WrongStateException(
230 OUString( "client site not set, yet" ),
231 *this
234 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
235 if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() )
237 xInplaceClient->activatingInplace();
239 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY );
240 if ( !xClientWindowSupplier.is() )
241 throw uno::RuntimeException(); // TODO: the inplace client implementation must support XWinSupp
243 m_xClientWindow = xClientWindowSupplier->getWindow();
244 m_aOwnRectangle = xInplaceClient->getPlacement();
245 m_aClipRectangle = xInplaceClient->getClipRectangle();
246 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
248 // create own window based on the client window
249 // place and resize the window according to the rectangles
250 uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY );
251 if ( !xClientWindowPeer.is() )
252 throw uno::RuntimeException(); // TODO: the container window must support the interface
254 // dispatch provider may not be provided
255 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
256 sal_Bool bOk = m_pDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
257 m_nObjectState = nNextState;
258 if ( !bOk )
260 SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
261 throw embed::WrongStateException(); //TODO: can't activate inplace
264 else
265 throw embed::WrongStateException(); //TODO: can't activate inplace
267 else if ( nNextState == embed::EmbedStates::ACTIVE )
269 if ( !m_xClientSite.is() )
270 throw embed::WrongStateException(); //TODO: client site is not set!
272 // create frame and load document in the frame
273 m_pDocHolder->Show();
275 m_xClientSite->visibilityChanged( sal_True );
276 m_nObjectState = nNextState;
278 else
280 OSL_FAIL( "Unacceptable state switch!\n" );
281 throw uno::RuntimeException(); // TODO
285 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
287 if ( nNextState == embed::EmbedStates::RUNNING )
289 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
290 if ( !xInplaceClient.is() )
291 throw uno::RuntimeException();
293 m_xClientSite->visibilityChanged( sal_True );
295 xInplaceClient->deactivatedInplace();
296 Deactivate();
297 m_nObjectState = nNextState;
299 else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
301 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
303 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
304 // TODO:
305 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
306 xInplaceClient->getLayoutManager();
307 if ( xContainerLM.is() )
309 // dispatch provider may not be provided
310 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
312 // get the container module name
313 OUString aModuleName;
316 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
317 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
319 uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
321 aModuleName = xManager->identify( xContDoc );
323 catch( const uno::Exception& )
326 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
327 // the container. Locking the LM will prevent flicker.
328 xContainerLM->lock();
329 xInplaceClient->activatingUI();
330 sal_Bool bOk = m_pDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
331 xContainerLM->unlock();
333 if ( bOk )
335 m_nObjectState = nNextState;
336 m_pDocHolder->ResizeHatchWindow();
338 else
340 xInplaceClient->deactivatedUI();
341 throw embed::WrongStateException(); //TODO: can't activate UI
344 else
345 throw embed::WrongStateException(); //TODO: can't activate UI
348 else
350 OSL_FAIL( "Unacceptable state switch!\n" );
351 throw uno::RuntimeException(); // TODO
354 else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
356 if ( nNextState == embed::EmbedStates::RUNNING )
358 Deactivate();
359 m_nObjectState = nNextState;
361 else
363 OSL_FAIL( "Unacceptable state switch!\n" );
364 throw uno::RuntimeException(); // TODO
367 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
369 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
371 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
372 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
373 xInplaceClient->getLayoutManager();
375 sal_Bool bOk = sal_False;
376 if ( xContainerLM.is() )
377 bOk = m_pDocHolder->HideUI( xContainerLM );
379 if ( bOk )
381 m_nObjectState = nNextState;
382 m_pDocHolder->ResizeHatchWindow();
383 xInplaceClient->deactivatedUI();
385 else
386 throw embed::WrongStateException(); //TODO: can't activate UI
389 else
390 throw embed::WrongStateException( OUString( "The object is in unacceptable state!\n" ),
391 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
394 //----------------------------------------------
395 uno::Sequence< sal_Int32 > OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
397 sal_Int32 nCurInd = 0;
398 for ( nCurInd = 0; nCurInd < m_aAcceptedStates.getLength(); nCurInd++ )
399 if ( m_aAcceptedStates[nCurInd] == m_nObjectState )
400 break;
402 if ( nCurInd == m_aAcceptedStates.getLength() )
403 throw embed::WrongStateException( OUString( "The object is in unacceptable state!\n" ),
404 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
406 sal_Int32 nDestInd = 0;
407 for ( nDestInd = 0; nDestInd < m_aAcceptedStates.getLength(); nDestInd++ )
408 if ( m_aAcceptedStates[nDestInd] == nNewState )
409 break;
411 if ( nDestInd == m_aAcceptedStates.getLength() )
412 throw embed::UnreachableStateException(
413 OUString( "The state either not reachable, or the object allows the state only as an intermediate one!\n" ),
414 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
415 m_nObjectState,
416 nNewState );
418 return m_pIntermediateStatesSeqs[nCurInd][nDestInd];
421 //----------------------------------------------
422 void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
423 throw ( embed::UnreachableStateException,
424 embed::WrongStateException,
425 uno::Exception,
426 uno::RuntimeException )
428 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::changeState" );
430 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY);
432 ::osl::ResettableMutexGuard aGuard( m_aMutex );
433 if ( m_bDisposed )
434 throw lang::DisposedException(); // TODO
436 if ( m_nObjectState == -1 )
437 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
438 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
440 sal_Int32 nOldState = m_nObjectState;
442 if ( m_nTargetState != -1 )
444 // means that the object is currently trying to reach the target state
445 throw embed::StateChangeInProgressException( OUString(),
446 uno::Reference< uno::XInterface >(),
447 m_nTargetState );
449 else
451 TargetStateControl_Impl aControl( m_nTargetState, nNewState );
453 // in case the object is already in requested state
454 if ( m_nObjectState == nNewState )
456 // if active object is activated again, bring it's window to top
457 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
458 m_pDocHolder->Show();
460 return;
463 // retrieve sequence of states that should be passed to reach desired state
464 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
466 // notify listeners that the object is going to change the state
467 StateChangeNotification_Impl( sal_True, nOldState, nNewState,aGuard );
469 try {
470 for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ )
471 SwitchStateTo_Impl( aIntermediateStates[nInd] );
473 SwitchStateTo_Impl( nNewState );
475 catch( const uno::Exception& )
477 if ( nOldState != m_nObjectState )
478 // notify listeners that the object has changed the state
479 StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState, aGuard );
481 throw;
485 // notify listeners that the object has changed the state
486 StateChangeNotification_Impl( sal_False, nOldState, nNewState, aGuard );
488 // let the object window be shown
489 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
490 PostEvent_Impl( OUString( "OnVisAreaChanged" ) );
494 //----------------------------------------------
495 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
496 throw ( embed::WrongStateException,
497 uno::RuntimeException )
499 if ( m_bDisposed )
500 throw lang::DisposedException(); // TODO
502 if ( m_nObjectState == -1 )
503 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
504 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
506 return m_aAcceptedStates;
509 //----------------------------------------------
510 sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState()
511 throw ( embed::WrongStateException,
512 uno::RuntimeException )
514 if ( m_bDisposed )
515 throw lang::DisposedException(); // TODO
517 if ( m_nObjectState == -1 )
518 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
519 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
521 return m_nObjectState;
524 //----------------------------------------------
525 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
526 throw ( lang::IllegalArgumentException,
527 embed::WrongStateException,
528 embed::UnreachableStateException,
529 uno::Exception,
530 uno::RuntimeException )
532 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" );
534 SolarMutexGuard aSolarGuard;
535 //TODO: a gross hack to avoid deadlocks when this is called from the
536 // outside and OCommonEmbeddedObject::changeState, with m_aMutex locked,
537 // calls into framework code that tries to lock the solar mutex, while
538 // another thread (through Window::ImplCallPaint, say) calls
539 // OCommonEmbeddedObject::getComponent with the solar mutex locked and
540 // then tries to lock m_aMutex (see fdo#56818); the alternative would be
541 // to get locking done right in this class, but that looks like a
542 // daunting task
544 ::osl::ResettableMutexGuard aGuard( m_aMutex );
545 if ( m_bDisposed )
546 throw lang::DisposedException(); // TODO
548 if ( m_nObjectState == -1 )
549 throw embed::WrongStateException( OUString( "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( const 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
566 else
568 aGuard.clear();
569 changeState( nNewState );
573 //----------------------------------------------
574 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
575 throw ( embed::WrongStateException,
576 uno::RuntimeException )
578 if ( m_bDisposed )
579 throw lang::DisposedException(); // TODO
581 if ( m_nObjectState == -1 )
582 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
583 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
585 return m_aObjectVerbs;
588 //----------------------------------------------
589 void SAL_CALL OCommonEmbeddedObject::setClientSite(
590 const uno::Reference< embed::XEmbeddedClient >& xClient )
591 throw ( embed::WrongStateException,
592 uno::RuntimeException )
594 ::osl::MutexGuard aGuard( m_aMutex );
595 if ( m_bDisposed )
596 throw lang::DisposedException(); // TODO
598 if ( m_xClientSite != xClient)
600 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
601 throw embed::WrongStateException(
602 OUString( "The client site can not be set currently!\n" ),
603 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
605 m_xClientSite = xClient;
609 //----------------------------------------------
610 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
611 throw ( embed::WrongStateException,
612 uno::RuntimeException )
614 if ( m_bDisposed )
615 throw lang::DisposedException(); // TODO
617 if ( m_nObjectState == -1 )
618 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
619 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
621 return m_xClientSite;
624 //----------------------------------------------
625 void SAL_CALL OCommonEmbeddedObject::update()
626 throw ( embed::WrongStateException,
627 uno::Exception,
628 uno::RuntimeException )
630 ::osl::MutexGuard aGuard( m_aMutex );
631 if ( m_bDisposed )
632 throw lang::DisposedException(); // TODO
634 if ( m_nObjectState == -1 )
635 throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
636 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
638 PostEvent_Impl( OUString( "OnVisAreaChanged" ) );
641 //----------------------------------------------
642 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
643 throw ( embed::WrongStateException,
644 uno::RuntimeException )
646 ::osl::MutexGuard aGuard( m_aMutex );
647 if ( m_bDisposed )
648 throw lang::DisposedException(); // TODO
650 if ( m_nObjectState == -1 )
651 throw embed::WrongStateException( OUString( "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 if ( m_bDisposed )
666 throw lang::DisposedException(); // TODO
668 return m_nMiscStatus;
671 //----------------------------------------------
672 void SAL_CALL OCommonEmbeddedObject::setContainerName( const OUString& sName )
673 throw ( uno::RuntimeException )
675 ::osl::MutexGuard aGuard( m_aMutex );
676 if ( m_bDisposed )
677 throw lang::DisposedException(); // TODO
679 m_aContainerName = sName;
682 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException)
684 return m_xParent;
687 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)
689 m_xParent = xParent;
690 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
692 uno::Reference < container::XChild > xChild( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
693 if ( xChild.is() )
694 xChild->setParent( xParent );
698 // XDefaultSizeTransmitter
699 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException)
701 //#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
702 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM;
705 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */