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