xref: /trunk/main/sd/source/ui/func/fudspord.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 
33 #include "fudspord.hxx"
34 
35 #include <svx/svxids.hrc>
36 #include <vcl/pointr.hxx>
37 
38 #include "app.hrc"
39 #include "fupoor.hxx"
40 #include "ViewShell.hxx"
41 #include "View.hxx"
42 #ifndef SD_WINDOW_SHELL_HXX
43 #include "Window.hxx"
44 #endif
45 #include "drawdoc.hxx"
46 
47 namespace sd {
48 
49 TYPEINIT1( FuDisplayOrder, FuPoor );
50 
51 /*************************************************************************
52 |*
53 |* Konstruktor
54 |*
55 \************************************************************************/
56 
57 FuDisplayOrder::FuDisplayOrder( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq)
58 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
59 , mpRefObj(NULL)
60 , mpOverlay(0L)
61 {
62 }
63 
64 /*************************************************************************
65 |*
66 |* Destruktor
67 |*
68 \************************************************************************/
69 
70 FuDisplayOrder::~FuDisplayOrder()
71 {
72     implClearOverlay();
73 }
74 
75 void FuDisplayOrder::implClearOverlay()
76 {
77     if(mpOverlay)
78     {
79         delete mpOverlay;
80         mpOverlay = 0L;
81     }
82 }
83 
84 FunctionReference FuDisplayOrder::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
85 {
86     FunctionReference xFunc( new FuDisplayOrder( pViewSh, pWin, pView, pDoc, rReq ) );
87     return xFunc;
88 }
89 
90 /*************************************************************************
91 |*
92 |* MouseButtonDown-event
93 |*
94 \************************************************************************/
95 
96 sal_Bool FuDisplayOrder::MouseButtonDown(const MouseEvent& rMEvt)
97 {
98     // #95491# remember button state for creation of own MouseEvents
99     SetMouseButtonCode(rMEvt.GetButtons());
100 
101     return sal_True;
102 }
103 
104 /*************************************************************************
105 |*
106 |* MouseMove-event
107 |*
108 \************************************************************************/
109 
110 sal_Bool FuDisplayOrder::MouseMove(const MouseEvent& rMEvt)
111 {
112     SdrObject* pPickObj;
113     SdrPageView* pPV;
114     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
115 
116     if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), pPickObj, pPV) )
117     {
118         if (mpRefObj != pPickObj)
119         {
120             // delete current overlay
121             implClearOverlay();
122 
123             // create new one
124             mpOverlay = new SdrDropMarkerOverlay(*mpView, *pPickObj);
125 
126             // remember referenced object
127             mpRefObj = pPickObj;
128         }
129     }
130     else
131     {
132         mpRefObj = NULL;
133         implClearOverlay();
134     }
135 
136     return sal_True;
137 }
138 
139 /*************************************************************************
140 |*
141 |* MouseButtonUp-event
142 |*
143 \************************************************************************/
144 
145 sal_Bool FuDisplayOrder::MouseButtonUp(const MouseEvent& rMEvt)
146 {
147     // #95491# remember button state for creation of own MouseEvents
148     SetMouseButtonCode(rMEvt.GetButtons());
149 
150     SdrPageView* pPV = NULL;
151     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
152 
153     if ( mpView->PickObj(aPnt, mpView->getHitTolLog(), mpRefObj, pPV) )
154     {
155         if (nSlotId == SID_BEFORE_OBJ)
156         {
157             mpView->PutMarkedInFrontOfObj(mpRefObj);
158         }
159         else
160         {
161             mpView->PutMarkedBehindObj(mpRefObj);
162         }
163     }
164 
165     mpViewShell->Cancel();
166 
167     return sal_True;
168 }
169 
170 /*************************************************************************
171 |*
172 |* Function aktivieren
173 |*
174 \************************************************************************/
175 
176 void FuDisplayOrder::Activate()
177 {
178     maPtr = mpWindow->GetPointer();
179     mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
180 }
181 
182 /*************************************************************************
183 |*
184 |* Function deaktivieren
185 |*
186 \************************************************************************/
187 
188 void FuDisplayOrder::Deactivate()
189 {
190     mpWindow->SetPointer( maPtr );
191 }
192 
193 
194 } // end of namespace sd
195