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 <comphelper/processfactory.hxx> 28 29 #include <com/sun/star/frame/UnknownModuleException.hpp> 30 #include <com/sun/star/frame/XModuleManager.hpp> 31 #include <com/sun/star/container/XNameAccess.hpp> 32 #include <com/sun/star/beans/PropertyValue.hpp> 33 34 #include "ViewShellBase.hxx" 35 #include <algorithm> 36 #include "EventMultiplexer.hxx" 37 #include "cache/SlsPageCacheManager.hxx" 38 #include "sdresid.hxx" 39 #include "app.hrc" 40 #include "strings.hrc" 41 #include "glob.hrc" 42 #include "unokywds.hxx" 43 #include <svx/svxids.hrc> 44 #include "DrawDocShell.hxx" 45 #include <sfx2/app.hxx> 46 #include "PaneChildWindows.hxx" 47 #include "NotesChildWindow.hxx" 48 #include "ViewShellManager.hxx" 49 #include "DrawController.hxx" 50 #include "UpdateLockManager.hxx" 51 #include "FrameView.hxx" 52 #include "ViewTabBar.hxx" 53 #include <sfx2/event.hxx> 54 #include "drawdoc.hxx" 55 #include <sfx2/dispatch.hxx> 56 #include <sfx2/request.hxx> 57 #include <sfx2/printer.hxx> 58 #include "DrawViewShell.hxx" 59 #include "GraphicViewShell.hxx" 60 #include "OutlineViewShell.hxx" 61 #include "SlideSorterViewShell.hxx" 62 #include "PresentationViewShell.hxx" 63 #include "FormShellManager.hxx" 64 #include "ToolBarManager.hxx" 65 #include "taskpane/PanelId.hxx" 66 #include "Window.hxx" 67 #include "framework/ConfigurationController.hxx" 68 #include "DocumentRenderer.hxx" 69 70 #include <com/sun/star/frame/XFrame.hpp> 71 #include <com/sun/star/awt/XWindow.hpp> 72 #include <com/sun/star/frame/XController.hpp> 73 #include <com/sun/star/frame/XModel.hpp> 74 #include <com/sun/star/document/XViewDataSupplier.hpp> 75 #include <com/sun/star/container/XIndexAccess.hpp> 76 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 77 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 78 #include <com/sun/star/drawing/framework/XControllerManager.hpp> 79 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 80 #include <com/sun/star/drawing/framework/ResourceId.hpp> 81 #include "framework/FrameworkHelper.hxx" 82 83 #include <rtl/ref.hxx> 84 #include <sfx2/msg.hxx> 85 #include <sfx2/objface.hxx> 86 #include <sfx2/viewfrm.hxx> 87 #include <svl/whiter.hxx> 88 #include <comphelper/processfactory.hxx> 89 #include <vcl/msgbox.hxx> 90 #include <tools/diagnose_ex.h> 91 92 #include "fubullet.hxx" 93 94 using namespace sd; 95 #define ViewShellBase 96 #include "sdslots.hxx" 97 98 using ::sd::framework::FrameworkHelper; 99 using ::rtl::OUString; 100 using namespace com::sun::star::uno; 101 using namespace com::sun::star::frame; 102 using namespace com::sun::star::container; 103 using namespace com::sun::star::lang; 104 using namespace com::sun::star::beans; 105 106 namespace { 107 108 class CurrentPageSetter 109 { 110 public: 111 CurrentPageSetter (ViewShellBase& rBase); 112 void operator () (bool); 113 private: 114 ViewShellBase& mrBase; 115 }; 116 117 } // end of anonymous namespace 118 119 120 using namespace ::com::sun::star; 121 using namespace ::com::sun::star::uno; 122 using namespace ::com::sun::star::drawing::framework; 123 using ::sd::framework::FrameworkHelper; 124 125 namespace sd { 126 127 class ViewShellBase::Implementation 128 { 129 public: 130 /** Main controller of the view shell. During the switching from one 131 stacked shell to another this pointer may be NULL. 132 */ 133 ::rtl::Reference<DrawController> mpController; 134 135 /** The view tab bar is the control for switching between different 136 views in one pane. 137 */ 138 ::rtl::Reference<ViewTabBar> mpViewTabBar; 139 140 // contains the complete area of the current view relative to the frame window 141 Rectangle maClientArea; 142 143 // This is set to true when PrepareClose() is called. 144 bool mbIsClosing; 145 146 /** The view window is the parent of all UI elements that belong to the 147 view or ViewShell. This comprises the rulers, the scroll bars, and 148 the content window. 149 It does not include the ViewTabBar. 150 */ 151 ::boost::scoped_ptr< ::Window> mpViewWindow; 152 153 ::boost::shared_ptr<ToolBarManager> mpToolBarManager; 154 155 ::boost::shared_ptr<ViewShellManager> mpViewShellManager; 156 157 ::boost::shared_ptr<tools::EventMultiplexer> mpEventMultiplexer; 158 159 ::boost::shared_ptr<UpdateLockManager> mpUpdateLockManager; 160 161 ::boost::shared_ptr<FormShellManager> mpFormShellManager; 162 163 Implementation (ViewShellBase& rBase); 164 ~Implementation (void); 165 166 void LateInit (void); 167 168 /** Show or hide the ViewTabBar. 169 @param bShow 170 When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden. 171 */ 172 void ShowViewTabBar (bool bShow); 173 174 /** Common code of ViewShellBase::OuterResizePixel() and 175 ViewShellBase::InnerResizePixel(). 176 */ 177 void ResizePixel ( 178 const Point& rOrigin, 179 const Size& rSize, 180 bool bOuterResize); 181 182 /** Show or hide the specified pane. The visibility state is taken 183 fromthe given request. 184 @param rRequest 185 The request determines the new visibility state. The state can 186 either be toggled or be set to a given value. 187 @param rsPaneURL 188 This URL specifies the pane whose visibility state to set. 189 @param rsViewURL 190 When the pane becomes visible then this view URL specifies which 191 type of view to show in it. 192 */ 193 void SetPaneVisibility ( 194 const SfxRequest& rRequest, 195 const ::rtl::OUString& rsPaneURL, 196 const ::rtl::OUString& rsViewURL); 197 198 void GetSlotState (SfxItemSet& rSet); 199 200 void ProcessRestoreEditingViewSlot (void); 201 void ProcessTaskPaneSlot (SfxRequest& rRequest); 202 203 private: 204 ViewShellBase& mrBase; 205 206 /** Hold a reference to the page cache manager of the slide sorter in 207 order to ensure that it stays alive while the ViewShellBase is 208 alive. 209 */ 210 ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager; 211 }; 212 213 214 namespace { 215 /** The only task of this window is to forward key presses to the content 216 window of the main view shell. With the key press it forwards the focus 217 so that it is not called very often. 218 */ 219 class FocusForwardingWindow : public ::Window 220 { 221 public: 222 FocusForwardingWindow (::Window& rParentWindow, ViewShellBase& rBase); 223 virtual ~FocusForwardingWindow (void); 224 virtual void KeyInput (const KeyEvent& rEvent); 225 virtual void Command (const CommandEvent& rEvent); 226 227 private: 228 ViewShellBase& mrBase; 229 }; 230 } // end of anonymous namespace 231 232 233 //===== ViewShellBase ========================================================= 234 235 TYPEINIT1(ViewShellBase, SfxViewShell); 236 237 // We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a 238 // new ViewShellBase object has been constructed. 239 240 SfxViewFactory* ViewShellBase::pFactory; 241 SfxViewShell* __EXPORT ViewShellBase::CreateInstance ( 242 SfxViewFrame *pFrame, SfxViewShell *pOldView) 243 { 244 ViewShellBase* pBase = new ViewShellBase(pFrame, pOldView); 245 pBase->LateInit(OUString()); 246 return pBase; 247 } 248 void ViewShellBase::RegisterFactory( sal_uInt16 nPrio ) 249 { 250 pFactory = new SfxViewFactory( 251 &CreateInstance,&InitFactory,nPrio,"Default"); 252 InitFactory(); 253 } 254 void ViewShellBase::InitFactory() 255 { 256 SFX_VIEW_REGISTRATION(DrawDocShell); 257 } 258 259 260 261 SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(STR_VIEWSHELLBASE)) 262 { 263 } 264 265 266 267 268 ViewShellBase::ViewShellBase ( 269 SfxViewFrame* _pFrame, 270 SfxViewShell*) 271 : SfxViewShell (_pFrame, 272 SFX_VIEW_CAN_PRINT 273 | SFX_VIEW_HAS_PRINTOPTIONS), 274 maMutex(), 275 mpImpl(), 276 mpDocShell (NULL), 277 mpDocument (NULL) 278 { 279 mpImpl.reset(new Implementation(*this)); 280 mpImpl->mpViewWindow.reset(new FocusForwardingWindow(_pFrame->GetWindow(),*this)); 281 mpImpl->mpViewWindow->SetBackground(Wallpaper()); 282 mpImpl->mpUpdateLockManager.reset(new UpdateLockManager(*this)); 283 284 _pFrame->GetWindow().SetBackground(Wallpaper()); 285 286 // Set up the members in the correct order. 287 if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell)) 288 mpDocShell = static_cast<DrawDocShell*>( 289 GetViewFrame()->GetObjectShell()); 290 if (mpDocShell != NULL) 291 mpDocument = mpDocShell->GetDoc(); 292 mpImpl->mpViewShellManager.reset(new ViewShellManager(*this)); 293 294 SetWindow(mpImpl->mpViewWindow.get()); 295 296 // Hide the window to avoid complaints from Sfx...SwitchViewShell... 297 _pFrame->GetWindow().Hide(); 298 } 299 300 301 302 303 /** In this destructor the order in which some of the members are destroyed 304 (and/or being prepared to being destroyed) is important. Change it only 305 when you know what you are doing. 306 */ 307 ViewShellBase::~ViewShellBase (void) 308 { 309 // Tell the controller that the ViewShellBase is not available anymore. 310 if (mpImpl->mpController.get() != NULL) 311 mpImpl->mpController->ReleaseViewShellBase(); 312 313 // We have to hide the main window to prevent SFX complaining after a 314 // reload about it being already visible. 315 ViewShell* pShell = GetMainViewShell().get(); 316 if (pShell!=NULL 317 && pShell->GetActiveWindow()!=NULL 318 && pShell->GetActiveWindow()->GetParent()!=NULL) 319 { 320 pShell->GetActiveWindow()->GetParent()->Hide(); 321 } 322 323 mpImpl->mpUpdateLockManager->Disable(); 324 mpImpl->mpToolBarManager->Shutdown(); 325 mpImpl->mpViewShellManager->Shutdown(); 326 327 EndListening(*GetViewFrame()); 328 EndListening(*GetDocShell()); 329 330 SetWindow(NULL); 331 } 332 333 334 335 336 void ViewShellBase::LateInit (const ::rtl::OUString& rsDefaultView) 337 { 338 StartListening(*GetViewFrame(),sal_True); 339 StartListening(*GetDocShell(),sal_True); 340 mpImpl->LateInit(); 341 InitializeFramework(); 342 343 mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this)); 344 345 mpImpl->mpFormShellManager.reset(new FormShellManager(*this)); 346 347 mpImpl->mpToolBarManager = ToolBarManager::Create( 348 *this, 349 mpImpl->mpEventMultiplexer, 350 mpImpl->mpViewShellManager); 351 352 try 353 { 354 Reference<XControllerManager> xControllerManager (GetDrawController(), UNO_QUERY_THROW); 355 Reference<XConfigurationController> xConfigurationController ( 356 xControllerManager->getConfigurationController()); 357 if (xConfigurationController.is()) 358 { 359 OUString sView (rsDefaultView); 360 if (sView.getLength() == 0) 361 sView = GetInitialViewShellType(); 362 363 ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*this)); 364 365 // Create the resource ids for the center pane and view. 366 const Reference<drawing::framework::XResourceId> xCenterPaneId ( 367 pHelper->CreateResourceId(FrameworkHelper::msCenterPaneURL)); 368 const Reference<drawing::framework::XResourceId> xCenterViewId ( 369 pHelper->CreateResourceId(sView, xCenterPaneId)); 370 371 // Request center pane and view. 372 xConfigurationController->requestResourceActivation(xCenterPaneId, ResourceActivationMode_ADD); 373 xConfigurationController->requestResourceActivation(xCenterViewId, ResourceActivationMode_REPLACE); 374 375 // Process configuration events synchronously until the center view 376 // has been created. 377 sd::framework::ConfigurationController* pConfigurationController 378 = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get()); 379 if (pConfigurationController != NULL) 380 { 381 while ( 382 ! pConfigurationController->getResource(xCenterViewId).is() 383 && pConfigurationController->hasPendingRequests()) 384 { 385 pConfigurationController->ProcessEvent(); 386 } 387 } 388 } 389 } 390 catch (RuntimeException&) 391 {} 392 393 // AutoLayouts have to be ready. 394 GetDocument()->StopWorkStartupDelay(); 395 396 UpdateBorder(); 397 398 // Remember the type of the current main view shell in the frame view. 399 ViewShell* pViewShell = GetMainViewShell().get(); 400 if (pViewShell != NULL) 401 { 402 FrameView* pFrameView = pViewShell->GetFrameView(); 403 if (pFrameView != NULL) 404 pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType()); 405 } 406 } 407 408 409 410 411 ::boost::shared_ptr<ViewShellManager> ViewShellBase::GetViewShellManager (void) const 412 { 413 return mpImpl->mpViewShellManager; 414 } 415 416 417 418 419 ::boost::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell (void) const 420 { 421 ::boost::shared_ptr<ViewShell> pMainViewShell ( 422 framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this)) 423 ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL)); 424 if (pMainViewShell.get() == NULL) 425 pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this)) 426 ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL); 427 return pMainViewShell; 428 } 429 430 431 432 433 ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame* pViewFrame) 434 { 435 ViewShellBase* pBase = NULL; 436 437 if (pViewFrame != NULL) 438 { 439 // Get the view shell for the frame and cast it to 440 // sd::ViewShellBase. 441 SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell(); 442 if (pSfxViewShell!=NULL && pSfxViewShell->ISA(::sd::ViewShellBase)) 443 pBase = static_cast<ViewShellBase*>(pSfxViewShell); 444 } 445 446 return pBase; 447 } 448 449 450 451 452 DrawDocShell* ViewShellBase::GetDocShell (void) const 453 { 454 return mpDocShell; 455 } 456 457 458 459 SdDrawDocument* ViewShellBase::GetDocument (void) const 460 { 461 return mpDocument; 462 } 463 464 465 466 467 void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 468 { 469 SfxViewShell::Notify(rBC, rHint); 470 471 if (rHint.IsA(TYPE(SfxEventHint))) 472 { 473 switch (static_cast<const SfxEventHint&>(rHint).GetEventId()) 474 { 475 case SFX_EVENT_OPENDOC: 476 if( GetDocument() && GetDocument()->IsStartWithPresentation() ) 477 { 478 if( GetViewFrame() ) 479 { 480 GetDocument()->SetStartWithPresentation( false ); 481 GetViewFrame()->GetDispatcher()->Execute( 482 SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON ); 483 } 484 } 485 else 486 { 487 // mpPaneManager->InitPanes(); 488 } 489 break; 490 491 default: 492 break; 493 } 494 } 495 } 496 497 498 499 500 void ViewShellBase::InitializeFramework (void) 501 { 502 } 503 504 505 506 507 void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize) 508 { 509 Size aObjSize = GetObjectShell()->GetVisArea().GetSize(); 510 if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 ) 511 { 512 SvBorder aBorder( GetBorderPixel() ); 513 Size aSize( rSize ); 514 aSize.Width() -= (aBorder.Left() + aBorder.Right()); 515 aSize.Height() -= (aBorder.Top() + aBorder.Bottom()); 516 Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM ); 517 SfxViewShell::SetZoomFactor( 518 Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ), 519 Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) ); 520 } 521 522 mpImpl->ResizePixel(rOrigin, rSize, false); 523 } 524 525 526 527 528 void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize) 529 { 530 mpImpl->ResizePixel (rOrigin, rSize, true); 531 } 532 533 534 535 536 void ViewShellBase::Rearrange (void) 537 { 538 OSL_ASSERT(GetViewFrame()!=NULL); 539 540 // There is a bug in the communication between embedded objects and the 541 // framework::LayoutManager that leads to missing resize updates. The 542 // following workaround enforces such an update by cycling the border to 543 // zero and back to the current value. 544 if (GetWindow() != NULL) 545 { 546 SetBorderPixel(SvBorder()); 547 UpdateBorder(true); 548 } 549 else 550 { 551 OSL_TRACE("Rearrange: window missing"); 552 } 553 554 GetViewFrame()->Resize(sal_True); 555 } 556 557 558 559 560 ErrCode ViewShellBase::DoVerb (long nVerb) 561 { 562 ErrCode aResult = ERRCODE_NONE; 563 564 ::sd::ViewShell* pShell = GetMainViewShell().get(); 565 if (pShell != NULL) 566 aResult = pShell->DoVerb (nVerb); 567 568 return aResult; 569 } 570 571 572 573 574 Reference<view::XRenderable> ViewShellBase::GetRenderable (void) 575 { 576 // Create a new DocumentRenderer on every call. It observes the life 577 // time of this ViewShellBase object. 578 return Reference<view::XRenderable>(new DocumentRenderer(*this)); 579 } 580 581 582 583 584 SfxPrinter* ViewShellBase::GetPrinter (sal_Bool bCreate) 585 { 586 OSL_ASSERT(mpImpl.get()!=NULL); 587 588 return GetDocShell()->GetPrinter (bCreate); 589 } 590 591 592 593 594 sal_uInt16 ViewShellBase::SetPrinter ( 595 SfxPrinter* pNewPrinter, 596 sal_uInt16 nDiffFlags, 597 bool bIsAPI) 598 { 599 OSL_ASSERT(mpImpl.get()!=NULL); 600 601 GetDocShell()->SetPrinter(pNewPrinter); 602 603 if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION || 604 nDiffFlags & SFX_PRINTER_CHG_SIZE) && pNewPrinter ) 605 { 606 MapMode aMap = pNewPrinter->GetMapMode(); 607 aMap.SetMapUnit(MAP_100TH_MM); 608 MapMode aOldMap = pNewPrinter->GetMapMode(); 609 pNewPrinter->SetMapMode(aMap); 610 Size aNewSize = pNewPrinter->GetOutputSize(); 611 612 sal_Bool bScaleAll = sal_False; 613 if ( bIsAPI ) 614 { 615 WarningBox aWarnBox ( 616 GetWindow(), 617 (WinBits)(WB_YES_NO | WB_DEF_YES), 618 String(SdResId(STR_SCALE_OBJS_TO_PAGE))); 619 bScaleAll = (aWarnBox.Execute() == RET_YES); 620 } 621 622 ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 623 ::boost::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell())); 624 if (pDrawViewShell) 625 { 626 SdPage* pPage = GetDocument()->GetSdPage( 627 0, PK_STANDARD ); 628 pDrawViewShell->SetPageSizeAndBorder ( 629 pDrawViewShell->GetPageKind(), 630 aNewSize, 631 -1,-1,-1,-1, 632 bScaleAll, 633 pNewPrinter->GetOrientation(), 634 pPage->GetPaperBin(), 635 pPage->IsBackgroundFullSize()); 636 } 637 638 pNewPrinter->SetMapMode(aOldMap); 639 } 640 641 return 0; 642 } 643 644 645 646 647 SfxTabPage* ViewShellBase::CreatePrintOptionsPage( 648 ::Window *pParent, 649 const SfxItemSet &rOptions) 650 { 651 (void)pParent; 652 (void)rOptions; 653 return NULL; 654 // return mpImpl->mpPrintManager->CreatePrintOptionsPage (pParent, rOptions); 655 } 656 657 658 659 660 void ViewShellBase::UIActivating( SfxInPlaceClient* pClient ) 661 { 662 mpImpl->ShowViewTabBar(false); 663 664 ViewShell* pViewShell = GetMainViewShell().get(); 665 if ( pViewShell ) 666 pViewShell->UIActivating( pClient ); 667 668 SfxViewShell::UIActivating( pClient ); 669 } 670 671 672 673 674 void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient ) 675 { 676 SfxViewShell::UIDeactivated( pClient ); 677 678 mpImpl->ShowViewTabBar(true); 679 680 ViewShell* pViewShell = GetMainViewShell().get(); 681 if ( pViewShell ) 682 pViewShell->UIDeactivated( pClient ); 683 } 684 685 686 687 688 SvBorder ViewShellBase::GetBorder (bool ) 689 { 690 int nTop = 0; 691 if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible()) 692 nTop = mpImpl->mpViewTabBar->GetHeight(); 693 return SvBorder(0,nTop,0,0); 694 } 695 696 697 698 699 void ViewShellBase::Execute (SfxRequest& rRequest) 700 { 701 sal_uInt16 nSlotId = rRequest.GetSlot(); 702 703 switch (nSlotId) 704 { 705 case SID_SWITCH_SHELL: 706 { 707 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY); 708 if (xControllerManager.is()) 709 { 710 Reference<XConfigurationController> xConfigurationController ( 711 xControllerManager->getConfigurationController()); 712 if (xConfigurationController.is()) 713 xConfigurationController->update(); 714 } 715 } 716 break; 717 718 case SID_LEFT_PANE_DRAW: 719 mpImpl->SetPaneVisibility( 720 rRequest, 721 framework::FrameworkHelper::msLeftDrawPaneURL, 722 framework::FrameworkHelper::msSlideSorterURL); 723 break; 724 725 case SID_LEFT_PANE_IMPRESS: 726 mpImpl->SetPaneVisibility( 727 rRequest, 728 framework::FrameworkHelper::msLeftImpressPaneURL, 729 framework::FrameworkHelper::msSlideSorterURL); 730 break; 731 732 case SID_TASKPANE: 733 mpImpl->SetPaneVisibility( 734 rRequest, 735 framework::FrameworkHelper::msRightPaneURL, 736 framework::FrameworkHelper::msTaskPaneURL); 737 break; 738 739 case SID_NORMAL_MULTI_PANE_GUI: 740 case SID_SLIDE_SORTER_MULTI_PANE_GUI: 741 case SID_DRAWINGMODE: 742 case SID_DIAMODE: 743 case SID_OUTLINEMODE: 744 case SID_NOTESMODE: 745 case SID_HANDOUTMODE: 746 framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest); 747 break; 748 749 case SID_WIN_FULLSCREEN: 750 // The full screen mode is not supported. Ignore the request. 751 break; 752 753 case SID_SHOW_TOOL_PANEL: 754 mpImpl->ProcessTaskPaneSlot(rRequest); 755 break; 756 757 case SID_RESTORE_EDITING_VIEW: 758 mpImpl->ProcessRestoreEditingViewSlot(); 759 break; 760 761 default: 762 // Ignore any other slot. 763 rRequest.Ignore (); 764 break; 765 } 766 } 767 768 769 770 771 void ViewShellBase::GetState (SfxItemSet& rSet) 772 { 773 // The full screen mode is not supported. Disable the the slot so that 774 // it appears grayed out when somebody uses configures the menu to show 775 // an menu item for it. 776 // if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE) 777 // rSet.DisableItem(SID_WIN_FULLSCREEN); 778 779 mpImpl->GetSlotState(rSet); 780 781 FuBullet::GetSlotState( rSet, 0, GetViewFrame() ); 782 } 783 784 785 786 787 void ViewShellBase::WriteUserDataSequence ( 788 ::com::sun::star::uno::Sequence < 789 ::com::sun::star::beans::PropertyValue >& rSequence, 790 sal_Bool bBrowse) 791 { 792 // Forward call to main sub shell. 793 ViewShell* pShell = GetMainViewShell().get(); 794 if (pShell != NULL) 795 pShell->WriteUserDataSequence (rSequence, bBrowse); 796 } 797 798 799 800 801 void ViewShellBase::ReadUserDataSequence ( 802 const ::com::sun::star::uno::Sequence < 803 ::com::sun::star::beans::PropertyValue >& rSequence, 804 sal_Bool bBrowse) 805 { 806 // Forward call to main sub shell. 807 ViewShell* pShell = GetMainViewShell().get(); 808 if (pShell != NULL) 809 { 810 pShell->ReadUserDataSequence (rSequence, bBrowse); 811 812 // For certain shell types ReadUserDataSequence may have changed the 813 // type to another one. Make sure that the center pane shows the 814 // right view shell. 815 switch (pShell->GetShellType()) 816 { 817 case ViewShell::ST_IMPRESS: 818 case ViewShell::ST_NOTES: 819 case ViewShell::ST_HANDOUT: 820 { 821 ::rtl::OUString sViewURL; 822 switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind()) 823 { 824 default: 825 case PK_STANDARD: 826 sViewURL = framework::FrameworkHelper::msImpressViewURL; 827 break; 828 case PK_NOTES: 829 sViewURL = framework::FrameworkHelper::msNotesViewURL; 830 break; 831 case PK_HANDOUT: 832 sViewURL = framework::FrameworkHelper::msHandoutViewURL; 833 break; 834 } 835 if (sViewURL.getLength() > 0) 836 framework::FrameworkHelper::Instance(*this)->RequestView( 837 sViewURL, 838 framework::FrameworkHelper::msCenterPaneURL); 839 } 840 break; 841 842 default: 843 break; 844 } 845 } 846 } 847 848 849 850 851 void ViewShellBase::Activate (sal_Bool bIsMDIActivate) 852 { 853 SfxViewShell::Activate(bIsMDIActivate); 854 855 Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY); 856 if (xControllerManager.is()) 857 { 858 Reference<XConfigurationController> xConfigurationController ( 859 xControllerManager->getConfigurationController()); 860 if (xConfigurationController.is()) 861 xConfigurationController->update(); 862 } 863 GetToolBarManager()->RequestUpdate(); 864 } 865 866 867 868 869 void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate) 870 { 871 SfxViewShell::Deactivate(bIsMDIActivate); 872 } 873 874 875 876 877 void ViewShellBase::SetZoomFactor ( 878 const Fraction &rZoomX, 879 const Fraction &rZoomY) 880 { 881 SfxViewShell::SetZoomFactor (rZoomX, rZoomY); 882 // Forward call to main sub shell. 883 ViewShell* pShell = GetMainViewShell().get(); 884 if (pShell != NULL) 885 pShell->SetZoomFactor (rZoomX, rZoomY); 886 } 887 888 889 890 891 sal_uInt16 ViewShellBase::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing) 892 { 893 sal_uInt16 nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing); 894 895 if (nResult == sal_True) 896 { 897 mpImpl->mbIsClosing = true; 898 899 // Forward call to main sub shell. 900 ViewShell* pShell = GetMainViewShell().get(); 901 if (pShell != NULL) 902 nResult = pShell->PrepareClose (bUI, bForBrowsing); 903 } 904 905 return nResult; 906 } 907 908 909 910 911 void ViewShellBase::WriteUserData (String& rString, sal_Bool bBrowse) 912 { 913 SfxViewShell::WriteUserData (rString, bBrowse); 914 915 // Forward call to main sub shell. 916 ViewShell* pShell = GetMainViewShell().get(); 917 if (pShell != NULL) 918 pShell->WriteUserData (rString); 919 } 920 921 922 923 924 void ViewShellBase::ReadUserData (const String& rString, sal_Bool bBrowse) 925 { 926 SfxViewShell::ReadUserData (rString, bBrowse); 927 928 // Forward call to main sub shell. 929 ViewShell* pShell = GetMainViewShell().get(); 930 if (pShell != NULL) 931 pShell->ReadUserData (rString); 932 } 933 934 935 936 937 SdrView* ViewShellBase::GetDrawView (void) const 938 { 939 // Forward call to main sub shell. 940 ViewShell* pShell = GetMainViewShell().get(); 941 if (pShell != NULL) 942 return pShell->GetDrawView (); 943 else 944 return SfxViewShell::GetDrawView(); 945 } 946 947 948 949 950 void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize) 951 { 952 SfxViewShell::AdjustPosSizePixel (rOfs, rSize); 953 } 954 955 956 957 958 void ViewShellBase::SetBusyState (bool bBusy) 959 { 960 if (GetDocShell() != NULL) 961 GetDocShell()->SetWaitCursor (bBusy); 962 } 963 964 965 966 967 void ViewShellBase::UpdateBorder ( bool bForce /* = false */ ) 968 { 969 // The following calls to SetBorderPixel() and InvalidateBorder() are 970 // made only for the main view shell. This not only avoids unnecessary 971 // calls for the views in side panes but prevents calling an already 972 // dying SfxViewShell base class. 973 // For issue #140703# we have to check the existence of the window, 974 // too. The SfxViewFrame accesses the window without checking it. 975 ViewShell* pMainViewShell = GetMainViewShell().get(); 976 if (pMainViewShell != NULL && GetWindow()!=NULL) 977 { 978 SvBorder aCurrentBorder (GetBorderPixel()); 979 bool bOuterResize ( ! GetDocShell()->IsInPlaceActive()); 980 SvBorder aBorder (GetBorder(bOuterResize)); 981 aBorder += pMainViewShell->GetBorder(bOuterResize); 982 983 if (bForce || (aBorder != aCurrentBorder)) 984 { 985 SetBorderPixel (aBorder); 986 InvalidateBorder(); 987 } 988 } 989 } 990 991 992 993 994 void ViewShellBase::ShowUIControls (bool bVisible) 995 { 996 if (mpImpl->mpViewTabBar.is()) 997 mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible); 998 999 ViewShell* pMainViewShell = GetMainViewShell().get(); 1000 if (pMainViewShell != NULL) 1001 pMainViewShell->ShowUIControls (bVisible); 1002 1003 UpdateBorder(); 1004 if (bVisible) 1005 Rearrange(); 1006 } 1007 1008 1009 1010 1011 OUString ViewShellBase::GetInitialViewShellType (void) 1012 { 1013 OUString sRequestedView (FrameworkHelper::msImpressViewURL); 1014 1015 do 1016 { 1017 Reference<document::XViewDataSupplier> xViewDataSupplier ( 1018 GetDocShell()->GetModel(), UNO_QUERY); 1019 if ( ! xViewDataSupplier.is()) 1020 break; 1021 1022 Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData()); 1023 if ( ! xViewData.is()) 1024 break; 1025 if (xViewData->getCount() == 0) 1026 break; 1027 1028 sal_Int32 nView = 0; 1029 ::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView); 1030 Sequence<beans::PropertyValue> aProperties; 1031 if ( ! (aAny >>= aProperties)) 1032 break; 1033 1034 // Search the properties for the one that tells us what page kind to 1035 // use. 1036 for (sal_Int32 n=0; n<aProperties.getLength(); n++) 1037 { 1038 const beans::PropertyValue& rProperty (aProperties[n]); 1039 if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL) 1040 { 1041 sal_Int16 nPageKind = 0; 1042 rProperty.Value >>= nPageKind; 1043 switch ((PageKind)nPageKind) 1044 { 1045 case PK_STANDARD: 1046 sRequestedView = FrameworkHelper::msImpressViewURL; 1047 break; 1048 1049 case PK_HANDOUT: 1050 sRequestedView = FrameworkHelper::msHandoutViewURL; 1051 break; 1052 1053 case PK_NOTES: 1054 sRequestedView = FrameworkHelper::msNotesViewURL; 1055 break; 1056 1057 default: 1058 // The page kind is invalid. This is propably an 1059 // error by the caller. We use the standard type to 1060 // keep things going. 1061 DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind"); 1062 sRequestedView = FrameworkHelper::msImpressViewURL; 1063 break; 1064 } 1065 break; 1066 } 1067 } 1068 } 1069 while (false); 1070 1071 return sRequestedView; 1072 } 1073 1074 1075 1076 1077 /** this method starts the presentation by 1078 executing the slot SID_PRESENTATION asynchronous */ 1079 void ViewShellBase::StartPresentation() 1080 { 1081 if( GetViewFrame() && GetViewFrame()->GetDispatcher() ) 1082 GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); 1083 } 1084 1085 1086 1087 1088 1089 ::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void) 1090 { 1091 OSL_ASSERT(mpImpl.get()!=NULL); 1092 OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL); 1093 1094 return mpImpl->mpEventMultiplexer; 1095 } 1096 1097 1098 1099 1100 const Rectangle& ViewShellBase::getClientRectangle (void) const 1101 { 1102 return mpImpl->maClientArea; 1103 } 1104 1105 1106 1107 1108 ::boost::shared_ptr<UpdateLockManager> ViewShellBase::GetUpdateLockManager (void) const 1109 { 1110 OSL_ASSERT(mpImpl.get()!=NULL); 1111 OSL_ASSERT(mpImpl->mpUpdateLockManager.get()!=NULL); 1112 1113 return mpImpl->mpUpdateLockManager; 1114 } 1115 1116 1117 1118 1119 ::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const 1120 { 1121 OSL_ASSERT(mpImpl.get()!=NULL); 1122 OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL); 1123 1124 return mpImpl->mpToolBarManager; 1125 } 1126 1127 1128 1129 1130 ::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const 1131 { 1132 OSL_ASSERT(mpImpl.get()!=NULL); 1133 OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL); 1134 1135 return mpImpl->mpFormShellManager; 1136 } 1137 1138 1139 1140 1141 DrawController& ViewShellBase::GetDrawController (void) const 1142 { 1143 OSL_ASSERT(mpImpl.get()!=NULL); 1144 1145 return *mpImpl->mpController; 1146 } 1147 1148 1149 1150 1151 void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar) 1152 { 1153 OSL_ASSERT(mpImpl.get()!=NULL); 1154 1155 mpImpl->mpViewTabBar = rViewTabBar; 1156 } 1157 1158 1159 1160 1161 ::Window* ViewShellBase::GetViewWindow (void) 1162 { 1163 OSL_ASSERT(mpImpl.get()!=NULL); 1164 1165 return mpImpl->mpViewWindow.get(); 1166 } 1167 1168 1169 ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const ::rtl::OUString& aCmdURL ) 1170 { 1171 ::rtl::OUString aLabel; 1172 1173 if ( aCmdURL.getLength() > 0 ) try 1174 { 1175 Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); 1176 1177 Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW ); 1178 Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW ); 1179 1180 ::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) ); 1181 1182 if( aModuleIdentifier.getLength() > 0 ) 1183 { 1184 Reference< XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY ); 1185 if( xNameAccess.is() ) 1186 { 1187 Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW ); 1188 Sequence< PropertyValue > aPropSeq; 1189 if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq ) 1190 { 1191 for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) 1192 { 1193 if( aPropSeq[i].Name.equalsAscii( "Name" )) 1194 { 1195 aPropSeq[i].Value >>= aLabel; 1196 break; 1197 } 1198 } 1199 } 1200 } 1201 } 1202 } 1203 catch ( Exception& ) 1204 { 1205 } 1206 1207 return aLabel; 1208 } 1209 1210 ::rtl::OUString ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const 1211 { 1212 Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); 1213 return ImplRetrieveLabelFromCommand( xFrame, aCmdURL ); 1214 } 1215 1216 1217 1218 //===== ViewShellBase::Implementation ========================================= 1219 1220 ViewShellBase::Implementation::Implementation (ViewShellBase& rBase) 1221 : mpController(), 1222 mpViewTabBar(), 1223 maClientArea(), 1224 mbIsClosing(false), 1225 mpViewWindow(), 1226 mpToolBarManager(), 1227 mpViewShellManager(), 1228 mpEventMultiplexer(), 1229 mpUpdateLockManager(), 1230 mpFormShellManager(), 1231 mrBase(rBase), 1232 mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance()) 1233 { 1234 } 1235 1236 1237 1238 1239 ViewShellBase::Implementation::~Implementation (void) 1240 { 1241 mpController = NULL; 1242 mpViewTabBar = NULL; 1243 mpViewWindow.reset(); 1244 mpToolBarManager.reset(); 1245 } 1246 1247 1248 1249 1250 void ViewShellBase::Implementation::LateInit (void) 1251 { 1252 mpController = new DrawController(mrBase); 1253 } 1254 1255 1256 1257 1258 void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void) 1259 { 1260 ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 1261 if (pViewShell != NULL) 1262 { 1263 FrameView* pFrameView = pViewShell->GetFrameView(); 1264 if (pFrameView != NULL) 1265 { 1266 // Set view shell, edit mode, and page kind. 1267 pFrameView->SetViewShEditMode( 1268 pFrameView->GetViewShEditModeOnLoad(), 1269 pFrameView->GetPageKindOnLoad()); 1270 pFrameView->SetPageKind( 1271 pFrameView->GetPageKindOnLoad()); 1272 ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase)); 1273 pHelper->RequestView( 1274 pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()), 1275 FrameworkHelper::msCenterPaneURL); 1276 pHelper->RunOnConfigurationEvent( 1277 ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"), 1278 CurrentPageSetter(mrBase)); 1279 } 1280 } 1281 } 1282 1283 1284 1285 1286 void ViewShellBase::Implementation::ShowViewTabBar (bool bShow) 1287 { 1288 if (mpViewTabBar.is() 1289 && (mpViewTabBar->GetTabControl()->IsVisible()==sal_True) != bShow) 1290 { 1291 mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False); 1292 mrBase.Rearrange(); 1293 } 1294 } 1295 1296 1297 1298 1299 void ViewShellBase::Implementation::ResizePixel ( 1300 const Point& rOrigin, 1301 const Size &rSize, 1302 bool bOuterResize) 1303 { 1304 if (mbIsClosing) 1305 return; 1306 1307 // Forward the call to both the base class and the main stacked sub 1308 // shell only when main sub shell exists. 1309 ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); 1310 1311 // Set the ViewTabBar temporarily to full size so that, when asked 1312 // later, it can return its true height. 1313 mrBase.SetWindow (mpViewWindow.get()); 1314 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible()) 1315 mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize); 1316 1317 // Calculate and set the border before the controls are placed. 1318 SvBorder aBorder; 1319 if (pMainViewShell != NULL) 1320 aBorder = pMainViewShell->GetBorder(bOuterResize); 1321 aBorder += mrBase.GetBorder(bOuterResize); 1322 if (mrBase.GetBorderPixel() != aBorder) 1323 mrBase.SetBorderPixel(aBorder); 1324 1325 // Place the ViewTabBar at the top. It is part of the border. 1326 SvBorder aBaseBorder; 1327 if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible()) 1328 { 1329 aBaseBorder.Top() = mpViewTabBar->GetHeight(); 1330 mpViewTabBar->GetTabControl()->SetPosSizePixel( 1331 rOrigin, Size(rSize.Width(),aBaseBorder.Top())); 1332 } 1333 1334 // The view window gets the remaining space. 1335 Point aViewWindowPosition ( 1336 rOrigin.X()+aBaseBorder.Left(), 1337 rOrigin.Y()+aBaseBorder.Top()); 1338 Size aViewWindowSize ( 1339 rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(), 1340 rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom()); 1341 mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize); 1342 1343 maClientArea = Rectangle(Point(0,0), aViewWindowSize); 1344 } 1345 1346 1347 1348 1349 void ViewShellBase::Implementation::SetPaneVisibility ( 1350 const SfxRequest& rRequest, 1351 const ::rtl::OUString& rsPaneURL, 1352 const ::rtl::OUString& rsViewURL) 1353 { 1354 try 1355 { 1356 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW); 1357 1358 const Reference< XComponentContext > xContext( 1359 ::comphelper::getProcessComponentContext() ); 1360 Reference<XResourceId> xPaneId (ResourceId::create( 1361 xContext, rsPaneURL)); 1362 Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL( 1363 xContext, rsViewURL, rsPaneURL)); 1364 1365 // Determine the new visibility state. 1366 const SfxItemSet* pArguments = rRequest.GetArgs(); 1367 sal_Bool bShowChildWindow; 1368 sal_uInt16 nSlotId = rRequest.GetSlot(); 1369 if (pArguments != NULL) 1370 bShowChildWindow = static_cast<const SfxBoolItem&>( 1371 pArguments->Get(nSlotId)).GetValue(); 1372 else 1373 { 1374 Reference<XConfigurationController> xConfigurationController ( 1375 xControllerManager->getConfigurationController()); 1376 if ( ! xConfigurationController.is()) 1377 throw RuntimeException(); 1378 Reference<XConfiguration> xConfiguration ( 1379 xConfigurationController->getRequestedConfiguration()); 1380 if ( ! xConfiguration.is()) 1381 throw RuntimeException(); 1382 1383 bShowChildWindow = ! xConfiguration->hasResource(xPaneId); 1384 } 1385 1386 // Set the desired visibility state at the current configuration 1387 // and update it accordingly. 1388 Reference<XConfigurationController> xConfigurationController ( 1389 xControllerManager->getConfigurationController()); 1390 if ( ! xConfigurationController.is()) 1391 throw RuntimeException(); 1392 if (bShowChildWindow) 1393 { 1394 xConfigurationController->requestResourceActivation( 1395 xPaneId, 1396 ResourceActivationMode_ADD); 1397 xConfigurationController->requestResourceActivation( 1398 xViewId, 1399 ResourceActivationMode_REPLACE); 1400 } 1401 else 1402 xConfigurationController->requestResourceDeactivation( 1403 xPaneId); 1404 } 1405 catch (const Exception &) 1406 { 1407 DBG_UNHANDLED_EXCEPTION(); 1408 } 1409 } 1410 1411 1412 1413 1414 1415 void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet) 1416 { 1417 try 1418 { 1419 // Get some frequently used values. 1420 Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW); 1421 Reference<XConfigurationController> xConfigurationController ( 1422 xControllerManager->getConfigurationController()); 1423 if ( ! xConfigurationController.is()) 1424 throw RuntimeException(); 1425 Reference<XConfiguration> xConfiguration ( 1426 xConfigurationController->getRequestedConfiguration()); 1427 if ( ! xConfiguration.is()) 1428 throw RuntimeException(); 1429 1430 const Reference< XComponentContext > xContext( 1431 ::comphelper::getProcessComponentContext() ); 1432 SfxWhichIter aSetIterator (rSet); 1433 sal_uInt16 nItemId (aSetIterator.FirstWhich()); 1434 while (nItemId > 0) 1435 { 1436 bool bState (false); 1437 Reference<XResourceId> xResourceId; 1438 try 1439 { 1440 switch (nItemId) 1441 { 1442 case SID_LEFT_PANE_IMPRESS: 1443 xResourceId = ResourceId::create( 1444 xContext, FrameworkHelper::msLeftImpressPaneURL); 1445 break; 1446 1447 case SID_LEFT_PANE_DRAW: 1448 xResourceId = ResourceId::create( 1449 xContext, FrameworkHelper::msLeftDrawPaneURL); 1450 break; 1451 1452 case SID_TASKPANE: 1453 xResourceId = ResourceId::create( 1454 xContext, FrameworkHelper::msRightPaneURL); 1455 break; 1456 1457 case SID_NORMAL_MULTI_PANE_GUI: 1458 xResourceId = ResourceId::createWithAnchorURL( 1459 xContext, 1460 FrameworkHelper::msImpressViewURL, 1461 FrameworkHelper::msCenterPaneURL); 1462 break; 1463 1464 case SID_SLIDE_SORTER_MULTI_PANE_GUI: 1465 case SID_DIAMODE: 1466 xResourceId = ResourceId::createWithAnchorURL( 1467 xContext, 1468 FrameworkHelper::msSlideSorterURL, 1469 FrameworkHelper::msCenterPaneURL); 1470 break; 1471 1472 case SID_OUTLINEMODE: 1473 xResourceId = ResourceId::createWithAnchorURL( 1474 xContext, 1475 FrameworkHelper::msOutlineViewURL, 1476 FrameworkHelper::msCenterPaneURL); 1477 break; 1478 1479 case SID_HANDOUTMODE: 1480 // There is only the master page mode for the handout 1481 // view so ignore the master page flag. 1482 xResourceId = ResourceId::createWithAnchorURL( 1483 xContext, 1484 FrameworkHelper::msHandoutViewURL, 1485 FrameworkHelper::msCenterPaneURL); 1486 break; 1487 1488 case SID_NOTESMODE: 1489 xResourceId = ResourceId::createWithAnchorURL( 1490 xContext, 1491 FrameworkHelper::msNotesViewURL, 1492 FrameworkHelper::msCenterPaneURL); 1493 break; 1494 1495 default: 1496 // Ignore all other items. They are not meant to be 1497 // handled by us. 1498 break; 1499 } 1500 } 1501 catch (DeploymentException) 1502 { 1503 } 1504 1505 // Determine the state for the resource. 1506 bState = xConfiguration->hasResource(xResourceId); 1507 1508 // Take the master page mode into account. 1509 switch (nItemId) 1510 { 1511 case SID_NORMAL_MULTI_PANE_GUI: 1512 case SID_NOTESMODE: 1513 { 1514 // Determine the master page mode. 1515 ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell( 1516 FrameworkHelper::msCenterPaneURL).get(); 1517 bool bMasterPageMode (false); 1518 if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell)) 1519 if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode() 1520 == EM_MASTERPAGE) 1521 { 1522 bMasterPageMode = true; 1523 } 1524 1525 bState &= !bMasterPageMode; 1526 break; 1527 } 1528 1529 case SID_HANDOUTMODE: 1530 // There is only the master page mode for the handout 1531 // view so ignore the master page flag. 1532 break; 1533 } 1534 1535 // And finally set the state. 1536 rSet.Put(SfxBoolItem(nItemId, bState)); 1537 1538 nItemId = aSetIterator.NextWhich(); 1539 } 1540 } 1541 catch (RuntimeException&) 1542 { 1543 DBG_UNHANDLED_EXCEPTION(); 1544 } 1545 1546 } 1547 1548 1549 1550 1551 void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest) 1552 { 1553 // Set the visibility state of the toolpanel and one of its top 1554 // level panels. 1555 sal_Bool bShowToolPanel = sal_True; 1556 toolpanel::PanelId nPanelId ( 1557 toolpanel::PID_UNKNOWN); 1558 bool bPanelIdGiven = false; 1559 1560 // Extract the given arguments. 1561 const SfxItemSet* pArgs = rRequest.GetArgs(); 1562 if (pArgs) 1563 { 1564 if ((pArgs->Count() == 1) || (pArgs->Count() == 2)) 1565 { 1566 SFX_REQUEST_ARG (rRequest, pIsPanelVisible, 1567 SfxBoolItem, ID_VAL_ISVISIBLE, sal_False); 1568 if (pIsPanelVisible != NULL) 1569 bShowToolPanel = pIsPanelVisible->GetValue(); 1570 } 1571 if (pArgs->Count() == 2) 1572 { 1573 SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item, 1574 ID_VAL_PANEL_INDEX, sal_False); 1575 if (pPanelId != NULL) 1576 { 1577 nPanelId = static_cast< 1578 toolpanel::PanelId>( 1579 pPanelId->GetValue()); 1580 bPanelIdGiven = true; 1581 } 1582 } 1583 } 1584 1585 // Ignore the request for some combinations of panels and view 1586 // shell types. 1587 if (bPanelIdGiven 1588 && ! (nPanelId==toolpanel::PID_LAYOUT 1589 && mrBase.GetMainViewShell()!=NULL 1590 && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE)) 1591 { 1592 framework::FrameworkHelper::Instance(mrBase)->RequestTaskPanel( 1593 framework::FrameworkHelper::msLayoutTaskPanelURL); 1594 } 1595 } 1596 1597 1598 } // end of namespace sd 1599 1600 1601 1602 1603 //===== CurrentPageSetter =========================================== 1604 1605 namespace { 1606 1607 CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase) 1608 : mrBase(rBase) 1609 { 1610 } 1611 1612 1613 1614 1615 1616 void CurrentPageSetter::operator() (bool) 1617 { 1618 FrameView* pFrameView = NULL; 1619 1620 if (mrBase.GetMainViewShell() != NULL) 1621 { 1622 pFrameView = mrBase.GetMainViewShell()->GetFrameView(); 1623 } 1624 1625 if (pFrameView!=NULL) 1626 { 1627 try 1628 { 1629 // Get the current page either from the DrawPagesSupplier or the 1630 // MasterPagesSupplier. 1631 Any aPage; 1632 if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE) 1633 { 1634 Reference<drawing::XDrawPagesSupplier> xPagesSupplier ( 1635 mrBase.GetController()->getModel(), UNO_QUERY_THROW); 1636 Reference<container::XIndexAccess> xPages ( 1637 xPagesSupplier->getDrawPages(), UNO_QUERY_THROW); 1638 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad()); 1639 } 1640 else 1641 { 1642 Reference<drawing::XMasterPagesSupplier> xPagesSupplier ( 1643 mrBase.GetController()->getModel(), UNO_QUERY_THROW); 1644 Reference<container::XIndexAccess> xPages ( 1645 xPagesSupplier->getMasterPages(), UNO_QUERY_THROW); 1646 aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad()); 1647 } 1648 // Switch to the page last edited by setting the CurrentPage 1649 // property. 1650 Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW); 1651 xSet->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage); 1652 } 1653 catch (RuntimeException aException) 1654 { 1655 // We have not been able to set the current page at the main view. 1656 // This is sad but still leaves us in a valid state. Therefore, 1657 // this exception is silently ignored. 1658 } 1659 catch (beans::UnknownPropertyException aException) 1660 { 1661 DBG_ASSERT(false,"CurrentPage property unknown"); 1662 } 1663 } 1664 } 1665 1666 } // end of anonymouse namespace 1667 1668 1669 1670 1671 //===== FocusForwardingWindow ================================================= 1672 1673 namespace sd { namespace { 1674 1675 FocusForwardingWindow::FocusForwardingWindow ( 1676 ::Window& rParentWindow, 1677 ViewShellBase& rBase) 1678 : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)), 1679 mrBase(rBase) 1680 { 1681 OSL_TRACE("created FocusForwardingWindow at %x", this); 1682 } 1683 1684 1685 1686 1687 FocusForwardingWindow::~FocusForwardingWindow (void) 1688 { 1689 OSL_TRACE("destroyed FocusForwardingWindow at %x", this); 1690 } 1691 1692 1693 1694 1695 void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt) 1696 { 1697 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell(); 1698 if (pViewShell.get() != NULL) 1699 { 1700 ::Window* pWindow = pViewShell->GetActiveWindow(); 1701 if (pWindow != NULL) 1702 { 1703 // Forward the focus so that the window is called directly the 1704 // next time. 1705 pWindow->GrabFocus(); 1706 // Forward the key press as well. 1707 pWindow->KeyInput(rKEvt); 1708 } 1709 } 1710 } 1711 1712 1713 1714 1715 void FocusForwardingWindow::Command (const CommandEvent& rEvent) 1716 { 1717 ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell(); 1718 if (pViewShell.get() != NULL) 1719 { 1720 ::Window* pWindow = pViewShell->GetActiveWindow(); 1721 if (pWindow != NULL) 1722 { 1723 pWindow->Command(rEvent); 1724 } 1725 } 1726 } 1727 1728 1729 } // end of anonymouse namespace 1730 1731 } // end of namespace sd 1732