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 "ViewShell.hxx" 28 #include "ViewShellImplementation.hxx" 29 30 #ifndef _COM_SUN_STAR_EMBED_EMBEDSTATE_HPP_ 31 #include <com/sun/star/embed/EmbedStates.hpp> 32 #endif 33 #include "ViewShellBase.hxx" 34 #include "ShellFactory.hxx" 35 #include "DrawController.hxx" 36 #include "LayerTabBar.hxx" 37 38 #include <sfx2/viewfrm.hxx> 39 #include <sfx2/bindings.hxx> 40 #include <sfx2/dispatch.hxx> 41 #ifndef _SCRBAR_HXX //autogen 42 #include <vcl/scrbar.hxx> 43 #endif 44 #include <svl/eitem.hxx> 45 #include <svx/ruler.hxx> 46 #ifndef _SVXIDS_HXX 47 #include <svx/svxids.hrc> 48 #endif 49 #include <svx/fmshell.hxx> 50 #ifndef SD_WINDOW_UPDATER_HXX 51 #include "WindowUpdater.hxx" 52 #endif 53 #include "GraphicViewShell.hxx" 54 #include <sfx2/childwin.hxx> 55 #include <sdxfer.hxx> 56 #include "GraphicViewShell.hxx" 57 #include <sfx2/childwin.hxx> 58 59 #include "app.hrc" 60 #include "helpids.h" 61 #include "strings.hrc" 62 #include "res_bmp.hrc" 63 #include "OutlineView.hxx" 64 #include "Client.hxx" 65 #include "sdresid.hxx" 66 #include "DrawDocShell.hxx" 67 #include "slideshow.hxx" 68 #include "drawdoc.hxx" 69 #include "sdpage.hxx" 70 #include "zoomlist.hxx" 71 #include "FrameView.hxx" 72 #include "optsitem.hxx" 73 #include "BezierObjectBar.hxx" 74 #include "TextObjectBar.hxx" 75 #include "GraphicObjectBar.hxx" 76 #include "MediaObjectBar.hxx" 77 #include "ViewShellManager.hxx" 78 #include "FormShellManager.hxx" 79 #include <svx/fmshell.hxx> 80 #include <svx/dialogs.hrc> 81 #include <svx/extrusionbar.hxx> 82 #include <svx/fontworkbar.hxx> 83 #include <svx/svdoutl.hxx> 84 #include <tools/diagnose_ex.h> 85 86 // #96090# 87 #include <svl/slstitm.hxx> 88 #include <sfx2/request.hxx> 89 #include "SpellDialogChildWindow.hxx" 90 91 #include "Window.hxx" 92 #include "fupoor.hxx" 93 94 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED 95 #define SO2_DECL_SVINPLACEOBJECT_DEFINED 96 SO2_DECL_REF(SvInPlaceObject) 97 #endif 98 99 namespace sd { namespace ui { namespace table { 100 extern SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView ); 101 } } } 102 103 using namespace ::com::sun::star; 104 using namespace ::com::sun::star::uno; 105 using namespace ::com::sun::star::presentation; 106 107 namespace { 108 109 class ViewShellObjectBarFactory 110 : public ::sd::ShellFactory<SfxShell> 111 { 112 public: 113 ViewShellObjectBarFactory (::sd::ViewShell& rViewShell); 114 virtual ~ViewShellObjectBarFactory (void); 115 virtual SfxShell* CreateShell ( 116 ::sd::ShellId nId, 117 ::Window* pParentWindow, 118 ::sd::FrameView* pFrameView); 119 virtual void ReleaseShell (SfxShell* pShell); 120 private: 121 ::sd::ViewShell& mrViewShell; 122 /** This cache holds the already created object bars. 123 */ 124 typedef ::std::map< ::sd::ShellId,SfxShell*> ShellCache; 125 ShellCache maShellCache; 126 }; 127 128 129 } // end of anonymous namespace 130 131 132 namespace sd { 133 134 static const int DELTA_ZOOM = 10; 135 136 sal_Bool ViewShell::IsPageFlipMode(void) const 137 { 138 return this->ISA(DrawViewShell) && mpContentWindow.get() != NULL && 139 mpContentWindow->GetVisibleHeight() >= 1.0; 140 } 141 142 SfxViewFrame* ViewShell::GetViewFrame (void) const 143 { 144 const SfxViewShell* pViewShell = GetViewShell(); 145 if (pViewShell != NULL) 146 { 147 return pViewShell->GetViewFrame(); 148 } 149 else 150 { 151 OSL_ASSERT (GetViewShell()!=NULL); 152 return NULL; 153 } 154 } 155 156 157 /************************************************************************* 158 |* 159 |* SFX-Slotmap und Standardinterface deklarieren 160 |* 161 \************************************************************************/ 162 TYPEINIT1(ViewShell, SfxShell); 163 164 165 ViewShell::ViewShell( SfxViewFrame*, ::Window* pParentWindow, ViewShellBase& rViewShellBase, bool bAllowCenter) 166 : SfxShell(&rViewShellBase) 167 , mbCenterAllowed(bAllowCenter) 168 , mpParentWindow(pParentWindow) 169 { 170 construct(); 171 } 172 173 ViewShell::~ViewShell() 174 { 175 // Keep the content window from accessing in its destructor the 176 // WindowUpdater. 177 if (mpContentWindow) 178 mpContentWindow->SetViewShell(NULL); 179 180 delete mpZoomList; 181 182 mpLayerTabBar.reset(); 183 184 if (mpImpl->mpSubShellFactory.get() != NULL) 185 GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory( 186 this,mpImpl->mpSubShellFactory); 187 188 if (mpContentWindow) 189 { 190 OSL_TRACE("destroying mpContentWindow at %x with parent %x", mpContentWindow.get(), 191 mpContentWindow->GetParent()); 192 mpContentWindow.reset(); 193 } 194 } 195 196 197 /************************************************************************* 198 |* 199 |* gemeinsamer Initialiserungsanteil der beiden Konstruktoren 200 |* 201 \************************************************************************/ 202 203 void ViewShell::construct(void) 204 { 205 mbHasRulers = false; 206 mpActiveWindow = 0; 207 mpView = 0; 208 mpFrameView = 0; 209 mpZoomList = 0; 210 mbStartShowWithDialog = sal_False; 211 mnPrintedHandoutPageNum = 1; 212 mnPrintedHandoutPageCount = 0; 213 mpWindowUpdater.reset( new ::sd::WindowUpdater() ); 214 mpImpl.reset(new Implementation(*this)); 215 meShellType = ST_NONE; 216 217 OSL_ASSERT (GetViewShell()!=NULL); 218 219 if (IsMainViewShell()) 220 GetDocSh()->Connect (this); 221 222 mpZoomList = new ZoomList( this ); 223 224 mpContentWindow.reset(new ::sd::Window(GetParentWindow())); 225 SetActiveWindow (mpContentWindow.get()); 226 227 GetParentWindow()->SetBackground (Wallpaper()); 228 mpContentWindow->SetBackground (Wallpaper()); 229 mpContentWindow->SetCenterAllowed(mbCenterAllowed); 230 mpContentWindow->SetViewShell(this); 231 mpContentWindow->SetPosSizePixel( 232 GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel()); 233 mpContentWindow->Show(); 234 static_cast< ::Window*>(mpContentWindow.get())->Resize(); 235 OSL_TRACE("content window has size %d %d", 236 mpContentWindow->GetSizePixel().Width(), 237 mpContentWindow->GetSizePixel().Height()); 238 239 if ( ! GetDocSh()->IsPreview()) 240 { 241 // Create scroll bars and the filler between the scroll bars. 242 mpHorizontalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_HSCROLL | WB_DRAG))); 243 mpHorizontalScrollBar->EnableRTL (sal_False); 244 mpHorizontalScrollBar->SetRange(Range(0, 32000)); 245 mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl)); 246 mpHorizontalScrollBar->Show(); 247 248 mpVerticalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL | WB_DRAG))); 249 mpVerticalScrollBar->SetRange(Range(0, 32000)); 250 mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl)); 251 mpVerticalScrollBar->Show(); 252 maScrBarWH = Size( 253 mpVerticalScrollBar->GetSizePixel().Width(), 254 mpHorizontalScrollBar->GetSizePixel().Height()); 255 256 mpScrollBarBox.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE)); 257 mpScrollBarBox->Show(); 258 } 259 260 String aName( RTL_CONSTASCII_USTRINGPARAM( "ViewShell" )); 261 SetName (aName); 262 263 GetDoc()->StartOnlineSpelling(sal_False); 264 265 mpWindowUpdater->SetViewShell (*this); 266 mpWindowUpdater->SetDocument (GetDoc()); 267 268 // Re-initialize the spell dialog. 269 ::sd::SpellDialogChildWindow* pSpellDialog = 270 static_cast< ::sd::SpellDialogChildWindow*> ( 271 GetViewFrame()->GetChildWindow ( 272 ::sd::SpellDialogChildWindow::GetChildWindowId())); 273 if (pSpellDialog != NULL) 274 pSpellDialog->InvalidateSpellDialog(); 275 276 // Register the sub shell factory. 277 mpImpl->mpSubShellFactory.reset(new ViewShellObjectBarFactory(*this)); 278 GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory); 279 280 GetParentWindow()->Show(); 281 } 282 283 284 285 286 void ViewShell::Init (bool bIsMainViewShell) 287 { 288 mpImpl->mbIsInitialized = true; 289 SetIsMainViewShell(bIsMainViewShell); 290 if (bIsMainViewShell) 291 SetActiveWindow (mpContentWindow.get()); 292 } 293 294 295 296 297 void ViewShell::Exit (void) 298 { 299 sd::View* pView = GetView(); 300 if (pView!=NULL && pView->IsTextEdit()) 301 { 302 pView->SdrEndTextEdit(); 303 pView->UnmarkAll(); 304 } 305 306 Deactivate (sal_True); 307 308 if (IsMainViewShell()) 309 { 310 GetDocSh()->Disconnect(this); 311 } 312 313 SetIsMainViewShell(false); 314 } 315 316 317 318 319 /************************************************************************* 320 |* 321 |* Aktivierung: Arbeitsfenster den Fokus zuweisen 322 |* 323 \************************************************************************/ 324 325 void ViewShell::Activate(sal_Bool bIsMDIActivate) 326 { 327 SfxShell::Activate(bIsMDIActivate); 328 329 // Laut MI darf keiner GrabFocus rufen, der nicht genau weiss von 330 // welchem Window der Focus gegrabt wird. Da Activate() vom SFX teilweise 331 // asynchron verschickt wird, kann es sein, dass ein falsches Window 332 // den Focus hat (#29682#): 333 //GetViewFrame()->GetWindow().GrabFocus(); 334 335 if (mpHorizontalRuler.get() != NULL) 336 mpHorizontalRuler->SetActive(sal_True); 337 if (mpVerticalRuler.get() != NULL) 338 mpVerticalRuler->SetActive(sal_True); 339 340 if (bIsMDIActivate) 341 { 342 // Damit der Navigator auch einen aktuellen Status bekommt 343 SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True ); 344 if (GetDispatcher() != NULL) 345 GetDispatcher()->Execute( 346 SID_NAVIGATOR_INIT, 347 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 348 &aItem, 349 0L); 350 351 SfxViewShell* pViewShell = GetViewShell(); 352 OSL_ASSERT (pViewShell!=NULL); 353 SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings(); 354 rBindings.Invalidate( SID_3D_STATE, sal_True, sal_False ); 355 356 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 357 if(xSlideShow.is() && xSlideShow->isRunning() ) 358 { 359 xSlideShow->activate(GetViewShellBase()); 360 } 361 if(HasCurrentFunction()) 362 { 363 GetCurrentFunction()->Activate(); 364 } 365 366 if(!GetDocSh()->IsUIActive()) 367 UpdatePreview( GetActualPage(), sal_True ); 368 369 //HMH::sd::View* pView = GetView(); 370 371 //HMHif (pView) 372 //HMH{ 373 //HMH pView->ShowMarkHdl(); 374 //HMH} 375 } 376 377 ReadFrameViewData( mpFrameView ); 378 379 if (IsMainViewShell()) 380 GetDocSh()->Connect(this); 381 } 382 383 void ViewShell::UIActivating( SfxInPlaceClient* ) 384 { 385 OSL_ASSERT (GetViewShell()!=NULL); 386 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed(); 387 } 388 389 390 391 void ViewShell::UIDeactivated( SfxInPlaceClient* ) 392 { 393 OSL_ASSERT (GetViewShell()!=NULL); 394 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed(); 395 if ( GetDrawView() ) 396 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView()); 397 } 398 399 /************************************************************************* 400 |* 401 |* Deaktivierung 402 |* 403 \************************************************************************/ 404 405 void ViewShell::Deactivate(sal_Bool bIsMDIActivate) 406 { 407 // remove view from a still active drag'n'drop session 408 SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag; 409 410 if (IsMainViewShell()) 411 GetDocSh()->Disconnect(this); 412 413 if( pDragTransferable ) 414 pDragTransferable->SetView( NULL ); 415 416 OSL_ASSERT (GetViewShell()!=NULL); 417 418 // View-Attribute an der FrameView merken 419 WriteFrameViewData(); 420 421 if (bIsMDIActivate) 422 { 423 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 424 if(xSlideShow.is() && xSlideShow->isRunning() ) 425 { 426 xSlideShow->deactivate(GetViewShellBase()); 427 } 428 if(HasCurrentFunction()) 429 { 430 GetCurrentFunction()->Deactivate(); 431 } 432 } 433 434 if (mpHorizontalRuler.get() != NULL) 435 mpHorizontalRuler->SetActive(sal_False); 436 if (mpVerticalRuler.get() != NULL) 437 mpVerticalRuler->SetActive(sal_False); 438 439 SfxShell::Deactivate(bIsMDIActivate); 440 } 441 442 443 444 445 void ViewShell::Shutdown (void) 446 { 447 Exit (); 448 } 449 450 451 452 453 /************************************************************************* 454 |* 455 |* Keyboard event 456 |* 457 \************************************************************************/ 458 459 sal_Bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) 460 { 461 sal_Bool bReturn(sal_False); 462 463 if(pWin) 464 { 465 SetActiveWindow(pWin); 466 } 467 468 if(!bReturn) 469 { 470 // #76008# 471 // give key input first to SfxViewShell to give CTRL+Key 472 // (e.g. CTRL+SHIFT+'+', to front) priority. 473 OSL_ASSERT (GetViewShell()!=NULL); 474 bReturn = (sal_Bool)GetViewShell()->KeyInput(rKEvt); 475 } 476 477 if(!bReturn) 478 { 479 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 480 if(xSlideShow.is() && xSlideShow->isRunning()) 481 { 482 bReturn = xSlideShow->keyInput(rKEvt); 483 } 484 else 485 { 486 bool bConsumed = false; 487 if( GetView() ) 488 bConsumed = GetView()->getSmartTags().KeyInput(rKEvt); 489 490 491 if( !bConsumed ) 492 { 493 rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); 494 if( !xSelectionController.is() || !xSelectionController->onKeyInput( rKEvt, pWin ) ) 495 { 496 if(HasCurrentFunction()) 497 bReturn = GetCurrentFunction()->KeyInput(rKEvt); 498 } 499 else 500 { 501 bReturn = sal_True; 502 } 503 } 504 } 505 } 506 507 if(!bReturn && GetActiveWindow()) 508 { 509 KeyCode aKeyCode = rKEvt.GetKeyCode(); 510 511 if (aKeyCode.IsMod1() && aKeyCode.IsShift() 512 && aKeyCode.GetCode() == KEY_R) 513 { 514 InvalidateWindows(); 515 bReturn = sal_True; 516 } 517 } 518 519 return(bReturn); 520 } 521 522 /************************************************************************* 523 |* 524 |* MouseButtonDown event 525 |* 526 \************************************************************************/ 527 528 void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin) 529 { 530 // We have to lock tool bar updates while the mouse button is pressed in 531 // order to prevent the shape under the mouse to be moved (this happens 532 // when the number of docked tool bars changes as result of a changed 533 // selection; this changes the window size and thus the mouse position 534 // in model coordinates: with respect to model coordinates the mouse 535 // moves.) 536 OSL_ASSERT(mpImpl->mpUpdateLockForMouse.expired()); 537 mpImpl->mpUpdateLockForMouse = ViewShell::Implementation::ToolBarManagerLock::Create( 538 GetViewShellBase().GetToolBarManager()); 539 540 if ( pWin && !pWin->HasFocus() ) 541 { 542 pWin->GrabFocus(); 543 SetActiveWindow(pWin); 544 // GetViewFrame()->GetWindow().GrabFocus(); 545 } 546 547 // MouseEvent in E3dView eintragen 548 if (GetView() != NULL) 549 GetView()->SetMouseEvent(rMEvt); 550 551 bool bConsumed = false; 552 if( GetView() ) 553 bConsumed = GetView()->getSmartTags().MouseButtonDown( rMEvt ); 554 555 if( !bConsumed ) 556 { 557 rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); 558 if( !xSelectionController.is() || !xSelectionController->onMouseButtonDown( rMEvt, pWin ) ) 559 { 560 if(HasCurrentFunction()) 561 { 562 GetCurrentFunction()->MouseButtonDown(rMEvt); 563 } 564 } 565 } 566 } 567 568 /************************************************************************* 569 |* 570 |* MouseMove event 571 |* 572 \************************************************************************/ 573 574 void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin) 575 { 576 if (rMEvt.IsLeaveWindow()) 577 { 578 if ( ! mpImpl->mpUpdateLockForMouse.expired()) 579 { 580 ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock( 581 mpImpl->mpUpdateLockForMouse); 582 if (pLock.get() != NULL) 583 pLock->Release(); 584 } 585 } 586 587 if ( pWin ) 588 { 589 SetActiveWindow(pWin); 590 } 591 592 // MouseEvent in E3dView eintragen 593 if (GetView() != NULL) 594 GetView()->SetMouseEvent(rMEvt); 595 596 if(HasCurrentFunction()) 597 { 598 rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); 599 if( !xSelectionController.is() || !xSelectionController->onMouseMove( rMEvt, pWin ) ) 600 { 601 if(HasCurrentFunction()) 602 GetCurrentFunction()->MouseMove(rMEvt); 603 } 604 } 605 } 606 607 /************************************************************************* 608 |* 609 |* MouseButtonUp event 610 |* 611 \************************************************************************/ 612 613 void ViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) 614 { 615 if ( pWin ) 616 { 617 SetActiveWindow(pWin); 618 } 619 620 // MouseEvent in E3dView eintragen 621 if (GetView() != NULL) 622 GetView()->SetMouseEvent(rMEvt); 623 624 if( HasCurrentFunction()) 625 { 626 rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() ); 627 if( !xSelectionController.is() || !xSelectionController->onMouseButtonUp( rMEvt, pWin ) ) 628 { 629 if(HasCurrentFunction()) 630 GetCurrentFunction()->MouseButtonUp(rMEvt); 631 } 632 } 633 634 if ( ! mpImpl->mpUpdateLockForMouse.expired()) 635 { 636 ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock( 637 mpImpl->mpUpdateLockForMouse); 638 if (pLock.get() != NULL) 639 pLock->Release(); 640 } 641 } 642 643 644 /************************************************************************* 645 |* 646 |* Command event 647 |* 648 \************************************************************************/ 649 650 void ViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) 651 { 652 sal_Bool bDone = HandleScrollCommand (rCEvt, pWin); 653 654 if( !bDone ) 655 { 656 if( rCEvt.GetCommand() == COMMAND_INPUTLANGUAGECHANGE ) 657 { 658 //#i42732# update state of fontname if input language changes 659 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT ); 660 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 661 } 662 else 663 { 664 bool bConsumed = false; 665 if( GetView() ) 666 { 667 bConsumed = GetView()->getSmartTags().Command(rCEvt); 668 } 669 670 if( !bConsumed && HasCurrentFunction()) 671 { 672 GetCurrentFunction()->Command(rCEvt); 673 } 674 } 675 } 676 } 677 678 long ViewShell::Notify(NotifyEvent& rNEvt, ::sd::Window* pWin) 679 { 680 // handle scroll commands when they arrived at child windows 681 long nRet = sal_False; 682 if( rNEvt.GetType() == EVENT_COMMAND ) 683 { 684 // note: dynamic_cast is not possible as GetData() returns a void* 685 CommandEvent* pCmdEvent = reinterpret_cast< CommandEvent* >(rNEvt.GetData()); 686 nRet = HandleScrollCommand(*pCmdEvent, pWin); 687 } 688 return nRet; 689 } 690 691 692 bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWin) 693 { 694 bool bDone = false; 695 696 switch( rCEvt.GetCommand() ) 697 { 698 case COMMAND_WHEEL: 699 { 700 Reference< XSlideShowController > xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) ); 701 if( xSlideShowController.is() ) 702 { 703 // We ignore zooming with control+mouse wheel. 704 const CommandWheelData* pData = rCEvt.GetWheelData(); 705 if( pData && !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) && !pData->IsHorz() ) 706 { 707 long nDelta = pData->GetDelta(); 708 if( nDelta > 0 ) 709 { 710 xSlideShowController->gotoPreviousSlide(); 711 } 712 else if( nDelta < 0 ) 713 { 714 xSlideShowController->gotoNextEffect(); 715 } 716 } 717 break; 718 } 719 } 720 // fall through when not running slideshow 721 case COMMAND_STARTAUTOSCROLL: 722 case COMMAND_AUTOSCROLL: 723 { 724 const CommandWheelData* pData = rCEvt.GetWheelData(); 725 726 if (pData != NULL) 727 { 728 if (pData->IsMod1()) 729 { 730 if( !GetDocSh()->IsUIActive() ) 731 { 732 const long nOldZoom = GetActiveWindow()->GetZoom(); 733 long nNewZoom; 734 735 if( pData->GetDelta() < 0L ) 736 nNewZoom = Max( (long) pWin->GetMinZoom(), (long)(nOldZoom - DELTA_ZOOM) ); 737 else 738 nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)(nOldZoom + DELTA_ZOOM) ); 739 740 SetZoom( nNewZoom ); 741 Invalidate( SID_ATTR_ZOOM ); 742 Invalidate( SID_ATTR_ZOOMSLIDER ); 743 744 bDone = true; 745 } 746 } 747 else 748 { 749 if( mpContentWindow.get() == pWin ) 750 { 751 sal_uLong nScrollLines = pData->GetScrollLines(); 752 if(IsPageFlipMode()) 753 nScrollLines = COMMAND_WHEEL_PAGESCROLL; 754 CommandWheelData aWheelData( pData->GetDelta(),pData->GetNotchDelta(), 755 nScrollLines,pData->GetMode(),pData->GetModifier(),pData->IsHorz() ); 756 CommandEvent aReWrite( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(), 757 rCEvt.IsMouseEvent(),(const void *) &aWheelData ); 758 bDone = pWin->HandleScrollCommand( aReWrite, 759 mpHorizontalScrollBar.get(), 760 mpVerticalScrollBar.get()) == sal_True; 761 } 762 } 763 } 764 } 765 break; 766 767 default: 768 break; 769 } 770 771 return bDone; 772 } 773 774 775 776 void ViewShell::SetupRulers (void) 777 { 778 if(mbHasRulers && (mpContentWindow.get() != NULL) && !SlideShow::IsRunning(GetViewShellBase())) 779 { 780 long nHRulerOfs = 0; 781 782 if ( mpVerticalRuler.get() == NULL ) 783 { 784 mpVerticalRuler.reset(CreateVRuler(GetActiveWindow())); 785 if ( mpVerticalRuler.get() != NULL ) 786 { 787 nHRulerOfs = mpVerticalRuler->GetSizePixel().Width(); 788 mpVerticalRuler->SetActive(sal_True); 789 mpVerticalRuler->Show(); 790 } 791 } 792 if ( mpHorizontalRuler.get() == NULL ) 793 { 794 mpHorizontalRuler.reset(CreateHRuler(GetActiveWindow(), sal_True)); 795 if ( mpHorizontalRuler.get() != NULL ) 796 { 797 mpHorizontalRuler->SetWinPos(nHRulerOfs); 798 mpHorizontalRuler->SetActive(sal_True); 799 mpHorizontalRuler->Show(); 800 } 801 } 802 } 803 } 804 805 806 807 808 sal_Bool ViewShell::HasRuler (void) 809 { 810 return mbHasRulers; 811 } 812 813 814 815 816 void ViewShell::Resize (void) 817 { 818 SetupRulers (); 819 820 if (mpParentWindow == NULL) 821 return; 822 823 // Make sure that the new size is not degenerate. 824 const Size aSize (mpParentWindow->GetSizePixel()); 825 if (aSize.Width()==0 || aSize.Height()==0) 826 return; 827 828 // Remember the new position and size. 829 maViewPos = Point(0,0); //mpParentWindow->GetPosPixel(); 830 maViewSize = aSize; 831 832 // Rearrange the UI elements to take care of the new position and size. 833 ArrangeGUIElements (); 834 // end of included AdjustPosSizePixel. 835 836 Size aS (GetParentWindow()->GetOutputSizePixel()); 837 Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel(); 838 Rectangle aVisArea = GetParentWindow()->PixelToLogic( 839 Rectangle( Point(0,0), aVisSizePixel)); 840 Rectangle aCurrentVisArea (GetDocSh()->GetVisArea(ASPECT_CONTENT)); 841 Rectangle aWindowRect = GetActiveWindow()->LogicToPixel(aCurrentVisArea); 842 if (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED 843 && IsMainViewShell()) 844 { 845 // GetDocSh()->SetVisArea(aVisArea); 846 } 847 848 // VisAreaChanged(aVisArea); 849 850 ::sd::View* pView = GetView(); 851 852 if (pView) 853 { 854 pView->VisAreaChanged(GetActiveWindow()); 855 } 856 } 857 858 SvBorder ViewShell::GetBorder (bool ) 859 { 860 SvBorder aBorder; 861 862 // Horizontal scrollbar. 863 if (mpHorizontalScrollBar.get()!=NULL 864 && mpHorizontalScrollBar->IsVisible()) 865 { 866 aBorder.Bottom() = maScrBarWH.Height(); 867 } 868 869 // Vertical scrollbar. 870 if (mpVerticalScrollBar.get()!=NULL 871 && mpVerticalScrollBar->IsVisible()) 872 { 873 aBorder.Right() = maScrBarWH.Width(); 874 } 875 876 // Place horizontal ruler below tab bar. 877 if (mbHasRulers && mpContentWindow.get() != NULL) 878 { 879 SetupRulers(); 880 if (mpHorizontalRuler.get() != NULL) 881 aBorder.Top() = mpHorizontalRuler->GetSizePixel().Height(); 882 if (mpVerticalRuler.get() != NULL) 883 aBorder.Left() = mpVerticalRuler->GetSizePixel().Width(); 884 } 885 886 return aBorder; 887 } 888 889 890 891 892 void ViewShell::ArrangeGUIElements (void) 893 { 894 if (mpImpl->mbArrangeActive) 895 return; 896 mpImpl->mbArrangeActive = true; 897 898 // Calculate border for in-place editing. 899 long nLeft = maViewPos.X(); 900 long nTop = maViewPos.Y(); 901 long nRight = maViewPos.X() + maViewSize.Width(); 902 long nBottom = maViewPos.Y() + maViewSize.Height(); 903 904 // Horizontal scrollbar. 905 if (mpHorizontalScrollBar.get()!=NULL 906 && mpHorizontalScrollBar->IsVisible()) 907 { 908 int nLocalLeft = nLeft; 909 if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible()) 910 nLocalLeft += mpLayerTabBar->GetSizePixel().Width(); 911 nBottom -= maScrBarWH.Height(); 912 mpHorizontalScrollBar->SetPosSizePixel ( 913 Point(nLocalLeft,nBottom), 914 Size(nRight-nLocalLeft-maScrBarWH.Width(),maScrBarWH.Height())); 915 } 916 917 // Vertical scrollbar. 918 if (mpVerticalScrollBar.get()!=NULL 919 && mpVerticalScrollBar->IsVisible()) 920 { 921 nRight -= maScrBarWH.Width(); 922 mpVerticalScrollBar->SetPosSizePixel ( 923 Point(nRight,nTop), 924 Size (maScrBarWH.Width(),nBottom-nTop)); 925 } 926 927 // Filler in the lower right corner. 928 if (mpScrollBarBox.get() != NULL) 929 { 930 if (mpHorizontalScrollBar.get()!=NULL 931 && mpHorizontalScrollBar->IsVisible() 932 && mpVerticalScrollBar.get()!=NULL 933 && mpVerticalScrollBar->IsVisible()) 934 { 935 mpScrollBarBox->Show(); 936 mpScrollBarBox->SetPosSizePixel(Point(nRight, nBottom), maScrBarWH); 937 } 938 else 939 mpScrollBarBox->Hide(); 940 } 941 942 // Place horizontal ruler below tab bar. 943 if (mbHasRulers && mpContentWindow.get() != NULL) 944 { 945 if (mpHorizontalRuler.get() != NULL) 946 { 947 Size aRulerSize = mpHorizontalRuler->GetSizePixel(); 948 aRulerSize.Width() = nRight - nLeft; 949 mpHorizontalRuler->SetPosSizePixel ( 950 Point(nLeft,nTop), aRulerSize); 951 if (mpVerticalRuler.get() != NULL) 952 mpHorizontalRuler->SetBorderPos( 953 mpVerticalRuler->GetSizePixel().Width()-1); 954 nTop += aRulerSize.Height(); 955 } 956 if (mpVerticalRuler.get() != NULL) 957 { 958 Size aRulerSize = mpVerticalRuler->GetSizePixel(); 959 aRulerSize.Height() = nBottom - nTop; 960 mpVerticalRuler->SetPosSizePixel ( 961 Point (nLeft,nTop), aRulerSize); 962 nLeft += aRulerSize.Width(); 963 } 964 } 965 966 rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) ); 967 968 // The size of the window of the center pane is set differently from 969 // that of the windows in the docking windows. 970 bool bSlideShowActive = (xSlideShow.is() && xSlideShow->isRunning()) && !xSlideShow->isFullScreen() && xSlideShow->getAnimationMode() == ANIMATIONMODE_SHOW; 971 if ( !bSlideShowActive) 972 { 973 OSL_ASSERT (GetViewShell()!=NULL); 974 975 if (mpContentWindow) 976 mpContentWindow->SetPosSizePixel( 977 Point(nLeft,nTop), 978 Size(nRight-nLeft,nBottom-nTop)); 979 } 980 981 // Windows in the center and rulers at the left and top side. 982 maAllWindowRectangle = Rectangle( 983 maViewPos, 984 Size(maViewSize.Width()-maScrBarWH.Width(), 985 maViewSize.Height()-maScrBarWH.Height())); 986 987 if (mpContentWindow.get() != NULL) 988 { 989 mpContentWindow->UpdateMapOrigin(); 990 } 991 992 UpdateScrollBars(); 993 994 mpImpl->mbArrangeActive = false; 995 } 996 997 998 999 1000 void ViewShell::SetUIUnit(FieldUnit eUnit) 1001 { 1002 // Set unit at horizontal and vertical rulers. 1003 if (mpHorizontalRuler.get() != NULL) 1004 mpHorizontalRuler->SetUnit(eUnit); 1005 1006 1007 if (mpVerticalRuler.get() != NULL) 1008 mpVerticalRuler->SetUnit(eUnit); 1009 } 1010 1011 /************************************************************************* 1012 |* 1013 |* DefTab an den horizontalen Linealen setzen 1014 |* 1015 \************************************************************************/ 1016 void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab ) 1017 { 1018 if (mpHorizontalRuler.get() != NULL) 1019 mpHorizontalRuler->SetDefTabDist( nDefTab ); 1020 } 1021 1022 1023 1024 1025 /** Tell the FmFormShell that the view shell is closing. Give it the 1026 oportunity to prevent that. 1027 */ 1028 sal_uInt16 ViewShell::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing) 1029 { 1030 sal_uInt16 nResult = sal_True; 1031 1032 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); 1033 if (pFormShell != NULL) 1034 nResult = pFormShell->PrepareClose (bUI, bForBrowsing); 1035 1036 return nResult; 1037 } 1038 1039 1040 1041 1042 void ViewShell::UpdatePreview (SdPage*, sal_Bool ) 1043 { 1044 // Do nothing. After the actual preview has been removed, 1045 // OutlineViewShell::UpdatePreview() is the place where something 1046 // usefull is still done. 1047 } 1048 1049 ::svl::IUndoManager* ViewShell::ImpGetUndoManager (void) const 1050 { 1051 const ViewShell* pMainViewShell = GetViewShellBase().GetMainViewShell().get(); 1052 1053 if( pMainViewShell == 0 ) 1054 pMainViewShell = this; 1055 1056 ::sd::View* pView = pMainViewShell->GetView(); 1057 1058 // check for text edit our outline view 1059 if( pView ) 1060 { 1061 if( pMainViewShell->GetShellType() == ViewShell::ST_OUTLINE ) 1062 { 1063 OutlineView* pOlView = dynamic_cast< OutlineView* >( pView ); 1064 if( pOlView ) 1065 { 1066 ::Outliner* pOutl = pOlView->GetOutliner(); 1067 if( pOutl ) 1068 return &pOutl->GetUndoManager(); 1069 } 1070 } 1071 else if( pView->IsTextEdit() ) 1072 { 1073 SdrOutliner* pOL = pView->GetTextEditOutliner(); 1074 if( pOL ) 1075 return &pOL->GetUndoManager(); 1076 } 1077 } 1078 1079 if( GetDocSh() ) 1080 return GetDocSh()->GetUndoManager(); 1081 1082 return NULL; 1083 } 1084 1085 1086 1087 1088 void ViewShell::ImpGetUndoStrings(SfxItemSet &rSet) const 1089 { 1090 ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 1091 if(pUndoManager) 1092 { 1093 sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); 1094 if(nCount) 1095 { 1096 // prepare list 1097 List aStringList; 1098 sal_uInt16 a; 1099 1100 for( a = 0; a < nCount; a++) 1101 { 1102 // generate one String in list per undo step 1103 String* pInsertString = new String(pUndoManager->GetUndoActionComment(a)); 1104 aStringList.Insert(pInsertString, LIST_APPEND); 1105 } 1106 1107 // set item 1108 rSet.Put(SfxStringListItem(SID_GETUNDOSTRINGS, &aStringList)); 1109 1110 // delete Strings again 1111 for(a = 0; a < nCount; a++) 1112 delete (String*)aStringList.GetObject(a); 1113 } 1114 else 1115 { 1116 rSet.DisableItem(SID_GETUNDOSTRINGS); 1117 } 1118 } 1119 } 1120 1121 // ----------------------------------------------------------------------------- 1122 1123 void ViewShell::ImpGetRedoStrings(SfxItemSet &rSet) const 1124 { 1125 ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 1126 if(pUndoManager) 1127 { 1128 sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); 1129 if(nCount) 1130 { 1131 // prepare list 1132 List aStringList; 1133 sal_uInt16 a; 1134 1135 for( a = 0; a < nCount; a++) 1136 { 1137 // generate one String in list per undo step 1138 String* pInsertString = new String(pUndoManager->GetRedoActionComment(a)); 1139 aStringList.Insert(pInsertString, LIST_APPEND); 1140 } 1141 1142 // set item 1143 rSet.Put(SfxStringListItem(SID_GETREDOSTRINGS, &aStringList)); 1144 1145 // delete Strings again 1146 for(a = 0; a < nCount; a++) 1147 delete (String*)aStringList.GetObject(a); 1148 } 1149 else 1150 { 1151 rSet.DisableItem(SID_GETREDOSTRINGS); 1152 } 1153 } 1154 } 1155 1156 // ----------------------------------------------------------------------------- 1157 1158 void ViewShell::ImpSidUndo(sal_Bool, SfxRequest& rReq) 1159 { 1160 ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 1161 sal_uInt16 nNumber(1); 1162 const SfxItemSet* pReqArgs = rReq.GetArgs(); 1163 1164 if(pReqArgs) 1165 { 1166 SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_UNDO); 1167 nNumber = pUIntItem->GetValue(); 1168 } 1169 1170 if(nNumber && pUndoManager) 1171 { 1172 sal_uInt16 nCount(pUndoManager->GetUndoActionCount()); 1173 if(nCount >= nNumber) 1174 { 1175 try 1176 { 1177 // #94637# when UndoStack is cleared by ModifyPageUndoAction 1178 // the nCount may have changed, so test GetUndoActionCount() 1179 while(nNumber-- && pUndoManager->GetUndoActionCount()) 1180 { 1181 pUndoManager->Undo(); 1182 } 1183 } 1184 catch( const Exception& e ) 1185 { 1186 // no need to handle. By definition, the UndoManager handled this by clearing the 1187 // Undo/Redo stacks 1188 } 1189 } 1190 1191 // #91081# refresh rulers, maybe UNDO was move of TAB marker in ruler 1192 if (mbHasRulers) 1193 { 1194 Invalidate(SID_ATTR_TABSTOP); 1195 } 1196 } 1197 1198 // This one is corresponding to the default handling 1199 // of SID_UNDO in sfx2 1200 GetViewFrame()->GetBindings().InvalidateAll(sal_False); 1201 1202 rReq.Done(); 1203 } 1204 1205 // ----------------------------------------------------------------------------- 1206 1207 void ViewShell::ImpSidRedo(sal_Bool, SfxRequest& rReq) 1208 { 1209 ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 1210 sal_uInt16 nNumber(1); 1211 const SfxItemSet* pReqArgs = rReq.GetArgs(); 1212 1213 if(pReqArgs) 1214 { 1215 SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_REDO); 1216 nNumber = pUIntItem->GetValue(); 1217 } 1218 1219 if(nNumber && pUndoManager) 1220 { 1221 sal_uInt16 nCount(pUndoManager->GetRedoActionCount()); 1222 if(nCount >= nNumber) 1223 { 1224 try 1225 { 1226 // #94637# when UndoStack is cleared by ModifyPageRedoAction 1227 // the nCount may have changed, so test GetRedoActionCount() 1228 while(nNumber-- && pUndoManager->GetRedoActionCount()) 1229 { 1230 pUndoManager->Redo(); 1231 } 1232 } 1233 catch( const Exception& e ) 1234 { 1235 // no need to handle. By definition, the UndoManager handled this by clearing the 1236 // Undo/Redo stacks 1237 } 1238 } 1239 1240 // #91081# refresh rulers, maybe REDO was move of TAB marker in ruler 1241 if (mbHasRulers) 1242 { 1243 Invalidate(SID_ATTR_TABSTOP); 1244 } 1245 } 1246 1247 // This one is corresponding to the default handling 1248 // of SID_UNDO in sfx2 1249 GetViewFrame()->GetBindings().InvalidateAll(sal_False); 1250 1251 rReq.Done(); 1252 } 1253 1254 // ----------------------------------------------------------------------------- 1255 1256 void ViewShell::ExecReq( SfxRequest& rReq ) 1257 { 1258 sal_uInt16 nSlot = rReq.GetSlot(); 1259 switch( nSlot ) 1260 { 1261 case SID_MAIL_SCROLLBODY_PAGEDOWN: 1262 { 1263 FunctionReference xFunc( GetCurrentFunction() ); 1264 if( xFunc.is() ) 1265 { 1266 xFunc->ScrollStart(); 1267 ScrollLines( 0, -1 ); 1268 xFunc->ScrollEnd(); 1269 } 1270 1271 rReq.Done(); 1272 } 1273 break; 1274 1275 case SID_OUTPUT_QUALITY_COLOR: 1276 case SID_OUTPUT_QUALITY_GRAYSCALE: 1277 case SID_OUTPUT_QUALITY_BLACKWHITE: 1278 case SID_OUTPUT_QUALITY_CONTRAST: 1279 { 1280 sal_uLong nMode = OUTPUT_DRAWMODE_COLOR; 1281 1282 switch( nSlot ) 1283 { 1284 case SID_OUTPUT_QUALITY_COLOR: nMode = OUTPUT_DRAWMODE_COLOR; break; 1285 case SID_OUTPUT_QUALITY_GRAYSCALE: nMode = OUTPUT_DRAWMODE_GRAYSCALE; break; 1286 case SID_OUTPUT_QUALITY_BLACKWHITE: nMode = OUTPUT_DRAWMODE_BLACKWHITE; break; 1287 case SID_OUTPUT_QUALITY_CONTRAST: nMode = OUTPUT_DRAWMODE_CONTRAST; break; 1288 } 1289 1290 GetActiveWindow()->SetDrawMode( nMode ); 1291 mpFrameView->SetDrawMode( nMode ); 1292 // #110094#-7 1293 // GetView()->ReleaseMasterPagePaintCache(); 1294 GetActiveWindow()->Invalidate(); 1295 1296 Invalidate(); 1297 rReq.Done(); 1298 break; 1299 } 1300 } 1301 } 1302 1303 1304 1305 1306 /** This default implemenation returns only an empty reference. See derived 1307 classes for more interesting examples. 1308 */ 1309 ::com::sun::star::uno::Reference< 1310 ::com::sun::star::accessibility::XAccessible> 1311 ViewShell::CreateAccessibleDocumentView (::sd::Window* ) 1312 { 1313 return ::com::sun::star::uno::Reference< 1314 ::com::sun::star::accessibility::XAccessible> (); 1315 } 1316 1317 1318 1319 ::sd::WindowUpdater* ViewShell::GetWindowUpdater (void) const 1320 { 1321 return mpWindowUpdater.get(); 1322 } 1323 1324 1325 1326 1327 ViewShellBase& ViewShell::GetViewShellBase (void) const 1328 { 1329 return *static_cast<ViewShellBase*>(GetViewShell()); 1330 } 1331 1332 1333 1334 1335 ViewShell::ShellType ViewShell::GetShellType (void) const 1336 { 1337 return meShellType; 1338 } 1339 1340 1341 1342 1343 DrawDocShell* ViewShell::GetDocSh (void) const 1344 { 1345 return GetViewShellBase().GetDocShell(); 1346 } 1347 1348 1349 1350 1351 SdDrawDocument* ViewShell::GetDoc (void) const 1352 { 1353 return GetViewShellBase().GetDocument(); 1354 } 1355 1356 ErrCode ViewShell::DoVerb (long ) 1357 { 1358 return ERRCODE_NONE; 1359 } 1360 1361 void ViewShell::SetCurrentFunction( const FunctionReference& xFunction) 1362 { 1363 if( mxCurrentFunction.is() && (mxOldFunction != mxCurrentFunction) ) 1364 mxCurrentFunction->Dispose(); 1365 FunctionReference xTemp( mxCurrentFunction ); 1366 mxCurrentFunction = xFunction; 1367 } 1368 1369 void ViewShell::SetOldFunction(const FunctionReference& xFunction) 1370 { 1371 if( mxOldFunction.is() && (xFunction != mxOldFunction) && (mxCurrentFunction != mxOldFunction) ) 1372 mxOldFunction->Dispose(); 1373 1374 FunctionReference xTemp( mxOldFunction ); 1375 mxOldFunction = xFunction; 1376 } 1377 1378 /** this method deactivates the current function. If an old function is 1379 saved, this will become activated and current function. 1380 */ 1381 void ViewShell::Cancel() 1382 { 1383 if(mxCurrentFunction.is() && (mxCurrentFunction != mxOldFunction )) 1384 { 1385 FunctionReference xTemp( mxCurrentFunction ); 1386 mxCurrentFunction.clear(); 1387 xTemp->Deactivate(); 1388 xTemp->Dispose(); 1389 } 1390 1391 if(mxOldFunction.is()) 1392 { 1393 mxCurrentFunction = mxOldFunction; 1394 mxCurrentFunction->Activate(); 1395 } 1396 } 1397 1398 void ViewShell::DeactivateCurrentFunction( bool bPermanent /* == false */ ) 1399 { 1400 if( mxCurrentFunction.is() ) 1401 { 1402 if(bPermanent && (mxOldFunction == mxCurrentFunction)) 1403 mxOldFunction.clear(); 1404 1405 mxCurrentFunction->Deactivate(); 1406 if( mxCurrentFunction != mxOldFunction ) 1407 mxCurrentFunction->Dispose(); 1408 1409 FunctionReference xTemp( mxCurrentFunction ); 1410 mxCurrentFunction.clear(); 1411 } 1412 } 1413 1414 void ViewShell::DisposeFunctions() 1415 { 1416 if(mxCurrentFunction.is()) 1417 { 1418 FunctionReference xTemp( mxCurrentFunction ); 1419 mxCurrentFunction.clear(); 1420 xTemp->Deactivate(); 1421 xTemp->Dispose(); 1422 } 1423 1424 if(mxOldFunction.is()) 1425 { 1426 FunctionReference xTemp( mxOldFunction ); 1427 mxOldFunction->Dispose(); 1428 mxOldFunction.clear(); 1429 } 1430 } 1431 1432 bool ViewShell::IsMainViewShell (void) const 1433 { 1434 return mpImpl->mbIsMainViewShell; 1435 // return GetViewShellBase().GetMainViewShell() == this; 1436 } 1437 1438 void ViewShell::SetIsMainViewShell (bool bIsMainViewShell) 1439 { 1440 if (bIsMainViewShell != mpImpl->mbIsMainViewShell) 1441 { 1442 mpImpl->mbIsMainViewShell = bIsMainViewShell; 1443 if (bIsMainViewShell) 1444 { 1445 GetDocSh()->Connect (this); 1446 } 1447 else 1448 { 1449 GetDocSh()->Disconnect (this); 1450 } 1451 } 1452 } 1453 1454 1455 1456 1457 ::sd::Window* ViewShell::GetActiveWindow (void) const 1458 { 1459 return mpActiveWindow; 1460 } 1461 1462 1463 1464 1465 void ViewShell::PrePaint() 1466 { 1467 } 1468 1469 1470 1471 1472 void ViewShell::Paint (const Rectangle&, ::sd::Window* ) 1473 { 1474 } 1475 1476 1477 1478 1479 void ViewShell::Draw(OutputDevice &, const Region &) 1480 { 1481 } 1482 1483 1484 1485 1486 ZoomList* ViewShell::GetZoomList (void) 1487 { 1488 return mpZoomList; 1489 } 1490 1491 1492 1493 1494 void ViewShell::ShowUIControls (bool bVisible) 1495 { 1496 mpImpl->mbIsShowingUIControls = bVisible; 1497 1498 if (mbHasRulers) 1499 { 1500 if (mpHorizontalRuler.get() != NULL) 1501 mpHorizontalRuler->Show( bVisible ); 1502 1503 if (mpVerticalRuler.get() != NULL) 1504 mpVerticalRuler->Show( bVisible ); 1505 } 1506 1507 if (mpVerticalScrollBar.get() != NULL) 1508 mpVerticalScrollBar->Show( bVisible ); 1509 1510 if (mpHorizontalScrollBar.get() != NULL) 1511 mpHorizontalScrollBar->Show( bVisible ); 1512 1513 if (mpScrollBarBox.get() != NULL) 1514 mpScrollBarBox->Show(bVisible); 1515 1516 if (mpContentWindow.get() != NULL) 1517 mpContentWindow->Show( bVisible ); 1518 } 1519 1520 1521 1522 1523 1524 bool ViewShell::RelocateToParentWindow (::Window* pParentWindow) 1525 { 1526 mpParentWindow = pParentWindow; 1527 1528 mpParentWindow->SetBackground (Wallpaper()); 1529 1530 if (mpContentWindow.get() != NULL) 1531 mpContentWindow->SetParent(pParentWindow); 1532 1533 if (mpHorizontalScrollBar.get() != NULL) 1534 mpHorizontalScrollBar->SetParent(mpParentWindow); 1535 if (mpVerticalScrollBar.get() != NULL) 1536 mpVerticalScrollBar->SetParent(mpParentWindow); 1537 if (mpScrollBarBox.get() != NULL) 1538 mpScrollBarBox->SetParent(mpParentWindow); 1539 1540 return true; 1541 } 1542 1543 1544 1545 } // end of namespace sd 1546 1547 1548 1549 1550 1551 //===== ViewShellObjectBarFactory ============================================= 1552 1553 namespace { 1554 1555 ViewShellObjectBarFactory::ViewShellObjectBarFactory ( 1556 ::sd::ViewShell& rViewShell) 1557 : mrViewShell (rViewShell) 1558 { 1559 } 1560 1561 1562 1563 1564 ViewShellObjectBarFactory::~ViewShellObjectBarFactory (void) 1565 { 1566 for (ShellCache::iterator aI(maShellCache.begin()); 1567 aI!=maShellCache.end(); 1568 aI++) 1569 { 1570 delete aI->second; 1571 } 1572 } 1573 1574 1575 1576 1577 SfxShell* ViewShellObjectBarFactory::CreateShell ( 1578 ::sd::ShellId nId, 1579 ::Window*, 1580 ::sd::FrameView* ) 1581 { 1582 SfxShell* pShell = NULL; 1583 1584 ShellCache::iterator aI (maShellCache.find(nId)); 1585 if (aI == maShellCache.end() || aI->second==NULL) 1586 { 1587 ::sd::View* pView = mrViewShell.GetView(); 1588 switch (nId) 1589 { 1590 case RID_BEZIER_TOOLBOX: 1591 pShell = new ::sd::BezierObjectBar(&mrViewShell, pView); 1592 break; 1593 1594 case RID_DRAW_TEXT_TOOLBOX: 1595 pShell = new ::sd::TextObjectBar( 1596 &mrViewShell, mrViewShell.GetDoc()->GetPool(), pView); 1597 break; 1598 1599 case RID_DRAW_GRAF_TOOLBOX: 1600 pShell = new ::sd::GraphicObjectBar(&mrViewShell, pView); 1601 break; 1602 1603 case RID_DRAW_MEDIA_TOOLBOX: 1604 pShell = new ::sd::MediaObjectBar(&mrViewShell, pView); 1605 break; 1606 1607 case RID_DRAW_TABLE_TOOLBOX: 1608 pShell = ::sd::ui::table::CreateTableObjectBar( mrViewShell, pView ); 1609 break; 1610 1611 case RID_SVX_EXTRUSION_BAR: 1612 pShell = new ::svx::ExtrusionBar( 1613 &mrViewShell.GetViewShellBase()); 1614 break; 1615 1616 case RID_SVX_FONTWORK_BAR: 1617 pShell = new ::svx::FontworkBar( 1618 &mrViewShell.GetViewShellBase()); 1619 break; 1620 1621 default: 1622 pShell = NULL; 1623 break; 1624 } 1625 } 1626 else 1627 pShell = aI->second; 1628 1629 return pShell; 1630 } 1631 1632 1633 1634 1635 void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell) 1636 { 1637 if (pShell != NULL) 1638 delete pShell; 1639 } 1640 1641 } // end of anonymous namespace 1642