LibreOffice Module embeddedobj (master) 1
embedobj.cxx
Go to the documentation of this file.
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>
41#include <comphelper/lok.hxx>
42#include <sal/log.hxx>
43
44#include <vcl/svapp.hxx>
45
47
48#include <commonembobj.hxx>
49#include "embedobj.hxx"
50#include <specialobject.hxx>
51#include <array>
52
53using namespace ::com::sun::star;
54
55awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
56{
57 awt::Rectangle aResult;
58
59 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
60 "Offset must not be less than zero!" );
61
62 aResult.X = std::max(aRect1.X, aRect2.X);
63 aResult.Y = std::max(aRect1.Y, aRect2.Y);
64
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;
71
72 return aResult;
73}
74
75namespace
76{
77 using IntermediateStatesMap = std::array<std::array<uno::Sequence< sal_Int32 >, NUM_SUPPORTED_STATES>, NUM_SUPPORTED_STATES>;
78 const IntermediateStatesMap & getIntermediateStatesMap()
79 {
80 static const IntermediateStatesMap map = [] () {
81 IntermediateStatesMap tmp;
82
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.
91
92 tmp[0][2] = { embed::EmbedStates::RUNNING };
93
94 tmp[0][3] = { embed::EmbedStates::RUNNING,
95 embed::EmbedStates::INPLACE_ACTIVE };
96
97 tmp[0][4] = {embed::EmbedStates::RUNNING};
98
99 tmp[1][3] = { embed::EmbedStates::INPLACE_ACTIVE };
100
101 tmp[2][0] = { embed::EmbedStates::RUNNING };
102
103 tmp[3][0] = { embed::EmbedStates::INPLACE_ACTIVE,
104 embed::EmbedStates::RUNNING };
105
106 tmp[3][1] = { embed::EmbedStates::INPLACE_ACTIVE };
107
108 tmp[4][0] = { embed::EmbedStates::RUNNING };
109
110 return tmp;
111 }();
112 return map;
113 }
114
115 // accepted states
116 const css::uno::Sequence< sal_Int32 > & getAcceptedStates()
117 {
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;
126 }
127
128}
129
131{
132 auto it = m_aVerbTable.find( nVerb );
133 if (it != m_aVerbTable.end())
134 return it->second;
135
136 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
137}
138
139
141{
142 uno::Reference< util::XModifiable > xModif( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
143
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!
148
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();
152
153 // store document if it is modified
154 if ( xModif.is() && xModif->isModified() )
155 {
156 try {
157 xClientSite->saveObject();
158
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())
164 }
165 catch( const embed::ObjectSaveVetoException& )
166 {
167 }
168 catch( const uno::Exception& )
169 {
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 );
175 }
176 }
177
178 xClientSite->visibilityChanged( false );
179}
180
181
182void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
183{
185 return;
186
189 if ( pContainer == nullptr )
190 return;
191
192 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
193 comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer);
194
195 // should be locked after the method is finished successfully
196 rGuard.clear();
197
198 while (pIterator.hasMoreElements())
199 {
200 try
201 {
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 );
206 }
207 catch( const uno::Exception& )
208 {
209 // even if the listener complains ignore it for now
210 }
211
212 if ( m_bDisposed )
213 return;
214 }
215
216 rGuard.reset();
217}
218
220{
221 if ( !m_xClientSite.is() )
222 throw embed::WrongStateException( "client site not set, yet", *this );
223
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();
228
229 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW );
230
231 m_xClientWindow = xClientWindowSupplier->getWindow();
232 m_aOwnRectangle = xInplaceClient->getPlacement();
233 m_aClipRectangle = xInplaceClient->getClipRectangle();
234 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
235
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 );
239
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 )
245 {
246 SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
247 throw embed::WrongStateException(); //TODO: can't activate inplace
248 }
249}
250
252{
253 // TODO: may be needs interaction handler to detect whether the object state
254 // can be changed even after errors
255
256 if ( m_nObjectState == embed::EmbedStates::LOADED )
257 {
258 if ( nNextState == embed::EmbedStates::RUNNING )
259 {
260 // after the object reaches the running state the cloned size is not necessary any more
261 m_bHasClonedSize = false;
262
263 if ( m_bIsLinkURL )
264 {
265 m_xDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
266 }
267 else
268 {
269 if ( !dynamic_cast<OSpecialEmbeddedObject*>(this) )
270 {
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
276
278 }
279 else
280 {
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 );
287
288 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
289 if ( xChild.is() )
290 xChild->setParent( m_xParent );
291
292 m_xDocHolder->SetComponent( xDocument, m_bReadOnly );
293 }
294 }
295
296 if ( !m_xDocHolder->GetComponent().is() )
297 throw embed::UnreachableStateException(); //TODO: can't open document
298
299 m_nObjectState = nNextState;
300 }
301 else
302 {
303 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
304 throw uno::RuntimeException("invalid next state, only RUNNING state allowed"); // TODO
305 }
306 }
307 else if ( m_nObjectState == embed::EmbedStates::RUNNING )
308 {
309 if ( nNextState == embed::EmbedStates::LOADED )
310 {
311 m_nClonedMapUnit = m_xDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
312 m_bHasClonedSize = m_xDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
313
314 // actually frame should not exist at this point
315 m_xDocHolder->CloseDocument( false, false );
316
317 m_nObjectState = nNextState;
318 }
319 else
320 {
321 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
322 {
324 }
325 else if ( nNextState == embed::EmbedStates::ACTIVE )
326 {
327 if ( !m_xClientSite.is() )
328 throw embed::WrongStateException(); //TODO: client site is not set!
329
330 // create frame and load document in the frame
331 m_xDocHolder->Show();
332
333 m_xClientSite->visibilityChanged( true );
334 m_nObjectState = nNextState;
335 }
336 else
337 {
338 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
339 throw uno::RuntimeException("invalid next state,only LOADED/INPLACE_ACTIVE/ACTIVE allowed"); // TODO
340 }
341 }
342 }
343 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
344 {
345 if ( nNextState == embed::EmbedStates::RUNNING )
346 {
347 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
348
349 m_xClientSite->visibilityChanged( true );
350
351 xInplaceClient->deactivatedInplace();
352 Deactivate();
353 m_nObjectState = nNextState;
354 }
355 else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
356 {
357 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
358 {
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();
367
368 // get the container module name
369 OUString aModuleName;
370 try
371 {
372 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
373 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
374
375 uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
376
377 aModuleName = xManager->identify( xContDoc );
378 }
379 catch( const uno::Exception& )
380 {}
381
383 {
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();
390
391 if ( bOk )
392 {
393 m_nObjectState = nNextState;
394 m_xDocHolder->ResizeHatchWindow();
395 }
396 else
397 {
398 xInplaceClient->deactivatedUI();
399 throw embed::WrongStateException(); //TODO: can't activate UI
400 }
401 }
402 }
403 }
404 else
405 {
406 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
407 throw uno::RuntimeException("invalid next state,only RUNNING/UI_ACTIVE allowed"); // TODO
408 }
409 }
410 else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
411 {
412 if ( nNextState == embed::EmbedStates::RUNNING )
413 {
414 Deactivate();
415 m_nObjectState = nNextState;
416 }
417 else
418 {
419 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
420 throw uno::RuntimeException("invalid next state, only RUNNING state allowed"); // TODO
421 }
422 }
423 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
424 {
425 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
426 {
427 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
428 uno::Reference< css::frame::XLayoutManager > xContainerLM =
429 xInplaceClient->getLayoutManager();
430
431 bool bOk = false;
432 if ( xContainerLM.is() )
433 bOk = m_xDocHolder->HideUI( xContainerLM );
434
435 if ( !bOk )
436 throw embed::WrongStateException(); //TODO: can't activate UI
437 m_nObjectState = nNextState;
438 m_xDocHolder->ResizeHatchWindow();
439 xInplaceClient->deactivatedUI();
440 }
441 }
442 else
443 throw embed::WrongStateException( "The object is in unacceptable state!",
444 static_cast< ::cppu::OWeakObject* >(this) );
445}
446
447
448uno::Sequence< sal_Int32 > const & OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
449{
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;
455
456 if ( nCurInd == rAcceptedStates.getLength() )
457 throw embed::WrongStateException( "The object is in unacceptable state!",
458 static_cast< ::cppu::OWeakObject* >(this) );
459
460 sal_Int32 nDestInd = 0;
461 for ( nDestInd = 0; nDestInd < rAcceptedStates.getLength(); nDestInd++ )
462 if ( rAcceptedStates[nDestInd] == nNewState )
463 break;
464
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),
470 nNewState );
471
472 return getIntermediateStatesMap()[nCurInd][nDestInd];
473}
474
475
476void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
477{
478 ::osl::ResettableMutexGuard aGuard( m_aMutex );
479 if ( m_bDisposed )
480 throw lang::DisposedException(); // TODO
481
482 if ( m_nObjectState == -1 )
483 throw embed::WrongStateException( "The object has no persistence!",
484 static_cast< ::cppu::OWeakObject* >(this) );
485
486 sal_Int32 nOldState = m_nObjectState;
487
488 if ( m_nTargetState != -1 )
489 {
490 // means that the object is currently trying to reach the target state
491 throw embed::StateChangeInProgressException( OUString(),
492 uno::Reference< uno::XInterface >(),
494 }
495 else
496 {
497 TargetStateControl_Impl aControl( m_nTargetState, nNewState );
498
499 // in case the object is already in requested state
500 if ( m_nObjectState == nNewState )
501 {
502 // if active object is activated again, bring its window to top
503 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
504 m_xDocHolder->Show();
505
506 return;
507 }
508
509 // retrieve sequence of states that should be passed to reach desired state
510 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
511
512 // notify listeners that the object is going to change the state
513 StateChangeNotification_Impl( true, nOldState, nNewState,aGuard );
514
515 try {
516 for ( sal_Int32 state : std::as_const(aIntermediateStates) )
517 SwitchStateTo_Impl( state );
518
519 SwitchStateTo_Impl( nNewState );
520 }
521 catch( const uno::Exception& )
522 {
523 if ( nOldState != m_nObjectState )
524 // notify listeners that the object has changed the state
525 StateChangeNotification_Impl( false, nOldState, m_nObjectState, aGuard );
526
527 throw;
528 }
529 }
530
531 // notify listeners that the object has changed the state
532 StateChangeNotification_Impl( false, nOldState, nNewState, aGuard );
533
534 // let the object window be shown
535 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
536 PostEvent_Impl( "OnVisAreaChanged" );
537}
538
539
540uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
541{
542 if ( m_bDisposed )
543 throw lang::DisposedException(); // TODO
544
545 if ( m_nObjectState == -1 )
546 throw embed::WrongStateException( "The object has no persistence!",
547 static_cast< ::cppu::OWeakObject* >(this) );
548
549 return getAcceptedStates();
550}
551
552
554{
555 if ( m_bDisposed )
556 throw lang::DisposedException(); // TODO
557
558 if ( m_nObjectState == -1 )
559 throw embed::WrongStateException( "The object has no persistence!",
560 static_cast< ::cppu::OWeakObject* >(this) );
561
562 return m_nObjectState;
563}
564
565
566void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
567{
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
577
578 osl::ClearableMutexGuard aGuard( m_aMutex );
579 if ( m_bDisposed )
580 throw lang::DisposedException(); // TODO
581
582 if ( m_nObjectState == -1 )
583 throw embed::WrongStateException( "The object has no persistence!",
584 static_cast< ::cppu::OWeakObject* >(this) );
585
586 // for internal documents this call is just a duplicate of changeState
587 sal_Int32 nNewState = -1;
588 try
589 {
590 nNewState = ConvertVerbToState_Impl( nVerbID );
591 }
592 catch( const uno::Exception& )
593 {}
594
595 if ( nNewState == -1 )
596 {
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
599 }
600 else
601 {
602 aGuard.clear();
603 changeState( nNewState );
604 }
605}
606
607
608uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
609{
610 if ( m_bDisposed )
611 throw lang::DisposedException(); // TODO
612
613 if ( m_nObjectState == -1 )
614 throw embed::WrongStateException( "The object has no persistence!",
615 static_cast< ::cppu::OWeakObject* >(this) );
616
617 return m_aObjectVerbs;
618}
619
620
622 const uno::Reference< embed::XEmbeddedClient >& xClient )
623{
624 ::osl::MutexGuard aGuard( m_aMutex );
625 if ( m_bDisposed )
626 throw lang::DisposedException(); // TODO
627
628 if ( m_xClientSite != xClient)
629 {
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) );
634
635 m_xClientSite = xClient;
636 }
637}
638
639
640uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
641{
642 if ( m_bDisposed )
643 throw lang::DisposedException(); // TODO
644
645 if ( m_nObjectState == -1 )
646 throw embed::WrongStateException( "The object has no persistence!",
647 static_cast< ::cppu::OWeakObject* >(this) );
648
649 return m_xClientSite;
650}
651
652
654{
655 ::osl::MutexGuard aGuard( m_aMutex );
656 if ( m_bDisposed )
657 throw lang::DisposedException(); // TODO
658
659 if ( m_nObjectState == -1 )
660 throw embed::WrongStateException( "The object has no persistence!",
661 static_cast< ::cppu::OWeakObject* >(this) );
662
663 PostEvent_Impl( "OnVisAreaChanged" );
664}
665
666
667void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
668{
669 ::osl::MutexGuard aGuard( m_aMutex );
670 if ( m_bDisposed )
671 throw lang::DisposedException(); // TODO
672
673 if ( m_nObjectState == -1 )
674 throw embed::WrongStateException( "The object has no persistence!",
675 static_cast< ::cppu::OWeakObject* >(this) );
676
677 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
678 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
679 "Unknown update mode!" );
680 m_nUpdateMode = nMode;
681}
682
683
684sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 )
685{
686 if ( m_bDisposed )
687 throw lang::DisposedException(); // TODO
688
689 return m_nMiscStatus;
690}
691
692
693void SAL_CALL OCommonEmbeddedObject::setContainerName( const OUString& sName )
694{
695 ::osl::MutexGuard aGuard( m_aMutex );
696 if ( m_bDisposed )
697 throw lang::DisposedException(); // TODO
698
700}
701
703{
704 ::osl::MutexGuard aGuard( m_aMutex );
705
706 m_bOleUpdate = bIsOleUpdate;
707}
708
709css::uno::Reference< css::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent()
710{
711 return m_xParent;
712}
713
714void SAL_CALL OCommonEmbeddedObject::setParent( const css::uno::Reference< css::uno::XInterface >& xParent )
715{
716 m_xParent = xParent;
717 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
718 {
719 uno::Reference < container::XChild > xChild( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
720 if ( xChild.is() )
721 xChild->setParent( xParent );
722 }
723}
724
725// XDefaultSizeTransmitter
726void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const css::awt::Size& rSize_100TH_MM )
727{
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;
730}
731
732/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< sal_Int32, sal_Int32 > m_aVerbTable
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Definition: embedobj.cxx:709
css::awt::Size m_aDefaultSizeForChart_In_100TH_MM
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::unique_ptr<::comphelper::OMultiTypeInterfaceContainerHelper2 > m_pInterfaceContainer
sal_Int32 ConvertVerbToState_Impl(sal_Int32 nVerb)
Definition: embedobj.cxx:130
const OUString & GetDocumentServiceName() const
css::uno::Reference< css::uno::XInterface > m_xParent
void PostEvent_Impl(const OUString &aEventName)
Definition: miscobj.cxx:313
void StateChangeNotification_Impl(bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState,::osl::ResettableMutexGuard &_rGuard)
Definition: embedobj.cxx:182
css::uno::Sequence< css::embed::VerbDescriptor > m_aObjectVerbs
css::awt::Rectangle m_aClipRectangle
css::uno::Reference< css::awt::XWindow > m_xClientWindow
virtual void SAL_CALL setUpdateMode(sal_Int32 nMode) override
Definition: embedobj.cxx:667
virtual void SAL_CALL changeState(sal_Int32 nNewState) override
Definition: embedobj.cxx:476
css::awt::Rectangle m_aOwnRectangle
virtual void SAL_CALL setDefaultSize(const css::awt::Size &rSize_100TH_MM) override
Definition: embedobj.cxx:726
css::uno::Reference< css::io::XTempFile > m_aLinkTempFile
virtual void SetOleState(bool bIsOleUpdate) override
Definition: embedobj.cxx:702
void SetInplaceActiveState()
Definition: embedobj.cxx:219
virtual css::uno::Reference< css::embed::XEmbeddedClient > SAL_CALL getClientSite() override
Definition: embedobj.cxx:640
css::uno::Reference< css::util::XCloseable > LoadLink_Impl()
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
Definition: embedobj.cxx:714
css::awt::Size m_aClonedSize
rtl::Reference< DocumentHolder > m_xDocHolder
virtual void SAL_CALL doVerb(sal_Int32 nVerbID) override
Definition: embedobj.cxx:566
virtual sal_Int64 SAL_CALL getStatus(sal_Int64 nAspect) override
Definition: embedobj.cxx:684
virtual css::uno::Sequence< css::embed::VerbDescriptor > SAL_CALL getSupportedVerbs() override
Definition: embedobj.cxx:608
css::uno::Reference< css::embed::XEmbeddedClient > m_xClientSite
virtual sal_Int32 SAL_CALL getCurrentState() override
Definition: embedobj.cxx:553
virtual void SAL_CALL setClientSite(const css::uno::Reference< css::embed::XEmbeddedClient > &xClient) override
Definition: embedobj.cxx:621
css::uno::Sequence< sal_Int32 > const & GetIntermediateStatesSequence_Impl(sal_Int32 nNewState)
Definition: embedobj.cxx:448
virtual void SAL_CALL setContainerName(const OUString &sName) override
Definition: embedobj.cxx:693
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getReachableStates() override
Definition: embedobj.cxx:540
css::uno::Reference< css::util::XCloseable > LoadDocumentFromStorage_Impl()
void SwitchStateTo_Impl(sal_Int32 nNextState)
Definition: embedobj.cxx:251
css::uno::Reference< css::embed::XStorage > m_xObjectStorage
virtual void SAL_CALL update() override
Definition: embedobj.cxx:653
css::uno::XInterface * next()
#define NUM_SUPPORTED_STATES
awt::Rectangle GetRectangleInterception(const awt::Rectangle &aRect1, const awt::Rectangle &aRect2)
Definition: embedobj.cxx:55
OUString sName
#define SAL_WARN(area, stream)
Any SAL_CALL getCaughtException()
std::map< OUString, rtl::Reference< Entity > > map