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 $
10 * $Revision: 1.9.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 "fuconarc.hxx"
36 #include "tabvwsh.hxx"
37 #include "drawview.hxx"
39 // #98185# Create default drawing objects via keyboard
40 #include <svx/svdocirc.hxx>
41 #include <svx/sxciaitm.hxx>
43 /*************************************************************************
47 \************************************************************************/
49 FuConstArc::FuConstArc( ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
50 SdrModel
* pDoc
, SfxRequest
& rReq
)
51 : FuConstruct( pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
55 /*************************************************************************
59 \************************************************************************/
61 FuConstArc::~FuConstArc()
65 /*************************************************************************
67 |* MouseButtonDown-event
69 \************************************************************************/
71 BOOL __EXPORT
FuConstArc::MouseButtonDown( const MouseEvent
& rMEvt
)
73 // #95491# remember button state for creation of own MouseEvents
74 SetMouseButtonCode(rMEvt
.GetButtons());
76 BOOL bReturn
= FuConstruct::MouseButtonDown( rMEvt
);
78 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
80 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
81 pWindow
->CaptureMouse();
82 pView
->BegCreateObj( aPnt
);
88 /*************************************************************************
92 \************************************************************************/
94 BOOL __EXPORT
FuConstArc::MouseMove( const MouseEvent
& rMEvt
)
96 return FuConstruct::MouseMove(rMEvt
);
99 /*************************************************************************
101 |* MouseButtonUp-event
103 \************************************************************************/
105 BOOL __EXPORT
FuConstArc::MouseButtonUp( const MouseEvent
& rMEvt
)
107 // #95491# remember button state for creation of own MouseEvents
108 SetMouseButtonCode(rMEvt
.GetButtons());
110 BOOL bReturn
= FALSE
;
112 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
114 // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
115 pView
->EndCreateObj( SDRCREATE_NEXTPOINT
);
119 else if ( pView->IsCreateObj() && rMEvt.IsRight() )
121 // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
122 pView->EndCreateObj( SDRCREATE_FORCEEND );
126 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
129 /*************************************************************************
131 |* Tastaturereignisse bearbeiten
133 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
136 \************************************************************************/
138 BOOL __EXPORT
FuConstArc::KeyInput(const KeyEvent
& rKEvt
)
140 BOOL bReturn
= FuConstruct::KeyInput(rKEvt
);
144 /*************************************************************************
146 |* Function aktivieren
148 \************************************************************************/
150 void FuConstArc::Activate()
154 switch (aSfxRequest
.GetSlot() )
157 aNewPointer
= Pointer( POINTER_DRAW_ARC
);
162 aNewPointer
= Pointer( POINTER_DRAW_PIE
);
166 case SID_DRAW_CIRCLECUT
:
167 aNewPointer
= Pointer( POINTER_DRAW_CIRCLECUT
);
172 aNewPointer
= Pointer( POINTER_CROSS
);
177 pView
->SetCurrentObj( sal::static_int_cast
<UINT16
>( aObjKind
) );
179 aOldPointer
= pWindow
->GetPointer();
180 pViewShell
->SetActivePointer( aNewPointer
);
185 /*************************************************************************
187 |* Function deaktivieren
189 \************************************************************************/
191 void FuConstArc::Deactivate()
193 FuDraw::Deactivate();
194 pViewShell
->SetActivePointer( aOldPointer
);
197 // #98185# Create default drawing objects via keyboard
198 SdrObject
* FuConstArc::CreateDefaultObject(const sal_uInt16 nID
, const Rectangle
& rRectangle
)
200 // case SID_DRAW_ARC:
201 // case SID_DRAW_PIE:
202 // case SID_DRAW_CIRCLECUT:
204 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
205 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
210 if(pObj
->ISA(SdrCircObj
))
212 Rectangle
aRect(rRectangle
);
214 if(SID_DRAW_ARC
== nID
|| SID_DRAW_CIRCLECUT
== nID
)
217 ImpForceQuadratic(aRect
);
220 pObj
->SetLogicRect(aRect
);
222 SfxItemSet
aAttr(pDrDoc
->GetItemPool());
223 aAttr
.Put(SdrCircStartAngleItem(9000));
224 aAttr
.Put(SdrCircEndAngleItem(0));
226 pObj
->SetMergedItemSet(aAttr
);
230 DBG_ERROR("Object is NO circle object");