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: fuconarc.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 "fuconarc.hxx"
35 #include <svx/svdpagv.hxx>
36 #include <svx/svdocirc.hxx>
37 #include <sfx2/request.hxx>
38 #include <svtools/intitem.hxx>
39 #include <svtools/aeitem.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <svx/svdobj.hxx>
42 #include <sfx2/viewfrm.hxx>
45 #include <svx/svxids.hrc>
50 #include "drawdoc.hxx"
51 #include "res_bmp.hrc"
53 #include "ViewShell.hxx"
54 #include "ViewShellBase.hxx"
55 #include "ToolBarManager.hxx"
58 #include <svx/sxciaitm.hxx>
62 TYPEINIT1( FuConstructArc
, FuConstruct
);
64 /*************************************************************************
68 \************************************************************************/
70 FuConstructArc::FuConstructArc (
76 : FuConstruct( pViewSh
, pWin
, pView
, pDoc
, rReq
)
80 FunctionReference
FuConstructArc::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
, bool bPermanent
)
82 FuConstructArc
* pFunc
;
83 FunctionReference
xFunc( pFunc
= new FuConstructArc( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
84 xFunc
->DoExecute(rReq
);
85 pFunc
->SetPermanent(bPermanent
);
89 void FuConstructArc::DoExecute( SfxRequest
& rReq
)
91 FuConstruct::DoExecute( rReq
);
93 mpViewShell
->GetViewShellBase().GetToolBarManager()->SetToolBar(
94 ToolBarManager::TBG_FUNCTION
,
95 ToolBarManager::msDrawingObjectToolBar
);
97 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
101 SFX_REQUEST_ARG (rReq
, pCenterX
, SfxUInt32Item
, ID_VAL_CENTER_X
, FALSE
);
102 SFX_REQUEST_ARG (rReq
, pCenterY
, SfxUInt32Item
, ID_VAL_CENTER_Y
, FALSE
);
103 SFX_REQUEST_ARG (rReq
, pAxisX
, SfxUInt32Item
, ID_VAL_AXIS_X
, FALSE
);
104 SFX_REQUEST_ARG (rReq
, pAxisY
, SfxUInt32Item
, ID_VAL_AXIS_Y
, FALSE
);
105 SFX_REQUEST_ARG (rReq
, pPhiStart
, SfxUInt32Item
, ID_VAL_ANGLESTART
, FALSE
);
106 SFX_REQUEST_ARG (rReq
, pPhiEnd
, SfxUInt32Item
, ID_VAL_ANGLEEND
, FALSE
);
108 Rectangle
aNewRectangle (pCenterX
->GetValue () - pAxisX
->GetValue () / 2,
109 pCenterY
->GetValue () - pAxisY
->GetValue () / 2,
110 pCenterX
->GetValue () + pAxisX
->GetValue () / 2,
111 pCenterY
->GetValue () + pAxisY
->GetValue () / 2);
113 Activate(); // Setzt aObjKind
114 SdrCircObj
* pNewCircle
=
115 new SdrCircObj((SdrObjKind
) mpView
->GetCurrentObjIdentifier(),
117 (long) (pPhiStart
->GetValue () * 10.0),
118 (long) (pPhiEnd
->GetValue () * 10.0));
119 SdrPageView
*pPV
= mpView
->GetSdrPageView();
121 mpView
->InsertObjectAtView(pNewCircle
, *pPV
, SDRINSERT_SETDEFLAYER
);
125 /*************************************************************************
127 |* MouseButtonDown-event
129 \************************************************************************/
131 BOOL
FuConstructArc::MouseButtonDown( const MouseEvent
& rMEvt
)
133 BOOL bReturn
= FuConstruct::MouseButtonDown( rMEvt
);
135 if ( rMEvt
.IsLeft() && !mpView
->IsAction() )
137 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
138 mpWindow
->CaptureMouse();
139 USHORT nDrgLog
= USHORT ( mpWindow
->PixelToLogic(Size(DRGPIX
,0)).Width() );
140 mpView
->BegCreateObj(aPnt
, (OutputDevice
*) NULL
, nDrgLog
);
142 SdrObject
* pObj
= mpView
->GetCreateObj();
146 SfxItemSet
aAttr(mpDoc
->GetPool());
147 SetStyleSheet(aAttr
, pObj
);
149 //-/ pObj->NbcSetAttributes(aAttr, FALSE);
150 pObj
->SetMergedItemSet(aAttr
);
158 /*************************************************************************
162 \************************************************************************/
164 BOOL
FuConstructArc::MouseMove( const MouseEvent
& rMEvt
)
166 return FuConstruct::MouseMove(rMEvt
);
169 /*************************************************************************
171 |* MouseButtonUp-event
173 \************************************************************************/
175 BOOL
FuConstructArc::MouseButtonUp( const MouseEvent
& rMEvt
)
177 BOOL bReturn
= FALSE
;
178 BOOL bCreated
= FALSE
;
180 if ( mpView
->IsCreateObj() && rMEvt
.IsLeft() )
182 Point
aPnt( mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
184 ULONG nCount
= mpView
->GetSdrPageView()->GetObjList()->GetObjCount();
186 if (mpView
->EndCreateObj(SDRCREATE_NEXTPOINT
) )
188 if (nCount
!= mpView
->GetSdrPageView()->GetObjList()->GetObjCount())
197 bReturn
= FuConstruct::MouseButtonUp (rMEvt
) || bReturn
;
199 if (!bPermanent
&& bCreated
)
200 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
205 /*************************************************************************
207 |* Tastaturereignisse bearbeiten
209 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
212 \************************************************************************/
214 BOOL
FuConstructArc::KeyInput(const KeyEvent
& rKEvt
)
216 BOOL bReturn
= FuConstruct::KeyInput(rKEvt
);
220 /*************************************************************************
222 |* Function aktivieren
224 \************************************************************************/
226 void FuConstructArc::Activate()
233 case SID_DRAW_CIRCLEARC
:
240 case SID_DRAW_PIE_NOFILL
:
241 case SID_DRAW_CIRCLEPIE
:
242 case SID_DRAW_CIRCLEPIE_NOFILL
:
248 case SID_DRAW_ELLIPSECUT
:
249 case SID_DRAW_ELLIPSECUT_NOFILL
:
250 case SID_DRAW_CIRCLECUT
:
251 case SID_DRAW_CIRCLECUT_NOFILL
:
264 mpView
->SetCurrentObj((UINT16
)aObjKind
);
266 FuConstruct::Activate();
267 // FuDraw::Activate();
270 /*************************************************************************
272 |* Function deaktivieren
274 \************************************************************************/
276 void FuConstructArc::Deactivate()
278 FuConstruct::Deactivate();
279 // FuDraw::Deactivate();
283 SdrObject
* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID
, const Rectangle
& rRectangle
)
285 // case SID_DRAW_ARC:
286 // case SID_DRAW_CIRCLEARC:
287 // case SID_DRAW_PIE:
288 // case SID_DRAW_PIE_NOFILL:
289 // case SID_DRAW_CIRCLEPIE:
290 // case SID_DRAW_CIRCLEPIE_NOFILL:
291 // case SID_DRAW_ELLIPSECUT:
292 // case SID_DRAW_ELLIPSECUT_NOFILL:
293 // case SID_DRAW_CIRCLECUT:
294 // case SID_DRAW_CIRCLECUT_NOFILL:
296 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
297 mpView
->GetCurrentObjInventor(), mpView
->GetCurrentObjIdentifier(),
302 if(pObj
->ISA(SdrCircObj
))
304 Rectangle
aRect(rRectangle
);
306 if(SID_DRAW_ARC
== nID
||
307 SID_DRAW_CIRCLEARC
== nID
||
308 SID_DRAW_CIRCLEPIE
== nID
||
309 SID_DRAW_CIRCLEPIE_NOFILL
== nID
||
310 SID_DRAW_CIRCLECUT
== nID
||
311 SID_DRAW_CIRCLECUT_NOFILL
== nID
)
314 ImpForceQuadratic(aRect
);
317 pObj
->SetLogicRect(aRect
);
319 SfxItemSet
aAttr(mpDoc
->GetPool());
320 aAttr
.Put(SdrCircStartAngleItem(9000));
321 aAttr
.Put(SdrCircEndAngleItem(0));
323 if(SID_DRAW_PIE_NOFILL
== nID
||
324 SID_DRAW_CIRCLEPIE_NOFILL
== nID
||
325 SID_DRAW_ELLIPSECUT_NOFILL
== nID
||
326 SID_DRAW_CIRCLECUT_NOFILL
== nID
)
328 aAttr
.Put(XFillStyleItem(XFILL_NONE
));
331 pObj
->SetMergedItemSet(aAttr
);
335 DBG_ERROR("Object is NO circle object");
342 } // end of namespace sd