Update ooo320-m1
[ooovba.git] / sc / source / ui / drawfunc / fuconstr.cxx
blob65b83d148cbaeb7f858688014833e91324aaba2f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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"
41 #include "fudraw.hxx"
42 #include "tabvwsh.hxx"
43 #include "futext.hxx"
44 #include "sc.hrc"
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 /*************************************************************************
55 |* Konstruktor
57 \************************************************************************/
59 FuConstruct::FuConstruct(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
60 SdrModel* pDoc, SfxRequest& rReq) :
61 FuDraw(pViewSh, pWin, pViewP, pDoc, rReq)
65 /*************************************************************************
67 |* Destruktor
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() )
98 pView->BckAction();
99 return TRUE;
102 aDragTimer.Start();
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);
115 bReturn = TRUE;
117 else if ( pView->AreObjectsMarked() )
119 pView->UnmarkAll();
120 bReturn = TRUE;
124 bIsInDragMode = FALSE;
126 return bReturn;
129 /*************************************************************************
131 |* MouseMove-event
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 )
145 aDragTimer.Stop();
148 Point aPix(rMEvt.GetPosPixel());
149 Point aPnt( pWindow->PixelToLogic(aPix) );
151 if ( pView->IsAction() )
153 ForceScroll(aPix);
154 pView->MovAction(aPnt);
156 else
158 SdrHdl* pHdl=pView->PickHandle(aPnt);
160 if ( pHdl != NULL )
162 pViewShell->SetActivePointer(pHdl->GetPointer());
164 else if ( pView->IsMarkedHit(aPnt) )
166 pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
168 else
170 pViewShell->SetActivePointer( aNewPointer );
173 return TRUE;
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 );
220 bReturn = TRUE;
226 FuDraw::MouseButtonUp(rMEvt);
228 return bReturn;
231 // SimpleMouseButtonUp - ohne Test auf Doppelklick
233 BOOL FuConstruct::SimpleMouseButtonUp(const MouseEvent& rMEvt)
235 BOOL bReturn = TRUE;
237 if (aDragTimer.IsActive() )
239 aDragTimer.Stop();
242 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
244 if ( pView->IsDragObj() )
245 pView->EndDragObj( rMEvt.IsMod1() );
247 else if ( pView->IsMarkObj() )
248 pView->EndMarkObj();
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);
263 else
264 rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
268 return bReturn;
271 /*************************************************************************
273 |* Tastaturereignisse bearbeiten
275 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
276 |* FALSE.
278 \************************************************************************/
280 BOOL __EXPORT FuConstruct::KeyInput(const KeyEvent& rKEvt)
282 BOOL bReturn = FALSE;
284 switch ( rKEvt.GetKeyCode().GetCode() )
286 case KEY_ESCAPE:
287 if ( pView->IsAction() )
289 pView->BrkAction();
290 pWindow->ReleaseMouse();
291 bReturn = TRUE;
293 else // Zeichenmodus beenden
295 pViewShell->GetViewData()->GetDispatcher().
296 Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
298 break;
300 case KEY_DELETE:
301 pView->DeleteMarked();
302 bReturn = TRUE;
303 break;
306 if ( !bReturn )
308 bReturn = FuDraw::KeyInput(rKEvt);
311 return(bReturn);
314 /*************************************************************************
316 |* Function aktivieren
318 \************************************************************************/
320 void FuConstruct::Activate()
322 FuDraw::Activate();
325 /*************************************************************************
327 |* Function deaktivieren
329 \************************************************************************/
331 void FuConstruct::Deactivate()
333 FuDraw::Deactivate();