cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / SlideSorterViewShell.hxx
blob797c44a8e8d0fe45712a1efdb44333707929f211
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include "ViewShell.hxx"
23 #include <glob.hxx>
24 #include <sfx2/shell.hxx>
25 #include <sddllapi.h>
26 #include <memory>
27 #include <vector>
29 namespace sd::slidesorter::controller { class SlotManager; }
31 namespace sd::slidesorter {
33 class SlideSorter;
35 class SAL_DLLPUBLIC_RTTI SlideSorterViewShell final
36 : public ViewShell
38 friend class controller::SlotManager;
40 public:
41 SFX_DECL_INTERFACE(SD_IF_SDSLIDESORTERVIEWSHELL)
43 private:
44 /// SfxInterface initializer.
45 static void InitInterface_Impl();
47 public:
48 static std::shared_ptr<SlideSorterViewShell> Create(
49 SfxViewFrame* pFrame,
50 ViewShellBase& rViewShellBase,
51 vcl::Window* pParentWindow,
52 FrameView* pFrameView);
54 virtual ~SlideSorterViewShell() override;
56 /** Late initialization that has to be called after a new instance has
57 completed its construction.
59 virtual void Init (bool bIsMainViewShell) override;
61 /** Return a slide sorter that is currently displayed in one of the
62 panes that belong to the given ViewShellBase object.
63 When there is only one slide sorter visible then that one is
64 returned. When two (or more) are visible then the one in the center
65 pane is returned. When no slidesorter is visible then NULL is
66 returned.
68 // Exported for unit test
69 SD_DLLPUBLIC static SlideSorterViewShell* GetSlideSorter(ViewShellBase& rBase);
71 virtual SdPage* GetActualPage() override;
73 /// inherited from sd::ViewShell
74 virtual SdPage* getCurrentPage() const override;
76 void ExecCtrl (SfxRequest& rRequest);
77 void GetCtrlState (SfxItemSet &rSet);
78 void FuSupport (SfxRequest& rRequest);
79 void FuTemporary (SfxRequest& rRequest);
80 void GetStatusBarState (SfxItemSet& rSet);
81 void FuPermanent (SfxRequest& rRequest);
82 void GetAttrState (SfxItemSet& rSet);
83 void ExecStatusBar (SfxRequest& rRequest);
84 virtual void Command (const CommandEvent& rEvent, ::sd::Window* pWindow) override;
85 void GetMenuState (SfxItemSet &rSet);
86 void GetClipboardState (SfxItemSet &rSet);
88 virtual void ReadFrameViewData (FrameView* pView) override;
89 virtual void WriteFrameViewData() override;
91 /** Set the zoom factor. The given value is clipped against an upper
92 bound.
93 @param nZoom
94 An integer percent value, i.e. nZoom/100 is the actual zoom
95 factor.
97 virtual void SetZoom (::tools::Long nZoom) override;
98 virtual void SetZoomRect (const ::tools::Rectangle& rZoomRect) override;
100 /** This is a callback method used by the active window to delegate its
101 Paint() call to. This view shell itself delegates it to the view.
103 virtual void Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin) override;
105 /** Place and size the controls and windows. You may want to call this
106 method when something has changed that for instance affects the
107 visibility state of the scroll bars.
109 virtual void ArrangeGUIElements() override;
111 virtual void Activate (bool IsMDIActivate) override;
112 virtual void Deactivate (bool IsMDIActivate) override;
114 /** Move slides up and down. Mainly uno commands. */
115 void ExecMovePageUp (SfxRequest& rReq);
116 void GetStateMovePageUp (SfxItemSet& rSet);
118 void ExecMovePageDown (SfxRequest& rReq);
119 void GetStateMovePageDown (SfxItemSet& rSet);
121 void ExecMovePageFirst (SfxRequest& rReq);
122 void GetStateMovePageFirst (SfxItemSet& rSet);
124 void ExecMovePageLast (SfxRequest& rReq);
125 void GetStateMovePageLast (SfxItemSet& rSet);
128 //===== Drag and Drop =====================================================
130 void StartDrag (
131 const Point& rDragPt,
132 vcl::Window* pWindow );
133 virtual sal_Int8 AcceptDrop (
134 const AcceptDropEvent& rEvt,
135 DropTargetHelper& rTargetHelper,
136 ::sd::Window* pTargetWindow,
137 sal_uInt16 nPage,
138 SdrLayerID nLayer ) override;
139 virtual sal_Int8 ExecuteDrop (
140 const ExecuteDropEvent& rEvt,
141 DropTargetHelper& rTargetHelper,
142 ::sd::Window* pTargetWindow,
143 sal_uInt16 nPage,
144 SdrLayerID nLayer) override;
146 typedef ::std::vector<SdPage*> PageSelection;
148 /** Return the set of selected pages.
150 std::shared_ptr<PageSelection> GetPageSelection() const;
152 void SetPageSelection (const std::shared_ptr<PageSelection>& rSelection);
154 /** Add a listener that is called when the selection of the slide sorter
155 changes.
156 @param rListener
157 When this method is called multiple times for the same listener
158 the second and all following calls are ignored. Each listener
159 is added only once.
161 void AddSelectionChangeListener (const Link<LinkParamNone*,void>& rListener);
163 /** Remove a listener that was called when the selection of the slide
164 sorter changes.
165 @param rListener
166 It is safe to pass a listener that was not added are has been
167 removed previously. Such calls are ignored.
169 void RemoveSelectionChangeListener (const Link<LinkParamNone*,void>& rListener);
171 virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController() override;
173 /** Create an accessible object representing the specified window.
174 @param pWindow
175 The returned object makes the document displayed in this window
176 accessible.
177 @return
178 Returns an <type>AccessibleSlideSorterView</type> object.
180 virtual css::uno::Reference<css::accessibility::XAccessible>
181 CreateAccessibleDocumentView (::sd::Window* pWindow) override;
182 // handle SlideSorterView specially because AccessibleSlideSorterView doesn't inherit from AccessibleDocumentViewBase
183 virtual void SwitchViewFireFocus( const css::uno::Reference< css::accessibility::XAccessible >& xAcc ) override;
185 // Exported for unit test
186 SD_DLLPUBLIC SlideSorter& GetSlideSorter() const;
188 /** Try to relocate all toplevel window elements to the given parent
189 window.
191 virtual bool RelocateToParentWindow (vcl::Window* pParentWindow) override;
193 private:
195 /** Override this method to handle a missing tool bar correctly.
196 This is the case when the slide sorter is not the main view shell.
198 virtual SfxUndoManager* ImpGetUndoManager() const override;
200 std::shared_ptr<SlideSorter> mpSlideSorter;
201 bool mbIsArrangeGUIElementsPending;
203 SlideSorterViewShell (
204 SfxViewFrame* pFrame,
205 ViewShellBase& rViewShellBase,
206 vcl::Window* pParentWindow,
207 FrameView* pFrameView);
208 void Initialize();
210 /** This method overwrites the one from our base class: We do our own
211 scroll bar and the base class call is thus unnecessary. It simply
212 calls UpdateScrollBars(false).
214 virtual void UpdateScrollBars() override;
216 void PostMoveSlidesActions(const std::shared_ptr<SlideSorterViewShell::PageSelection> &rpSelection);
218 void MainViewEndEditAndUnmarkAll();
220 /** Select the same pages in the document as are selected in the
221 SlideSorterViewShell
223 return the page numbers of the first and last selected pages
225 std::pair<sal_uInt16, sal_uInt16> SyncPageSelectionToDocument(const std::shared_ptr<SlideSorterViewShell::PageSelection> &rpSelection);
228 typedef std::shared_ptr<SlideSorterViewShell::PageSelection> SharedPageSelection;
230 } // end of namespace ::sd::slidesorter
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */