Update git submodules
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsSelectionFunction.hxx
blob7d80fbd26cf177ebbc382b92520d4ebe0f3dce0e
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 <controller/SlsFocusManager.hxx>
23 #include <fupoor.hxx>
24 #include <memory>
26 namespace sd::slidesorter
28 class SlideSorter;
31 struct AcceptDropEvent;
33 namespace sd::slidesorter::controller
35 class SlideSorterController;
37 class SelectionFunction final : public FuPoor
39 public:
40 SelectionFunction(const SelectionFunction&) = delete;
41 SelectionFunction& operator=(const SelectionFunction&) = delete;
43 static rtl::Reference<FuPoor> Create(SlideSorter& rSlideSorter, SfxRequest& rRequest);
45 // Mouse- & Key-Events
46 virtual bool KeyInput(const KeyEvent& rKEvt) override;
47 virtual bool MouseMove(const MouseEvent& rMEvt) override;
48 virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
49 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
51 /// Forward to the clipboard manager.
52 virtual void DoCut() override;
54 /// Forward to the clipboard manager.
55 virtual void DoCopy() override;
57 /// Forward to the clipboard manager.
58 virtual void DoPaste() override;
60 /** is called when the current function should be aborted. <p>
61 This is used when a function gets a KEY_ESCAPE but can also
62 be called directly.
64 @returns
65 true if an active function was aborted
67 virtual bool cancel() override;
69 void MouseDragged(const AcceptDropEvent& rEvent, const sal_Int8 nDragAction);
71 /** Turn of substitution display and insertion indicator.
73 void NotifyDragFinished();
75 class EventDescriptor;
76 class ModeHandler;
77 friend class ModeHandler;
78 enum Mode
80 NormalMode,
81 MultiSelectionMode,
82 DragAndDropMode
84 void SwitchToNormalMode();
85 void SwitchToDragAndDropMode(const Point& rMousePosition);
86 void SwitchToMultiSelectionMode(const Point& rMousePosition, const sal_uInt32 nEventCode);
88 void ResetShiftKeySelectionAnchor();
89 /** Special case handling for when the context menu is hidden. This
90 method will reinitialize the current mouse position to prevent the
91 mouse motion during the time the context menu is displayed from
92 being interpreted as drag-and-drop start.
94 void ResetMouseAnchor();
96 private:
97 SlideSorter& mrSlideSorter;
98 SlideSorterController& mrController;
100 SelectionFunction(SlideSorter& rSlideSorter, SfxRequest& rRequest);
102 virtual ~SelectionFunction() override;
104 /** Remember the slide where the shift key was pressed and started a
105 multiselection via keyboard.
107 sal_Int32 mnShiftKeySelectionAnchor;
109 /** The selection function can be in one of several mutually
110 exclusive modes.
112 std::shared_ptr<ModeHandler> mpModeHandler;
114 /** Make the slide nOffset slides away of the current one the new
115 current slide. When the new index is outside the range of valid
116 page numbers it is clipped to that range.
117 @param nOffset
118 When nOffset is negative then go back. When nOffset if positive go
119 forward. When it is zero then ignore the call.
121 void GotoNextPage(int nOffset);
123 /** Make the slide with the given index the new current slide.
124 @param nIndex
125 Index of the new current slide. When the new index is outside
126 the range of valid page numbers it is clipped to that range.
128 void GotoPage(int nIndex);
130 void ProcessMouseEvent(sal_uInt32 nEventType, const MouseEvent& rEvent);
132 // What follows are a couple of helper methods that are used by
133 // ProcessMouseEvent().
135 void ProcessEvent(EventDescriptor& rEvent);
137 void MoveFocus(const FocusManager::FocusMoveDirection eDirection, const bool bIsShiftDown,
138 const bool bIsControlDown);
140 void SwitchMode(const std::shared_ptr<ModeHandler>& rpHandler);
143 } // end of namespace ::sd::slidesorter::controller
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */