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_sd.hxx" 26 27 #include "DrawController.hxx" 28 #include "DrawDocShell.hxx" 29 30 #include "DrawSubController.hxx" 31 #include "sdpage.hxx" 32 #include "ViewShellBase.hxx" 33 #include "ViewShellManager.hxx" 34 #include "FormShellManager.hxx" 35 #include "Window.hxx" 36 37 #include <comphelper/anytostring.hxx> 38 #include <comphelper/processfactory.hxx> 39 #include <comphelper/sequence.hxx> 40 #include <comphelper/stl_types.hxx> 41 #include <cppuhelper/exc_hlp.hxx> 42 #include <cppuhelper/bootstrap.hxx> 43 44 #include <com/sun/star/beans/PropertyAttribute.hpp> 45 #include <com/sun/star/drawing/framework/ConfigurationController.hpp> 46 #include <com/sun/star/drawing/framework/ModuleController.hpp> 47 #include <com/sun/star/lang/XInitialization.hpp> 48 49 #include "slideshow.hxx" 50 51 #include <svx/fmshell.hxx> 52 #include <vos/mutex.hxx> 53 #include <vcl/svapp.hxx> 54 #include <sfx2/sidebar/EnumContext.hxx> 55 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx> 56 57 #include <boost/shared_ptr.hpp> 58 59 using namespace ::std; 60 using ::rtl::OUString; 61 using namespace ::cppu; 62 using namespace ::vos; 63 using namespace ::com::sun::star; 64 using namespace ::com::sun::star::uno; 65 using namespace ::com::sun::star::drawing::framework; 66 using ::sfx2::sidebar::EnumContext; 67 68 namespace { 69 static const ::com::sun::star::uno::Type saComponentTypeIdentifier ( 70 ::getCppuType( (Reference<lang::XEventListener > *)0 )); 71 static const ::com::sun::star::uno::Type saSelectionTypeIdentifier ( 72 ::getCppuType( (Reference<view::XSelectionChangeListener > *)0 )); 73 74 } // end of anonymous namespace 75 76 namespace sd { 77 78 DrawController::DrawController (ViewShellBase& rBase) throw() 79 : DrawControllerInterfaceBase(&rBase), 80 BroadcastHelperOwner(SfxBaseController::m_aMutex), 81 OPropertySetHelper( static_cast<OBroadcastHelperVar< 82 OMultiTypeInterfaceContainerHelper, 83 OMultiTypeInterfaceContainerHelper::keyType>& >( 84 BroadcastHelperOwner::maBroadcastHelper)), 85 mpBase(&rBase), 86 maLastVisArea(), 87 mpCurrentPage(NULL), 88 mbMasterPageMode(false), 89 mbLayerMode(false), 90 mbDisposing(false), 91 mpPropertyArrayHelper(NULL), 92 mxSubController(), 93 mxConfigurationController(), 94 mxModuleController() 95 { 96 ProvideFrameworkControllers(); 97 } 98 99 100 101 102 DrawController::~DrawController (void) throw() 103 { 104 } 105 106 107 108 109 void DrawController::SetSubController ( 110 const Reference<drawing::XDrawSubController>& rxSubController) 111 { 112 // Update the internal state. 113 mxSubController = rxSubController; 114 mpPropertyArrayHelper.reset(); 115 maLastVisArea = Rectangle(); 116 117 // Inform listeners about the changed state. 118 FireSelectionChangeListener(); 119 } 120 121 122 123 124 // XInterface 125 126 IMPLEMENT_FORWARD_XINTERFACE2( 127 DrawController, 128 DrawControllerInterfaceBase, 129 OPropertySetHelper); 130 131 132 // XTypeProvider 133 134 Sequence<Type> SAL_CALL DrawController::getTypes (void) 135 throw (::com::sun::star::uno::RuntimeException) 136 { 137 ThrowIfDisposed(); 138 // OPropertySetHelper does not provide getTypes, so we have to 139 // implement this method manually and list its three interfaces. 140 OTypeCollection aTypeCollection ( 141 ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL), 142 ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL), 143 ::getCppuType (( const Reference<beans::XPropertySet>*)NULL)); 144 145 return ::comphelper::concatSequences( 146 SfxBaseController::getTypes(), 147 aTypeCollection.getTypes(), 148 DrawControllerInterfaceBase::getTypes()); 149 } 150 151 IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController); 152 153 154 155 // XComponent 156 157 158 void SAL_CALL DrawController::dispose (void) 159 throw( RuntimeException ) 160 { 161 if( !mbDisposing ) 162 { 163 OGuard aGuard( Application::GetSolarMutex() ); 164 165 if( !mbDisposing ) 166 { 167 mbDisposing = true; 168 169 boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 170 if ( pViewShell ) 171 { 172 pViewShell->DeactivateCurrentFunction(); 173 DrawDocShell* pDocShell = pViewShell->GetDocSh(); 174 if ( pDocShell != NULL ) 175 pDocShell->SetDocShellFunction(0); 176 } 177 pViewShell.reset(); 178 179 // When the controller has not been detached from its view 180 // shell, i.e. mpViewShell is not NULL, then tell PaneManager 181 // and ViewShellManager to clear the shell stack. 182 if (mxSubController.is() && mpBase!=NULL) 183 { 184 mpBase->DisconnectAllClients(); 185 mpBase->GetViewShellManager()->Shutdown(); 186 } 187 188 OPropertySetHelper::disposing(); 189 190 DisposeFrameworkControllers(); 191 192 SfxBaseController::dispose(); 193 } 194 } 195 } 196 197 198 199 200 void SAL_CALL DrawController::addEventListener( 201 const Reference<lang::XEventListener >& xListener) 202 throw (RuntimeException) 203 { 204 ThrowIfDisposed(); 205 SfxBaseController::addEventListener( xListener ); 206 } 207 208 209 210 211 void SAL_CALL DrawController::removeEventListener ( 212 const Reference<lang::XEventListener >& aListener) 213 throw (RuntimeException) 214 { 215 if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing) 216 SfxBaseController::removeEventListener( aListener ); 217 } 218 219 // XController 220 ::sal_Bool SAL_CALL DrawController::suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException) 221 { 222 if( Suspend ) 223 { 224 ViewShellBase* pViewShellBase = GetViewShellBase(); 225 if( pViewShellBase ) 226 { 227 // do not allow suspend if a slideshow needs this controller! 228 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) ); 229 if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) ) 230 return sal_False; 231 } 232 } 233 234 return SfxBaseController::suspend( Suspend ); 235 } 236 237 238 // XServiceInfo 239 240 OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException) 241 { 242 // Do not throw an excepetion at the moment. This leads to a crash 243 // under Solaris on relead. See issue i70929 for details. 244 // ThrowIfDisposed(); 245 return OUString( RTL_CONSTASCII_USTRINGPARAM( "DrawController" ) ); 246 } 247 248 249 250 static OUString ssServiceName (OUString::createFromAscii( 251 "com.sun.star.drawing.DrawingDocumentDrawView")); 252 253 sal_Bool SAL_CALL DrawController::supportsService ( 254 const OUString& rsServiceName) 255 throw(RuntimeException) 256 { 257 // Do not throw an excepetion at the moment. This leads to a crash 258 // under Solaris on relead. See issue i70929 for details. 259 // ThrowIfDisposed(); 260 return rsServiceName.equals(ssServiceName); 261 } 262 263 264 265 266 Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void) 267 throw(RuntimeException) 268 { 269 ThrowIfDisposed(); 270 Sequence<OUString> aSupportedServices (1); 271 OUString* pServices = aSupportedServices.getArray(); 272 pServices[0] = ssServiceName; 273 return aSupportedServices; 274 } 275 276 277 278 279 //------ XSelectionSupplier -------------------------------------------- 280 281 sal_Bool SAL_CALL DrawController::select (const Any& aSelection) 282 throw(lang::IllegalArgumentException, RuntimeException) 283 { 284 ThrowIfDisposed(); 285 ::vos::OGuard aGuard (Application::GetSolarMutex()); 286 287 if (mxSubController.is()) 288 return mxSubController->select(aSelection); 289 else 290 return false; 291 } 292 293 294 295 296 Any SAL_CALL DrawController::getSelection() 297 throw(RuntimeException) 298 { 299 ThrowIfDisposed(); 300 ::vos::OGuard aGuard (Application::GetSolarMutex()); 301 302 if (mxSubController.is()) 303 return mxSubController->getSelection(); 304 else 305 return Any(); 306 } 307 308 309 310 311 void SAL_CALL DrawController::addSelectionChangeListener( 312 const Reference< view::XSelectionChangeListener >& xListener) 313 throw(RuntimeException) 314 { 315 if( mbDisposing ) 316 throw lang::DisposedException(); 317 318 BroadcastHelperOwner::maBroadcastHelper.addListener (saSelectionTypeIdentifier, xListener); 319 } 320 321 322 323 324 void SAL_CALL DrawController::removeSelectionChangeListener( 325 const Reference< view::XSelectionChangeListener >& xListener ) 326 throw(RuntimeException) 327 { 328 if (rBHelper.bDisposed) 329 throw lang::DisposedException(); 330 331 BroadcastHelperOwner::maBroadcastHelper.removeListener (saSelectionTypeIdentifier, xListener); 332 } 333 334 335 336 337 338 //===== lang::XEventListener ================================================ 339 340 void SAL_CALL 341 DrawController::disposing (const lang::EventObject& ) 342 throw (uno::RuntimeException) 343 { 344 } 345 346 347 348 349 //===== view::XSelectionChangeListener ====================================== 350 351 void SAL_CALL 352 DrawController::selectionChanged (const lang::EventObject& rEvent) 353 throw (uno::RuntimeException) 354 { 355 ThrowIfDisposed(); 356 // Have to forward the event to our selection change listeners. 357 OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer( 358 ::getCppuType((Reference<view::XSelectionChangeListener>*)0)); 359 if (pListeners) 360 { 361 // Re-send the event to all of our listeners. 362 OInterfaceIteratorHelper aIterator (*pListeners); 363 while (aIterator.hasMoreElements()) 364 { 365 try 366 { 367 view::XSelectionChangeListener* pListener = 368 static_cast<view::XSelectionChangeListener*>( 369 aIterator.next()); 370 if (pListener != NULL) 371 pListener->selectionChanged (rEvent); 372 } 373 catch (RuntimeException aException) 374 { 375 } 376 } 377 } 378 } 379 380 381 382 383 // XDrawView 384 385 void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage ) 386 throw(RuntimeException) 387 { 388 ThrowIfDisposed(); 389 ::vos::OGuard aGuard (Application::GetSolarMutex()); 390 391 if (mxSubController.is()) 392 mxSubController->setCurrentPage(xPage); 393 } 394 395 396 397 398 Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void) 399 throw(RuntimeException) 400 { 401 ThrowIfDisposed(); 402 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 403 Reference<drawing::XDrawPage> xPage; 404 405 // Get current page from sub controller. 406 if (mxSubController.is()) 407 xPage = mxSubController->getCurrentPage(); 408 409 // When there is not yet a sub controller (during initialization) then fall back 410 // to the current page in mpCurrentPage. 411 if ( ! xPage.is() && mpCurrentPage.is()) 412 xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY); 413 414 return xPage; 415 } 416 417 418 419 420 void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw() 421 { 422 if( maLastVisArea != rVisArea ) 423 { 424 Any aNewValue; 425 aNewValue <<= awt::Rectangle( 426 rVisArea.Left(), 427 rVisArea.Top(), 428 rVisArea.GetWidth(), 429 rVisArea.GetHeight() ); 430 431 Any aOldValue; 432 aOldValue <<= awt::Rectangle( 433 maLastVisArea.Left(), 434 maLastVisArea.Top(), 435 maLastVisArea.GetWidth(), 436 maLastVisArea.GetHeight() ); 437 438 FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue); 439 440 maLastVisArea = rVisArea; 441 } 442 } 443 444 445 446 447 void DrawController::FireSelectionChangeListener() throw() 448 { 449 OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer( 450 saSelectionTypeIdentifier); 451 if( pLC ) 452 { 453 Reference< XInterface > xSource( (XWeak*)this ); 454 const lang::EventObject aEvent( xSource ); 455 456 // Ueber alle Listener iterieren und Events senden 457 OInterfaceIteratorHelper aIt( *pLC); 458 while( aIt.hasMoreElements() ) 459 { 460 try 461 { 462 view::XSelectionChangeListener * pL = 463 static_cast<view::XSelectionChangeListener*>(aIt.next()); 464 if (pL != NULL) 465 pL->selectionChanged( aEvent ); 466 } 467 catch (RuntimeException aException) 468 { 469 } 470 } 471 } 472 } 473 474 475 476 477 void DrawController::FireChangeEditMode (bool bMasterPageMode) throw() 478 { 479 if (bMasterPageMode != mbMasterPageMode ) 480 { 481 FirePropertyChange( 482 PROPERTY_MASTERPAGEMODE, 483 makeAny(bMasterPageMode), 484 makeAny(mbMasterPageMode)); 485 486 mbMasterPageMode = bMasterPageMode; 487 } 488 } 489 490 491 492 493 void DrawController::FireChangeLayerMode (bool bLayerMode) throw() 494 { 495 if (bLayerMode != mbLayerMode) 496 { 497 FirePropertyChange( 498 PROPERTY_LAYERMODE, 499 makeAny(bLayerMode), 500 makeAny(mbLayerMode)); 501 502 mbLayerMode = bLayerMode; 503 } 504 } 505 506 507 508 509 void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw() 510 { 511 SdrPage* pCurrentPage = mpCurrentPage.get(); 512 if (pNewCurrentPage != pCurrentPage) 513 { 514 try 515 { 516 Any aNewValue ( 517 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY))); 518 519 Any aOldValue; 520 if (pCurrentPage != NULL) 521 { 522 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY); 523 aOldValue <<= xOldPage; 524 } 525 526 FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue); 527 528 mpCurrentPage.reset(pNewCurrentPage); 529 } 530 catch( uno::Exception& e ) 531 { 532 (void)e; 533 DBG_ERROR( 534 (::rtl::OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), " 535 "exception caught: ") + 536 ::rtl::OUStringToOString( 537 comphelper::anyToString( cppu::getCaughtException() ), 538 RTL_TEXTENCODING_UTF8 )).getStr() ); 539 } 540 } 541 } 542 void DrawController::NotifyAccUpdate() 543 { 544 sal_Int32 nHandle = PROPERTY_UPDATEACC; 545 Any aNewValue, aOldValue; 546 fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False); 547 } 548 549 void DrawController::fireChangeLayer( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* pCurrentLayer ) throw() 550 { 551 if( pCurrentLayer != mpCurrentLayer ) 552 { 553 sal_Int32 nHandle = PROPERTY_ACTIVE_LAYER; 554 555 Any aNewValue (makeAny( *pCurrentLayer) ); 556 557 Any aOldValue ; 558 559 fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False); 560 561 mpCurrentLayer = pCurrentLayer; 562 } 563 } 564 565 // This method is only called in slide show and outline view 566 //void DrawController::fireSwitchCurrentPage(String pageName ) throw() 567 void DrawController::fireSwitchCurrentPage(sal_Int32 pageIndex ) throw() 568 { 569 Any aNewValue; 570 Any aOldValue; 571 //OUString aPageName( pageName ); 572 //aNewValue <<= aPageName ; 573 aNewValue <<= pageIndex; 574 575 // Use new property to handle page change event 576 sal_Int32 nHandles = PROPERTY_PAGE_CHANGE; 577 fire( &nHandles, &aNewValue, &aOldValue, 1, sal_False ); 578 } 579 580 void DrawController::FirePropertyChange ( 581 sal_Int32 nHandle, 582 const Any& rNewValue, 583 const Any& rOldValue) 584 { 585 try 586 { 587 fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False); 588 } 589 catch (RuntimeException aException) 590 { 591 // Ignore this exception. Exceptions should be handled in the 592 // fire() function so that all listeners are called. This is 593 // not the case at the moment, so we simply ignore the 594 // exception. 595 } 596 597 } 598 599 600 601 602 void DrawController::BroadcastContextChange (void) const 603 { 604 ::boost::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell()); 605 if ( ! pViewShell) 606 return; 607 608 EnumContext::Context eContext (EnumContext::Context_Unknown); 609 switch (pViewShell->GetShellType()) 610 { 611 case ViewShell::ST_IMPRESS: 612 case ViewShell::ST_DRAW: 613 if (mbMasterPageMode) 614 eContext = EnumContext::Context_MasterPage; 615 else 616 eContext = EnumContext::Context_DrawPage; 617 break; 618 619 case ViewShell::ST_NOTES: 620 eContext = EnumContext::Context_NotesPage; 621 break; 622 623 case ViewShell::ST_HANDOUT: 624 eContext = EnumContext::Context_HandoutPage; 625 break; 626 627 case ViewShell::ST_OUTLINE: 628 eContext = EnumContext::Context_OutlineText; 629 break; 630 631 case ViewShell::ST_SLIDE_SORTER: 632 eContext = EnumContext::Context_SlidesorterPage; 633 break; 634 635 case ViewShell::ST_PRESENTATION: 636 case ViewShell::ST_NONE: 637 default: 638 eContext = EnumContext::Context_Empty; 639 break; 640 } 641 642 ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext); 643 } 644 645 646 647 648 ViewShellBase* DrawController::GetViewShellBase (void) 649 { 650 return mpBase; 651 } 652 653 654 655 656 void DrawController::ReleaseViewShellBase (void) 657 { 658 DisposeFrameworkControllers(); 659 mpBase = NULL; 660 } 661 662 663 664 665 //===== XControllerManager ============================================================== 666 667 Reference<XConfigurationController> SAL_CALL 668 DrawController::getConfigurationController (void) 669 throw (RuntimeException) 670 { 671 ThrowIfDisposed(); 672 673 return mxConfigurationController; 674 } 675 676 677 678 679 Reference<XModuleController> SAL_CALL 680 DrawController::getModuleController (void) 681 throw (RuntimeException) 682 { 683 ThrowIfDisposed(); 684 685 return mxModuleController; 686 } 687 688 689 690 691 //===== XUnoTunnel ============================================================ 692 693 const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void) 694 { 695 static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL; 696 if (pSequence == NULL) 697 { 698 ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex()); 699 if (pSequence == NULL) 700 { 701 static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16); 702 rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True); 703 pSequence = &aSequence; 704 } 705 } 706 return *pSequence; 707 } 708 709 710 711 712 sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId) 713 throw (RuntimeException) 714 { 715 sal_Int64 nResult = 0; 716 717 if (rId.getLength() == 16 718 && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0) 719 { 720 nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 721 } 722 723 return nResult; 724 } 725 726 727 728 729 //===== Properties ============================================================ 730 731 void DrawController::FillPropertyTable ( 732 ::std::vector<beans::Property>& rProperties) 733 { 734 rProperties.push_back( 735 beans::Property( 736 OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleArea") ), 737 PROPERTY_WORKAREA, 738 ::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 739 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY)); 740 rProperties.push_back( 741 beans::Property( 742 OUString( RTL_CONSTASCII_USTRINGPARAM("SubController") ), 743 PROPERTY_SUB_CONTROLLER, 744 ::getCppuType((const Reference<drawing::XDrawSubController>*)0), 745 beans::PropertyAttribute::BOUND)); 746 rProperties.push_back( 747 beans::Property( 748 OUString( RTL_CONSTASCII_USTRINGPARAM("CurrentPage") ), 749 PROPERTY_CURRENTPAGE, 750 ::getCppuType((const Reference< drawing::XDrawPage > *)0), 751 beans::PropertyAttribute::BOUND )); 752 rProperties.push_back( 753 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsLayerMode") ), 754 PROPERTY_LAYERMODE, 755 ::getCppuBooleanType(), 756 beans::PropertyAttribute::BOUND )); 757 rProperties.push_back( 758 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode") ), 759 PROPERTY_MASTERPAGEMODE, 760 ::getCppuBooleanType(), 761 beans::PropertyAttribute::BOUND )); 762 rProperties.push_back( 763 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ActiveLayer") ), 764 PROPERTY_ACTIVE_LAYER, 765 ::getCppuBooleanType(), 766 beans::PropertyAttribute::BOUND )); 767 rProperties.push_back( 768 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomValue") ), 769 PROPERTY_ZOOMVALUE, 770 ::getCppuType((const sal_Int16*)0), 771 beans::PropertyAttribute::BOUND )); 772 rProperties.push_back( 773 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomType") ), 774 PROPERTY_ZOOMTYPE, 775 ::getCppuType((const sal_Int16*)0), 776 beans::PropertyAttribute::BOUND )); 777 rProperties.push_back( 778 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOffset") ), 779 PROPERTY_VIEWOFFSET, 780 ::getCppuType((const ::com::sun::star::awt::Point*)0), 781 beans::PropertyAttribute::BOUND )); 782 rProperties.push_back( 783 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("DrawViewMode") ), 784 PROPERTY_DRAWVIEWMODE, 785 ::getCppuType((const ::com::sun::star::awt::Point*)0), 786 beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID )); 787 // add new property to update current page's acc information 788 rProperties.push_back( 789 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("UpdateAcc") ), 790 PROPERTY_UPDATEACC, 791 ::getCppuType((const sal_Int16*)0), 792 beans::PropertyAttribute::BOUND )); 793 rProperties.push_back( 794 beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("PageChange") ), 795 PROPERTY_PAGE_CHANGE, 796 ::getCppuType((const sal_Int16*)0), 797 beans::PropertyAttribute::BOUND )); 798 } 799 800 801 802 803 IPropertyArrayHelper & DrawController::getInfoHelper() 804 { 805 OGuard aGuard( Application::GetSolarMutex() ); 806 807 if (mpPropertyArrayHelper.get() == NULL) 808 { 809 ::std::vector<beans::Property> aProperties; 810 FillPropertyTable (aProperties); 811 Sequence<beans::Property> aPropertySequence (aProperties.size()); 812 for (unsigned int i=0; i<aProperties.size(); i++) 813 aPropertySequence[i] = aProperties[i]; 814 mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False)); 815 } 816 817 return *mpPropertyArrayHelper.get(); 818 } 819 820 821 822 823 Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo() 824 throw ( ::com::sun::star::uno::RuntimeException) 825 { 826 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 827 828 static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 829 return xInfo; 830 } 831 832 833 uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException) 834 { 835 OGuard aGuard( Application::GetSolarMutex() ); 836 837 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 838 SdrView* pSdrView = mpBase->GetDrawView(); 839 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 840 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL; 841 842 uno::Reference< form::runtime::XFormController > xController( NULL ); 843 if ( pFormShell && pSdrView && pWindow ) 844 xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow ); 845 return xController; 846 } 847 848 ::sal_Bool SAL_CALL DrawController::isFormDesignMode( ) throw (uno::RuntimeException) 849 { 850 OGuard aGuard( Application::GetSolarMutex() ); 851 852 sal_Bool bIsDesignMode = sal_True; 853 854 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 855 if ( pFormShell ) 856 bIsDesignMode = pFormShell->IsDesignMode(); 857 858 return bIsDesignMode; 859 } 860 861 void SAL_CALL DrawController::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException) 862 { 863 OGuard aGuard( Application::GetSolarMutex() ); 864 865 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 866 if ( pFormShell ) 867 pFormShell->SetDesignMode( _DesignMode ); 868 } 869 870 uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException) 871 { 872 OGuard aGuard( Application::GetSolarMutex() ); 873 874 FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell(); 875 SdrView* pSdrView = mpBase->GetDrawView(); 876 ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell(); 877 ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL; 878 879 uno::Reference< awt::XControl > xControl( NULL ); 880 if ( pFormShell && pSdrView && pWindow ) 881 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl ); 882 return xControl; 883 } 884 885 886 887 888 sal_Bool DrawController::convertFastPropertyValue ( 889 Any & rConvertedValue, 890 Any & rOldValue, 891 sal_Int32 nHandle, 892 const Any& rValue) 893 throw ( com::sun::star::lang::IllegalArgumentException) 894 { 895 sal_Bool bResult = sal_False; 896 897 if (nHandle == PROPERTY_SUB_CONTROLLER) 898 { 899 rOldValue <<= mxSubController; 900 rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY); 901 bResult = (rOldValue != rConvertedValue); 902 } 903 else if (mxSubController.is()) 904 { 905 rConvertedValue = rValue; 906 try 907 { 908 rOldValue = mxSubController->getFastPropertyValue(nHandle); 909 bResult = (rOldValue != rConvertedValue); 910 } 911 catch(beans::UnknownPropertyException aException) 912 { 913 // The prperty is unknown and thus an illegal argument to this method. 914 throw com::sun::star::lang::IllegalArgumentException(); 915 } 916 } 917 918 return bResult; 919 } 920 921 922 923 924 void DrawController::setFastPropertyValue_NoBroadcast ( 925 sal_Int32 nHandle, 926 const Any& rValue) 927 throw ( com::sun::star::uno::Exception) 928 { 929 OGuard aGuard( Application::GetSolarMutex() ); 930 if (nHandle == PROPERTY_SUB_CONTROLLER) 931 SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY)); 932 else if (mxSubController.is()) 933 mxSubController->setFastPropertyValue(nHandle, rValue); 934 } 935 936 937 938 939 void DrawController::getFastPropertyValue ( 940 Any & rRet, 941 sal_Int32 nHandle ) const 942 { 943 OGuard aGuard( Application::GetSolarMutex() ); 944 945 switch( nHandle ) 946 { 947 case PROPERTY_WORKAREA: 948 rRet <<= awt::Rectangle( 949 maLastVisArea.Left(), 950 maLastVisArea.Top(), 951 maLastVisArea.GetWidth(), 952 maLastVisArea.GetHeight()); 953 break; 954 955 case PROPERTY_SUB_CONTROLLER: 956 rRet <<= mxSubController; 957 break; 958 959 default: 960 if (mxSubController.is()) 961 rRet = mxSubController->getFastPropertyValue(nHandle); 962 break; 963 } 964 } 965 966 967 968 969 //----------------------------------------------------------------------------- 970 971 void DrawController::ProvideFrameworkControllers (void) 972 { 973 ::vos::OGuard aGuard (Application::GetSolarMutex()); 974 try 975 { 976 Reference<XController> xController (this); 977 const Reference<XComponentContext> xContext ( 978 ::comphelper::getProcessComponentContext() ); 979 mxConfigurationController = ConfigurationController::create( 980 xContext, 981 xController); 982 mxModuleController = ModuleController::create( 983 xContext, 984 xController); 985 } 986 catch (RuntimeException&) 987 { 988 mxConfigurationController = NULL; 989 mxModuleController = NULL; 990 } 991 } 992 993 994 995 996 void DrawController::DisposeFrameworkControllers (void) 997 { 998 Reference<XComponent> xComponent (mxModuleController, UNO_QUERY); 999 if (xComponent.is()) 1000 xComponent->dispose(); 1001 1002 xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY); 1003 if (xComponent.is()) 1004 xComponent->dispose(); 1005 } 1006 1007 1008 1009 1010 void DrawController::ThrowIfDisposed (void) const 1011 throw (::com::sun::star::lang::DisposedException) 1012 { 1013 if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing) 1014 { 1015 OSL_TRACE ("Calling disposed DrawController object. Throwing exception:"); 1016 throw lang::DisposedException ( 1017 OUString(RTL_CONSTASCII_USTRINGPARAM( 1018 "DrawController object has already been disposed")), 1019 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this))); 1020 } 1021 } 1022 1023 1024 1025 1026 1027 } // end of namespace sd 1028 1029 1030