1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_SLIDESORTER_SUBSTITUTION_HANDLER_HXX
25 #define SD_SLIDESORTER_SUBSTITUTION_HANDLER_HXX
26 
27 #include <tools/gen.hxx>
28 
29 #include "model/SlsSharedPageDescriptor.hxx"
30 #include "controller/SlsInsertionIndicatorHandler.hxx"
31 #include <vector>
32 
33 
34 namespace sd { namespace slidesorter {
35 class SlideSorter;
36 } }
37 
38 
39 
40 namespace sd { namespace slidesorter { namespace controller {
41 
42 /** A DragAndDropContext object handles an active drag and drop operation.
43     When the mouse is moved from one slide sorter window to another the
44     target SlideSorter object is exchanged accordingly.
45 */
46 class DragAndDropContext
47 {
48 public:
49     /** Create a substitution display of the currently selected pages or,
50         when provided, the pages in the transferable.
51     */
52     DragAndDropContext (SlideSorter& rSlideSorter);
53     ~DragAndDropContext (void);
54 
55     /** Call this method (for example as reaction to ESC key press) to avoid
56         processing (ie moving or inserting) the substition when the called
57         DragAndDropContext object is destroyed.
58     */
59     void Dispose (void);
60 
61     /** Move the substitution display by the distance the mouse has
62         travelled since the last call to this method or to
63         CreateSubstitution().  The given point becomes the new anchor.
64     */
65     void UpdatePosition (
66         const Point& rMousePosition,
67         const InsertionIndicatorHandler::Mode eMode,
68         const bool bAllowAutoScroll = true);
69 
70     void SetTargetSlideSorter (
71         SlideSorter* pSlideSorter = NULL,
72         const Point aMousePosition = Point(0,0),
73         const InsertionIndicatorHandler::Mode eMode = InsertionIndicatorHandler::UnknownMode,
74         const bool bIsOverSourceView = false);
75 
76 private:
77     SlideSorter* mpTargetSlideSorter;
78     model::SharedPageDescriptor mpHitDescriptor;
79     sal_Int32 mnInsertionIndex;
80 
81     void GetPagesFromBookmarks (
82         ::std::vector<const SdPage*>& rPages,
83         sal_Int32& rnSelectionCount,
84         DrawDocShell* pDocShell,
85         const List& rBookmarks) const;
86     void GetPagesFromSelection (
87         ::std::vector<const SdPage*>& rPages,
88         sal_Int32& rnSelectionCount,
89         model::PageEnumeration& rSelection) const;
90 };
91 
92 
93 
94 } } } // end of namespace ::sd::slidesorter::controller
95 
96 #endif
97