1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <ViewShell.hxx>
22 #include <ViewShellImplementation.hxx>
23 #include <createtableobjectbar.hxx>
25 #include <ViewShellBase.hxx>
26 #include <ShellFactory.hxx>
27 #include <DrawController.hxx>
28 #include <LayerTabBar.hxx>
30 #include <sal/log.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/bindings.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <vcl/commandevent.hxx>
35 #include <svl/eitem.hxx>
36 #include <svx/ruler.hxx>
37 #include <svx/svxids.hrc>
38 #include <svx/fmshell.hxx>
39 #include <WindowUpdater.hxx>
44 #include <OutlineView.hxx>
45 #include <DrawViewShell.hxx>
46 #include <DrawDocShell.hxx>
47 #include <slideshow.hxx>
48 #include <drawdoc.hxx>
50 #include <zoomlist.hxx>
51 #include <FrameView.hxx>
52 #include <BezierObjectBar.hxx>
53 #include <TextObjectBar.hxx>
54 #include <GraphicObjectBar.hxx>
55 #include <MediaObjectBar.hxx>
56 #include <SlideSorter.hxx>
57 #include <SlideSorterViewShell.hxx>
58 #include <ViewShellManager.hxx>
59 #include <FormShellManager.hxx>
60 #include <svx/extrusionbar.hxx>
61 #include <svx/fontworkbar.hxx>
62 #include <svx/svdoutl.hxx>
63 #include <tools/svborder.hxx>
64 #include <comphelper/lok.hxx>
66 #include <svl/slstitm.hxx>
67 #include <sfx2/request.hxx>
68 #include <SpellDialogChildWindow.hxx>
69 #include <controller/SlideSorterController.hxx>
70 #include <controller/SlsPageSelector.hxx>
71 #include <controller/SlsSelectionObserver.hxx>
72 #include <view/SlideSorterView.hxx>
74 #include <basegfx/utils/zoomtools.hxx>
80 #include <editeng/numitem.hxx>
81 #include <editeng/eeitem.hxx>
82 #include <editeng/editview.hxx>
83 #include <editeng/editeng.hxx>
84 #include <svl/itempool.hxx>
85 #include <svl/intitem.hxx>
86 #include <svl/poolitem.hxx>
87 #include <strings.hxx>
89 #include <AccessibleDocumentViewBase.hxx>
91 using namespace ::com::sun::star
;
92 using namespace ::com::sun::star::uno
;
93 using namespace ::com::sun::star::presentation
;
97 class ViewShellObjectBarFactory
98 : public ::sd::ShellFactory
<SfxShell
>
101 explicit ViewShellObjectBarFactory (::sd::ViewShell
& rViewShell
);
102 virtual SfxShell
* CreateShell( ::sd::ShellId nId
) override
;
103 virtual void ReleaseShell (SfxShell
* pShell
) override
;
105 ::sd::ViewShell
& mrViewShell
;
108 } // end of anonymous namespace
112 bool ViewShell::IsPageFlipMode() const
114 return dynamic_cast< const DrawViewShell
*>( this ) != nullptr && mpContentWindow
&&
115 mpContentWindow
->GetVisibleHeight() >= 1.0;
118 SfxViewFrame
* ViewShell::GetViewFrame() const
120 const SfxViewShell
* pViewShell
= GetViewShell();
121 if (pViewShell
!= nullptr)
123 return &pViewShell
->GetViewFrame();
127 OSL_ASSERT (GetViewShell()!=nullptr);
132 /// declare SFX-Slotmap and standard interface
134 ViewShell::ViewShell( vcl::Window
* pParentWindow
, ViewShellBase
& rViewShellBase
)
135 : SfxShell(&rViewShellBase
)
136 , mpParentWindow(pParentWindow
)
141 ViewShell::~ViewShell()
143 // Keep the content window from accessing in its destructor the
146 mpContentWindow
->SetViewShell(nullptr);
150 mpLayerTabBar
.disposeAndClear();
152 if (mpImpl
->mpSubShellFactory
)
153 GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(
154 this,mpImpl
->mpSubShellFactory
);
160 "destroying mpContentWindow at " << mpContentWindow
.get()
161 << " with parent " << mpContentWindow
->GetParent());
162 mpContentWindow
.disposeAndClear();
165 mpVerticalRuler
.disposeAndClear();
166 mpHorizontalRuler
.disposeAndClear();
167 mpVerticalScrollBar
.disposeAndClear();
168 mpHorizontalScrollBar
.disposeAndClear();
172 * common initialization part of both constructors
174 void ViewShell::construct()
177 mpActiveWindow
= nullptr;
179 mpFrameView
= nullptr;
180 mpZoomList
= nullptr;
182 mbStartShowWithDialog
= false;
183 mnPrintedHandoutPageNum
= 1;
184 mnPrintedHandoutPageCount
= 0;
185 mpWindowUpdater
.reset( new ::sd::WindowUpdater() );
186 mpImpl
.reset(new Implementation(*this));
187 meShellType
= ST_NONE
;
189 OSL_ASSERT (GetViewShell()!=nullptr);
191 if (IsMainViewShell())
192 GetDocSh()->Connect (this);
194 mpZoomList
.reset( new ZoomList( this ) );
196 mpContentWindow
.reset(VclPtr
< ::sd::Window
>::Create(GetParentWindow()));
197 SetActiveWindow (mpContentWindow
.get());
199 GetParentWindow()->SetBackground(Application::GetSettings().GetStyleSettings().GetFaceColor());
200 mpContentWindow
->SetBackground (Wallpaper());
201 mpContentWindow
->SetCenterAllowed(true);
202 mpContentWindow
->SetViewShell(this);
203 mpContentWindow
->SetPosSizePixel(
204 GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel());
206 if ( ! GetDocSh()->IsPreview())
208 // Create scroll bars and the filler between the scroll bars.
209 mpHorizontalScrollBar
.reset (VclPtr
<ScrollAdaptor
>::Create(GetParentWindow(), true));
210 mpHorizontalScrollBar
->EnableRTL (false);
211 mpHorizontalScrollBar
->SetRange(Range(0, 32000));
212 mpHorizontalScrollBar
->SetScrollHdl(LINK(this, ViewShell
, HScrollHdl
));
214 mpVerticalScrollBar
.reset (VclPtr
<ScrollAdaptor
>::Create(GetParentWindow(), false));
215 mpVerticalScrollBar
->SetRange(Range(0, 32000));
216 mpVerticalScrollBar
->SetScrollHdl(LINK(this, ViewShell
, VScrollHdl
));
219 SetName ("ViewShell");
221 GetDoc()->StartOnlineSpelling(false);
223 mpWindowUpdater
->SetDocument (GetDoc());
225 // Re-initialize the spell dialog.
226 ::sd::SpellDialogChildWindow
* pSpellDialog
=
227 static_cast< ::sd::SpellDialogChildWindow
*> (
228 GetViewFrame()->GetChildWindow (
229 ::sd::SpellDialogChildWindow::GetChildWindowId()));
230 if (pSpellDialog
!= nullptr)
231 pSpellDialog
->InvalidateSpellDialog();
233 // Register the sub shell factory.
234 mpImpl
->mpSubShellFactory
= std::make_shared
<ViewShellObjectBarFactory
>(*this);
235 GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl
->mpSubShellFactory
);
238 void ViewShell::doShow()
240 mpContentWindow
->Show();
241 static_cast< vcl::Window
*>(mpContentWindow
.get())->Resize();
244 "content window has size " << mpContentWindow
->GetSizePixel().Width()
245 << " " << mpContentWindow
->GetSizePixel().Height());
247 if ( ! GetDocSh()->IsPreview())
250 mpHorizontalScrollBar
->Show();
252 mpVerticalScrollBar
->Show();
254 mpVerticalScrollBar
->GetSizePixel().Width(),
255 mpHorizontalScrollBar
->GetSizePixel().Height());
258 GetParentWindow()->Show();
261 void ViewShell::Init (bool bIsMainViewShell
)
263 mpImpl
->mbIsInitialized
= true;
264 SetIsMainViewShell(bIsMainViewShell
);
265 if (bIsMainViewShell
)
266 SetActiveWindow (mpContentWindow
.get());
269 void ViewShell::Exit()
271 sd::View
* pView
= GetView();
272 if (pView
!=nullptr && pView
->IsTextEdit())
274 pView
->SdrEndTextEdit();
280 if (IsMainViewShell())
281 GetDocSh()->Disconnect(this);
283 SetIsMainViewShell(false);
287 * set focus to working window
289 void ViewShell::Activate(bool bIsMDIActivate
)
291 // Do not forward to SfxShell::Activate()
293 /* According to MI, nobody is allowed to call GrabFocus, who does not
294 exactly know from which window the focus is grabbed. Since Activate()
295 is sent sometimes asynchronous, it can happen, that the wrong window
298 if (mpHorizontalRuler
)
299 mpHorizontalRuler
->SetActive();
301 mpVerticalRuler
->SetActive();
305 // thus, the Navigator will also get a current status
306 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, true );
307 if (GetDispatcher() != nullptr)
308 GetDispatcher()->ExecuteList(
310 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
,
313 SfxViewShell
* pViewShell
= GetViewShell();
314 OSL_ASSERT (pViewShell
!=nullptr);
315 SfxBindings
& rBindings
= pViewShell
->GetViewFrame().GetBindings();
316 rBindings
.Invalidate( SID_3D_STATE
, true );
318 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
319 if (xSlideShow
.is() && xSlideShow
->isRunning())
321 bool bSuccess
= xSlideShow
->activate(GetViewShellBase());
322 assert(bSuccess
&& "can only return false with a PresentationViewShell"); (void)bSuccess
;
325 if(HasCurrentFunction())
326 GetCurrentFunction()->Activate();
328 if(!GetDocSh()->IsUIActive())
329 UpdatePreview( GetActualPage() );
332 ReadFrameViewData( mpFrameView
);
334 if (IsMainViewShell())
335 GetDocSh()->Connect(this);
338 void ViewShell::UIActivating( SfxInPlaceClient
* )
340 OSL_ASSERT (GetViewShell()!=nullptr);
341 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
344 void ViewShell::UIDeactivated( SfxInPlaceClient
* )
346 OSL_ASSERT (GetViewShell()!=nullptr);
347 GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
349 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView());
352 void ViewShell::Deactivate(bool bIsMDIActivate
)
354 // remove view from a still active drag'n'drop session
355 SdTransferable
* pDragTransferable
= SD_MOD()->pTransferDrag
;
357 if (IsMainViewShell())
358 GetDocSh()->Disconnect(this);
360 if( pDragTransferable
)
361 pDragTransferable
->SetView( nullptr );
363 OSL_ASSERT (GetViewShell()!=nullptr);
365 // remember view attributes of FrameView
366 WriteFrameViewData();
370 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
371 if(xSlideShow
.is() && xSlideShow
->isRunning() )
372 xSlideShow
->deactivate();
374 if(HasCurrentFunction())
375 GetCurrentFunction()->Deactivate();
378 if (mpHorizontalRuler
)
379 mpHorizontalRuler
->SetActive(false);
381 mpVerticalRuler
->SetActive(false);
383 SfxShell::Deactivate(bIsMDIActivate
);
386 void ViewShell::Shutdown()
391 bool ViewShell::KeyInput(const KeyEvent
& rKEvt
, ::sd::Window
* pWin
)
396 SetActiveWindow(pWin
);
398 // give key input first to SfxViewShell to give CTRL+Key
399 // (e.g. CTRL+SHIFT+'+', to front) priority.
400 OSL_ASSERT(GetViewShell() != nullptr);
401 bReturn
= GetViewShell()->KeyInput(rKEvt
);
403 const size_t OriCount
= GetView()->GetMarkedObjectList().GetMarkCount();
406 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
407 if(xSlideShow
.is() && xSlideShow
->isRunning())
409 bReturn
= xSlideShow
->keyInput(rKEvt
);
413 bool bConsumed
= false;
415 bConsumed
= GetView()->getSmartTags().KeyInput(rKEvt
);
419 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
420 if( !xSelectionController
.is() || !xSelectionController
->onKeyInput( rKEvt
, pWin
) )
422 if(HasCurrentFunction())
423 bReturn
= GetCurrentFunction()->KeyInput(rKEvt
);
428 if (HasCurrentFunction())
430 FuText
* pTextFunction
= dynamic_cast<FuText
*>(GetCurrentFunction().get());
431 if(pTextFunction
!= nullptr)
432 pTextFunction
->InvalidateBindings();
438 const size_t EndCount
= GetView()->GetMarkedObjectList().GetMarkCount();
439 // Here, oriCount or endCount must have one value=0, another value > 0, then to switch focus between Document and shape objects
440 if(bReturn
&& (OriCount
+ EndCount
> 0) && (OriCount
* EndCount
== 0))
441 SwitchActiveViewFireFocus();
443 if(!bReturn
&& GetActiveWindow())
445 vcl::KeyCode aKeyCode
= rKEvt
.GetKeyCode();
447 if (aKeyCode
.IsMod1() && aKeyCode
.IsShift()
448 && aKeyCode
.GetCode() == KEY_R
)
458 void ViewShell::MouseButtonDown(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
460 // We have to lock tool bar updates while the mouse button is pressed in
461 // order to prevent the shape under the mouse to be moved (this happens
462 // when the number of docked tool bars changes as result of a changed
463 // selection; this changes the window size and thus the mouse position
464 // in model coordinates: with respect to model coordinates the mouse
466 OSL_ASSERT(mpImpl
->mpUpdateLockForMouse
.expired());
467 mpImpl
->mpUpdateLockForMouse
= ViewShell::Implementation::ToolBarManagerLock::Create(
468 GetViewShellBase().GetToolBarManager());
470 if ( pWin
&& !pWin
->HasFocus() )
473 SetActiveWindow(pWin
);
476 // insert MouseEvent into E3dView
477 if (GetView() != nullptr)
478 GetView()->SetMouseEvent(rMEvt
);
480 bool bConsumed
= false;
482 bConsumed
= GetView()->getSmartTags().MouseButtonDown( rMEvt
);
487 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
488 if( !xSelectionController
.is() || !xSelectionController
->onMouseButtonDown( rMEvt
, pWin
) )
490 if(HasCurrentFunction())
491 GetCurrentFunction()->MouseButtonDown(rMEvt
);
495 if (HasCurrentFunction())
497 FuText
* pTextFunction
= dynamic_cast<FuText
*>(GetCurrentFunction().get());
498 if (pTextFunction
!= nullptr)
499 pTextFunction
->InvalidateBindings();
504 void ViewShell::SetCursorMm100Position(const Point
& rPosition
, bool bPoint
, bool bClearMark
)
506 if (SdrView
* pSdrView
= GetView())
508 rtl::Reference
<sdr::SelectionController
> xSelectionController(GetView()->getSelectionController());
509 if (!xSelectionController
.is() || !xSelectionController
->setCursorLogicPosition(rPosition
, bPoint
))
511 if (pSdrView
->GetTextEditObject())
513 EditView
& rEditView
= pSdrView
->GetTextEditOutlinerView()->GetEditView();
514 rEditView
.SetCursorLogicPosition(rPosition
, bPoint
, bClearMark
);
520 uno::Reference
<datatransfer::XTransferable
> ViewShell::GetSelectionTransferable() const
522 SdrView
* pSdrView
= GetView();
524 return uno::Reference
<datatransfer::XTransferable
>();
526 if (!pSdrView
->GetTextEditObject())
527 return uno::Reference
<datatransfer::XTransferable
>();
529 EditView
& rEditView
= pSdrView
->GetTextEditOutlinerView()->GetEditView();
530 return rEditView
.GetEditEngine()->CreateTransferable(rEditView
.GetSelection());
533 void ViewShell::SetGraphicMm100Position(bool bStart
, const Point
& rPosition
)
537 MouseEvent
aClickEvent(rPosition
, 1, MouseEventModifiers::SIMPLECLICK
, MOUSE_LEFT
);
538 MouseButtonDown(aClickEvent
, mpActiveWindow
);
539 MouseEvent
aMoveEvent(Point(rPosition
.getX(), rPosition
.getY()), 0, MouseEventModifiers::SIMPLEMOVE
, MOUSE_LEFT
);
540 MouseMove(aMoveEvent
, mpActiveWindow
);
544 MouseEvent
aMoveEvent(Point(rPosition
.getX(), rPosition
.getY()), 0, MouseEventModifiers::SIMPLEMOVE
, MOUSE_LEFT
);
545 MouseMove(aMoveEvent
, mpActiveWindow
);
546 MouseEvent
aClickEvent(rPosition
, 1, MouseEventModifiers::SIMPLECLICK
, MOUSE_LEFT
);
547 MouseButtonUp(aClickEvent
, mpActiveWindow
);
551 void ViewShell::MouseMove(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
553 if (rMEvt
.IsLeaveWindow())
555 if ( ! mpImpl
->mpUpdateLockForMouse
.expired())
557 std::shared_ptr
<ViewShell::Implementation::ToolBarManagerLock
> pLock(
558 mpImpl
->mpUpdateLockForMouse
);
559 if (pLock
!= nullptr)
566 SetActiveWindow(pWin
);
569 // insert MouseEvent into E3dView
570 if (GetView() != nullptr)
571 GetView()->SetMouseEvent(rMEvt
);
573 if(HasCurrentFunction())
575 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
576 if( !xSelectionController
.is() || !xSelectionController
->onMouseMove( rMEvt
, pWin
) )
578 if(HasCurrentFunction())
579 GetCurrentFunction()->MouseMove(rMEvt
);
584 void ViewShell::MouseButtonUp(const MouseEvent
& rMEvt
, ::sd::Window
* pWin
)
587 SetActiveWindow(pWin
);
589 // insert MouseEvent into E3dView
590 if (GetView() != nullptr)
591 GetView()->SetMouseEvent(rMEvt
);
593 if( HasCurrentFunction())
595 rtl::Reference
< sdr::SelectionController
> xSelectionController( GetView()->getSelectionController() );
596 if( !xSelectionController
.is() || !xSelectionController
->onMouseButtonUp( rMEvt
, pWin
) )
598 if(HasCurrentFunction())
599 GetCurrentFunction()->MouseButtonUp(rMEvt
);
603 if (HasCurrentFunction())
605 FuText
* pTextFunction
= dynamic_cast<FuText
*>(GetCurrentFunction().get());
606 if (pTextFunction
!= nullptr)
607 pTextFunction
->InvalidateBindings();
612 if ( ! mpImpl
->mpUpdateLockForMouse
.expired())
614 std::shared_ptr
<ViewShell::Implementation::ToolBarManagerLock
> pLock(
615 mpImpl
->mpUpdateLockForMouse
);
616 if (pLock
!= nullptr)
621 void ViewShell::Command(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
)
623 bool bDone
= HandleScrollCommand (rCEvt
, pWin
);
628 if( rCEvt
.GetCommand() == CommandEventId::InputLanguageChange
)
630 //#i42732# update state of fontname if input language changes
631 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT
);
632 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT
);
636 bool bConsumed
= false;
638 bConsumed
= GetView()->getSmartTags().Command(rCEvt
);
640 if( !bConsumed
&& HasCurrentFunction())
641 GetCurrentFunction()->Command(rCEvt
);
645 bool ViewShell::Notify(NotifyEvent
const & rNEvt
, ::sd::Window
* pWin
)
647 // handle scroll commands when they arrived at child windows
649 if( rNEvt
.GetType() == NotifyEventType::COMMAND
)
651 // note: dynamic_cast is not possible as GetData() returns a void*
652 CommandEvent
* pCmdEvent
= static_cast< CommandEvent
* >(rNEvt
.GetData());
653 bRet
= HandleScrollCommand(*pCmdEvent
, pWin
);
658 bool ViewShell::HandleScrollCommand(const CommandEvent
& rCEvt
, ::sd::Window
* pWin
)
662 switch( rCEvt
.GetCommand() )
664 case CommandEventId::GestureSwipe
:
666 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
669 const CommandGestureSwipeData
* pSwipeData
= rCEvt
.GetGestureSwipeData();
670 bDone
= xSlideShow
->swipe(*pSwipeData
);
674 case CommandEventId::GestureLongPress
:
676 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
679 const CommandGestureLongPressData
* pLongPressData
= rCEvt
.GetLongPressData();
680 bDone
= xSlideShow
->longpress(*pLongPressData
);
685 case CommandEventId::Wheel
:
687 Reference
< XSlideShowController
> xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) );
688 if( xSlideShowController
.is() )
690 // We ignore zooming with control+mouse wheel.
691 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
692 if( pData
&& !pData
->GetModifier() && ( pData
->GetMode() == CommandWheelMode::SCROLL
) && !pData
->IsHorz() )
694 ::tools::Long nDelta
= pData
->GetDelta();
696 xSlideShowController
->gotoPreviousSlide();
697 else if( nDelta
< 0 )
698 xSlideShowController
->gotoNextEffect();
704 case CommandEventId::StartAutoScroll
:
705 case CommandEventId::AutoScroll
:
707 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
709 if (pData
!= nullptr)
713 if( !GetDocSh()->IsUIActive() )
715 const sal_uInt16 nOldZoom
= GetActiveWindow()->GetZoom();
717 Point aOldMousePos
= GetActiveWindow()->PixelToLogic(rCEvt
.GetMousePosPixel());
719 if( pData
->GetDelta() < 0 )
720 nNewZoom
= std::max
<sal_uInt16
>( pWin
->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom
));
722 nNewZoom
= std::min
<sal_uInt16
>( pWin
->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom
));
725 // Keep mouse at same doc point before zoom
726 Point aNewMousePos
= GetActiveWindow()->PixelToLogic(rCEvt
.GetMousePosPixel());
727 SetWinViewPos(GetWinViewPos() - (aNewMousePos
- aOldMousePos
));
729 Invalidate( SID_ATTR_ZOOM
);
730 Invalidate( SID_ATTR_ZOOMSLIDER
);
737 if( mpContentWindow
.get() == pWin
)
739 sal_uLong nScrollLines
= pData
->GetScrollLines();
741 nScrollLines
= COMMAND_WHEEL_PAGESCROLL
;
742 CommandWheelData
aWheelData( pData
->GetDelta(),pData
->GetNotchDelta(),
743 nScrollLines
,pData
->GetMode(),pData
->GetModifier(),pData
->IsHorz() );
744 CommandEvent
aReWrite( rCEvt
.GetMousePosPixel(),rCEvt
.GetCommand(),
745 rCEvt
.IsMouseEvent(),static_cast<const void *>(&aWheelData
) );
746 bDone
= pWin
->HandleScrollCommand( aReWrite
,
747 mpHorizontalScrollBar
.get(),
748 mpVerticalScrollBar
.get());
755 case CommandEventId::GestureZoom
:
757 const CommandGestureZoomData
* pData
= rCEvt
.GetGestureZoomData();
759 Reference
<XSlideShowController
> xSlideShowController(SlideShow::GetSlideShowController(GetViewShellBase()));
761 if (pData
->meEventType
== GestureEventZoomType::Begin
)
763 mfLastZoomScale
= pData
->mfScaleDelta
;
768 if (pData
->meEventType
== GestureEventZoomType::Update
)
770 double deltaBetweenEvents
= (pData
->mfScaleDelta
- mfLastZoomScale
) / mfLastZoomScale
;
771 mfLastZoomScale
= pData
->mfScaleDelta
;
773 if (!GetDocSh()->IsUIActive() && !xSlideShowController
.is())
775 const ::tools::Long nOldZoom
= GetActiveWindow()->GetZoom();
776 ::tools::Long nNewZoom
;
777 Point aOldMousePos
= GetActiveWindow()->PixelToLogic(rCEvt
.GetMousePosPixel());
779 // Accumulate fractional zoom to avoid small zoom changes from being ignored
780 mfAccumulatedZoom
+= deltaBetweenEvents
;
781 int nZoomChangePercent
= mfAccumulatedZoom
* 100;
782 mfAccumulatedZoom
-= nZoomChangePercent
/ 100.0;
784 nNewZoom
= nOldZoom
+ nZoomChangePercent
;
785 nNewZoom
= std::max
<::tools::Long
>(pWin
->GetMinZoom(), nNewZoom
);
786 nNewZoom
= std::min
<::tools::Long
>(pWin
->GetMaxZoom(), nNewZoom
);
790 // Keep mouse at same doc point before zoom
791 Point aNewMousePos
= GetActiveWindow()->PixelToLogic(rCEvt
.GetMousePosPixel());
792 SetWinViewPos(GetWinViewPos() - (aNewMousePos
- aOldMousePos
));
794 Invalidate(SID_ATTR_ZOOM
);
795 Invalidate(SID_ATTR_ZOOMSLIDER
);
810 void ViewShell::SetupRulers()
812 if(!mbHasRulers
|| !mpContentWindow
|| SlideShow::IsRunning(GetViewShellBase()))
815 ::tools::Long nHRulerOfs
= 0;
817 if ( !mpVerticalRuler
)
819 mpVerticalRuler
.reset(CreateVRuler(GetActiveWindow()));
820 if ( mpVerticalRuler
)
822 nHRulerOfs
= mpVerticalRuler
->GetSizePixel().Width();
823 mpVerticalRuler
->SetActive();
824 mpVerticalRuler
->Show();
827 if ( !mpHorizontalRuler
)
829 mpHorizontalRuler
.reset(CreateHRuler(GetActiveWindow()));
830 if ( mpHorizontalRuler
)
832 mpHorizontalRuler
->SetWinPos(nHRulerOfs
);
833 mpHorizontalRuler
->SetActive();
834 mpHorizontalRuler
->Show();
839 const SvxNumBulletItem
* ViewShell::GetNumBulletItem(SfxItemSet
& aNewAttr
, TypedWhichId
<SvxNumBulletItem
>& nNumItemId
)
841 const SvxNumBulletItem
* pTmpItem
= aNewAttr
.GetItemIfSet(nNumItemId
, false);
845 nNumItemId
= aNewAttr
.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE
);
846 pTmpItem
= aNewAttr
.GetItemIfSet(nNumItemId
, false);
850 bool bOutliner
= false;
855 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
856 const size_t nCount
= rMarkList
.GetMarkCount();
858 for(size_t nNum
= 0; nNum
< nCount
; ++nNum
)
860 SdrObject
* pObj
= rMarkList
.GetMark(nNum
)->GetMarkedSdrObj();
861 if( pObj
->GetObjInventor() == SdrInventor::Default
)
863 switch(pObj
->GetObjIdentifier())
865 case SdrObjKind::TitleText
:
868 case SdrObjKind::OutlineText
:
878 const SvxNumBulletItem
*pItem
= nullptr;
881 SfxStyleSheetBasePool
* pSSPool
= mpView
->GetDocSh()->GetStyleSheetPool();
882 SfxStyleSheetBase
* pFirstStyleSheet
= pSSPool
->Find( STR_LAYOUT_OUTLINE
+ " 1", SfxStyleFamily::Pseudo
);
883 if( pFirstStyleSheet
)
884 pItem
= pFirstStyleSheet
->GetItemSet().GetItemIfSet(EE_PARA_NUMBULLET
, false);
887 if( pItem
== nullptr )
888 pItem
= aNewAttr
.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
);
890 aNewAttr
.Put(pItem
->CloneSetWhich(EE_PARA_NUMBULLET
));
892 if(bTitle
&& aNewAttr
.GetItemState(EE_PARA_NUMBULLET
) == SfxItemState::SET
)
894 const SvxNumBulletItem
* pBulletItem
= aNewAttr
.GetItem(EE_PARA_NUMBULLET
);
895 const SvxNumRule
& rRule
= pBulletItem
->GetNumRule();
896 SvxNumRule
aNewRule( rRule
);
897 aNewRule
.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS
);
899 SvxNumBulletItem
aNewItem( std::move(aNewRule
), EE_PARA_NUMBULLET
);
900 aNewAttr
.Put(aNewItem
);
903 pTmpItem
= aNewAttr
.GetItemIfSet(nNumItemId
, false);
908 void ViewShell::Resize()
912 if (mpParentWindow
== nullptr)
915 // Make sure that the new size is not degenerate.
916 const Size
aSize (mpParentWindow
->GetSizePixel());
920 // Remember the new position and size.
921 maViewPos
= Point(0,0);
924 // Rearrange the UI elements to take care of the new position and size.
925 ArrangeGUIElements ();
926 // end of included AdjustPosSizePixel.
928 ::sd::View
* pView
= GetView();
931 pView
->VisAreaChanged(GetActiveWindow()->GetOutDev());
934 SvBorder
ViewShell::GetBorder()
938 // Horizontal scrollbar.
939 if (mpHorizontalScrollBar
940 && mpHorizontalScrollBar
->IsVisible())
942 aBorder
.Bottom() = maScrBarWH
.Height();
945 // Vertical scrollbar.
946 if (mpVerticalScrollBar
947 && mpVerticalScrollBar
->IsVisible())
949 aBorder
.Right() = maScrBarWH
.Width();
952 // Place horizontal ruler below tab bar.
953 if (mbHasRulers
&& mpContentWindow
)
956 if (mpHorizontalRuler
)
957 aBorder
.Top() = mpHorizontalRuler
->GetSizePixel().Height();
959 aBorder
.Left() = mpVerticalRuler
->GetSizePixel().Width();
965 void ViewShell::ArrangeGUIElements()
967 if (mpImpl
->mbArrangeActive
)
969 if (maViewSize
.IsEmpty())
971 mpImpl
->mbArrangeActive
= true;
973 // Calculate border for in-place editing.
974 ::tools::Long nLeft
= maViewPos
.X();
975 ::tools::Long nTop
= maViewPos
.Y();
976 ::tools::Long nRight
= maViewPos
.X() + maViewSize
.Width();
977 ::tools::Long nBottom
= maViewPos
.Y() + maViewSize
.Height();
979 // Horizontal scrollbar.
980 if (mpHorizontalScrollBar
981 && mpHorizontalScrollBar
->IsVisible())
983 nBottom
-= maScrBarWH
.Height();
984 if (mpLayerTabBar
&& mpLayerTabBar
->IsVisible())
985 nBottom
-= mpLayerTabBar
->GetSizePixel().Height();
986 mpHorizontalScrollBar
->SetPosSizePixel (
987 Point(nLeft
, nBottom
),
988 Size(nRight
- nLeft
- maScrBarWH
.Width(), maScrBarWH
.Height()));
991 // Vertical scrollbar.
992 if (mpVerticalScrollBar
993 && mpVerticalScrollBar
->IsVisible())
995 nRight
-= maScrBarWH
.Width();
996 mpVerticalScrollBar
->SetPosSizePixel (
998 Size (maScrBarWH
.Width(), nBottom
-nTop
));
1001 // Place horizontal ruler below tab bar.
1002 if (mbHasRulers
&& mpContentWindow
)
1004 if (mpHorizontalRuler
)
1006 Size aRulerSize
= mpHorizontalRuler
->GetSizePixel();
1007 aRulerSize
.setWidth( nRight
- nLeft
);
1008 mpHorizontalRuler
->SetPosSizePixel (
1009 Point(nLeft
,nTop
), aRulerSize
);
1010 if (mpVerticalRuler
)
1011 mpHorizontalRuler
->SetBorderPos(
1012 mpVerticalRuler
->GetSizePixel().Width()-1);
1013 nTop
+= aRulerSize
.Height();
1015 if (mpVerticalRuler
)
1017 Size aRulerSize
= mpVerticalRuler
->GetSizePixel();
1018 aRulerSize
.setHeight( nBottom
- nTop
);
1019 mpVerticalRuler
->SetPosSizePixel (
1020 Point (nLeft
,nTop
), aRulerSize
);
1021 nLeft
+= aRulerSize
.Width();
1025 rtl::Reference
< SlideShow
> xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
1027 // The size of the window of the center pane is set differently from
1028 // that of the windows in the docking windows.
1029 bool bSlideShowActive
= (xSlideShow
.is() && xSlideShow
->isRunning()) && !xSlideShow
->isFullScreen() && xSlideShow
->getAnimationMode() == ANIMATIONMODE_SHOW
;
1030 if ( !bSlideShowActive
)
1032 OSL_ASSERT (GetViewShell()!=nullptr);
1034 if (mpContentWindow
)
1035 mpContentWindow
->SetPosSizePixel(
1037 Size(nRight
-nLeft
,nBottom
-nTop
));
1040 // Windows in the center and rulers at the left and top side.
1041 maAllWindowRectangle
= ::tools::Rectangle(
1043 Size(maViewSize
.Width()-maScrBarWH
.Width(),
1044 maViewSize
.Height()-maScrBarWH
.Height()));
1046 if (mpContentWindow
)
1047 mpContentWindow
->UpdateMapOrigin();
1051 mpImpl
->mbArrangeActive
= false;
1054 void ViewShell::SetUIUnit(FieldUnit eUnit
)
1056 // Set unit at horizontal and vertical rulers.
1057 if (mpHorizontalRuler
)
1058 mpHorizontalRuler
->SetUnit(eUnit
);
1060 if (mpVerticalRuler
)
1061 mpVerticalRuler
->SetUnit(eUnit
);
1065 * set DefTab at horizontal rulers
1067 void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab
)
1069 if (mpHorizontalRuler
)
1070 mpHorizontalRuler
->SetDefTabDist( nDefTab
);
1073 /** Tell the FmFormShell that the view shell is closing. Give it the
1074 opportunity to prevent that.
1076 bool ViewShell::PrepareClose (bool bUI
)
1078 bool bResult
= true;
1080 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
1081 if (pFormShell
!= nullptr)
1082 bResult
= pFormShell
->PrepareClose (bUI
);
1087 void ViewShell::UpdatePreview (SdPage
*)
1089 // Do nothing. After the actual preview has been removed,
1090 // OutlineViewShell::UpdatePreview() is the place where something
1091 // useful is still done.
1094 SfxUndoManager
* ViewShell::ImpGetUndoManager() const
1096 const ViewShell
* pMainViewShell
= GetViewShellBase().GetMainViewShell().get();
1098 if( pMainViewShell
== nullptr )
1099 pMainViewShell
= this;
1101 ::sd::View
* pView
= pMainViewShell
->GetView();
1103 // check for text edit our outline view
1106 if( pMainViewShell
->GetShellType() == ViewShell::ST_OUTLINE
)
1108 OutlineView
* pOlView
= dynamic_cast< OutlineView
* >( pView
);
1111 ::Outliner
& rOutl
= pOlView
->GetOutliner();
1112 return &rOutl
.GetUndoManager();
1115 else if( pView
->IsTextEdit() )
1117 SdrOutliner
* pOL
= pView
->GetTextEditOutliner();
1119 return &pOL
->GetUndoManager();
1124 return GetDocSh()->GetUndoManager();
1129 void ViewShell::ImpGetUndoStrings(SfxItemSet
&rSet
) const
1131 SfxUndoManager
* pUndoManager
= ImpGetUndoManager();
1135 sal_uInt16
nCount(pUndoManager
->GetUndoActionCount());
1139 std::vector
<OUString
> aStringList
;
1140 aStringList
.reserve(nCount
);
1141 for (sal_uInt16 a
= 0; a
< nCount
; ++a
)
1143 // generate one String in list per undo step
1144 aStringList
.push_back( pUndoManager
->GetUndoActionComment(a
) );
1148 rSet
.Put(SfxStringListItem(SID_GETUNDOSTRINGS
, &aStringList
));
1152 rSet
.DisableItem(SID_GETUNDOSTRINGS
);
1156 void ViewShell::ImpGetRedoStrings(SfxItemSet
&rSet
) const
1158 SfxUndoManager
* pUndoManager
= ImpGetUndoManager();
1162 sal_uInt16
nCount(pUndoManager
->GetRedoActionCount());
1166 ::std::vector
< OUString
> aStringList
;
1167 aStringList
.reserve(nCount
);
1168 for(sal_uInt16 a
= 0; a
< nCount
; a
++)
1169 // generate one String in list per undo step
1170 aStringList
.push_back( pUndoManager
->GetRedoActionComment(a
) );
1173 rSet
.Put(SfxStringListItem(SID_GETREDOSTRINGS
, &aStringList
));
1177 rSet
.DisableItem(SID_GETREDOSTRINGS
);
1183 class KeepSlideSorterInSyncWithPageChanges
1185 sd::slidesorter::view::SlideSorterView::DrawLock m_aDrawLock
;
1186 sd::slidesorter::controller::SlideSorterController::ModelChangeLock m_aModelLock
;
1187 sd::slidesorter::controller::PageSelector::UpdateLock m_aUpdateLock
;
1188 sd::slidesorter::controller::SelectionObserver::Context m_aContext
;
1191 explicit KeepSlideSorterInSyncWithPageChanges(sd::slidesorter::SlideSorter
const & rSlideSorter
)
1192 : m_aDrawLock(rSlideSorter
)
1193 , m_aModelLock(rSlideSorter
.GetController())
1194 , m_aUpdateLock(rSlideSorter
)
1195 , m_aContext(rSlideSorter
)
1202 void ViewShell::ImpSidUndo(SfxRequest
& rReq
)
1204 //The xWatcher keeps the SlideSorter selection in sync
1205 //with the page insertions/deletions that Undo may introduce
1206 std::unique_ptr
<KeepSlideSorterInSyncWithPageChanges
, o3tl::default_delete
<KeepSlideSorterInSyncWithPageChanges
>> xWatcher
;
1207 slidesorter::SlideSorterViewShell
* pSlideSorterViewShell
1208 = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
1209 if (pSlideSorterViewShell
)
1210 xWatcher
.reset(new KeepSlideSorterInSyncWithPageChanges(pSlideSorterViewShell
->GetSlideSorter()));
1212 SfxUndoManager
* pUndoManager
= ImpGetUndoManager();
1213 sal_uInt16
nNumber(1);
1214 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1215 bool bRepair
= false;
1219 const SfxUInt16Item
* pUIntItem
= static_cast<const SfxUInt16Item
*>(&pReqArgs
->Get(SID_UNDO
));
1220 nNumber
= pUIntItem
->GetValue();
1222 // Repair mode: allow undo/redo of all undo actions, even if access would
1223 // be limited based on the view shell ID.
1224 if (const SfxBoolItem
* pRepairItem
= pReqArgs
->GetItemIfSet(SID_REPAIRPACKAGE
, false))
1225 bRepair
= pRepairItem
->GetValue();
1228 if(nNumber
&& pUndoManager
)
1230 sal_uInt16
nCount(pUndoManager
->GetUndoActionCount());
1231 if(nCount
>= nNumber
)
1233 if (comphelper::LibreOfficeKit::isActive() && !bRepair
)
1235 // If another view created the first undo action, prevent redoing it from this view.
1236 const SfxUndoAction
* pAction
= pUndoManager
->GetUndoAction();
1237 if (pAction
->GetViewShellId() != GetViewShellBase().GetViewShellId())
1239 rReq
.SetReturnValue(SfxUInt32Item(SID_UNDO
, static_cast<sal_uInt32
>(SID_REPAIRPACKAGE
)));
1246 // when UndoStack is cleared by ModifyPageUndoAction
1247 // the nCount may have changed, so test GetUndoActionCount()
1248 while(nNumber
-- && pUndoManager
->GetUndoActionCount())
1249 pUndoManager
->Undo();
1251 catch( const Exception
& )
1253 // no need to handle. By definition, the UndoManager handled this by clearing the
1258 // refresh rulers, maybe UNDO was move of TAB marker in ruler
1260 Invalidate(SID_ATTR_TABSTOP
);
1263 // This one is corresponding to the default handling
1264 // of SID_UNDO in sfx2
1265 GetViewFrame()->GetBindings().InvalidateAll(false);
1270 void ViewShell::ImpSidRedo(SfxRequest
& rReq
)
1272 //The xWatcher keeps the SlideSorter selection in sync
1273 //with the page insertions/deletions that Undo may introduce
1274 std::unique_ptr
<KeepSlideSorterInSyncWithPageChanges
, o3tl::default_delete
<KeepSlideSorterInSyncWithPageChanges
>> xWatcher
;
1275 slidesorter::SlideSorterViewShell
* pSlideSorterViewShell
1276 = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
1277 if (pSlideSorterViewShell
)
1278 xWatcher
.reset(new KeepSlideSorterInSyncWithPageChanges(pSlideSorterViewShell
->GetSlideSorter()));
1280 SfxUndoManager
* pUndoManager
= ImpGetUndoManager();
1281 sal_uInt16
nNumber(1);
1282 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1283 bool bRepair
= false;
1287 const SfxUInt16Item
* pUIntItem
= static_cast<const SfxUInt16Item
*>(&pReqArgs
->Get(SID_REDO
));
1288 nNumber
= pUIntItem
->GetValue();
1289 // Repair mode: allow undo/redo of all undo actions, even if access would
1290 // be limited based on the view shell ID.
1291 if (const SfxBoolItem
* pRepairItem
= pReqArgs
->GetItemIfSet(SID_REPAIRPACKAGE
, false))
1292 bRepair
= pRepairItem
->GetValue();
1295 if(nNumber
&& pUndoManager
)
1297 sal_uInt16
nCount(pUndoManager
->GetRedoActionCount());
1298 if(nCount
>= nNumber
)
1300 if (comphelper::LibreOfficeKit::isActive() && !bRepair
)
1302 // If another view created the first undo action, prevent redoing it from this view.
1303 const SfxUndoAction
* pAction
= pUndoManager
->GetRedoAction();
1304 if (pAction
->GetViewShellId() != GetViewShellBase().GetViewShellId())
1306 rReq
.SetReturnValue(SfxUInt32Item(SID_REDO
, static_cast<sal_uInt32
>(SID_REPAIRPACKAGE
)));
1313 // when UndoStack is cleared by ModifyPageRedoAction
1314 // the nCount may have changed, so test GetRedoActionCount()
1315 while(nNumber
-- && pUndoManager
->GetRedoActionCount())
1316 pUndoManager
->Redo();
1318 catch( const Exception
& )
1320 // no need to handle. By definition, the UndoManager handled this by clearing the
1325 // refresh rulers, maybe REDO was move of TAB marker in ruler
1328 Invalidate(SID_ATTR_TABSTOP
);
1332 // This one is corresponding to the default handling
1333 // of SID_UNDO in sfx2
1334 GetViewFrame()->GetBindings().InvalidateAll(false);
1339 void ViewShell::ExecReq( SfxRequest
& rReq
)
1341 sal_uInt16 nSlot
= rReq
.GetSlot();
1344 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
1346 rtl::Reference
<FuPoor
> xFunc( GetCurrentFunction() );
1348 ScrollLines( 0, -1 );
1354 case SID_OUTPUT_QUALITY_COLOR
:
1355 case SID_OUTPUT_QUALITY_GRAYSCALE
:
1356 case SID_OUTPUT_QUALITY_BLACKWHITE
:
1357 case SID_OUTPUT_QUALITY_CONTRAST
:
1359 DrawModeFlags nMode
= OUTPUT_DRAWMODE_COLOR
;
1363 case SID_OUTPUT_QUALITY_COLOR
: nMode
= OUTPUT_DRAWMODE_COLOR
; break;
1364 case SID_OUTPUT_QUALITY_GRAYSCALE
: nMode
= OUTPUT_DRAWMODE_GRAYSCALE
; break;
1365 case SID_OUTPUT_QUALITY_BLACKWHITE
: nMode
= OUTPUT_DRAWMODE_BLACKWHITE
; break;
1366 case SID_OUTPUT_QUALITY_CONTRAST
: nMode
= OUTPUT_DRAWMODE_CONTRAST
; break;
1369 GetActiveWindow()->GetOutDev()->SetDrawMode( nMode
);
1370 mpFrameView
->SetDrawMode( nMode
);
1372 GetActiveWindow()->Invalidate();
1381 /** This default implementation returns only an empty reference. See derived
1382 classes for more interesting examples.
1384 css::uno::Reference
<css::accessibility::XAccessible
>
1385 ViewShell::CreateAccessibleDocumentView (::sd::Window
* )
1387 OSL_FAIL("ViewShell::CreateAccessibleDocumentView should not be called!, perhaps Meyers, 3rd edition, Item 9:");
1389 return css::uno::Reference
<css::accessibility::XAccessible
> ();
1392 ::sd::WindowUpdater
* ViewShell::GetWindowUpdater() const
1394 return mpWindowUpdater
.get();
1397 ViewShellBase
& ViewShell::GetViewShellBase() const
1399 return *static_cast<ViewShellBase
*>(GetViewShell());
1402 ViewShell::ShellType
ViewShell::GetShellType() const
1407 DrawDocShell
* ViewShell::GetDocSh() const
1409 return GetViewShellBase().GetDocShell();
1412 SdDrawDocument
* ViewShell::GetDoc() const
1414 return GetViewShellBase().GetDocument();
1417 ErrCode
ViewShell::DoVerb(sal_Int32
/*nVerb*/)
1419 return ERRCODE_NONE
;
1422 void ViewShell::SetCurrentFunction( const rtl::Reference
<FuPoor
>& xFunction
)
1424 if( mxCurrentFunction
.is() && (mxOldFunction
!= mxCurrentFunction
) )
1425 mxCurrentFunction
->Dispose();
1426 rtl::Reference
<FuPoor
> xDisposeAfterNewOne( mxCurrentFunction
);
1427 mxCurrentFunction
= xFunction
;
1430 void ViewShell::SetOldFunction(const rtl::Reference
<FuPoor
>& xFunction
)
1432 if( mxOldFunction
.is() && (xFunction
!= mxOldFunction
) && (mxCurrentFunction
!= mxOldFunction
) )
1433 mxOldFunction
->Dispose();
1435 rtl::Reference
<FuPoor
> xDisposeAfterNewOne( mxOldFunction
);
1436 mxOldFunction
= xFunction
;
1439 /** this method deactivates the current function. If an old function is
1440 saved, this will become activated and current function.
1442 void ViewShell::Cancel()
1444 if(mxCurrentFunction
.is() && (mxCurrentFunction
!= mxOldFunction
))
1446 rtl::Reference
<FuPoor
> xTemp( mxCurrentFunction
);
1447 mxCurrentFunction
.clear();
1448 xTemp
->Deactivate();
1452 if(mxOldFunction
.is())
1454 mxCurrentFunction
= mxOldFunction
;
1455 mxCurrentFunction
->Activate();
1459 void ViewShell::DeactivateCurrentFunction( bool bPermanent
/* == false */ )
1461 if( mxCurrentFunction
.is() )
1463 if(bPermanent
&& (mxOldFunction
== mxCurrentFunction
))
1464 mxOldFunction
.clear();
1466 mxCurrentFunction
->Deactivate();
1467 if( mxCurrentFunction
!= mxOldFunction
)
1468 mxCurrentFunction
->Dispose();
1470 rtl::Reference
<FuPoor
> xDisposeAfterNewOne( mxCurrentFunction
);
1471 mxCurrentFunction
.clear();
1475 void ViewShell::DisposeFunctions()
1477 if(mxCurrentFunction
.is())
1479 rtl::Reference
<FuPoor
> xTemp( mxCurrentFunction
);
1480 mxCurrentFunction
.clear();
1481 xTemp
->Deactivate();
1485 if(mxOldFunction
.is())
1487 rtl::Reference
<FuPoor
> xDisposeAfterNewOne( mxOldFunction
);
1488 mxOldFunction
->Dispose();
1489 mxOldFunction
.clear();
1493 bool ViewShell::IsMainViewShell() const
1495 return mpImpl
->mbIsMainViewShell
;
1498 void ViewShell::SetIsMainViewShell (bool bIsMainViewShell
)
1500 if (bIsMainViewShell
!= mpImpl
->mbIsMainViewShell
)
1502 mpImpl
->mbIsMainViewShell
= bIsMainViewShell
;
1503 if (bIsMainViewShell
)
1504 GetDocSh()->Connect (this);
1506 GetDocSh()->Disconnect (this);
1510 void ViewShell::PrePaint()
1514 void ViewShell::Paint (const ::tools::Rectangle
&, ::sd::Window
* )
1518 void ViewShell::ShowUIControls (bool bVisible
)
1522 if (mpHorizontalRuler
)
1523 mpHorizontalRuler
->Show( bVisible
);
1525 if (mpVerticalRuler
)
1526 mpVerticalRuler
->Show( bVisible
);
1529 if (mpVerticalScrollBar
)
1530 mpVerticalScrollBar
->Show( bVisible
);
1532 if (mpHorizontalScrollBar
)
1533 mpHorizontalScrollBar
->Show( bVisible
);
1535 if (mpContentWindow
)
1536 mpContentWindow
->Show( bVisible
);
1539 bool ViewShell::RelocateToParentWindow (vcl::Window
* pParentWindow
)
1541 mpParentWindow
= pParentWindow
;
1543 mpParentWindow
->SetBackground (Wallpaper());
1545 if (mpContentWindow
)
1546 mpContentWindow
->SetParent(pParentWindow
);
1548 if (mpHorizontalScrollBar
)
1549 mpHorizontalScrollBar
->SetParent(mpParentWindow
);
1550 if (mpVerticalScrollBar
)
1551 mpVerticalScrollBar
->SetParent(mpParentWindow
);
1556 void ViewShell::SwitchViewFireFocus(const css::uno::Reference
< css::accessibility::XAccessible
>& xAcc
)
1560 ::accessibility::AccessibleDocumentViewBase
* pBase
= static_cast< ::accessibility::AccessibleDocumentViewBase
* >(xAcc
.get());
1562 pBase
->SwitchViewActivated();
1565 void ViewShell::SwitchActiveViewFireFocus()
1567 if (mpContentWindow
)
1569 SwitchViewFireFocus(mpContentWindow
->GetAccessible(false));
1572 // move these two methods from DrawViewShell.
1573 void ViewShell::fireSwitchCurrentPage(sal_Int32 pageIndex
)
1575 GetViewShellBase().GetDrawController()->fireSwitchCurrentPage(pageIndex
);
1577 void ViewShell::NotifyAccUpdate( )
1579 GetViewShellBase().GetDrawController()->NotifyAccUpdate();
1582 weld::Window
* ViewShell::GetFrameWeld() const
1584 return mpActiveWindow
? mpActiveWindow
->GetFrameWeld() : nullptr;
1587 sd::Window
* ViewShell::GetContentWindow() const
1589 return mpContentWindow
.get();
1592 } // end of namespace sd
1594 //===== ViewShellObjectBarFactory =============================================
1598 ViewShellObjectBarFactory::ViewShellObjectBarFactory (
1599 ::sd::ViewShell
& rViewShell
)
1600 : mrViewShell (rViewShell
)
1604 SfxShell
* ViewShellObjectBarFactory::CreateShell( ::sd::ShellId nId
)
1606 SfxShell
* pShell
= nullptr;
1608 ::sd::View
* pView
= mrViewShell
.GetView();
1611 case ToolbarId::Bezier_Toolbox_Sd
:
1612 pShell
= new ::sd::BezierObjectBar(&mrViewShell
, pView
);
1615 case ToolbarId::Draw_Text_Toolbox_Sd
:
1616 pShell
= new ::sd::TextObjectBar(
1617 &mrViewShell
, mrViewShell
.GetDoc()->GetPool(), pView
);
1620 case ToolbarId::Draw_Graf_Toolbox
:
1621 pShell
= new ::sd::GraphicObjectBar(&mrViewShell
, pView
);
1624 case ToolbarId::Draw_Media_Toolbox
:
1625 pShell
= new ::sd::MediaObjectBar(&mrViewShell
, pView
);
1628 case ToolbarId::Draw_Table_Toolbox
:
1629 pShell
= ::sd::ui::table::CreateTableObjectBar( mrViewShell
, pView
);
1632 case ToolbarId::Svx_Extrusion_Bar
:
1633 pShell
= new svx::ExtrusionBar(
1634 &mrViewShell
.GetViewShellBase());
1637 case ToolbarId::Svx_Fontwork_Bar
:
1638 pShell
= new svx::FontworkBar(
1639 &mrViewShell
.GetViewShellBase());
1650 void ViewShellObjectBarFactory::ReleaseShell (SfxShell
* pShell
)
1655 } // end of anonymous namespace
1657 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */