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 throw ( embed::UnreachableStateException, 432 embed::WrongStateException, 433 uno::Exception, 434 uno::RuntimeException ) 435 { 436 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::changeState" ); 437 438 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY); 439 { 440 ::osl::ResettableMutexGuard aGuard( m_aMutex ); 441 if ( m_bDisposed ) 442 throw lang::DisposedException(); // TODO 443 444 if ( m_nObjectState == -1 ) 445 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 446 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 447 448 sal_Int32 nOldState = m_nObjectState; 449 450 if ( m_nTargetState != -1 ) 451 { 452 // means that the object is currently trying to reach the target state 453 throw embed::StateChangeInProgressException( ::rtl::OUString(), 454 uno::Reference< uno::XInterface >(), 455 m_nTargetState ); 456 } 457 else 458 { 459 TargetStateControl_Impl aControl( m_nTargetState, nNewState ); 460 461 // in case the object is already in requested state 462 if ( m_nObjectState == nNewState ) 463 { 464 // if active object is activated again, bring it's window to top 465 if ( m_nObjectState == embed::EmbedStates::ACTIVE ) 466 m_pDocHolder->Show(); 467 468 return; 469 } 470 471 // retrieve sequence of states that should be passed to reach desired state 472 uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState ); 473 474 // notify listeners that the object is going to change the state 475 StateChangeNotification_Impl( sal_True, nOldState, nNewState,aGuard ); 476 477 try { 478 for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ ) 479 SwitchStateTo_Impl( aIntermediateStates[nInd] ); 480 481 SwitchStateTo_Impl( nNewState ); 482 } 483 catch( uno::Exception& ) 484 { 485 if ( nOldState != m_nObjectState ) 486 // notify listeners that the object has changed the state 487 StateChangeNotification_Impl( sal_False, nOldState, m_nObjectState, aGuard ); 488 489 throw; 490 } 491 } 492 493 // notify listeners that the object has changed the state 494 StateChangeNotification_Impl( sal_False, nOldState, nNewState, aGuard ); 495 496 // let the object window be shown 497 if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE ) 498 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ), 499 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 500 } 501 } 502 503 //---------------------------------------------- 504 uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates() 505 throw ( embed::WrongStateException, 506 uno::RuntimeException ) 507 { 508 if ( m_bDisposed ) 509 throw lang::DisposedException(); // TODO 510 511 if ( m_nObjectState == -1 ) 512 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 513 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 514 515 return m_aAcceptedStates; 516 } 517 518 //---------------------------------------------- 519 sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState() 520 throw ( embed::WrongStateException, 521 uno::RuntimeException ) 522 { 523 if ( m_bDisposed ) 524 throw lang::DisposedException(); // TODO 525 526 if ( m_nObjectState == -1 ) 527 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 528 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 529 530 return m_nObjectState; 531 } 532 533 //---------------------------------------------- 534 void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID ) 535 throw ( lang::IllegalArgumentException, 536 embed::WrongStateException, 537 embed::UnreachableStateException, 538 uno::Exception, 539 uno::RuntimeException ) 540 { 541 RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OCommonEmbeddedObject::doVerb" ); 542 543 ::osl::ResettableMutexGuard aGuard( m_aMutex ); 544 if ( m_bDisposed ) 545 throw lang::DisposedException(); // TODO 546 547 if ( m_nObjectState == -1 ) 548 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 549 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 550 551 // for internal documents this call is just a duplicate of changeState 552 sal_Int32 nNewState = -1; 553 try 554 { 555 nNewState = ConvertVerbToState_Impl( nVerbID ); 556 } 557 catch( uno::Exception& ) 558 {} 559 560 if ( nNewState == -1 ) 561 { 562 // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container 563 // TODO/LATER: check if the verb is a supported one and if it is produce related operation 564 } 565 else 566 { 567 aGuard.clear(); 568 changeState( nNewState ); 569 } 570 } 571 572 //---------------------------------------------- 573 uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs() 574 throw ( embed::WrongStateException, 575 uno::RuntimeException ) 576 { 577 if ( m_bDisposed ) 578 throw lang::DisposedException(); // TODO 579 580 if ( m_nObjectState == -1 ) 581 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 582 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 583 584 return m_aObjectVerbs; 585 } 586 587 //---------------------------------------------- 588 void SAL_CALL OCommonEmbeddedObject::setClientSite( 589 const uno::Reference< embed::XEmbeddedClient >& xClient ) 590 throw ( embed::WrongStateException, 591 uno::RuntimeException ) 592 { 593 ::osl::MutexGuard aGuard( m_aMutex ); 594 if ( m_bDisposed ) 595 throw lang::DisposedException(); // TODO 596 597 if ( m_xClientSite != xClient) 598 { 599 if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING ) 600 throw embed::WrongStateException( 601 ::rtl::OUString::createFromAscii( "The client site can not be set currently!\n" ), 602 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 603 604 m_xClientSite = xClient; 605 } 606 } 607 608 //---------------------------------------------- 609 uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite() 610 throw ( embed::WrongStateException, 611 uno::RuntimeException ) 612 { 613 if ( m_bDisposed ) 614 throw lang::DisposedException(); // TODO 615 616 if ( m_nObjectState == -1 ) 617 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 618 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 619 620 return m_xClientSite; 621 } 622 623 //---------------------------------------------- 624 void SAL_CALL OCommonEmbeddedObject::update() 625 throw ( embed::WrongStateException, 626 uno::Exception, 627 uno::RuntimeException ) 628 { 629 ::osl::MutexGuard aGuard( m_aMutex ); 630 if ( m_bDisposed ) 631 throw lang::DisposedException(); // TODO 632 633 if ( m_nObjectState == -1 ) 634 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 635 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 636 637 PostEvent_Impl( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnVisAreaChanged" ) ), 638 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 639 } 640 641 //---------------------------------------------- 642 void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode ) 643 throw ( embed::WrongStateException, 644 uno::RuntimeException ) 645 { 646 ::osl::MutexGuard aGuard( m_aMutex ); 647 if ( m_bDisposed ) 648 throw lang::DisposedException(); // TODO 649 650 if ( m_nObjectState == -1 ) 651 throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object has no persistence!\n" ), 652 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) ); 653 654 OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE 655 || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE, 656 "Unknown update mode!\n" ); 657 m_nUpdateMode = nMode; 658 } 659 660 //---------------------------------------------- 661 sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 ) 662 throw ( embed::WrongStateException, 663 uno::RuntimeException ) 664 { 665 if ( m_bDisposed ) 666 throw lang::DisposedException(); // TODO 667 668 return m_nMiscStatus; 669 } 670 671 //---------------------------------------------- 672 void SAL_CALL OCommonEmbeddedObject::setContainerName( const ::rtl::OUString& sName ) 673 throw ( uno::RuntimeException ) 674 { 675 ::osl::MutexGuard aGuard( m_aMutex ); 676 if ( m_bDisposed ) 677 throw lang::DisposedException(); // TODO 678 679 m_aContainerName = sName; 680 } 681 682 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException) 683 { 684 return m_xParent; 685 } 686 687 void SAL_CALL OCommonEmbeddedObject::setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xParent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException) 688 { 689 m_xParent = xParent; 690 if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED ) 691 { 692 uno::Reference < container::XChild > xChild( m_pDocHolder->GetComponent(), uno::UNO_QUERY ); 693 if ( xChild.is() ) 694 xChild->setParent( xParent ); 695 } 696 } 697 698 // XDefaultSizeTransmitter 699 void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException) 700 { 701 //#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method 702 m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM; 703 } 704