Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "SlsDragAndDropContext.hxx"
31 : :
32 : : #include "SlideSorter.hxx"
33 : : #include "model/SlideSorterModel.hxx"
34 : : #include "model/SlsPageEnumerationProvider.hxx"
35 : : #include "view/SlideSorterView.hxx"
36 : : #include "controller/SlideSorterController.hxx"
37 : : #include "controller/SlsInsertionIndicatorHandler.hxx"
38 : : #include "controller/SlsScrollBarManager.hxx"
39 : : #include "controller/SlsProperties.hxx"
40 : : #include "controller/SlsSelectionFunction.hxx"
41 : : #include "controller/SlsSelectionManager.hxx"
42 : : #include "controller/SlsTransferable.hxx"
43 : : #include "DrawDocShell.hxx"
44 : : #include "drawdoc.hxx"
45 : : #include "app.hrc"
46 : : #include <sfx2/bindings.hxx>
47 : : #include <boost/bind.hpp>
48 : :
49 : : namespace sd { namespace slidesorter { namespace controller {
50 : :
51 : 0 : DragAndDropContext::DragAndDropContext (SlideSorter& rSlideSorter)
52 : : : mpTargetSlideSorter(&rSlideSorter),
53 : 0 : mnInsertionIndex(-1)
54 : : {
55 [ # # ]: 0 : ::std::vector<const SdPage*> aPages;
56 : :
57 : : // No Drag-and-Drop for master pages.
58 [ # # ][ # # ]: 0 : if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE)
[ # # ]
59 : 0 : return;
60 : :
61 [ # # ]: 0 : rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(
62 [ # # ][ # # ]: 0 : dynamic_cast<Transferable*>(SD_MOD()->pTransferDrag));
[ # # ][ # # ]
[ # # ][ # # ]
63 : : }
64 : :
65 : :
66 : :
67 : :
68 : 0 : DragAndDropContext::~DragAndDropContext (void)
69 : : {
70 [ # # ]: 0 : SetTargetSlideSorter (NULL, Point(0,0), InsertionIndicatorHandler::UnknownMode, false);
71 : 0 : }
72 : :
73 : :
74 : :
75 : :
76 : 0 : void DragAndDropContext::Dispose (void)
77 : : {
78 : 0 : mnInsertionIndex = -1;
79 : 0 : }
80 : :
81 : :
82 : :
83 : :
84 : 0 : void DragAndDropContext::UpdatePosition (
85 : : const Point& rMousePosition,
86 : : const InsertionIndicatorHandler::Mode eMode,
87 : : const bool bAllowAutoScroll)
88 : : {
89 [ # # ]: 0 : if (mpTargetSlideSorter == NULL)
90 : : return;
91 : :
92 [ # # ][ # # ]: 0 : if (mpTargetSlideSorter->GetProperties()->IsUIReadOnly())
[ # # ][ # # ]
93 : : return;
94 : :
95 : : // Convert window coordinates into model coordinates (we need the
96 : : // window coordinates for auto-scrolling because that remains
97 : : // constant while scrolling.)
98 [ # # ]: 0 : SharedSdWindow pWindow (mpTargetSlideSorter->GetContentWindow());
99 [ # # ]: 0 : const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
100 : : ::boost::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler (
101 [ # # ][ # # ]: 0 : mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler());
102 : :
103 : : bool bDoAutoScroll = bAllowAutoScroll
104 [ # # ][ # # ]: 0 : && mpTargetSlideSorter->GetController().GetScrollBarManager().AutoScroll(
105 : : rMousePosition,
106 : : ::boost::bind(
107 [ # # ][ # # ]: 0 : &DragAndDropContext::UpdatePosition, this, rMousePosition, eMode, false));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
108 : :
109 [ # # ]: 0 : if (!bDoAutoScroll)
110 : : {
111 [ # # ]: 0 : pInsertionIndicatorHandler->UpdatePosition(aMouseModelPosition, eMode);
112 : :
113 : : // Remember the new insertion index.
114 [ # # ]: 0 : mnInsertionIndex = pInsertionIndicatorHandler->GetInsertionPageIndex();
115 [ # # ][ # # ]: 0 : if (pInsertionIndicatorHandler->IsInsertionTrivial(mnInsertionIndex, eMode))
116 : 0 : mnInsertionIndex = -1;
117 [ # # ][ # # ]: 0 : }
118 : : }
119 : :
120 : :
121 : :
122 : :
123 : 0 : void DragAndDropContext::SetTargetSlideSorter (
124 : : SlideSorter* pSlideSorter,
125 : : const Point aMousePosition,
126 : : const InsertionIndicatorHandler::Mode eMode,
127 : : const bool bIsOverSourceView)
128 : : {
129 [ # # ]: 0 : if (mpTargetSlideSorter != NULL)
130 : : {
131 : 0 : mpTargetSlideSorter->GetController().GetScrollBarManager().StopAutoScroll();
132 : 0 : mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->End(
133 [ # # ]: 0 : Animator::AM_Animated);
134 : : }
135 : :
136 : 0 : mpTargetSlideSorter = pSlideSorter;
137 : :
138 [ # # ]: 0 : if (mpTargetSlideSorter != NULL)
139 : : {
140 : 0 : mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->Start(
141 [ # # ]: 0 : bIsOverSourceView);
142 : 0 : mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->UpdatePosition(
143 : : aMousePosition,
144 [ # # ]: 0 : eMode);
145 : :
146 : : }
147 : 0 : }
148 : :
149 : :
150 [ + - ][ + - ]: 75 : } } } // end of namespace ::sd::slidesorter::controller
151 : :
152 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|