Debian Codegraph @

embeddedobj/source/commonembedding/embedobj.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <com/sun/star/embed/EmbedStates.hpp>
21 #include <com/sun/star/embed/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>
30
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>
37
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>
43 #include <officecfg/Office/Common.hxx>
44
45 #include <vcl/svapp.hxx>
46
47 #include <targetstatecontrol.hxx>
48
49 #include <commonembobj.hxx>
50 #include "embedobj.hxx"
51 #include <specialobject.hxx>
52 #include <array>
53
54 using namespace ::com::sun::star;
55
56 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
57 {
58 awt::Rectangle aResult;
59
60 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
61 "Offset must not be less than zero!" );
62
63 aResult.X = std::max(aRect1.X, aRect2.X);
64 aResult.Y = std::max(aRect1.Y, aRect2.Y);
65
66 sal_Int32 nRight1 = aRect1.X + aRect1.Width;
67 sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
68 sal_Int32 nRight2 = aRect2.X + aRect2.Width;
69 sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
70 aResult.Width = std::min( nRight1, nRight2 ) - aResult.X;
71 aResult.Height = std::min( nBottom1, nBottom2 ) - aResult.Y;
72
73 return aResult;
74 }
75
76 namespace
77 {
78 using IntermediateStatesMap = std::array<std::array<uno::Sequence< sal_Int32 >, NUM_SUPPORTED_STATES>, NUM_SUPPORTED_STATES>;
79 const IntermediateStatesMap & getIntermediateStatesMap()
80 {
81 static const IntermediateStatesMap map = [] () {
82 IntermediateStatesMap tmp;
83
84 // intermediate states
85 // In the following table the first index points to starting state,
86 // the second one to the target state, and the sequence referenced by
87 // first two indexes contains intermediate states, that should be
88 // passed by object to reach the target state.
89 // If the sequence is empty that means that indirect switch from start
90 // state to the target state is forbidden, only if direct switch is possible
91 // the state can be reached.
92
93 tmp[0][2] = { embed::EmbedStates::RUNNING };
94
95 tmp[0][3] = { embed::EmbedStates::RUNNING,
96 embed::EmbedStates::INPLACE_ACTIVE };
97
98 tmp[0][4] = {embed::EmbedStates::RUNNING};
99
100 tmp[1][3] = { embed::EmbedStates::INPLACE_ACTIVE };
101
102 tmp[2][0] = { embed::EmbedStates::RUNNING };
103
104 tmp[3][0] = { embed::EmbedStates::INPLACE_ACTIVE,
105 embed::EmbedStates::RUNNING };
106
107 tmp[3][1] = { embed::EmbedStates::INPLACE_ACTIVE };
108
109 tmp[4][0] = { embed::EmbedStates::RUNNING };
110
111 return tmp;
112 }();
113 return map;
114 }
115
116 // accepted states
117 const css::uno::Sequence< sal_Int32 > & getAcceptedStates()
118 {
119 static const css::uno::Sequence< sal_Int32 > states {
120 /* [0] */ embed::EmbedStates::LOADED,
121 /* [1] */ embed::EmbedStates::RUNNING,
122 /* [2] */ embed::EmbedStates::INPLACE_ACTIVE,
123 /* [3] */ embed::EmbedStates::UI_ACTIVE,
124 /* [4] */ embed::EmbedStates::ACTIVE };
125 assert(states.getLength() == NUM_SUPPORTED_STATES);
126 return states;
127 }
128
129 }
130
131 sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb )
132 {
133 auto it = m_aVerbTable.find( nVerb );
134 if (it != m_aVerbTable.end())
135 return it->second;
136
137 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
138 }
139
140
141 void OCommonEmbeddedObject::Deactivate()
142 {
143 uno::Reference< util::XModifiable > xModif( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
144
145 // no need to lock for the initialization
146 uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite;
147 if ( !xClientSite.is() )
148 throw embed::WrongStateException(); //TODO: client site is not set!
149
150 // tdf#131146 close frame before saving of the document
151 // (during CloseFrame() call some changes could be detected not registered in util::XModifiable)
152 m_xDocHolder->CloseFrame();
153
154 // store document if it is modified
155 if ( xModif.is() && xModif->isModified() )
156 {
157 try {
158 xClientSite->saveObject();
159
160 // tdf#141529 take note that an eventually used linked file
161 // got changed/saved/written and that we need to copy it back if the
162 // hosting file/document gets saved
163 if(m_aLinkTempFile.is())
164 m_bLinkTempFileChanged = true;
165 }
166 catch( const embed::ObjectSaveVetoException& )
167 {
168 }
169 catch( const uno::Exception& )
170 {
171 css::uno::Any anyEx = cppu::getCaughtException();
172 throw embed::StorageWrappedTargetException(
173 u"The client could not store the object!"_ustr,
174 static_cast< ::cppu::OWeakObject* >( this ),
175 anyEx );
176 }
177 }
178
179 xClientSite->visibilityChanged( false );
180 }
181
182
183 void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
184 {
185 if ( !m_pInterfaceContainer )
186 return;
187
188 comphelper::OInterfaceContainerHelper2* pContainer = m_pInterfaceContainer->getContainer(
189 cppu::UnoType<embed::XStateChangeListener>::get());
190 if ( pContainer == nullptr )
191 return;
192
193 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
194 comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
195
196 // should be locked after the method is finished successfully
197 rGuard.clear();
198
199 while (pIterator.hasMoreElements())
200 {
201 try
202 {
203 if ( bBeforeChange )
204 static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState );
205 else
206 static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState );
207 }
208 catch( const uno::Exception& )
209 {
210 // even if the listener complains ignore it for now
211 }
212
213 if ( m_bDisposed )
214 return;
215 }
216
217 rGuard.reset();
218 }
219
220 void OCommonEmbeddedObject::SetInplaceActiveState()
221 {
222 if ( !m_xClientSite.is() )
223 throw embed::WrongStateException( u"client site not set, yet"_ustr, *this );
224
225 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
226 if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() )
227 throw embed::WrongStateException(); //TODO: can't activate inplace
228 xInplaceClient->activatingInplace();
229
230 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW );
231
232 m_xClientWindow = xClientWindowSupplier->getWindow();
233 m_aOwnRectangle = xInplaceClient->getPlacement();
234 m_aClipRectangle = xInplaceClient->getClipRectangle();
235 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
236
237 // create own window based on the client window
238 // place and resize the window according to the rectangles
239 uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW );
240
241 // dispatch provider may not be provided
242 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
243 bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
244 m_nObjectState = embed::EmbedStates::INPLACE_ACTIVE;
245 if ( !bOk )
246 {
247 SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
248 throw embed::WrongStateException(); //TODO: can't activate inplace
249 }
250 }
251
252 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
253 {
254 // TODO: may be needs interaction handler to detect whether the object state
255 // can be changed even after errors
256
257 if ( m_nObjectState == embed::EmbedStates::LOADED )
258 {
259 if ( nNextState == embed::EmbedStates::RUNNING )
260 {
261 // after the object reaches the running state the cloned size is not necessary any more
262 m_bHasClonedSize = false;
263
264 if ( m_bIsLinkURL )
265 {
266 m_xDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
267 }
268 else
269 {
270 if ( !dynamic_cast<OSpecialEmbeddedObject*>(this) )
271 {
272 // in case embedded object is in loaded state the contents must
273 // be stored in the related storage and the storage
274 // must be created already
275 if ( !m_xObjectStorage.is() )
276 throw io::IOException(); //TODO: access denied
277
278 m_xDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly );
279 }
280 else
281 {
282 // objects without persistence will be initialized internally
283 uno::Sequence < uno::Any > aArgs{ uno::Any(
284 uno::Reference < embed::XEmbeddedObject >( this )) };
285 uno::Reference< util::XCloseable > xDocument(
286 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( GetDocumentServiceName(), aArgs, m_xContext),
287 uno::UNO_QUERY );
288
289 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
290 if ( xChild.is() )
291 xChild->setParent( m_xParent );
292
293 m_xDocHolder->SetComponent( xDocument, m_bReadOnly );
294 }
295 }
296
297 if ( !m_xDocHolder->GetComponent().is() )
298 throw embed::UnreachableStateException(); //TODO: can't open document
299
300 m_nObjectState = nNextState;
301 }
302 else
303 {
304 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
305 throw uno::RuntimeException(u"invalid next state, only RUNNING state allowed"_ustr); // TODO
306 }
307 }
308 else if ( m_nObjectState == embed::EmbedStates::RUNNING )
309 {
310 if ( nNextState == embed::EmbedStates::LOADED )
311 {
312 m_nClonedMapUnit = m_xDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
313 m_bHasClonedSize = m_xDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
314
315 // actually frame should not exist at this point
316 m_xDocHolder->CloseDocument( false, false );
317
318 m_nObjectState = nNextState;
319 }
320 else
321 {
322 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
323 {
324 SetInplaceActiveState();
325 }
326 else if ( nNextState == embed::EmbedStates::ACTIVE )
327 {
328 if ( !m_xClientSite.is() )
329 throw embed::WrongStateException(); //TODO: client site is not set!
330
331 // create frame and load document in the frame
332 m_xDocHolder->Show();
333
334 m_xClientSite->visibilityChanged( true );
335 m_nObjectState = nNextState;
336 }
337 else
338 {
339 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
340 throw uno::RuntimeException(u"invalid next state,only LOADED/INPLACE_ACTIVE/ACTIVE allowed"_ustr); // TODO
341 }
342 }
343 }
344 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
345 {
346 if ( nNextState == embed::EmbedStates::RUNNING )
347 {
348 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
349
350 m_xClientSite->visibilityChanged( true );
351
352 xInplaceClient->deactivatedInplace();
353 Deactivate();
354 m_nObjectState = nNextState;
355 }
356 else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
357 {
358 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
359 {
360 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
361 // TODO:
362 uno::Reference< css::frame::XLayoutManager > xContainerLM =
363 xInplaceClient->getLayoutManager();
364 if ( !xContainerLM.is() )
365 throw embed::WrongStateException(); //TODO: can't activate UI
366 // dispatch provider may not be provided
367 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
368
369 // get the container module name
370 OUString aModuleName;
371 try
372 {
373 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
374 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
375
376 uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
377
378 aModuleName = xManager->identify( xContDoc );
379 }
380 catch( const uno::Exception& )
381 {}
382
383 if (!comphelper::LibreOfficeKit::isActive())
384 {
385 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
386 // the container. Locking the LM will prevent flicker.
387 xContainerLM->lock();
388 xInplaceClient->activatingUI();
389 bool bOk = m_xDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
390 xContainerLM->unlock();
391
392 if ( bOk )
393 {
394 m_nObjectState = nNextState;
395 m_xDocHolder->ResizeHatchWindow();
396 }
397 else
398 {
399 xInplaceClient->deactivatedUI();
400 throw embed::WrongStateException(); //TODO: can't activate UI
401 }
402 }
403 }
404 }
405 else
406 {
407 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
408 throw uno::RuntimeException(u"invalid next state,only RUNNING/UI_ACTIVE allowed"_ustr); // TODO
409 }
410 }
411 else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
412 {
413 if ( nNextState == embed::EmbedStates::RUNNING )
414 {
415 Deactivate();
416 m_nObjectState = nNextState;
417 }
418 else
419 {
420 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
421 throw uno::RuntimeException(u"invalid next state, only RUNNING state allowed"_ustr); // TODO
422 }
423 }
424 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
425 {
426 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
427 {
428 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
429 uno::Reference< css::frame::XLayoutManager > xContainerLM =
430 xInplaceClient->getLayoutManager();
431
432 bool bOk = false;
433 if ( xContainerLM.is() )
434 bOk = m_xDocHolder->HideUI( xContainerLM );
435
436 if ( !bOk )
437 throw embed::WrongStateException(); //TODO: can't activate UI
438 m_nObjectState = nNextState;
439 m_xDocHolder->ResizeHatchWindow();
440 xInplaceClient->deactivatedUI();
441 }
442 }
443 else
444 throw embed::WrongStateException( u"The object is in unacceptable state!"_ustr,
445 static_cast< ::cppu::OWeakObject* >(this) );
446 }
447
448
449 uno::Sequence< sal_Int32 > const & OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
450 {
451 sal_Int32 nCurInd = 0;
452 auto & rAcceptedStates = getAcceptedStates();
453 for ( nCurInd = 0; nCurInd < rAcceptedStates.getLength(); nCurInd++ )
454 if ( rAcceptedStates[nCurInd] == m_nObjectState )
455 break;
456
457 if ( nCurInd == rAcceptedStates.getLength() )
458 throw embed::WrongStateException( u"The object is in unacceptable state!"_ustr,
459 static_cast< ::cppu::OWeakObject* >(this) );
460
461 sal_Int32 nDestInd = 0;
462 for ( nDestInd = 0; nDestInd < rAcceptedStates.getLength(); nDestInd++ )
463 if ( rAcceptedStates[nDestInd] == nNewState )
464 break;
465
466 if ( nDestInd == rAcceptedStates.getLength() )
467 throw embed::UnreachableStateException(
468 u"The state either not reachable, or the object allows the state only as an intermediate one!"_ustr,
469 static_cast< ::cppu::OWeakObject* >(this),
470 m_nObjectState,
471 nNewState );
472
473 return getIntermediateStatesMap()[nCurInd][nDestInd];
474 }
475
476
477 void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
478 {
479 if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get()
480 && nNewState != embed::EmbedStates::LOADED )
481 throw embed::UnreachableStateException();
482 ::osl::ResettableMutexGuard aGuard( m_aMutex );
483 if ( m_bDisposed )
484 throw lang::DisposedException(); // TODO
485
486 if ( m_nObjectState == -1 )
487 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
488 static_cast< ::cppu::OWeakObject* >(this) );
489
490 sal_Int32 nOldState = m_nObjectState;
491
492 if ( m_nTargetState != -1 )
493 {
494 // means that the object is currently trying to reach the target state
495 throw embed::StateChangeInProgressException( OUString(),
496 uno::Reference< uno::XInterface >(),
497 m_nTargetState );
498 }
499 else
500 {
501 TargetStateControl_Impl aControl( m_nTargetState, nNewState );
502
503 // in case the object is already in requested state
504 if ( m_nObjectState == nNewState )
505 {
506 // if active object is activated again, bring its window to top
507 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
508 m_xDocHolder->Show();
509
510 return;
511 }
512
513 // retrieve sequence of states that should be passed to reach desired state
514 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
515
516 // notify listeners that the object is going to change the state
517 StateChangeNotification_Impl( true, nOldState, nNewState,aGuard );
518
519 try {
520 for (sal_Int32 state : aIntermediateStates)
521 SwitchStateTo_Impl( state );
522
523 SwitchStateTo_Impl( nNewState );
524 }
525 catch( const uno::Exception& )
526 {
527 if ( nOldState != m_nObjectState )
528 // notify listeners that the object has changed the state
529 StateChangeNotification_Impl( false, nOldState, m_nObjectState, aGuard );
530
531 throw;
532 }
533 }
534
535 // notify listeners that the object has changed the state
536 StateChangeNotification_Impl( false, nOldState, nNewState, aGuard );
537
538 // let the object window be shown
539 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
540 PostEvent_Impl( u"OnVisAreaChanged"_ustr );
541 }
542
543
544 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
545 {
546 if ( m_bDisposed )
547 throw lang::DisposedException(); // TODO
548
549 if ( m_nObjectState == -1 )
550 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
551 static_cast< ::cppu::OWeakObject* >(this) );
552
553 return getAcceptedStates();
554 }
555
556
557 sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState()
558 {
559 if ( m_bDisposed )
560 throw lang::DisposedException(); // TODO
561
562 if ( m_nObjectState == -1 )
563 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
564 static_cast< ::cppu::OWeakObject* >(this) );
565
566 return m_nObjectState;
567 }
568
569
570 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
571 {
572 SolarMutexGuard aSolarGuard;
573 //TODO: a gross hack to avoid deadlocks when this is called from the
574 // outside and OCommonEmbeddedObject::changeState, with m_aMutex locked,
575 // calls into framework code that tries to lock the solar mutex, while
576 // another thread (through Window::ImplCallPaint, say) calls
577 // OCommonEmbeddedObject::getComponent with the solar mutex locked and
578 // then tries to lock m_aMutex (see fdo#56818); the alternative would be
579 // to get locking done right in this class, but that looks like a
580 // daunting task
581
582 osl::ClearableMutexGuard aGuard( m_aMutex );
583 if ( m_bDisposed )
584 throw lang::DisposedException(); // TODO
585
586 if ( m_nObjectState == -1 )
587 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
588 static_cast< ::cppu::OWeakObject* >(this) );
589
590 // for internal documents this call is just a duplicate of changeState
591 sal_Int32 nNewState = -1;
592 try
593 {
594 nNewState = ConvertVerbToState_Impl( nVerbID );
595 }
596 catch( const uno::Exception& )
597 {}
598
599 if ( nNewState == -1 )
600 {
601 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container
602 // TODO/LATER: check if the verb is a supported one and if it is produce related operation
603 }
604 else
605 {
606 aGuard.clear();
607 changeState( nNewState );
608 }
609 }
610
611
612 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
613 {
614 if ( m_bDisposed )
615 throw lang::DisposedException(); // TODO
616
617 if ( m_nObjectState == -1 )
618 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
619 static_cast< ::cppu::OWeakObject* >(this) );
620
621 return m_aObjectVerbs;
622 }
623
624
625 void SAL_CALL OCommonEmbeddedObject::setClientSite(
626 const uno::Reference< embed::XEmbeddedClient >& xClient )
627 {
628 ::osl::MutexGuard aGuard( m_aMutex );
629 if ( m_bDisposed )
630 throw lang::DisposedException(); // TODO
631
632 if ( m_xClientSite != xClient)
633 {
634 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
635 throw embed::WrongStateException(
636 u"The client site can not be set currently!"_ustr,
637 static_cast< ::cppu::OWeakObject* >(this) );
638
639 m_xClientSite = xClient;
640 }
641 }
642
643
644 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
645 {
646 if ( m_bDisposed )
647 throw lang::DisposedException(); // TODO
648
649 if ( m_nObjectState == -1 )
650 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
651 static_cast< ::cppu::OWeakObject* >(this) );
652
653 return m_xClientSite;
654 }
655
656
657 void SAL_CALL OCommonEmbeddedObject::update()
658 {
659 ::osl::MutexGuard aGuard( m_aMutex );
660 if ( m_bDisposed )
661 throw lang::DisposedException(); // TODO
662
663 if ( m_nObjectState == -1 )
664 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
665 static_cast< ::cppu::OWeakObject* >(this) );
666
667 PostEvent_Impl( u"OnVisAreaChanged"_ustr );
668 }
669
670
671 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
672 {
673 ::osl::MutexGuard aGuard( m_aMutex );
674 if ( m_bDisposed )
675 throw lang::DisposedException(); // TODO
676
677 if ( m_nObjectState == -1 )
678 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
679 static_cast< ::cppu::OWeakObject* >(this) );
680
681 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
682 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
683 "Unknown update mode!" );
684 m_nUpdateMode = nMode;
685 }
686
687
688 sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 )
689 {
690 if ( m_bDisposed )
691 throw lang::DisposedException(); // TODO
692
693 return m_nMiscStatus;
694 }
695
696
697 void SAL_CALL OCommonEmbeddedObject::setContainerName( const OUString& sName )
698 {
699 ::osl::MutexGuard aGuard( m_aMutex );
700 if ( m_bDisposed )
701 throw lang::DisposedException(); // TODO
702
703 m_aContainerName = sName;
704 }
705
706 void OCommonEmbeddedObject::SetOleState(bool bIsOleUpdate)
707 {
708 ::osl::MutexGuard aGuard( m_aMutex );
709
710 m_bOleUpdate = bIsOleUpdate;
711 }
712
713 css::uno::Reference< css::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent()
714 {
715 return m_xParent;
716 }
717
718 void SAL_CALL OCommonEmbeddedObject::setParent( const css::uno::Reference< css::uno::XInterface >& xParent )
719 {
720 m_xParent = xParent;
721 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
722 {
723 uno::Reference < container::XChild > xChild( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
724 if ( xChild.is() )
725 xChild->setParent( xParent );
726 }
727 }
728
729 // XDefaultSizeTransmitter
730 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const css::awt::Size& rSize_100TH_MM )
731 {
732 //#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
733 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM;
734 }
735
736 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */