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: fuediglu.cxx,v $
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_sd.hxx"
34 #include "fuediglu.hxx"
35 #include <svtools/eitem.hxx>
36 #include <svx/dialogs.hrc>
37 #include <svx/svdglue.hxx>
38 #include <sfx2/request.hxx>
42 #include "strings.hrc"
43 #include "res_bmp.hrc"
44 #ifndef SD_WINDOW_SHELL_HXX
47 #include "drawdoc.hxx"
48 #ifndef SD_FRAMW_VIEW_HXX
49 #include "FrameView.hxx"
52 #include "ViewShell.hxx"
53 #include "ViewShellBase.hxx"
54 #include "ToolBarManager.hxx"
58 TYPEINIT1( FuEditGluePoints
, FuDraw
);
60 /*************************************************************************
64 \************************************************************************/
66 FuEditGluePoints::FuEditGluePoints (
72 : FuDraw(pViewSh
, pWin
, pView
, pDoc
, rReq
)
76 FunctionReference
FuEditGluePoints::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
, bool bPermanent
)
78 FuEditGluePoints
* pFunc
;
79 FunctionReference
xFunc( pFunc
= new FuEditGluePoints( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
80 xFunc
->DoExecute(rReq
);
81 pFunc
->SetPermanent( bPermanent
);
85 void FuEditGluePoints::DoExecute( SfxRequest
& rReq
)
87 FuDraw::DoExecute( rReq
);
88 mpView
->SetInsGluePointMode(FALSE
);
89 mpViewShell
->GetViewShellBase().GetToolBarManager()->AddToolBar(
90 ToolBarManager::TBG_FUNCTION
,
91 ToolBarManager::msGluePointsToolBar
);
94 /*************************************************************************
98 \************************************************************************/
100 FuEditGluePoints::~FuEditGluePoints()
103 mpView
->UnmarkAllGluePoints();
104 mpView
->SetInsGluePointMode(FALSE
);
107 /*************************************************************************
109 |* MouseButtonDown-event
111 \************************************************************************/
113 BOOL
FuEditGluePoints::MouseButtonDown(const MouseEvent
& rMEvt
)
115 mpView
->SetActualWin( mpWindow
);
117 BOOL bReturn
= FuDraw::MouseButtonDown(rMEvt
);
119 if (mpView
->IsAction())
130 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
131 USHORT nDrgLog
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
132 mpWindow
->CaptureMouse();
135 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
137 if (eHit
== SDRHIT_HANDLE
)
139 /******************************************************************
141 ******************************************************************/
142 SdrHdl
* pHdl
= aVEvt
.pHdl
;
144 if (mpView
->IsGluePointMarked(aVEvt
.pObj
, aVEvt
.nGlueId
) && rMEvt
.IsShift())
146 mpView
->UnmarkGluePoint(aVEvt
.pObj
, aVEvt
.nGlueId
, aVEvt
.pPV
);
153 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, aVEvt
.pHdl
, nDrgLog
);
156 else if (eHit
== SDRHIT_MARKEDOBJECT
&& mpView
->IsInsGluePointMode())
158 /******************************************************************
159 * Klebepunkt einfuegen
160 ******************************************************************/
161 mpView
->BegInsGluePoint(aMDPos
);
163 else if (eHit
== SDRHIT_MARKEDOBJECT
&& rMEvt
.IsMod1())
165 /******************************************************************
166 * Klebepunkt selektieren
167 ******************************************************************/
168 if (!rMEvt
.IsShift())
169 mpView
->UnmarkAllGluePoints();
171 mpView
->BegMarkGluePoints(aMDPos
);
173 else if (eHit
== SDRHIT_MARKEDOBJECT
&& !rMEvt
.IsShift() && !rMEvt
.IsMod2())
175 /******************************************************************
177 ******************************************************************/
178 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, NULL
, nDrgLog
);
180 else if (eHit
== SDRHIT_GLUEPOINT
)
182 /******************************************************************
183 * Klebepunkt selektieren
184 ******************************************************************/
185 if (!rMEvt
.IsShift())
186 mpView
->UnmarkAllGluePoints();
188 mpView
->MarkGluePoint(aVEvt
.pObj
, aVEvt
.nGlueId
, aVEvt
.pPV
);
189 SdrHdl
* pHdl
= mpView
->GetGluePointHdl(aVEvt
.pObj
, aVEvt
.nGlueId
);
193 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, pHdl
, nDrgLog
);
198 /******************************************************************
199 * Objekt selektieren oder draggen
200 ******************************************************************/
201 if (!rMEvt
.IsShift() && !rMEvt
.IsMod2() && eHit
== SDRHIT_UNMARKEDOBJECT
)
203 mpView
->UnmarkAllObj();
206 BOOL bMarked
= FALSE
;
212 bMarked
= mpView
->MarkNextObj(aMDPos
, nHitLog
, rMEvt
.IsShift());
216 bMarked
= mpView
->MarkObj(aMDPos
, nHitLog
, rMEvt
.IsShift());
221 (!rMEvt
.IsShift() || eHit
== SDRHIT_MARKEDOBJECT
))
223 // Objekt verschieben
224 mpView
->BegDragObj(aMDPos
, (OutputDevice
*) NULL
, aVEvt
.pHdl
, nDrgLog
);
226 else if (mpView
->AreObjectsMarked())
228 /**************************************************************
229 * Klebepunkt selektieren
230 **************************************************************/
231 if (!rMEvt
.IsShift())
232 mpView
->UnmarkAllGluePoints();
234 mpView
->BegMarkGluePoints(aMDPos
);
238 /**************************************************************
240 **************************************************************/
241 mpView
->BegMarkObj(aMDPos
);
245 ForcePointer(&rMEvt
);
251 /*************************************************************************
255 \************************************************************************/
257 BOOL
FuEditGluePoints::MouseMove(const MouseEvent
& rMEvt
)
259 mpView
->SetActualWin( mpWindow
);
261 FuDraw::MouseMove(rMEvt
);
263 if (mpView
->IsAction())
265 Point
aPix(rMEvt
.GetPosPixel());
266 Point
aPnt( mpWindow
->PixelToLogic(aPix
) );
268 mpView
->MovAction(aPnt
);
271 ForcePointer(&rMEvt
);
276 /*************************************************************************
278 |* MouseButtonUp-event
280 \************************************************************************/
282 BOOL
FuEditGluePoints::MouseButtonUp(const MouseEvent
& rMEvt
)
284 mpView
->SetActualWin( mpWindow
);
286 BOOL bReturn
= FALSE
;
288 if (mpView
->IsAction())
294 FuDraw::MouseButtonUp(rMEvt
);
296 USHORT nDrgLog
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
297 Point aPos
= mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() );
299 if (Abs(aMDPos
.X() - aPos
.X()) < nDrgLog
&&
300 Abs(aMDPos
.Y() - aPos
.Y()) < nDrgLog
&&
301 !rMEvt
.IsShift() && !rMEvt
.IsMod2())
304 SdrHitKind eHit
= mpView
->PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
306 if (eHit
== SDRHIT_NONE
)
308 // Klick auf der Stelle: deselektieren
309 mpView
->UnmarkAllObj();
313 mpWindow
->ReleaseMouse();
318 /*************************************************************************
320 |* Tastaturereignisse bearbeiten
322 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
325 \************************************************************************/
327 BOOL
FuEditGluePoints::KeyInput(const KeyEvent
& rKEvt
)
329 mpView
->SetActualWin( mpWindow
);
331 BOOL bReturn
= FuDraw::KeyInput(rKEvt
);
336 /*************************************************************************
340 \************************************************************************/
342 BOOL
FuEditGluePoints::Command(const CommandEvent
& rCEvt
)
344 mpView
->SetActualWin( mpWindow
);
345 return FuPoor::Command( rCEvt
);
348 /*************************************************************************
350 |* Funktion aktivieren
352 \************************************************************************/
354 void FuEditGluePoints::Activate()
356 mpView
->SetGluePointEditMode();
360 /*************************************************************************
362 |* Funktion deaktivieren
364 \************************************************************************/
366 void FuEditGluePoints::Deactivate()
368 mpView
->SetGluePointEditMode( FALSE
);
369 FuDraw::Deactivate();
372 /*************************************************************************
374 |* Request verarbeiten
376 \************************************************************************/
378 void FuEditGluePoints::ReceiveRequest(SfxRequest
& rReq
)
380 switch (rReq
.GetSlot())
382 case SID_GLUE_INSERT_POINT
:
384 mpView
->SetInsGluePointMode(!mpView
->IsInsGluePointMode());
388 case SID_GLUE_ESCDIR_LEFT
:
390 mpView
->SetMarkedGluePointsEscDir( SDRESC_LEFT
,
391 !mpView
->IsMarkedGluePointsEscDir( SDRESC_LEFT
) );
395 case SID_GLUE_ESCDIR_RIGHT
:
397 mpView
->SetMarkedGluePointsEscDir( SDRESC_RIGHT
,
398 !mpView
->IsMarkedGluePointsEscDir( SDRESC_RIGHT
) );
402 case SID_GLUE_ESCDIR_TOP
:
404 mpView
->SetMarkedGluePointsEscDir( SDRESC_TOP
,
405 !mpView
->IsMarkedGluePointsEscDir( SDRESC_TOP
) );
409 case SID_GLUE_ESCDIR_BOTTOM
:
411 mpView
->SetMarkedGluePointsEscDir( SDRESC_BOTTOM
,
412 !mpView
->IsMarkedGluePointsEscDir( SDRESC_BOTTOM
) );
416 case SID_GLUE_PERCENT
:
418 const SfxItemSet
* pSet
= rReq
.GetArgs();
419 const SfxPoolItem
& rItem
= pSet
->Get(SID_GLUE_PERCENT
);
420 BOOL bPercent
= ((const SfxBoolItem
&) rItem
).GetValue();
421 mpView
->SetMarkedGluePointsPercent(bPercent
);
425 case SID_GLUE_HORZALIGN_CENTER
:
427 mpView
->SetMarkedGluePointsAlign(FALSE
, SDRHORZALIGN_CENTER
);
431 case SID_GLUE_HORZALIGN_LEFT
:
433 mpView
->SetMarkedGluePointsAlign(FALSE
, SDRHORZALIGN_LEFT
);
437 case SID_GLUE_HORZALIGN_RIGHT
:
439 mpView
->SetMarkedGluePointsAlign(FALSE
, SDRHORZALIGN_RIGHT
);
443 case SID_GLUE_VERTALIGN_CENTER
:
445 mpView
->SetMarkedGluePointsAlign(TRUE
, SDRVERTALIGN_CENTER
);
449 case SID_GLUE_VERTALIGN_TOP
:
451 mpView
->SetMarkedGluePointsAlign(TRUE
, SDRVERTALIGN_TOP
);
455 case SID_GLUE_VERTALIGN_BOTTOM
:
457 mpView
->SetMarkedGluePointsAlign(TRUE
, SDRVERTALIGN_BOTTOM
);
462 // Zum Schluss Basisklasse rufen
463 FuPoor::ReceiveRequest(rReq
);
467 } // end of namespace sd