1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuconstr.cxx,v $
10 * $Revision: 1.11.128.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <svx/outliner.hxx>
35 #include <svx/outlobj.hxx>
36 #include <svx/svdotext.hxx>
37 #include <svx/svdouno.hxx>
38 #include <sfx2/dispatch.hxx>
40 #include "fuconstr.hxx"
42 #include "tabvwsh.hxx"
45 #include "drawview.hxx"
47 // Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
48 //! fusel,fuconstr,futext - zusammenfassen!
49 #define SC_MAXDRAGMOVE 3
51 //------------------------------------------------------------------------
53 /*************************************************************************
57 \************************************************************************/
59 FuConstruct::FuConstruct(ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
60 SdrModel
* pDoc
, SfxRequest
& rReq
) :
61 FuDraw(pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
65 /*************************************************************************
69 \************************************************************************/
71 FuConstruct::~FuConstruct()
75 BYTE
FuConstruct::Command(const CommandEvent
& rCEvt
)
77 // special code for non-VCL OS2/UNX removed
79 return FuDraw::Command( rCEvt
);
82 /*************************************************************************
84 |* MouseButtonDown-event
86 \************************************************************************/
88 BOOL __EXPORT
FuConstruct::MouseButtonDown(const MouseEvent
& rMEvt
)
90 // #95491# remember button state for creation of own MouseEvents
91 SetMouseButtonCode(rMEvt
.GetButtons());
93 BOOL bReturn
= FuDraw::MouseButtonDown(rMEvt
);
95 if ( pView
->IsAction() )
97 if ( rMEvt
.IsRight() )
104 aMDPos
= pWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
106 if ( rMEvt
.IsLeft() )
108 pWindow
->CaptureMouse();
110 SdrHdl
* pHdl
= pView
->PickHandle(aMDPos
);
112 if ( pHdl
!= NULL
|| pView
->IsMarkedHit(aMDPos
) )
114 pView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, pHdl
, 1);
117 else if ( pView
->AreObjectsMarked() )
124 bIsInDragMode
= FALSE
;
129 /*************************************************************************
133 \************************************************************************/
135 BOOL __EXPORT
FuConstruct::MouseMove(const MouseEvent
& rMEvt
)
137 FuDraw::MouseMove(rMEvt
);
139 if (aDragTimer
.IsActive() )
141 Point aOldPixel
= pWindow
->LogicToPixel( aMDPos
);
142 Point aNewPixel
= rMEvt
.GetPosPixel();
143 if ( Abs( aOldPixel
.X() - aNewPixel
.X() ) > SC_MAXDRAGMOVE
||
144 Abs( aOldPixel
.Y() - aNewPixel
.Y() ) > SC_MAXDRAGMOVE
)
148 Point
aPix(rMEvt
.GetPosPixel());
149 Point
aPnt( pWindow
->PixelToLogic(aPix
) );
151 if ( pView
->IsAction() )
154 pView
->MovAction(aPnt
);
158 SdrHdl
* pHdl
=pView
->PickHandle(aPnt
);
162 pViewShell
->SetActivePointer(pHdl
->GetPointer());
164 else if ( pView
->IsMarkedHit(aPnt
) )
166 pViewShell
->SetActivePointer(Pointer(POINTER_MOVE
));
170 pViewShell
->SetActivePointer( aNewPointer
);
176 /*************************************************************************
178 |* MouseButtonUp-event
180 \************************************************************************/
182 BOOL __EXPORT
FuConstruct::MouseButtonUp(const MouseEvent
& rMEvt
)
184 // #95491# remember button state for creation of own MouseEvents
185 SetMouseButtonCode(rMEvt
.GetButtons());
187 BOOL bReturn
= SimpleMouseButtonUp( rMEvt
);
189 // Doppelklick auf Textobjekt? (->fusel)
191 USHORT nClicks
= rMEvt
.GetClicks();
192 if ( nClicks
== 2 && rMEvt
.IsLeft() )
194 if ( pView
->AreObjectsMarked() )
196 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
197 if (rMarkList
.GetMarkCount() == 1)
199 SdrMark
* pMark
= rMarkList
.GetMark(0);
200 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
202 // #49458# bei Uno-Controls nicht in Textmodus
203 if ( pObj
->ISA(SdrTextObj
) && !pObj
->ISA(SdrUnoObj
) )
205 OutlinerParaObject
* pOPO
= pObj
->GetOutlinerParaObject();
206 BOOL bVertical
= ( pOPO
&& pOPO
->IsVertical() );
207 USHORT nTextSlotId
= bVertical
? SID_DRAW_TEXT_VERTICAL
: SID_DRAW_TEXT
;
209 pViewShell
->GetViewData()->GetDispatcher().
210 Execute(nTextSlotId
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
212 // jetzt den erzeugten FuText holen und in den EditModus setzen
213 FuPoor
* pPoor
= pViewShell
->GetViewData()->GetView()->GetDrawFuncPtr();
214 if ( pPoor
&& pPoor
->GetSlotID() == nTextSlotId
) // hat keine RTTI
216 FuText
* pText
= (FuText
*)pPoor
;
217 Point aMousePixel
= rMEvt
.GetPosPixel();
218 pText
->SetInEditMode( pObj
, &aMousePixel
);
226 FuDraw::MouseButtonUp(rMEvt
);
231 // SimpleMouseButtonUp - ohne Test auf Doppelklick
233 BOOL
FuConstruct::SimpleMouseButtonUp(const MouseEvent
& rMEvt
)
237 if (aDragTimer
.IsActive() )
242 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
244 if ( pView
->IsDragObj() )
245 pView
->EndDragObj( rMEvt
.IsMod1() );
247 else if ( pView
->IsMarkObj() )
250 else bReturn
= FALSE
;
252 if ( !pView
->IsAction() )
254 pWindow
->ReleaseMouse();
256 if ( !pView
->AreObjectsMarked() && rMEvt
.GetClicks() < 2 )
258 pView
->MarkObj(aPnt
, -2, FALSE
, rMEvt
.IsMod1());
260 SfxDispatcher
& rDisp
= pViewShell
->GetViewData()->GetDispatcher();
261 if ( pView
->AreObjectsMarked() )
262 rDisp
.Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
264 rDisp
.Execute(aSfxRequest
.GetSlot(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
271 /*************************************************************************
273 |* Tastaturereignisse bearbeiten
275 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
278 \************************************************************************/
280 BOOL __EXPORT
FuConstruct::KeyInput(const KeyEvent
& rKEvt
)
282 BOOL bReturn
= FALSE
;
284 switch ( rKEvt
.GetKeyCode().GetCode() )
287 if ( pView
->IsAction() )
290 pWindow
->ReleaseMouse();
293 else // Zeichenmodus beenden
295 pViewShell
->GetViewData()->GetDispatcher().
296 Execute(aSfxRequest
.GetSlot(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
301 pView
->DeleteMarked();
308 bReturn
= FuDraw::KeyInput(rKEvt
);
314 /*************************************************************************
316 |* Function aktivieren
318 \************************************************************************/
320 void FuConstruct::Activate()
325 /*************************************************************************
327 |* Function deaktivieren
329 \************************************************************************/
331 void FuConstruct::Deactivate()
333 FuDraw::Deactivate();