1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_embeddedobj.hxx" 26 #include <com/sun/star/embed/EmbedStates.hpp> 27 #include <com/sun/star/embed/EmbedVerbs.hpp> 28 #include <com/sun/star/embed/EmbedUpdateModes.hpp> 29 #include <com/sun/star/embed/XEmbeddedClient.hpp> 30 #include <com/sun/star/embed/XInplaceClient.hpp> 31 #include <com/sun/star/embed/XWindowSupplier.hpp> 32 #include <com/sun/star/embed/StateChangeInProgressException.hpp> 33 #include <com/sun/star/embed/Aspects.hpp> 34 35 #include <com/sun/star/awt/XWindowPeer.hpp> 36 #include <com/sun/star/util/XCloseBroadcaster.hpp> 37 #include <com/sun/star/util/XCloseable.hpp> 38 #include <com/sun/star/util/XModifiable.hpp> 39 #include <com/sun/star/frame/XFrame.hpp> 40 #include <com/sun/star/frame/XComponentLoader.hpp> 41 #include <com/sun/star/frame/XDispatchProviderInterception.hpp> 42 #include <com/sun/star/frame/XModuleManager.hpp> 43 #include <com/sun/star/lang/DisposedException.hpp> 44 45 #include <com/sun/star/embed/EmbedMisc.hpp> 46 47 #include <rtl/logfile.hxx> 48 49 #include <targetstatecontrol.hxx> 50 51 #include "commonembobj.hxx" 52 #include "intercept.hxx" 53 54 55 using namespace ::com::sun::star; 56 57 awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 ) 58 { 59 awt::Rectangle aResult; 60 61 OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0, 62 "Offset must not be less then zero!" ); 63 64 aResult.X = aRect1.X > aRect2.X ? aRect1.X : aRect2.X; 65 aResult.Y = aRect1.Y > aRect2.Y ? aRect1.Y : aRect2.Y; 66 67 sal_Int32 nRight1 = aRect1.X + aRect1.Width; 68 sal_Int32 nBottom1 = aRect1.Y + aRect1.Height; 69 sal_Int32 nRight2 = aRect2.X + aRect2.Width; 70 sal_Int32 nBottom2 = aRect2.Y + aRect2.Height; 71 aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X; 72 aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y; 73 74 return aResult; 75 } 76 77 //---------------------------------------------- 78 sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb ) 79 { 80 for ( sal_Int32 nInd = 0; nInd < m_aVerbTable.getLength(); nInd++ ) 81 if ( m_aVerbTable[nInd][0] == nVerb ) 82 return m_aVerbTable[nInd][1]; 83 84 throw lang::IllegalArgumentException(); // TODO: unexpected verb provided 85 } 86 87 //---------------------------------------------- 88 void OCommonEmbeddedObject::Deactivate() 89 { 90 uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); 91 //MBA if ( !xModif.is() ) 92 //MBA throw uno::RuntimeException(); 93 94 // no need to lock for the initialization 95 uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite; 96 if ( !xClientSite.is() ) 97 throw embed::WrongStateException(); //TODO: client site is not set! 98 99 // store document if it is modified 100 if ( xModif.is() && xModif->isModified() ) 101 { 102 try { 103 xClientSite->saveObject(); 104 } 105 catch( embed::ObjectSaveVetoException& ) 106 { 107 } 108 catch( uno::Exception& e ) 109 { 110 throw embed::StorageWrappedTargetException( 111 ::rtl::OUString::createFromAscii( "The client could not store the object!" ), 112 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ), 113 uno::makeAny( e ) ); 114 } 115 } 116 117 m_pDocHolder->CloseFrame(); 118 119 xClientSite->visibilityChanged( sal_False ); 120 } 121 122 //---------------------------------------------- 123 void OCommonEmbeddedObject::StateChangeNotification_Impl( sal_Bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard ) 124 { 125 if ( m_pInterfaceContainer ) 126 { 127 ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( 128 ::getCppuType( ( const uno::Reference< embed::XStateChangeListener >*) NULL ) ); 129 if ( pContainer != NULL ) 130 { 131 lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); 132 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); 133 134 // should be locked after the method is finished successfully 135 rGuard.clear(); 136 137 while (pIterator.hasMoreElements()) 138 { 139 try 140 { 141 if ( bBeforeChange ) 142 ((embed::XStateChangeListener*)pIterator.next())->changingState( aSource, nOldState, nNewState ); 143 else 144 ((embed::XStateChangeListener*)pIterator.next())->stateChanged( aSource, nOldState, nNewState ); 145 } 146 catch( uno::Exception& ) 147 { 148 // even if the listener complains ignore it for now 149 } 150 151 if ( m_bDisposed ) 152 return; 153 } 154 155 rGuard.reset(); 156 } 157 } 158 } 159 160 //---------------------------------------------- 161 void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) 162 { 163 // TODO: may be needs interaction handler to detect wherether the object state 164 // can be changed even after errors 165 166 if ( m_nObjectState == embed::EmbedStates::LOADED ) 167 { 168 if ( nNextState == embed::EmbedStates::RUNNING ) 169 { 170 // after the object reaches the running state the cloned size is not necessary any more 171 m_bHasClonedSize = sal_False; 172 173 if ( m_bIsLink ) 174 { 175 m_pDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly ); 176 } 177 else 178 { 179 uno::Reference < embed::XEmbedPersist > xPersist( static_cast < embed::XClassifiedObject* > (this), uno::UNO_QUERY ); 180 if ( xPersist.is() ) 181 { 182 // in case embedded object is in loaded state the contents must 183 // be stored in the related storage and the storage 184 // must be created already 185 if ( !m_xObjectStorage.is() ) 186 throw io::IOException(); //TODO: access denied 187 188 m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly ); 189 } 190 else 191 { 192 // objects without persistence will be initialized internally 193 uno::Sequence < uno::Any > aArgs(1); 194 aArgs[0] <<= uno::Reference < embed::XEmbeddedObject >( this ); 195 uno::Reference< util::XCloseable > xDocument( 196 m_xFactory->createInstanceWithArguments( GetDocumentServiceName(), aArgs ), uno::UNO_QUERY ); 197 198 uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY ); 199 if ( xChild.is() ) 200 xChild->setParent( m_xParent ); 201 202 m_pDocHolder->SetComponent( xDocument, m_bReadOnly ); 203 } 204 } 205 206 if ( !m_pDocHolder->GetComponent().is() ) 207 throw embed::UnreachableStateException(); //TODO: can't open document 208 209 m_nObjectState = nNextState; 210 } 211 else 212 { 213 OSL_ENSURE( sal_False, "Unacceptable state switch!\n" ); 214 throw uno::RuntimeException(); // TODO 215 } 216 } 217 else if ( m_nObjectState == embed::EmbedStates::RUNNING ) 218 { 219 if ( nNextState == embed::EmbedStates::LOADED ) 220 { 221 m_nClonedMapUnit = m_pDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT ); 222 m_bHasClonedSize = m_pDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize ); 223 224 // actually frame should not exist at this point 225 m_pDocHolder->CloseDocument( sal_False, sal_False ); 226 227 m_nObjectState = nNextState; 228 } 229 else 230 { 231 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) 232 { 233 if ( !m_xClientSite.is() ) 234 throw embed::WrongStateException( 235 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "client site not set, yet" ) ), 236 *this 237 ); 238 239 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); 240 if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() ) 241 { 242 xInplaceClient->activatingInplace(); 243 244 uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY ); 245 if ( !xClientWindowSupplier.is() ) 246 throw uno::RuntimeException(); // TODO: the inplace client implementation must support XWinSupp 247 248 m_xClientWindow = xClientWindowSupplier->getWindow(); 249 m_aOwnRectangle = xInplaceClient->getPlacement(); 250 m_aClipRectangle = xInplaceClient->getClipRectangle(); 251 awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle ); 252 253 // create own window based on the client window 254 // place and resize the window according to the rectangles 255 uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY ); 256 if ( !xClientWindowPeer.is() ) 257 throw uno::RuntimeException(); // TODO: the container window must support the interface 258 259 // dispatch provider may not be provided 260 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); 261 sal_Bool bOk = m_pDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP ); 262 m_nObjectState = nNextState; 263 if ( !bOk ) 264 { 265 SwitchStateTo_Impl( embed::EmbedStates::RUNNING ); 266 throw embed::WrongStateException(); //TODO: can't activate inplace 267 } 268 } 269 else 270 throw embed::WrongStateException(); //TODO: can't activate inplace 271 } 272 else if ( nNextState == embed::EmbedStates::ACTIVE ) 273 { 274 if ( !m_xClientSite.is() ) 275 throw embed::WrongStateException(); //TODO: client site is not set! 276 277 // create frame and load document in the frame 278 m_pDocHolder->Show(); 279 280 m_xClientSite->visibilityChanged( sal_True ); 281 m_nObjectState = nNextState; 282 } 283 else 284 { 285 OSL_ENSURE( sal_False, "Unacceptable state switch!\n" ); 286 throw uno::RuntimeException(); // TODO 287 } 288 } 289 } 290 else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE ) 291 { 292 if ( nNextState == embed::EmbedStates::RUNNING ) 293 { 294 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); 295 if ( !xInplaceClient.is() ) 296 throw uno::RuntimeException(); 297 298 m_xClientSite->visibilityChanged( sal_True ); 299 300 xInplaceClient->deactivatedInplace(); 301 Deactivate(); 302 m_nObjectState = nNextState; 303 } 304 else if ( nNextState == embed::EmbedStates::UI_ACTIVE ) 305 { 306 if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) ) 307 { 308 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW ); 309 // TODO: 310 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM = 311 xInplaceClient->getLayoutManager(); 312 if ( xContainerLM.is() ) 313 { 314 // dispatch provider may not be provided 315 uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); 316 317 // get the container module name 318 ::rtl::OUString aModuleName; 319 try 320 { 321 uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW ); 322 uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW ); 323 324 uno::Reference< frame::XModuleManager > xManager( 325 m_xFactory->createInstance( 326 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), 327 uno::UNO_QUERY_THROW ); 328 329 aModuleName = xManager->identify( xContDoc ); 330 } 331 catch( uno::Exception& ) 332 {} 333 334 // if currently another object is UIactive it will be deactivated; usually this will activate the LM of 335 // the container. Locking the LM will prevent flicker. 336 xContainerLM->lock(); 337 xInplaceClient->activatingUI(); 338 sal_Bool bOk = m_pDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName ); 339 xContainerLM->unlock(); 340 341 if ( bOk ) 342 { 343 m_nObjectState = nNextState; 344 m_pDocHolder->ResizeHatchWindow(); 345 } 346 else 347 { 348 xInplaceClient->deactivatedUI(); 349 throw embed::WrongStateException(); //TODO: can't activate UI 350 } 351 } 352 else 353 throw embed::WrongStateException(); //TODO: can't activate UI 354 } 355 } 356 else 357 { 358 OSL_ENSURE( sal_False, "Unacceptable state switch!\n" ); 359 throw uno::RuntimeException(); // TODO 360 } 361 } 362 else if ( m_nObjectState == embed::EmbedStates::ACTIVE ) 363 { 364 if ( nNextState == embed::EmbedStates::RUNNING ) 365 { 366 Deactivate(); 367 m_nObjectState = nNextState; 368 } 369 else 370 { 371 OSL_ENSURE( sal_False, "Unacceptable state switch!\n" ); 372 throw uno::RuntimeException(); // TODO 373 } 374 } 375 else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE ) 376 { 377 if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) 378 { 379 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW ); 380 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM = 381 xInplaceClient->getLayoutManager(); 382 383 sal_Bool bOk = sal_False; 384 if ( xContainerLM.is() ) 385 bOk = m_pDocHolder->HideUI( xContainerLM ); 386 387 if ( bOk ) 388 { 389 m_nObjectState = nNextState; 390 m_pDocHolder->ResizeHatchWindow(); 391 xInplaceClient->deactivatedUI(); 392 } 393 else 394 throw embed::WrongStateException(); //TODO: can't activate UI 395 } 396 } 397 else 398 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is in unacceptable state!\n" ), 399 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 400 } 401 402 //---------------------------------------------- 403 uno::Sequence< sal_Int32 > OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState ) 404 { 405 sal_Int32 nCurInd = 0; 406 for ( nCurInd = 0; nCurInd < m_aAcceptedStates.getLength(); nCurInd++ ) 407 if ( m_aAcceptedStates[nCurInd] == m_nObjectState ) 408 break; 409 410 if ( nCurInd == m_aAcceptedStates.getLength() ) 411 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is in unacceptable state!\n" ), 412 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 413 414 sal_Int32 nDestInd = 0; 415 for ( nDestInd = 0; nDestInd < m_aAcceptedStates.getLength(); nDestInd++ ) 416 if ( m_aAcceptedStates[nDestInd] == nNewState ) 417 break; 418 419 if ( nDestInd == m_aAcceptedStates.getLength() ) 420 throw embed::UnreachableStateException( 421 ::rtl::OUString::createFromAscii( "The state either not reachable, or the object allows the state only as an intermediate one!\n" ), 422 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ), 423 m_nObjectState, 424 nNewState ); 425 426 return m_pIntermediateStatesSeqs[nCurInd][nDestInd]; 427 } 428 429 //---------------------------------------------- 430 void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState ) 431 { 432 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::changeState" ); 433 434 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY); 435 { 436 ::osl::ResettableMutexGuard aGuard( m_aMutex ); 437 if ( m_bDisposed ) 438 throw lang::DisposedException(); // TODO 439 440 if ( m_nObjectState == -1 ) 441 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 442 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 443 444 sal_Int32 nOldState = m_nObjectState; 445 446 if ( m_nTargetState != -1 ) 447 { 448 // means that the object is currently trying to reach the target state 449 throw embed::StateChangeInProgressException( ::rtl::OUString(), 450 uno::Reference< uno::XInterface >(), 451 m_nTargetState ); 452 } 453 else 454 { 455 TargetStateControl_Impl aControl( m_nTargetState, nNewState ); 456 457 // in case the object is already in requested state 458 if ( m_nObjectState == nNewState ) 459 { 460 // if active object is activated again, bring it's window to top 461 if ( m_nObjectState == embed::EmbedStates::ACTIVE ) 462 m_pDocHolder->Show(); 463 464 return; 465 } 466 467 // retrieve sequence of states that should be passed to reach desired state 468 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState ); 469 470 // notify listeners that the object is going to change the state 471 StateChangeNotification_Impl( sal_True, nOldState, nNewState,aGuard ); 472 473 try { 474 for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ ) 475 SwitchStateTo_Impl( aIntermediateStates[nInd] ); 476 477 SwitchStateTo_Impl( nNewState ); 478 } 479 catch( uno::Exception& ) 480 { 481 if ( nOldState != m_nObjectState ) 482 // notify listeners that the object has changed the state 483 StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState, aGuard ); 484 485 throw; 486 } 487 } 488 489 // notify listeners that the object has changed the state 490 StateChangeNotification_Impl( sal_False, nOldState, nNewState, aGuard ); 491 492 // let the object window be shown 493 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE ) 494 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ), 495 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 496 } 497 } 498 499 //---------------------------------------------- 500 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates() 501 { 502 if ( m_bDisposed ) 503 throw lang::DisposedException(); // TODO 504 505 if ( m_nObjectState == -1 ) 506 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 507 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 508 509 return m_aAcceptedStates; 510 } 511 512 //---------------------------------------------- 513 sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState() 514 { 515 if ( m_bDisposed ) 516 throw lang::DisposedException(); // TODO 517 518 if ( m_nObjectState == -1 ) 519 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 520 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 521 522 return m_nObjectState; 523 } 524 525 //---------------------------------------------- 526 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID ) 527 { 528 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" ); 529 530 ::osl::ResettableMutexGuard aGuard( m_aMutex ); 531 if ( m_bDisposed ) 532 throw lang::DisposedException(); // TODO 533 534 if ( m_nObjectState == -1 ) 535 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 536 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 537 538 // for internal documents this call is just a duplicate of changeState 539 sal_Int32 nNewState = -1; 540 try 541 { 542 nNewState = ConvertVerbToState_Impl( nVerbID ); 543 } 544 catch( uno::Exception& ) 545 {} 546 547 if ( nNewState == -1 ) 548 { 549 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container 550 // TODO/LATER: check if the verb is a supported one and if it is produce related operation 551 } 552 else 553 { 554 aGuard.clear(); 555 changeState( nNewState ); 556 } 557 } 558 559 //---------------------------------------------- 560 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs() 561 { 562 if ( m_bDisposed ) 563 throw lang::DisposedException(); // TODO 564 565 if ( m_nObjectState == -1 ) 566 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 567 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 568 569 return m_aObjectVerbs; 570 } 571 572 //---------------------------------------------- 573 void SAL_CALL OCommonEmbeddedObject::setClientSite( 574 const uno::Reference< embed::XEmbeddedClient >& xClient ) 575 { 576 ::osl::MutexGuard aGuard( m_aMutex ); 577 if ( m_bDisposed ) 578 throw lang::DisposedException(); // TODO 579 580 if ( m_xClientSite != xClient) 581 { 582 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING ) 583 throw embed::WrongStateException( 584 ::rtl::OUString::createFromAscii( "The client site can not be set currently!\n" ), 585 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 586 587 m_xClientSite = xClient; 588 } 589 } 590 591 //---------------------------------------------- 592 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite() 593 { 594 if ( m_bDisposed ) 595 throw lang::DisposedException(); // TODO 596 597 if ( m_nObjectState == -1 ) 598 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 599 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 600 601 return m_xClientSite; 602 } 603 604 //---------------------------------------------- 605 void SAL_CALL OCommonEmbeddedObject::update() 606 { 607 ::osl::MutexGuard aGuard( m_aMutex ); 608 if ( m_bDisposed ) 609 throw lang::DisposedException(); // TODO 610 611 if ( m_nObjectState == -1 ) 612 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 613 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 614 615 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ), 616 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 617 } 618 619 //---------------------------------------------- 620 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode ) 621 { 622 ::osl::MutexGuard aGuard( m_aMutex ); 623 if ( m_bDisposed ) 624 throw lang::DisposedException(); // TODO 625 626 if ( m_nObjectState == -1 ) 627 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 628 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 629 630 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE 631 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE, 632 "Unknown update mode!\n" ); 633 m_nUpdateMode = nMode; 634 } 635 636 //---------------------------------------------- 637 sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 ) 638 { 639 if ( m_bDisposed ) 640 throw lang::DisposedException(); // TODO 641 642 return m_nMiscStatus; 643 } 644 645 //---------------------------------------------- 646 void SAL_CALL OCommonEmbeddedObject::setContainerName( const ::rtl::OUString& sName ) 647 { 648 ::osl::MutexGuard aGuard( m_aMutex ); 649 if ( m_bDisposed ) 650 throw lang::DisposedException(); // TODO 651 652 m_aContainerName = sName; 653 } 654 655 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent() 656 { 657 return m_xParent; 658 } 659 660 void SAL_CALL OCommonEmbeddedObject::setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xParent ) 661 { 662 m_xParent = xParent; 663 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED ) 664 { 665 uno::Reference < container::XChild > xChild( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); 666 if ( xChild.is() ) 667 xChild->setParent( xParent ); 668 } 669 } 670 671 // XDefaultSizeTransmitter 672 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) 673 { 674 //#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 675 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM; 676 } 677