bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsClipboard.hxx
blob2805d874be8a6ffa9d562188b9a7effda76a6b6a
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 "ViewClipboard.hxx"
24 #include "controller/SlsSelectionObserver.hxx"
25 #include "sdxfer.hxx"
27 #include <sal/types.h>
28 #include <tools/solar.h>
29 #include <svx/svdpage.hxx>
31 #include <set>
33 class SfxRequest;
34 struct AcceptDropEvent;
35 class DropTargetHelper;
36 struct ExecuteDropEvent;
37 struct ImplSVEvent;
38 class Point;
39 class SdPage;
40 namespace vcl { class Window; }
42 namespace sd {
43 class Window;
46 namespace sd { namespace slidesorter {
47 class SlideSorter;
48 } }
50 namespace sd { namespace slidesorter { namespace model {
51 class PageDescriptor;
52 } } }
54 namespace sd { namespace slidesorter { namespace controller {
56 class SlideSorterController;
58 class Clipboard
59 : public ViewClipboard
61 public:
62 Clipboard (SlideSorter& rSlideSorter);
63 virtual ~Clipboard();
65 /** Create a slide sorter transferable from the given sd
66 transferable. The returned transferable is set up with all
67 information necessary so that it can be dropped on a slide sorter.
69 static ::boost::shared_ptr<SdTransferable::UserData> CreateTransferableUserData (SdTransferable* pTransferable);
71 void HandleSlotCall (SfxRequest& rRequest);
73 void DoCut (vcl::Window* pWindow = 0);
74 void DoCopy (vcl::Window* pWindow = 0);
75 void DoPaste (vcl::Window* pWindow = 0);
76 void DoDelete (vcl::Window* pWindow = 0);
78 void StartDrag (
79 const Point& rDragPt,
80 vcl::Window* pWindow );
82 void DragFinished (
83 sal_Int8 nDropAction);
85 sal_Int8 AcceptDrop (
86 const AcceptDropEvent& rEvt,
87 DropTargetHelper& rTargetHelper,
88 ::sd::Window* pTargetWindow = NULL,
89 sal_uInt16 nPage = SDRPAGE_NOTFOUND,
90 sal_uInt16 nLayer = SDRPAGE_NOTFOUND );
92 sal_Int8 ExecuteDrop (
93 const ExecuteDropEvent& rEvt,
94 DropTargetHelper& rTargetHelper,
95 ::sd::Window* pTargetWindow = NULL,
96 sal_uInt16 nPage = SDRPAGE_NOTFOUND,
97 sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
99 void Abort();
101 protected:
102 virtual sal_uInt16 DetermineInsertPosition (
103 const SdTransferable& rTransferable) SAL_OVERRIDE;
105 virtual sal_uInt16 InsertSlides (
106 const SdTransferable& rTransferable,
107 sal_uInt16 nInsertPosition) SAL_OVERRIDE;
109 private:
110 SlideSorter& mrSlideSorter;
111 SlideSorterController& mrController;
113 typedef ::std::vector<SdPage*> PageList;
114 /** Remember the pages that are dragged to another document or to
115 another place in the same document so that they can be removed after
116 a move operation.
118 PageList maPagesToRemove;
120 /** Remember the pages inserted from another document or another place
121 in the same document so that they can be selected after the
122 drag-and-drop operation is completed.
124 PageList maPagesToSelect;
126 /** When pages are moved or copied then the selection of the slide
127 sorter has to be updated. This flag is used to remember whether the
128 selection has to be updated or can stay as it is (sal_False).
130 bool mbUpdateSelectionPending;
132 /** Used when a drop is executed to combine all undo actions into one.
133 Typically created in ExecuteDrop() and released in DragFinish().
135 class UndoContext;
136 std::unique_ptr<UndoContext> mxUndoContext;
138 std::unique_ptr<SelectionObserver::Context> mxSelectionObserverContext;
139 ImplSVEvent * mnDragFinishedUserEventId;
141 void CreateSlideTransferable (
142 vcl::Window* pWindow,
143 bool bDrag);
145 /** Determine the position of where to insert the pages in the current
146 transferable of the sd module.
147 @param pWindow
148 This window is used as parent for dialogs that have to be shown
149 to the user.
150 @return
151 The index in the range [0,n] (both inclusive) with n the number
152 of pages is returned.
154 sal_Int32 GetInsertionPosition (vcl::Window* pWindow);
156 /** Paste the pages of the transferable of the sd module at the given
157 position.
158 @param nInsertPosition
159 The position at which to insert the pages. The valid range is
160 [0,n] (both inclusive) with n the number of pages in the
161 document.
162 @return
163 The number of inserted pages is returned.
165 sal_Int32 PasteTransferable (sal_Int32 nInsertPosition);
167 /** Select a range of pages of the model. Typicall usage is the
168 selection of newly inserted pages.
169 @param nFirstIndex
170 The index of the first page to select.
171 @param nPageCount
172 The number of pages to select.
174 void SelectPageRange (sal_Int32 nFirstIndex, sal_Int32 nPageCount);
176 /** Return <TRUE/> when the current transferable in the current state of
177 the slidesorter is acceptable to be pasted. For this the
178 transferable has to
179 a) exist,
180 b) contain one or more regular draw pages, no master pages.
181 When master pages are involved, either in the transferable or in the
182 slide sorter (by it displaying master pages) the drop of the
183 transferable is not accepted. The reason is the missing
184 implementation of proper handling master pages copy-and-paste.
186 enum DropType { DT_PAGE, DT_PAGE_FROM_NAVIGATOR, DT_SHAPE, DT_NONE };
187 DropType IsDropAccepted (DropTargetHelper& rTargetHelper) const;
189 /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes.
190 There are only minor differences for the two cases at this level.
191 @param eCommand
192 This parameter specifies whether to do a AcceptDrop() or
193 ExecuteDrop().
194 @param rPosition
195 Since the event is given as void pointer we can not take the
196 mouse position from it. The caller has to supply it in this
197 parameter.
198 @param pDropEvent
199 Event though the AcceptDropEvent and ExecuteDropEvent are very
200 similar they do not have a common base class. Because of that
201 we have to use a void* to pase these structs.
202 @param nPage
203 When the page number is given as 0xffff then it is replaced by
204 the number of the page at the mouse position. If the mouse is
205 not over a page then neither AcceptDrop() nor ExecuteDrop() are
206 executed.
208 enum DropCommand { DC_ACCEPT, DC_EXECUTE };
209 sal_Int8 ExecuteOrAcceptShapeDrop (
210 DropCommand eCommand,
211 const Point& rPosition,
212 const void* pDropEvent ,
213 DropTargetHelper& rTargetHelper,
214 ::sd::Window* pTargetWindow,
215 sal_uInt16 nPage,
216 sal_uInt16 nLayer);
218 /** Return whether the insertion defined by the transferable is
219 trivial, ie would not change either source nor target document.
221 bool IsInsertionTrivial (
222 SdTransferable* pTransferable,
223 const sal_Int8 nDndAction) const;
225 /** Asynchronous part of DragFinished. The argument is the sal_Int8
226 nDropAction, disguised as void*.
228 DECL_LINK(ProcessDragFinished, void*);
231 } } } // end of namespace ::sd::slidesorter::controller
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */