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 .
23 #include <ViewClipboard.hxx>
24 #include <controller/SlsSelectionObserver.hxx>
27 #include <sal/types.h>
28 #include <o3tl/deleter.hxx>
29 #include <svx/svdtypes.hxx>
34 struct AcceptDropEvent
;
35 class DropTargetHelper
;
36 struct ExecuteDropEvent
;
40 namespace vcl
{ class Window
; }
46 namespace sd::slidesorter
{ class SlideSorter
; }
48 namespace sd::slidesorter::controller
{
50 class SlideSorterController
;
52 class SAL_DLLPUBLIC_RTTI Clipboard final
53 : public ViewClipboard
56 Clipboard (SlideSorter
& rSlideSorter
);
57 virtual ~Clipboard() override
;
59 /** Create a slide sorter transferable from the given sd
60 transferable. The returned transferable is set up with all
61 information necessary so that it can be dropped on a slide sorter.
63 static std::shared_ptr
<SdTransferable::UserData
> CreateTransferableUserData (SdTransferable
* pTransferable
);
65 void HandleSlotCall (SfxRequest
& rRequest
);
68 // Exported for unit test
69 SD_DLLPUBLIC
void DoCopy();
70 // Exported for unit test
71 SD_DLLPUBLIC
void DoPaste();
76 vcl::Window
* pWindow
);
79 sal_Int8 nDropAction
);
82 const AcceptDropEvent
& rEvt
,
83 DropTargetHelper
& rTargetHelper
,
84 ::sd::Window
* pTargetWindow
,
88 sal_Int8
ExecuteDrop (
89 const ExecuteDropEvent
& rEvt
,
90 DropTargetHelper
& rTargetHelper
,
91 ::sd::Window
* pTargetWindow
,
98 virtual sal_uInt16
DetermineInsertPosition () override
;
100 SlideSorter
& mrSlideSorter
;
101 SlideSorterController
& mrController
;
103 typedef ::std::vector
<SdPage
*> PageList
;
104 /** Remember the pages that are dragged to another document or to
105 another place in the same document so that they can be removed after
108 PageList maPagesToRemove
;
110 /** Used when a drop is executed to combine all undo actions into one.
111 Typically created in ExecuteDrop() and released in DragFinish().
114 std::unique_ptr
<UndoContext
> mxUndoContext
;
116 std::unique_ptr
<SelectionObserver::Context
, o3tl::default_delete
<SelectionObserver::Context
>> mxSelectionObserverContext
;
117 ImplSVEvent
* mnDragFinishedUserEventId
;
119 void CreateSlideTransferable (
120 vcl::Window
* pWindow
,
123 /** Determine the position of where to insert the pages in the current
124 transferable of the sd module.
126 The index in the range [0,n] (both inclusive) with n the number
127 of pages is returned.
129 sal_Int32
GetInsertionPosition ();
131 /** Paste the pages of the transferable of the sd module at the given
133 @param nInsertPosition
134 The position at which to insert the pages. The valid range is
135 [0,n] (both inclusive) with n the number of pages in the
138 The number of inserted pages is returned.
140 sal_Int32
PasteTransferable (sal_Int32 nInsertPosition
);
142 /** Select a range of pages of the model. Typically usage is the
143 selection of newly inserted pages.
145 The index of the first page to select.
147 The number of pages to select.
149 void SelectPageRange (sal_Int32 nFirstIndex
, sal_Int32 nPageCount
);
151 /** Return <TRUE/> when the current transferable in the current state of
152 the slidesorter is acceptable to be pasted. For this the
155 b) contain one or more regular draw pages, no master pages.
156 When master pages are involved, either in the transferable or in the
157 slide sorter (by it displaying master pages) the drop of the
158 transferable is not accepted. The reason is the missing
159 implementation of proper handling master pages copy-and-paste.
161 enum DropType
{ DT_PAGE
, DT_PAGE_FROM_NAVIGATOR
, DT_SHAPE
, DT_NONE
};
162 DropType
IsDropAccepted() const;
164 /** This method contains the code for AcceptDrop() and ExecuteDrop() shapes.
165 There are only minor differences for the two cases at this level.
167 This parameter specifies whether to do an AcceptDrop() or
170 Since the event is given as void pointer we can not take the
171 mouse position from it. The caller has to supply it in this
174 Event though the AcceptDropEvent and ExecuteDropEvent are very
175 similar they do not have a common base class. Because of that
176 we have to use a void* to pass these structs.
178 When the page number is given as 0xffff then it is replaced by
179 the number of the page at the mouse position. If the mouse is
180 not over a page then neither AcceptDrop() nor ExecuteDrop() are
183 enum DropCommand
{ DC_ACCEPT
, DC_EXECUTE
};
184 sal_Int8
ExecuteOrAcceptShapeDrop (
185 DropCommand eCommand
,
186 const Point
& rPosition
,
187 const void* pDropEvent
,
188 DropTargetHelper
& rTargetHelper
,
189 ::sd::Window
* pTargetWindow
,
193 /** Return whether the insertion defined by the transferable is
194 trivial, ie would not change either source nor target document.
196 bool IsInsertionTrivial (
197 SdTransferable
const * pTransferable
,
198 const sal_Int8 nDndAction
) const;
200 /** Asynchronous part of DragFinished. The argument is the sal_Int8
201 nDropAction, disguised as void*.
203 DECL_DLLPRIVATE_LINK(ProcessDragFinished
, void*, void);
206 } // end of namespace ::sd::slidesorter::controller
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */