merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / drawfunc / fuconarc.cxx
blob6a89efd31884a72f51fd3a4597244e799c6f8f29
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: 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"
35 #include "sc.hrc"
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 /*************************************************************************
45 |* Konstruktor
47 \************************************************************************/
49 FuConstArc::FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
50 SdrModel* pDoc, SfxRequest& rReq )
51 : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq )
55 /*************************************************************************
57 |* Destruktor
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 );
83 bReturn = TRUE;
85 return bReturn;
88 /*************************************************************************
90 |* MouseMove-event
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 );
116 bReturn = TRUE;
119 else if ( pView->IsCreateObj() && rMEvt.IsRight() )
121 // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
122 pView->EndCreateObj( SDRCREATE_FORCEEND );
123 bReturn = TRUE;
126 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
129 /*************************************************************************
131 |* Tastaturereignisse bearbeiten
133 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
134 |* FALSE.
136 \************************************************************************/
138 BOOL __EXPORT FuConstArc::KeyInput(const KeyEvent& rKEvt)
140 BOOL bReturn = FuConstruct::KeyInput(rKEvt);
141 return(bReturn);
144 /*************************************************************************
146 |* Function aktivieren
148 \************************************************************************/
150 void FuConstArc::Activate()
152 SdrObjKind aObjKind;
154 switch (aSfxRequest.GetSlot() )
156 case SID_DRAW_ARC:
157 aNewPointer = Pointer( POINTER_DRAW_ARC );
158 aObjKind = OBJ_CARC;
159 break;
161 case SID_DRAW_PIE:
162 aNewPointer = Pointer( POINTER_DRAW_PIE );
163 aObjKind = OBJ_SECT;
164 break;
166 case SID_DRAW_CIRCLECUT:
167 aNewPointer = Pointer( POINTER_DRAW_CIRCLECUT );
168 aObjKind = OBJ_CCUT;
169 break;
171 default:
172 aNewPointer = Pointer( POINTER_CROSS );
173 aObjKind = OBJ_CARC;
174 break;
177 pView->SetCurrentObj( sal::static_int_cast<UINT16>( aObjKind ) );
179 aOldPointer = pWindow->GetPointer();
180 pViewShell->SetActivePointer( aNewPointer );
182 FuDraw::Activate();
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(),
206 0L, pDrDoc);
208 if(pObj)
210 if(pObj->ISA(SdrCircObj))
212 Rectangle aRect(rRectangle);
214 if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
216 // force quadratic
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);
228 else
230 DBG_ERROR("Object is NO circle object");
234 return pObj;