bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsClipboard.hxx
blobb79af210bfe5bb4e6a007477f7ee5a9d918d9eec
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 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSCLIPBOARD_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSCLIPBOARD_HXX
23 #include <memory>
24 #include <ViewClipboard.hxx>
25 #include <controller/SlsSelectionObserver.hxx>
26 #include <sdxfer.hxx>
28 #include <sal/types.h>
29 #include <o3tl/deleter.hxx>
30 #include <svx/svdtypes.hxx>
32 #include <sddllapi.h>
34 class SfxRequest;
35 struct AcceptDropEvent;
36 class DropTargetHelper;
37 struct ExecuteDropEvent;
38 struct ImplSVEvent;
39 class Point;
40 class SdPage;
41 namespace vcl { class Window; }
43 namespace sd {
44 class Window;
47 namespace sd { namespace slidesorter {
48 class SlideSorter;
49 } }
51 namespace sd { namespace slidesorter { namespace controller {
53 class SlideSorterController;
55 class SAL_DLLPUBLIC_RTTI Clipboard
56 : public ViewClipboard
58 public:
59 Clipboard (SlideSorter& rSlideSorter);
60 virtual ~Clipboard() override;
62 /** Create a slide sorter transferable from the given sd
63 transferable. The returned transferable is set up with all
64 information necessary so that it can be dropped on a slide sorter.
66 static std::shared_ptr<SdTransferable::UserData> CreateTransferableUserData (SdTransferable* pTransferable);
68 void HandleSlotCall (SfxRequest& rRequest);
70 void DoCut ();
71 // Exported for unit test
72 SD_DLLPUBLIC void DoCopy();
73 // Exported for unit test
74 SD_DLLPUBLIC void DoPaste();
75 void DoDelete ();
77 void StartDrag (
78 const Point& rDragPt,
79 vcl::Window* pWindow );
81 void DragFinished (
82 sal_Int8 nDropAction);
84 sal_Int8 AcceptDrop (
85 const AcceptDropEvent& rEvt,
86 DropTargetHelper& rTargetHelper,
87 ::sd::Window* pTargetWindow,
88 sal_uInt16 nPage,
89 SdrLayerID nLayer );
91 sal_Int8 ExecuteDrop (
92 const ExecuteDropEvent& rEvt,
93 DropTargetHelper& rTargetHelper,
94 ::sd::Window* pTargetWindow,
95 sal_uInt16 nPage,
96 SdrLayerID nLayer );
98 void Abort();
100 protected:
101 virtual sal_uInt16 DetermineInsertPosition (
102 const SdTransferable& rTransferable) override;
104 private:
105 SlideSorter& mrSlideSorter;
106 SlideSorterController& mrController;
108 typedef ::std::vector<SdPage*> PageList;
109 /** Remember the pages that are dragged to another document or to
110 another place in the same document so that they can be removed after
111 a move operation.
113 PageList maPagesToRemove;
115 /** Used when a drop is executed to combine all undo actions into one.
116 Typically created in ExecuteDrop() and released in DragFinish().
118 class UndoContext;
119 std::unique_ptr<UndoContext> mxUndoContext;
121 std::unique_ptr<SelectionObserver::Context, o3tl::default_delete<SelectionObserver::Context>> mxSelectionObserverContext;
122 ImplSVEvent * mnDragFinishedUserEventId;
124 void CreateSlideTransferable (
125 vcl::Window* pWindow,
126 bool bDrag);
128 /** Determine the position of where to insert the pages in the current
129 transferable of the sd module.
130 @return
131 The index in the range [0,n] (both inclusive) with n the number
132 of pages is returned.
134 sal_Int32 GetInsertionPosition ();
136 /** Paste the pages of the transferable of the sd module at the given
137 position.
138 @param nInsertPosition
139 The position at which to insert the pages. The valid range is
140 [0,n] (both inclusive) with n the number of pages in the
141 document.
142 @return
143 The number of inserted pages is returned.
145 sal_Int32 PasteTransferable (sal_Int32 nInsertPosition);
147 /** Select a range of pages of the model. Typically usage is the
148 selection of newly inserted pages.
149 @param nFirstIndex
150 The index of the first page to select.
151 @param nPageCount
152 The number of pages to select.
154 void SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount);
156 /** Return <TRUE/> when the current transferable in the current state of
157 the slidesorter is acceptable to be pasted. For this the
158 transferable has to
159 a) exist,
160 b) contain one or more regular draw pages, no master pages.
161 When master pages are involved, either in the transferable or in the
162 slide sorter (by it displaying master pages) the drop of the
163 transferable is not accepted. The reason is the missing
164 implementation of proper handling master pages copy-and-paste.
166 enum DropType { DT_PAGE, DT_PAGE_FROM_NAVIGATOR, DT_SHAPE, DT_NONE };
167 DropType IsDropAccepted() const;
169 /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes.
170 There are only minor differences for the two cases at this level.
171 @param eCommand
172 This parameter specifies whether to do a AcceptDrop() or
173 ExecuteDrop().
174 @param rPosition
175 Since the event is given as void pointer we can not take the
176 mouse position from it. The caller has to supply it in this
177 parameter.
178 @param pDropEvent
179 Event though the AcceptDropEvent and ExecuteDropEvent are very
180 similar they do not have a common base class. Because of that
181 we have to use a void* to pass these structs.
182 @param nPage
183 When the page number is given as 0xffff then it is replaced by
184 the number of the page at the mouse position. If the mouse is
185 not over a page then neither AcceptDrop() nor ExecuteDrop() are
186 executed.
188 enum DropCommand { DC_ACCEPT, DC_EXECUTE };
189 sal_Int8 ExecuteOrAcceptShapeDrop (
190 DropCommand eCommand,
191 const Point& rPosition,
192 const void* pDropEvent ,
193 DropTargetHelper& rTargetHelper,
194 ::sd::Window* pTargetWindow,
195 sal_uInt16 nPage,
196 SdrLayerID nLayer);
198 /** Return whether the insertion defined by the transferable is
199 trivial, ie would not change either source nor target document.
201 bool IsInsertionTrivial (
202 SdTransferable const * pTransferable,
203 const sal_Int8 nDndAction) const;
205 /** Asynchronous part of DragFinished. The argument is the sal_Int8
206 nDropAction, disguised as void*.
208 DECL_LINK(ProcessDragFinished, void*, void);
211 } } } // end of namespace ::sd::slidesorter::controller
213 #endif
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */