Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / embeddedobj / source / commonembedding / embedobj.cxx
blobef627941921e0ded1e2cf359ca0c8cd7dce385d3
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/EmbedUpdateModes.hpp>
22 #include <com/sun/star/embed/ObjectSaveVetoException.hpp>
23 #include <com/sun/star/embed/StorageWrappedTargetException.hpp>
24 #include <com/sun/star/embed/UnreachableStateException.hpp>
25 #include <com/sun/star/embed/XEmbeddedClient.hpp>
26 #include <com/sun/star/embed/XInplaceClient.hpp>
27 #include <com/sun/star/embed/XWindowSupplier.hpp>
28 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
29 #include <com/sun/star/embed/Aspects.hpp>
31 #include <com/sun/star/awt/XWindowPeer.hpp>
32 #include <com/sun/star/io/IOException.hpp>
33 #include <com/sun/star/util/XCloseable.hpp>
34 #include <com/sun/star/util/XModifiable.hpp>
35 #include <com/sun/star/frame/ModuleManager.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
38 #include <com/sun/star/embed/EmbedMisc.hpp>
39 #include <cppuhelper/exc_hlp.hxx>
40 #include <comphelper/multicontainer2.hxx>
41 #include <comphelper/lok.hxx>
42 #include <sal/log.hxx>
44 #include <vcl/svapp.hxx>
46 #include <targetstatecontrol.hxx>
48 #include <commonembobj.hxx>
49 #include "embedobj.hxx"
50 #include <specialobject.hxx>
51 #include <array>
53 using namespace ::com::sun::star;
55 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
57 awt::Rectangle aResult;
59 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
60 "Offset must not be less than zero!" );
62 aResult.X = std::max(aRect1.X, aRect2.X);
63 aResult.Y = std::max(aRect1.Y, aRect2.Y);
65 sal_Int32 nRight1 = aRect1.X + aRect1.Width;
66 sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
67 sal_Int32 nRight2 = aRect2.X + aRect2.Width;
68 sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
69 aResult.Width = std::min( nRight1, nRight2 ) - aResult.X;
70 aResult.Height = std::min( nBottom1, nBottom2 ) - aResult.Y;
72 return aResult;
75 namespace
77 using IntermediateStatesMap = std::array<std::array<uno::Sequence< sal_Int32 >, NUM_SUPPORTED_STATES>, NUM_SUPPORTED_STATES>;
78 const IntermediateStatesMap & getIntermediateStatesMap()
80 static const IntermediateStatesMap map = [] () {
81 IntermediateStatesMap tmp;
83 // intermediate states
84 // In the following table the first index points to starting state,
85 // the second one to the target state, and the sequence referenced by
86 // first two indexes contains intermediate states, that should be
87 // passed by object to reach the target state.
88 // If the sequence is empty that means that indirect switch from start
89 // state to the target state is forbidden, only if direct switch is possible
90 // the state can be reached.
92 tmp[0][2] = { embed::EmbedStates::RUNNING };
94 tmp[0][3] = { embed::EmbedStates::RUNNING,
95 embed::EmbedStates::INPLACE_ACTIVE };
97 tmp[0][4] = {embed::EmbedStates::RUNNING};
99 tmp[1][3] = { embed::EmbedStates::INPLACE_ACTIVE };
101 tmp[2][0] = { embed::EmbedStates::RUNNING };
103 tmp[3][0] = { embed::EmbedStates::INPLACE_ACTIVE,
104 embed::EmbedStates::RUNNING };
106 tmp[3][1] = { embed::EmbedStates::INPLACE_ACTIVE };
108 tmp[4][0] = { embed::EmbedStates::RUNNING };
110 return tmp;
111 }();
112 return map;
115 // accepted states
116 const css::uno::Sequence< sal_Int32 > & getAcceptedStates()
118 static const css::uno::Sequence< sal_Int32 > states {
119 /* [0] */ embed::EmbedStates::LOADED,
120 /* [1] */ embed::EmbedStates::RUNNING,
121 /* [2] */ embed::EmbedStates::INPLACE_ACTIVE,
122 /* [3] */ embed::EmbedStates::UI_ACTIVE,
123 /* [4] */ embed::EmbedStates::ACTIVE };
124 assert(states.getLength() == NUM_SUPPORTED_STATES);
125 return states;
130 sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb )
132 auto it = m_aVerbTable.find( nVerb );
133 if (it != m_aVerbTable.end())
134 return it->second;
136 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
140 void OCommonEmbeddedObject::Deactivate()
142 uno::Reference< util::XModifiable > xModif( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
144 // no need to lock for the initialization
145 uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite;
146 if ( !xClientSite.is() )
147 throw embed::WrongStateException(); //TODO: client site is not set!
149 // tdf#131146 close frame before saving of the document
150 // (during CloseFrame() call some changes could be detected not registered in util::XModifiable)
151 m_xDocHolder->CloseFrame();
153 // store document if it is modified
154 if ( xModif.is() && xModif->isModified() )
156 try {
157 xClientSite->saveObject();
159 // tdf#141529 take note that an eventually used linked file
160 // got changed/saved/written and that we need to copy it back if the
161 // hosting file/document gets saved
162 if(m_aLinkTempFile.is())
163 m_bLinkTempFileChanged = true;
165 catch( const embed::ObjectSaveVetoException& )
168 catch( const uno::Exception& )
170 css::uno::Any anyEx = cppu::getCaughtException();
171 throw embed::StorageWrappedTargetException(
172 "The client could not store the object!",
173 static_cast< ::cppu::OWeakObject* >( this ),
174 anyEx );
178 xClientSite->visibilityChanged( false );
182 void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
184 if ( !m_pInterfaceContainer )
185 return;
187 comphelper::OInterfaceContainerHelper2* pContainer = m_pInterfaceContainer->getContainer(
188 cppu::UnoType<embed::XStateChangeListener>::get());
189 if ( pContainer == nullptr )
190 return;
192 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
193 comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
195 // should be locked after the method is finished successfully
196 rGuard.clear();
198 while (pIterator.hasMoreElements())
202 if ( bBeforeChange )
203 static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState );
204 else
205 static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState );
207 catch( const uno::Exception& )
209 // even if the listener complains ignore it for now
212 if ( m_bDisposed )
213 return;
216 rGuard.reset();
219 void OCommonEmbeddedObject::SetInplaceActiveState()
221 if ( !m_xClientSite.is() )
222 throw embed::WrongStateException( "client site not set, yet", *this );
224 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
225 if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() )
226 throw embed::WrongStateException(); //TODO: can't activate inplace
227 xInplaceClient->activatingInplace();
229 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW );
231 m_xClientWindow = xClientWindowSupplier->getWindow();
232 m_aOwnRectangle = xInplaceClient->getPlacement();
233 m_aClipRectangle = xInplaceClient->getClipRectangle();
234 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
236 // create own window based on the client window
237 // place and resize the window according to the rectangles
238 uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW );
240 // dispatch provider may not be provided
241 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
242 bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
243 m_nObjectState = embed::EmbedStates::INPLACE_ACTIVE;
244 if ( !bOk )
246 SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
247 throw embed::WrongStateException(); //TODO: can't activate inplace
251 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
253 // TODO: may be needs interaction handler to detect whether the object state
254 // can be changed even after errors
256 if ( m_nObjectState == embed::EmbedStates::LOADED )
258 if ( nNextState == embed::EmbedStates::RUNNING )
260 // after the object reaches the running state the cloned size is not necessary any more
261 m_bHasClonedSize = false;
263 if ( m_bIsLinkURL )
265 m_xDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
267 else
269 if ( !dynamic_cast<OSpecialEmbeddedObject*>(this) )
271 // in case embedded object is in loaded state the contents must
272 // be stored in the related storage and the storage
273 // must be created already
274 if ( !m_xObjectStorage.is() )
275 throw io::IOException(); //TODO: access denied
277 m_xDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly );
279 else
281 // objects without persistence will be initialized internally
282 uno::Sequence < uno::Any > aArgs{ uno::Any(
283 uno::Reference < embed::XEmbeddedObject >( this )) };
284 uno::Reference< util::XCloseable > xDocument(
285 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( GetDocumentServiceName(), aArgs, m_xContext),
286 uno::UNO_QUERY );
288 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
289 if ( xChild.is() )
290 xChild->setParent( m_xParent );
292 m_xDocHolder->SetComponent( xDocument, m_bReadOnly );
296 if ( !m_xDocHolder->GetComponent().is() )
297 throw embed::UnreachableStateException(); //TODO: can't open document
299 m_nObjectState = nNextState;
301 else
303 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
304 throw uno::RuntimeException("invalid next state, only RUNNING state allowed"); // TODO
307 else if ( m_nObjectState == embed::EmbedStates::RUNNING )
309 if ( nNextState == embed::EmbedStates::LOADED )
311 m_nClonedMapUnit = m_xDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
312 m_bHasClonedSize = m_xDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
314 // actually frame should not exist at this point
315 m_xDocHolder->CloseDocument( false, false );
317 m_nObjectState = nNextState;
319 else
321 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
323 SetInplaceActiveState();
325 else if ( nNextState == embed::EmbedStates::ACTIVE )
327 if ( !m_xClientSite.is() )
328 throw embed::WrongStateException(); //TODO: client site is not set!
330 // create frame and load document in the frame
331 m_xDocHolder->Show();
333 m_xClientSite->visibilityChanged( true );
334 m_nObjectState = nNextState;
336 else
338 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
339 throw uno::RuntimeException("invalid next state,only LOADED/INPLACE_ACTIVE/ACTIVE allowed"); // TODO
343 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
345 if ( nNextState == embed::EmbedStates::RUNNING )
347 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
349 m_xClientSite->visibilityChanged( true );
351 xInplaceClient->deactivatedInplace();
352 Deactivate();
353 m_nObjectState = nNextState;
355 else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
357 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
359 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
360 // TODO:
361 uno::Reference< css::frame::XLayoutManager > xContainerLM =
362 xInplaceClient->getLayoutManager();
363 if ( !xContainerLM.is() )
364 throw embed::WrongStateException(); //TODO: can't activate UI
365 // dispatch provider may not be provided
366 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
368 // get the container module name
369 OUString aModuleName;
372 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
373 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
375 uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
377 aModuleName = xManager->identify( xContDoc );
379 catch( const uno::Exception& )
382 if (!comphelper::LibreOfficeKit::isActive())
384 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
385 // the container. Locking the LM will prevent flicker.
386 xContainerLM->lock();
387 xInplaceClient->activatingUI();
388 bool bOk = m_xDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
389 xContainerLM->unlock();
391 if ( bOk )
393 m_nObjectState = nNextState;
394 m_xDocHolder->ResizeHatchWindow();
396 else
398 xInplaceClient->deactivatedUI();
399 throw embed::WrongStateException(); //TODO: can't activate UI
404 else
406 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
407 throw uno::RuntimeException("invalid next state,only RUNNING/UI_ACTIVE allowed"); // TODO
410 else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
412 if ( nNextState == embed::EmbedStates::RUNNING )
414 Deactivate();
415 m_nObjectState = nNextState;
417 else
419 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
420 throw uno::RuntimeException("invalid next state, only RUNNING state allowed"); // TODO
423 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
425 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
427 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
428 uno::Reference< css::frame::XLayoutManager > xContainerLM =
429 xInplaceClient->getLayoutManager();
431 bool bOk = false;
432 if ( xContainerLM.is() )
433 bOk = m_xDocHolder->HideUI( xContainerLM );
435 if ( !bOk )
436 throw embed::WrongStateException(); //TODO: can't activate UI
437 m_nObjectState = nNextState;
438 m_xDocHolder->ResizeHatchWindow();
439 xInplaceClient->deactivatedUI();
442 else
443 throw embed::WrongStateException( "The object is in unacceptable state!",
444 static_cast< ::cppu::OWeakObject* >(this) );
448 uno::Sequence< sal_Int32 > const & OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
450 sal_Int32 nCurInd = 0;
451 auto & rAcceptedStates = getAcceptedStates();
452 for ( nCurInd = 0; nCurInd < rAcceptedStates.getLength(); nCurInd++ )
453 if ( rAcceptedStates[nCurInd] == m_nObjectState )
454 break;
456 if ( nCurInd == rAcceptedStates.getLength() )
457 throw embed::WrongStateException( "The object is in unacceptable state!",
458 static_cast< ::cppu::OWeakObject* >(this) );
460 sal_Int32 nDestInd = 0;
461 for ( nDestInd = 0; nDestInd < rAcceptedStates.getLength(); nDestInd++ )
462 if ( rAcceptedStates[nDestInd] == nNewState )
463 break;
465 if ( nDestInd == rAcceptedStates.getLength() )
466 throw embed::UnreachableStateException(
467 "The state either not reachable, or the object allows the state only as an intermediate one!",
468 static_cast< ::cppu::OWeakObject* >(this),
469 m_nObjectState,
470 nNewState );
472 return getIntermediateStatesMap()[nCurInd][nDestInd];
476 void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
478 ::osl::ResettableMutexGuard aGuard( m_aMutex );
479 if ( m_bDisposed )
480 throw lang::DisposedException(); // TODO
482 if ( m_nObjectState == -1 )
483 throw embed::WrongStateException( "The object has no persistence!",
484 static_cast< ::cppu::OWeakObject* >(this) );
486 sal_Int32 nOldState = m_nObjectState;
488 if ( m_nTargetState != -1 )
490 // means that the object is currently trying to reach the target state
491 throw embed::StateChangeInProgressException( OUString(),
492 uno::Reference< uno::XInterface >(),
493 m_nTargetState );
495 else
497 TargetStateControl_Impl aControl( m_nTargetState, nNewState );
499 // in case the object is already in requested state
500 if ( m_nObjectState == nNewState )
502 // if active object is activated again, bring its window to top
503 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
504 m_xDocHolder->Show();
506 return;
509 // retrieve sequence of states that should be passed to reach desired state
510 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
512 // notify listeners that the object is going to change the state
513 StateChangeNotification_Impl( true, nOldState, nNewState,aGuard );
515 try {
516 for ( sal_Int32 state : std::as_const(aIntermediateStates) )
517 SwitchStateTo_Impl( state );
519 SwitchStateTo_Impl( nNewState );
521 catch( const uno::Exception& )
523 if ( nOldState != m_nObjectState )
524 // notify listeners that the object has changed the state
525 StateChangeNotification_Impl( false, nOldState, m_nObjectState, aGuard );
527 throw;
531 // notify listeners that the object has changed the state
532 StateChangeNotification_Impl( false, nOldState, nNewState, aGuard );
534 // let the object window be shown
535 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
536 PostEvent_Impl( "OnVisAreaChanged" );
540 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
542 if ( m_bDisposed )
543 throw lang::DisposedException(); // TODO
545 if ( m_nObjectState == -1 )
546 throw embed::WrongStateException( "The object has no persistence!",
547 static_cast< ::cppu::OWeakObject* >(this) );
549 return getAcceptedStates();
553 sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState()
555 if ( m_bDisposed )
556 throw lang::DisposedException(); // TODO
558 if ( m_nObjectState == -1 )
559 throw embed::WrongStateException( "The object has no persistence!",
560 static_cast< ::cppu::OWeakObject* >(this) );
562 return m_nObjectState;
566 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
568 SolarMutexGuard aSolarGuard;
569 //TODO: a gross hack to avoid deadlocks when this is called from the
570 // outside and OCommonEmbeddedObject::changeState, with m_aMutex locked,
571 // calls into framework code that tries to lock the solar mutex, while
572 // another thread (through Window::ImplCallPaint, say) calls
573 // OCommonEmbeddedObject::getComponent with the solar mutex locked and
574 // then tries to lock m_aMutex (see fdo#56818); the alternative would be
575 // to get locking done right in this class, but that looks like a
576 // daunting task
578 osl::ClearableMutexGuard aGuard( m_aMutex );
579 if ( m_bDisposed )
580 throw lang::DisposedException(); // TODO
582 if ( m_nObjectState == -1 )
583 throw embed::WrongStateException( "The object has no persistence!",
584 static_cast< ::cppu::OWeakObject* >(this) );
586 // for internal documents this call is just a duplicate of changeState
587 sal_Int32 nNewState = -1;
590 nNewState = ConvertVerbToState_Impl( nVerbID );
592 catch( const uno::Exception& )
595 if ( nNewState == -1 )
597 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container
598 // TODO/LATER: check if the verb is a supported one and if it is produce related operation
600 else
602 aGuard.clear();
603 changeState( nNewState );
608 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
610 if ( m_bDisposed )
611 throw lang::DisposedException(); // TODO
613 if ( m_nObjectState == -1 )
614 throw embed::WrongStateException( "The object has no persistence!",
615 static_cast< ::cppu::OWeakObject* >(this) );
617 return m_aObjectVerbs;
621 void SAL_CALL OCommonEmbeddedObject::setClientSite(
622 const uno::Reference< embed::XEmbeddedClient >& xClient )
624 ::osl::MutexGuard aGuard( m_aMutex );
625 if ( m_bDisposed )
626 throw lang::DisposedException(); // TODO
628 if ( m_xClientSite != xClient)
630 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
631 throw embed::WrongStateException(
632 "The client site can not be set currently!",
633 static_cast< ::cppu::OWeakObject* >(this) );
635 m_xClientSite = xClient;
640 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
642 if ( m_bDisposed )
643 throw lang::DisposedException(); // TODO
645 if ( m_nObjectState == -1 )
646 throw embed::WrongStateException( "The object has no persistence!",
647 static_cast< ::cppu::OWeakObject* >(this) );
649 return m_xClientSite;
653 void SAL_CALL OCommonEmbeddedObject::update()
655 ::osl::MutexGuard aGuard( m_aMutex );
656 if ( m_bDisposed )
657 throw lang::DisposedException(); // TODO
659 if ( m_nObjectState == -1 )
660 throw embed::WrongStateException( "The object has no persistence!",
661 static_cast< ::cppu::OWeakObject* >(this) );
663 PostEvent_Impl( "OnVisAreaChanged" );
667 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
669 ::osl::MutexGuard aGuard( m_aMutex );
670 if ( m_bDisposed )
671 throw lang::DisposedException(); // TODO
673 if ( m_nObjectState == -1 )
674 throw embed::WrongStateException( "The object has no persistence!",
675 static_cast< ::cppu::OWeakObject* >(this) );
677 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
678 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
679 "Unknown update mode!" );
680 m_nUpdateMode = nMode;
684 sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 )
686 if ( m_bDisposed )
687 throw lang::DisposedException(); // TODO
689 return m_nMiscStatus;
693 void SAL_CALL OCommonEmbeddedObject::setContainerName( const OUString& sName )
695 ::osl::MutexGuard aGuard( m_aMutex );
696 if ( m_bDisposed )
697 throw lang::DisposedException(); // TODO
699 m_aContainerName = sName;
702 void OCommonEmbeddedObject::SetOleState(bool bIsOleUpdate)
704 ::osl::MutexGuard aGuard( m_aMutex );
706 m_bOleUpdate = bIsOleUpdate;
709 css::uno::Reference< css::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent()
711 return m_xParent;
714 void SAL_CALL OCommonEmbeddedObject::setParent( const css::uno::Reference< css::uno::XInterface >& xParent )
716 m_xParent = xParent;
717 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
719 uno::Reference < container::XChild > xChild( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
720 if ( xChild.is() )
721 xChild->setParent( xParent );
725 // XDefaultSizeTransmitter
726 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const css::awt::Size& rSize_100TH_MM )
728 //#i103460# charts do not necessarily 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
729 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM;
732 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */