xref: /trunk/main/sc/source/ui/drawfunc/fudraw.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //------------------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <editeng/editeng.hxx>  // EditEngine::IsSimpleCharInput
34*cdf0e10cSrcweir #include <editeng/outlobj.hxx>
35*cdf0e10cSrcweir #include <svx/svdobj.hxx>
36*cdf0e10cSrcweir #include <svx/svdoole2.hxx>
37*cdf0e10cSrcweir #include <svx/svdouno.hxx>
38*cdf0e10cSrcweir #include <svx/svdocapt.hxx>
39*cdf0e10cSrcweir #include <svx/svdpage.hxx>
40*cdf0e10cSrcweir #include <svx/svditer.hxx>
41*cdf0e10cSrcweir #include <svx/svdundo.hxx>
42*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
43*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include "sc.hrc"
46*cdf0e10cSrcweir #include "fudraw.hxx"
47*cdf0e10cSrcweir #include "futext.hxx"
48*cdf0e10cSrcweir #include "tabvwsh.hxx"
49*cdf0e10cSrcweir #include "drwlayer.hxx"
50*cdf0e10cSrcweir #include "scresid.hxx"
51*cdf0e10cSrcweir #include "userdat.hxx"
52*cdf0e10cSrcweir #include "docsh.hxx"
53*cdf0e10cSrcweir #include "postit.hxx"
54*cdf0e10cSrcweir #include "globstr.hrc"
55*cdf0e10cSrcweir #include "drawview.hxx"
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /*************************************************************************
58*cdf0e10cSrcweir |*
59*cdf0e10cSrcweir |* Basisklasse fuer alle Drawmodul-spezifischen Funktionen
60*cdf0e10cSrcweir |*
61*cdf0e10cSrcweir \************************************************************************/
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir FuDraw::FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
64*cdf0e10cSrcweir                SdrModel* pDoc, SfxRequest& rReq) :
65*cdf0e10cSrcweir     FuPoor      (pViewSh, pWin, pViewP, pDoc, rReq),
66*cdf0e10cSrcweir     aNewPointer ( POINTER_ARROW ),
67*cdf0e10cSrcweir     aOldPointer ( POINTER_ARROW )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir /*************************************************************************
72*cdf0e10cSrcweir |*
73*cdf0e10cSrcweir |* Destruktor
74*cdf0e10cSrcweir |*
75*cdf0e10cSrcweir \************************************************************************/
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir FuDraw::~FuDraw()
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir /*************************************************************************
82*cdf0e10cSrcweir |*
83*cdf0e10cSrcweir |* Modifier-Tasten auswerten
84*cdf0e10cSrcweir |*
85*cdf0e10cSrcweir \************************************************************************/
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir void FuDraw::DoModifiers(const MouseEvent& rMEvt)
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir     //  Shift   = Ortho und AngleSnap
90*cdf0e10cSrcweir     //  Control = Snap (Toggle)
91*cdf0e10cSrcweir     //  Alt     = zentrisch
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     sal_Bool bShift = rMEvt.IsShift();
94*cdf0e10cSrcweir //    sal_Bool bCtrl  = rMEvt.IsMod1();
95*cdf0e10cSrcweir     sal_Bool bAlt   = rMEvt.IsMod2();
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir //    ScViewData* pViewData = pViewShell->GetViewData();
98*cdf0e10cSrcweir //    const ScViewOptions& rOpt = pViewData->GetOptions();
99*cdf0e10cSrcweir //    const ScGridOptions& rGrid = rOpt.GetGridOptions();
100*cdf0e10cSrcweir //    sal_Bool bGridOpt = rGrid.GetUseGridSnap();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     sal_Bool bOrtho     = bShift;
103*cdf0e10cSrcweir     sal_Bool bAngleSnap = bShift;
104*cdf0e10cSrcweir //    sal_Bool bGridSnap  = ( bGridOpt != bCtrl );        // andere Snap's nicht unterstuetzt
105*cdf0e10cSrcweir     sal_Bool bCenter    = bAlt;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     // #i33136#
108*cdf0e10cSrcweir     if(doConstructOrthogonal())
109*cdf0e10cSrcweir     {
110*cdf0e10cSrcweir         bOrtho = !bShift;
111*cdf0e10cSrcweir     }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     if (pView->IsOrtho() != bOrtho)
114*cdf0e10cSrcweir         pView->SetOrtho(bOrtho);
115*cdf0e10cSrcweir     if (pView->IsAngleSnapEnabled() != bAngleSnap)
116*cdf0e10cSrcweir         pView->SetAngleSnapEnabled(bAngleSnap);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir /*  Control fuer Snap beisst sich beim Verschieben mit "kopieren" !!!
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     if (pView->IsGridSnap() != bGridSnap)
121*cdf0e10cSrcweir         pView->SetGridSnap(bGridSnap);
122*cdf0e10cSrcweir     if (pView->IsSnapEnabled() != bGridSnap)
123*cdf0e10cSrcweir         pView->SetSnapEnabled(bGridSnap);
124*cdf0e10cSrcweir */
125*cdf0e10cSrcweir     if (pView->IsCreate1stPointAsCenter() != bCenter)
126*cdf0e10cSrcweir         pView->SetCreate1stPointAsCenter(bCenter);
127*cdf0e10cSrcweir     if (pView->IsResizeAtCenter() != bCenter)
128*cdf0e10cSrcweir         pView->SetResizeAtCenter(bCenter);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir void FuDraw::ResetModifiers()
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir     ScViewData* pViewData = pViewShell->GetViewData();
135*cdf0e10cSrcweir     const ScViewOptions& rOpt = pViewData->GetOptions();
136*cdf0e10cSrcweir     const ScGridOptions& rGrid = rOpt.GetGridOptions();
137*cdf0e10cSrcweir     sal_Bool bGridOpt = rGrid.GetUseGridSnap();
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     if (pView->IsOrtho())
140*cdf0e10cSrcweir         pView->SetOrtho(sal_False);
141*cdf0e10cSrcweir     if (pView->IsAngleSnapEnabled())
142*cdf0e10cSrcweir         pView->SetAngleSnapEnabled(sal_False);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     if (pView->IsGridSnap() != bGridOpt)
145*cdf0e10cSrcweir         pView->SetGridSnap(bGridOpt);
146*cdf0e10cSrcweir     if (pView->IsSnapEnabled() != bGridOpt)
147*cdf0e10cSrcweir         pView->SetSnapEnabled(bGridOpt);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     if (pView->IsCreate1stPointAsCenter())
150*cdf0e10cSrcweir         pView->SetCreate1stPointAsCenter(sal_False);
151*cdf0e10cSrcweir     if (pView->IsResizeAtCenter())
152*cdf0e10cSrcweir         pView->SetResizeAtCenter(sal_False);
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir /*************************************************************************
156*cdf0e10cSrcweir |*
157*cdf0e10cSrcweir |* MouseButtonDown-event
158*cdf0e10cSrcweir |*
159*cdf0e10cSrcweir \************************************************************************/
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     // #95491# remember button state for creation of own MouseEvents
164*cdf0e10cSrcweir     SetMouseButtonCode(rMEvt.GetButtons());
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     DoModifiers( rMEvt );
167*cdf0e10cSrcweir     return sal_False;
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir /*************************************************************************
171*cdf0e10cSrcweir |*
172*cdf0e10cSrcweir |* MouseMove-event
173*cdf0e10cSrcweir |*
174*cdf0e10cSrcweir \************************************************************************/
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseMove(const MouseEvent& rMEvt)
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     //  #106438# evaluate modifiers only if in a drawing layer action
179*cdf0e10cSrcweir     //  (don't interfere with keyboard shortcut handling)
180*cdf0e10cSrcweir     if (pView->IsAction())
181*cdf0e10cSrcweir         DoModifiers( rMEvt );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     return sal_False;
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir /*************************************************************************
187*cdf0e10cSrcweir |*
188*cdf0e10cSrcweir |* MouseButtonUp-event
189*cdf0e10cSrcweir |*
190*cdf0e10cSrcweir \************************************************************************/
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     // #95491# remember button state for creation of own MouseEvents
195*cdf0e10cSrcweir     SetMouseButtonCode(rMEvt.GetButtons());
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     ResetModifiers();
198*cdf0e10cSrcweir     return sal_False;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir /*************************************************************************
202*cdf0e10cSrcweir |*
203*cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
204*cdf0e10cSrcweir |*
205*cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
206*cdf0e10cSrcweir |* FALSE.
207*cdf0e10cSrcweir |*
208*cdf0e10cSrcweir \************************************************************************/
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir sal_Bool lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell* pViewShell, const KeyEvent* pInitialKey )
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
213*cdf0e10cSrcweir     if ( pObj && pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) )
214*cdf0e10cSrcweir     {
215*cdf0e10cSrcweir         // start text edit - like FuSelection::MouseButtonUp,
216*cdf0e10cSrcweir         // but with bCursorToEnd instead of mouse position
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
219*cdf0e10cSrcweir         sal_Bool bVertical = ( pOPO && pOPO->IsVertical() );
220*cdf0e10cSrcweir         sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         // don't switch shells if text shell is already active
223*cdf0e10cSrcweir         FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
224*cdf0e10cSrcweir         if ( !pPoor || pPoor->GetSlotID() != nTextSlotId )
225*cdf0e10cSrcweir         {
226*cdf0e10cSrcweir             pViewShell->GetViewData()->GetDispatcher().
227*cdf0e10cSrcweir                 Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
228*cdf0e10cSrcweir         }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         // get the resulting FuText and set in edit mode
231*cdf0e10cSrcweir         pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
232*cdf0e10cSrcweir         if ( pPoor && pPoor->GetSlotID() == nTextSlotId )    // no RTTI
233*cdf0e10cSrcweir         {
234*cdf0e10cSrcweir             FuText* pText = (FuText*)pPoor;
235*cdf0e10cSrcweir             pText->SetInEditMode( pObj, NULL, sal_True, pInitialKey );
236*cdf0e10cSrcweir             //! set cursor to end of text
237*cdf0e10cSrcweir         }
238*cdf0e10cSrcweir         bReturn = sal_True;
239*cdf0e10cSrcweir     }
240*cdf0e10cSrcweir     return bReturn;
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir sal_Bool __EXPORT FuDraw::KeyInput(const KeyEvent& rKEvt)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
246*cdf0e10cSrcweir     ScViewData& rViewData = *pViewShell->GetViewData();
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     switch ( rKEvt.GetKeyCode().GetCode() )
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         case KEY_ESCAPE:
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir     /* 18.12.95: TextShell beibehalten nicht mehr gewuenscht...
253*cdf0e10cSrcweir      *
254*cdf0e10cSrcweir      *          if ( pView->IsAction() )
255*cdf0e10cSrcweir      *          {
256*cdf0e10cSrcweir      *              pView->BrkAction();
257*cdf0e10cSrcweir      *              pWindow->ReleaseMouse();
258*cdf0e10cSrcweir      *              bReturn = sal_True;
259*cdf0e10cSrcweir      *          }
260*cdf0e10cSrcweir      *          else if ( pView->IsTextEdit() )
261*cdf0e10cSrcweir      *          {
262*cdf0e10cSrcweir      *              pView->EndTextEdit();
263*cdf0e10cSrcweir      *              pView->SetCreateMode();
264*cdf0e10cSrcweir      *              pViewShell->GetScDrawView()->InvalidateDrawTextAttrs();
265*cdf0e10cSrcweir      *              bReturn = sal_True;
266*cdf0e10cSrcweir      *          }
267*cdf0e10cSrcweir      *          else
268*cdf0e10cSrcweir      */
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir             if ( pViewShell->IsDrawTextShell() || aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
271*cdf0e10cSrcweir             {
272*cdf0e10cSrcweir                 // in normale Draw-Shell, wenn Objekt selektiert, sonst Zeichnen aus
273*cdf0e10cSrcweir                 rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
274*cdf0e10cSrcweir                 bReturn = sal_True;
275*cdf0e10cSrcweir             }
276*cdf0e10cSrcweir             else if ( pViewShell->IsDrawSelMode() )
277*cdf0e10cSrcweir             {
278*cdf0e10cSrcweir                 pView->UnmarkAll();
279*cdf0e10cSrcweir                 rViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
280*cdf0e10cSrcweir                 bReturn = sal_True;
281*cdf0e10cSrcweir             }
282*cdf0e10cSrcweir             else if ( pView->AreObjectsMarked() )
283*cdf0e10cSrcweir             {
284*cdf0e10cSrcweir                 // #97016# III
285*cdf0e10cSrcweir                 SdrHdlList& rHdlList = const_cast< SdrHdlList& >( pView->GetHdlList() );
286*cdf0e10cSrcweir                 if( rHdlList.GetFocusHdl() )
287*cdf0e10cSrcweir                     rHdlList.ResetFocusHdl();
288*cdf0e10cSrcweir                 else
289*cdf0e10cSrcweir                     pView->UnmarkAll();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir                 //  Beim Bezier-Editieren ist jetzt wieder das Objekt selektiert
292*cdf0e10cSrcweir                 if (!pView->AreObjectsMarked())
293*cdf0e10cSrcweir                     pViewShell->SetDrawShell( sal_False );
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir                 bReturn = sal_True;
296*cdf0e10cSrcweir             }
297*cdf0e10cSrcweir             break;
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir         case KEY_DELETE:                    //! ueber Accelerator
300*cdf0e10cSrcweir             pView->DeleteMarked();
301*cdf0e10cSrcweir             bReturn = sal_True;
302*cdf0e10cSrcweir         break;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir         case KEY_RETURN:
305*cdf0e10cSrcweir         {
306*cdf0e10cSrcweir             if( rKEvt.GetKeyCode().GetModifier() == 0 )
307*cdf0e10cSrcweir             {
308*cdf0e10cSrcweir                 // #98256# activate OLE object on RETURN for selected object
309*cdf0e10cSrcweir                 // #98198# put selected text object in edit mode
310*cdf0e10cSrcweir                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
311*cdf0e10cSrcweir                 if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
312*cdf0e10cSrcweir                 {
313*cdf0e10cSrcweir                     sal_Bool bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
314*cdf0e10cSrcweir                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
315*cdf0e10cSrcweir                     if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle )
316*cdf0e10cSrcweir                     {
317*cdf0e10cSrcweir                         //HMHpView->HideMarkHdl();
318*cdf0e10cSrcweir                         pViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir                         // consumed
321*cdf0e10cSrcweir                         bReturn = sal_True;
322*cdf0e10cSrcweir                     }
323*cdf0e10cSrcweir                     else if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )       // start text edit for suitable object
324*cdf0e10cSrcweir                         bReturn = sal_True;
325*cdf0e10cSrcweir                 }
326*cdf0e10cSrcweir             }
327*cdf0e10cSrcweir         }
328*cdf0e10cSrcweir         break;
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir         case KEY_F2:
331*cdf0e10cSrcweir         {
332*cdf0e10cSrcweir             if( rKEvt.GetKeyCode().GetModifier() == 0 )
333*cdf0e10cSrcweir             {
334*cdf0e10cSrcweir                 // #98198# put selected text object in edit mode
335*cdf0e10cSrcweir                 // (this is not SID_SETINPUTMODE, but F2 hardcoded, like in Writer)
336*cdf0e10cSrcweir                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
337*cdf0e10cSrcweir                 if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
338*cdf0e10cSrcweir                 {
339*cdf0e10cSrcweir                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
340*cdf0e10cSrcweir                     if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) )            // start text edit for suitable object
341*cdf0e10cSrcweir                         bReturn = sal_True;
342*cdf0e10cSrcweir                 }
343*cdf0e10cSrcweir             }
344*cdf0e10cSrcweir         }
345*cdf0e10cSrcweir         break;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         // #97016#
348*cdf0e10cSrcweir         case KEY_TAB:
349*cdf0e10cSrcweir         {
350*cdf0e10cSrcweir             // in calc do NOT start draw object selection using TAB/SHIFT-TAB when
351*cdf0e10cSrcweir             // there is not yet a object selected
352*cdf0e10cSrcweir             if(pView->AreObjectsMarked())
353*cdf0e10cSrcweir             {
354*cdf0e10cSrcweir                 KeyCode aCode = rKEvt.GetKeyCode();
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir                 if ( !aCode.IsMod1() && !aCode.IsMod2() )
357*cdf0e10cSrcweir                 {
358*cdf0e10cSrcweir                     // changeover to the next object
359*cdf0e10cSrcweir                     if(!pView->MarkNextObj( !aCode.IsShift() ))
360*cdf0e10cSrcweir                     {
361*cdf0e10cSrcweir                         // #97016# No next object: go over open end and
362*cdf0e10cSrcweir                         // get first from the other side
363*cdf0e10cSrcweir                         pView->UnmarkAllObj();
364*cdf0e10cSrcweir                         pView->MarkNextObj(!aCode.IsShift());
365*cdf0e10cSrcweir                     }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir                     // #97016# II
368*cdf0e10cSrcweir                     if(pView->AreObjectsMarked())
369*cdf0e10cSrcweir                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir                     bReturn = sal_True;
372*cdf0e10cSrcweir                 }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir                 // #98994# handle Mod1 and Mod2 to get travelling running on different systems
375*cdf0e10cSrcweir                 if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
376*cdf0e10cSrcweir                 {
377*cdf0e10cSrcweir                     // #97016# II do something with a selected handle?
378*cdf0e10cSrcweir                     const SdrHdlList& rHdlList = pView->GetHdlList();
379*cdf0e10cSrcweir                     sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir                     ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir                     // guarantee visibility of focused handle
384*cdf0e10cSrcweir                     SdrHdl* pHdl = rHdlList.GetFocusHdl();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir                     if(pHdl)
387*cdf0e10cSrcweir                     {
388*cdf0e10cSrcweir                         Point aHdlPosition(pHdl->GetPos());
389*cdf0e10cSrcweir                         Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
390*cdf0e10cSrcweir                         pView->MakeVisible(aVisRect, *pWindow);
391*cdf0e10cSrcweir                     }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir                     // consumed
394*cdf0e10cSrcweir                     bReturn = sal_True;
395*cdf0e10cSrcweir                 }
396*cdf0e10cSrcweir             }
397*cdf0e10cSrcweir         }
398*cdf0e10cSrcweir         break;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir         // #97016#
401*cdf0e10cSrcweir         case KEY_END:
402*cdf0e10cSrcweir         {
403*cdf0e10cSrcweir             // in calc do NOT select the last draw object when
404*cdf0e10cSrcweir             // there is not yet a object selected
405*cdf0e10cSrcweir             if(pView->AreObjectsMarked())
406*cdf0e10cSrcweir             {
407*cdf0e10cSrcweir                 KeyCode aCode = rKEvt.GetKeyCode();
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir                 if ( aCode.IsMod1() )
410*cdf0e10cSrcweir                 {
411*cdf0e10cSrcweir                     // #97016# mark last object
412*cdf0e10cSrcweir                     pView->UnmarkAllObj();
413*cdf0e10cSrcweir                     pView->MarkNextObj(sal_False);
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir                     // #97016# II
416*cdf0e10cSrcweir                     if(pView->AreObjectsMarked())
417*cdf0e10cSrcweir                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir                     bReturn = sal_True;
420*cdf0e10cSrcweir                 }
421*cdf0e10cSrcweir             }
422*cdf0e10cSrcweir         }
423*cdf0e10cSrcweir         break;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir         // #97016#
426*cdf0e10cSrcweir         case KEY_HOME:
427*cdf0e10cSrcweir         {
428*cdf0e10cSrcweir             // in calc do NOT select the first draw object when
429*cdf0e10cSrcweir             // there is not yet a object selected
430*cdf0e10cSrcweir             if(pView->AreObjectsMarked())
431*cdf0e10cSrcweir             {
432*cdf0e10cSrcweir                 KeyCode aCode = rKEvt.GetKeyCode();
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir                 if ( aCode.IsMod1() )
435*cdf0e10cSrcweir                 {
436*cdf0e10cSrcweir                     // #97016# mark first object
437*cdf0e10cSrcweir                     pView->UnmarkAllObj();
438*cdf0e10cSrcweir                     pView->MarkNextObj(sal_True);
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir                     // #97016# II
441*cdf0e10cSrcweir                     if(pView->AreObjectsMarked())
442*cdf0e10cSrcweir                         pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir                     bReturn = sal_True;
445*cdf0e10cSrcweir                 }
446*cdf0e10cSrcweir             }
447*cdf0e10cSrcweir         }
448*cdf0e10cSrcweir         break;
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir         // #97016#
451*cdf0e10cSrcweir         case KEY_UP:
452*cdf0e10cSrcweir         case KEY_DOWN:
453*cdf0e10cSrcweir         case KEY_LEFT:
454*cdf0e10cSrcweir         case KEY_RIGHT:
455*cdf0e10cSrcweir         {
456*cdf0e10cSrcweir             // in calc do cursor travelling of draw objects only when
457*cdf0e10cSrcweir             // there is a object selected yet
458*cdf0e10cSrcweir             if(pView->AreObjectsMarked())
459*cdf0e10cSrcweir             {
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir                 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
462*cdf0e10cSrcweir                 if(rMarkList.GetMarkCount() == 1)
463*cdf0e10cSrcweir                 {
464*cdf0e10cSrcweir                     // disable cursor travelling on note objects as the tail connector position
465*cdf0e10cSrcweir                     // must not move.
466*cdf0e10cSrcweir                     SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
467*cdf0e10cSrcweir                     if( ScDrawLayer::IsNoteCaption( pObj ) )
468*cdf0e10cSrcweir                         break;
469*cdf0e10cSrcweir                 }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir                 long nX = 0;
472*cdf0e10cSrcweir                 long nY = 0;
473*cdf0e10cSrcweir                 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir                 if (nCode == KEY_UP)
476*cdf0e10cSrcweir                 {
477*cdf0e10cSrcweir                     // Scroll nach oben
478*cdf0e10cSrcweir                     nX = 0;
479*cdf0e10cSrcweir                     nY =-1;
480*cdf0e10cSrcweir                 }
481*cdf0e10cSrcweir                 else if (nCode == KEY_DOWN)
482*cdf0e10cSrcweir                 {
483*cdf0e10cSrcweir                     // Scroll nach unten
484*cdf0e10cSrcweir                     nX = 0;
485*cdf0e10cSrcweir                     nY = 1;
486*cdf0e10cSrcweir                 }
487*cdf0e10cSrcweir                 else if (nCode == KEY_LEFT)
488*cdf0e10cSrcweir                 {
489*cdf0e10cSrcweir                     // Scroll nach links
490*cdf0e10cSrcweir                     nX =-1;
491*cdf0e10cSrcweir                     nY = 0;
492*cdf0e10cSrcweir                 }
493*cdf0e10cSrcweir                 else if (nCode == KEY_RIGHT)
494*cdf0e10cSrcweir                 {
495*cdf0e10cSrcweir                     // Scroll nach rechts
496*cdf0e10cSrcweir                     nX = 1;
497*cdf0e10cSrcweir                     nY = 0;
498*cdf0e10cSrcweir                 }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir                 sal_Bool bReadOnly = rViewData.GetDocShell()->IsReadOnly();
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir                 if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly)
503*cdf0e10cSrcweir                 {
504*cdf0e10cSrcweir                     if(rKEvt.GetKeyCode().IsMod2())
505*cdf0e10cSrcweir                     {
506*cdf0e10cSrcweir                         // #97016# move in 1 pixel distance
507*cdf0e10cSrcweir                         Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
508*cdf0e10cSrcweir                         nX *= aLogicSizeOnePixel.Width();
509*cdf0e10cSrcweir                         nY *= aLogicSizeOnePixel.Height();
510*cdf0e10cSrcweir                     }
511*cdf0e10cSrcweir                     else
512*cdf0e10cSrcweir                     {
513*cdf0e10cSrcweir                         // old, fixed move distance
514*cdf0e10cSrcweir                         nX *= 100;
515*cdf0e10cSrcweir                         nY *= 100;
516*cdf0e10cSrcweir                     }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir                     // is there a movement to do?
519*cdf0e10cSrcweir                     if(0 != nX || 0 != nY)
520*cdf0e10cSrcweir                     {
521*cdf0e10cSrcweir                         // #97016# II
522*cdf0e10cSrcweir                         const SdrHdlList& rHdlList = pView->GetHdlList();
523*cdf0e10cSrcweir                         SdrHdl* pHdl = rHdlList.GetFocusHdl();
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir                         if(0L == pHdl)
526*cdf0e10cSrcweir                         {
527*cdf0e10cSrcweir                             // #107086# only take action when move is allowed
528*cdf0e10cSrcweir                             if(pView->IsMoveAllowed())
529*cdf0e10cSrcweir                             {
530*cdf0e10cSrcweir                                 // #90129# restrict movement to WorkArea
531*cdf0e10cSrcweir                                 const Rectangle& rWorkArea = pView->GetWorkArea();
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir                                 if(!rWorkArea.IsEmpty())
534*cdf0e10cSrcweir                                 {
535*cdf0e10cSrcweir                                     Rectangle aMarkRect(pView->GetMarkedObjRect());
536*cdf0e10cSrcweir                                     aMarkRect.Move(nX, nY);
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir                                     if(!aMarkRect.IsInside(rWorkArea))
539*cdf0e10cSrcweir                                     {
540*cdf0e10cSrcweir                                         if(aMarkRect.Left() < rWorkArea.Left())
541*cdf0e10cSrcweir                                         {
542*cdf0e10cSrcweir                                             nX += rWorkArea.Left() - aMarkRect.Left();
543*cdf0e10cSrcweir                                         }
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir                                         if(aMarkRect.Right() > rWorkArea.Right())
546*cdf0e10cSrcweir                                         {
547*cdf0e10cSrcweir                                             nX -= aMarkRect.Right() - rWorkArea.Right();
548*cdf0e10cSrcweir                                         }
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir                                         if(aMarkRect.Top() < rWorkArea.Top())
551*cdf0e10cSrcweir                                         {
552*cdf0e10cSrcweir                                             nY += rWorkArea.Top() - aMarkRect.Top();
553*cdf0e10cSrcweir                                         }
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir                                         if(aMarkRect.Bottom() > rWorkArea.Bottom())
556*cdf0e10cSrcweir                                         {
557*cdf0e10cSrcweir                                             nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
558*cdf0e10cSrcweir                                         }
559*cdf0e10cSrcweir                                     }
560*cdf0e10cSrcweir                                 }
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir                                 // now move the selected draw objects
563*cdf0e10cSrcweir                                 pView->MoveAllMarked(Size(nX, nY));
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir                                 // #97016# II
566*cdf0e10cSrcweir                                 pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir                                 bReturn = sal_True;
569*cdf0e10cSrcweir                             }
570*cdf0e10cSrcweir                         }
571*cdf0e10cSrcweir                         else
572*cdf0e10cSrcweir                         {
573*cdf0e10cSrcweir                             // move handle with index nHandleIndex
574*cdf0e10cSrcweir                             if(pHdl && (nX || nY))
575*cdf0e10cSrcweir                             {
576*cdf0e10cSrcweir                                 // now move the Handle (nX, nY)
577*cdf0e10cSrcweir                                 Point aStartPoint(pHdl->GetPos());
578*cdf0e10cSrcweir                                 Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
579*cdf0e10cSrcweir                                 const SdrDragStat& rDragStat = pView->GetDragStat();
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir                                 // start dragging
582*cdf0e10cSrcweir                                 pView->BegDragObj(aStartPoint, 0, pHdl, 0);
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir                                 if(pView->IsDragObj())
585*cdf0e10cSrcweir                                 {
586*cdf0e10cSrcweir                                     FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
587*cdf0e10cSrcweir                                     sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir                                     // switch snapping off
590*cdf0e10cSrcweir                                     if(!bWasNoSnap)
591*cdf0e10cSrcweir                                         ((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
592*cdf0e10cSrcweir                                     if(bWasSnapEnabled)
593*cdf0e10cSrcweir                                         pView->SetSnapEnabled(sal_False);
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir                                     pView->MovAction(aEndPoint);
596*cdf0e10cSrcweir                                     pView->EndDragObj();
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir                                     // restore snap
599*cdf0e10cSrcweir                                     if(!bWasNoSnap)
600*cdf0e10cSrcweir                                         ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
601*cdf0e10cSrcweir                                     if(bWasSnapEnabled)
602*cdf0e10cSrcweir                                         pView->SetSnapEnabled(bWasSnapEnabled);
603*cdf0e10cSrcweir                                 }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir                                 // make moved handle visible
606*cdf0e10cSrcweir                                 Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
607*cdf0e10cSrcweir                                 pView->MakeVisible(aVisRect, *pWindow);
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir                                 bReturn = sal_True;
610*cdf0e10cSrcweir                             }
611*cdf0e10cSrcweir                         }
612*cdf0e10cSrcweir                     }
613*cdf0e10cSrcweir                 }
614*cdf0e10cSrcweir             }
615*cdf0e10cSrcweir         }
616*cdf0e10cSrcweir         break;
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir         // #97016#
619*cdf0e10cSrcweir         case KEY_SPACE:
620*cdf0e10cSrcweir         {
621*cdf0e10cSrcweir             // in calc do only something when draw objects are selected
622*cdf0e10cSrcweir             if(pView->AreObjectsMarked())
623*cdf0e10cSrcweir             {
624*cdf0e10cSrcweir                 const SdrHdlList& rHdlList = pView->GetHdlList();
625*cdf0e10cSrcweir                 SdrHdl* pHdl = rHdlList.GetFocusHdl();
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir                 if(pHdl)
628*cdf0e10cSrcweir                 {
629*cdf0e10cSrcweir                     if(pHdl->GetKind() == HDL_POLY)
630*cdf0e10cSrcweir                     {
631*cdf0e10cSrcweir                         // rescue ID of point with focus
632*cdf0e10cSrcweir                         sal_uInt32 nPol(pHdl->GetPolyNum());
633*cdf0e10cSrcweir                         sal_uInt32 nPnt(pHdl->GetPointNum());
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir                         if(pView->IsPointMarked(*pHdl))
636*cdf0e10cSrcweir                         {
637*cdf0e10cSrcweir                             if(rKEvt.GetKeyCode().IsShift())
638*cdf0e10cSrcweir                             {
639*cdf0e10cSrcweir                                 pView->UnmarkPoint(*pHdl);
640*cdf0e10cSrcweir                             }
641*cdf0e10cSrcweir                         }
642*cdf0e10cSrcweir                         else
643*cdf0e10cSrcweir                         {
644*cdf0e10cSrcweir                             if(!rKEvt.GetKeyCode().IsShift())
645*cdf0e10cSrcweir                             {
646*cdf0e10cSrcweir                                 pView->UnmarkAllPoints();
647*cdf0e10cSrcweir                             }
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir                             pView->MarkPoint(*pHdl);
650*cdf0e10cSrcweir                         }
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir                         if(0L == rHdlList.GetFocusHdl())
653*cdf0e10cSrcweir                         {
654*cdf0e10cSrcweir                             // restore point with focus
655*cdf0e10cSrcweir                             SdrHdl* pNewOne = 0L;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir                             for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
658*cdf0e10cSrcweir                             {
659*cdf0e10cSrcweir                                 SdrHdl* pAct = rHdlList.GetHdl(a);
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir                                 if(pAct
662*cdf0e10cSrcweir                                     && pAct->GetKind() == HDL_POLY
663*cdf0e10cSrcweir                                     && pAct->GetPolyNum() == nPol
664*cdf0e10cSrcweir                                     && pAct->GetPointNum() == nPnt)
665*cdf0e10cSrcweir                                 {
666*cdf0e10cSrcweir                                     pNewOne = pAct;
667*cdf0e10cSrcweir                                 }
668*cdf0e10cSrcweir                             }
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir                             if(pNewOne)
671*cdf0e10cSrcweir                             {
672*cdf0e10cSrcweir                                 ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
673*cdf0e10cSrcweir                             }
674*cdf0e10cSrcweir                         }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir                         bReturn = sal_True;
677*cdf0e10cSrcweir                     }
678*cdf0e10cSrcweir                 }
679*cdf0e10cSrcweir             }
680*cdf0e10cSrcweir         }
681*cdf0e10cSrcweir         break;
682*cdf0e10cSrcweir     }
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir     if (!bReturn)
685*cdf0e10cSrcweir     {
686*cdf0e10cSrcweir         bReturn = FuPoor::KeyInput(rKEvt);
687*cdf0e10cSrcweir     }
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     if (!bReturn)
690*cdf0e10cSrcweir     {
691*cdf0e10cSrcweir         // #98198# allow direct typing into a selected text object
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir         const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
694*cdf0e10cSrcweir         if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) )
695*cdf0e10cSrcweir         {
696*cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir             // start text edit for suitable object, pass key event to OutlinerView
699*cdf0e10cSrcweir             if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) )
700*cdf0e10cSrcweir                 bReturn = sal_True;
701*cdf0e10cSrcweir         }
702*cdf0e10cSrcweir     }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir     return (bReturn);
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir // #97016# II
708*cdf0e10cSrcweir void FuDraw::SelectionHasChanged()
709*cdf0e10cSrcweir {
710*cdf0e10cSrcweir     const SdrHdlList& rHdlList = pView->GetHdlList();
711*cdf0e10cSrcweir     ((SdrHdlList&)rHdlList).ResetFocusHdl();
712*cdf0e10cSrcweir }
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir /*************************************************************************
715*cdf0e10cSrcweir |*
716*cdf0e10cSrcweir |* Vor dem Scrollen Selektionsdarstellung ausblenden
717*cdf0e10cSrcweir |*
718*cdf0e10cSrcweir \************************************************************************/
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir void FuDraw::ScrollStart()
721*cdf0e10cSrcweir {
722*cdf0e10cSrcweir //      HideShownXor in Gridwin
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir /*************************************************************************
726*cdf0e10cSrcweir |*
727*cdf0e10cSrcweir |* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
728*cdf0e10cSrcweir |*
729*cdf0e10cSrcweir \************************************************************************/
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir void FuDraw::ScrollEnd()
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir //      ShowShownXor in Gridwin
734*cdf0e10cSrcweir }
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir /*************************************************************************
737*cdf0e10cSrcweir |*
738*cdf0e10cSrcweir |* Function aktivieren
739*cdf0e10cSrcweir |*
740*cdf0e10cSrcweir \************************************************************************/
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir void FuDraw::Activate()
743*cdf0e10cSrcweir {
744*cdf0e10cSrcweir     FuPoor::Activate();
745*cdf0e10cSrcweir }
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir /*************************************************************************
748*cdf0e10cSrcweir |*
749*cdf0e10cSrcweir |* Function deaktivieren
750*cdf0e10cSrcweir |*
751*cdf0e10cSrcweir \************************************************************************/
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir void FuDraw::Deactivate()
754*cdf0e10cSrcweir {
755*cdf0e10cSrcweir     FuPoor::Deactivate();
756*cdf0e10cSrcweir }
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir /*************************************************************************
759*cdf0e10cSrcweir |*
760*cdf0e10cSrcweir |* Maus-Pointer umschalten
761*cdf0e10cSrcweir |*
762*cdf0e10cSrcweir \************************************************************************/
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir sal_Bool lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow )
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir     SdrViewEvent aVEvt;
767*cdf0e10cSrcweir     MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT );
768*cdf0e10cSrcweir     SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir     if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
771*cdf0e10cSrcweir     {
772*cdf0e10cSrcweir         if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject(
773*cdf0e10cSrcweir                                 aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) )
774*cdf0e10cSrcweir             return sal_True;
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir         if ( aVEvt.eEvent == SDREVENT_EXECUTEURL )
777*cdf0e10cSrcweir             return sal_True;
778*cdf0e10cSrcweir     }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir     return sal_False;
781*cdf0e10cSrcweir }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir void FuDraw::ForcePointer(const MouseEvent* pMEvt)
784*cdf0e10cSrcweir {
785*cdf0e10cSrcweir     if ( !pView->IsAction() )
786*cdf0e10cSrcweir     {
787*cdf0e10cSrcweir         Point aPosPixel = pWindow->GetPointerPosPixel();
788*cdf0e10cSrcweir         sal_Bool bAlt       = pMEvt && pMEvt->IsMod2();
789*cdf0e10cSrcweir         Point aPnt      = pWindow->PixelToLogic( aPosPixel );
790*cdf0e10cSrcweir         SdrHdl* pHdl    = pView->PickHandle(aPnt);
791*cdf0e10cSrcweir         SdrObject* pObj;
792*cdf0e10cSrcweir         SdrPageView* pPV;
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir         ScMacroInfo* pInfo = 0;
795*cdf0e10cSrcweir         if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
796*cdf0e10cSrcweir         {
797*cdf0e10cSrcweir             if ( pObj->IsGroupObject() )
798*cdf0e10cSrcweir             {
799*cdf0e10cSrcweir                 SdrObject* pHit = 0;
800*cdf0e10cSrcweir                 if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
801*cdf0e10cSrcweir                     pObj = pHit;
802*cdf0e10cSrcweir             }
803*cdf0e10cSrcweir             pInfo = ScDrawLayer::GetMacroInfo( pObj );
804*cdf0e10cSrcweir         }
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir         if ( pView->IsTextEdit() )
807*cdf0e10cSrcweir         {
808*cdf0e10cSrcweir             pViewShell->SetActivePointer(Pointer(POINTER_TEXT));        // kann nicht sein ?
809*cdf0e10cSrcweir         }
810*cdf0e10cSrcweir         else if ( pHdl )
811*cdf0e10cSrcweir         {
812*cdf0e10cSrcweir             pViewShell->SetActivePointer(
813*cdf0e10cSrcweir                 pView->GetPreferedPointer( aPnt, pWindow ) );
814*cdf0e10cSrcweir         }
815*cdf0e10cSrcweir         else if ( pView->IsMarkedHit(aPnt) )
816*cdf0e10cSrcweir         {
817*cdf0e10cSrcweir             pViewShell->SetActivePointer( Pointer(POINTER_MOVE) );
818*cdf0e10cSrcweir         }
819*cdf0e10cSrcweir         else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() )
820*cdf0e10cSrcweir                         && lcl_UrlHit( pView, aPosPixel, pWindow ) )
821*cdf0e10cSrcweir         {
822*cdf0e10cSrcweir             //  kann mit ALT unterdrueckt werden
823*cdf0e10cSrcweir             pWindow->SetPointer( Pointer( POINTER_REFHAND ) );          // Text-URL / ImageMap
824*cdf0e10cSrcweir         }
825*cdf0e10cSrcweir         else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
826*cdf0e10cSrcweir         {
827*cdf0e10cSrcweir             //  kann mit ALT unterdrueckt werden
828*cdf0e10cSrcweir             SdrObjMacroHitRec aHitRec;  //! muss da noch irgendwas gesetzt werden ????
829*cdf0e10cSrcweir             pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
830*cdf0e10cSrcweir         }
831*cdf0e10cSrcweir #ifdef ISSUE66550_HLINK_FOR_SHAPES
832*cdf0e10cSrcweir         else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) )
833*cdf0e10cSrcweir #else
834*cdf0e10cSrcweir         else if ( !bAlt && pInfo && (pInfo->GetMacro().getLength() > 0) )
835*cdf0e10cSrcweir #endif
836*cdf0e10cSrcweir             pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
837*cdf0e10cSrcweir         else if ( IsDetectiveHit( aPnt ) )
838*cdf0e10cSrcweir             pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
839*cdf0e10cSrcweir         else
840*cdf0e10cSrcweir             pViewShell->SetActivePointer( aNewPointer );            //! in Gridwin?
841*cdf0e10cSrcweir     }
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir sal_Bool FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const
845*cdf0e10cSrcweir {
846*cdf0e10cSrcweir     sal_Bool bIsSizingOrMoving = sal_False;
847*cdf0e10cSrcweir     if ( rMEvt.IsLeft() )
848*cdf0e10cSrcweir     {
849*cdf0e10cSrcweir         const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList();
850*cdf0e10cSrcweir         if(rNoteMarkList.GetMarkCount() == 1)
851*cdf0e10cSrcweir         {
852*cdf0e10cSrcweir             SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj();
853*cdf0e10cSrcweir             if ( ScDrawLayer::IsNoteCaption( pObj ) )
854*cdf0e10cSrcweir             {
855*cdf0e10cSrcweir                 Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
856*cdf0e10cSrcweir                 bIsSizingOrMoving =
857*cdf0e10cSrcweir                     pView->PickHandle( aMPos ) ||      // handles to resize the note
858*cdf0e10cSrcweir                     pView->IsTextEditFrameHit( aMPos );         // frame for moving the note
859*cdf0e10cSrcweir             }
860*cdf0e10cSrcweir         }
861*cdf0e10cSrcweir     }
862*cdf0e10cSrcweir     return bIsSizingOrMoving;
863*cdf0e10cSrcweir }
864