1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "fuconarc.hxx"
23 #include "tabvwsh.hxx"
24 #include "drawview.hxx"
26 // Create default drawing objects via keyboard
27 #include <svx/svdocirc.hxx>
28 #include <svx/sxciaitm.hxx>
30 /*************************************************************************
34 \************************************************************************/
36 FuConstArc::FuConstArc( ScTabViewShell
* pViewSh
, Window
* pWin
, ScDrawView
* pViewP
,
37 SdrModel
* pDoc
, SfxRequest
& rReq
)
38 : FuConstruct( pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
42 /*************************************************************************
46 \************************************************************************/
48 FuConstArc::~FuConstArc()
52 /*************************************************************************
54 |* MouseButtonDown-event
56 \************************************************************************/
58 sal_Bool
FuConstArc::MouseButtonDown( const MouseEvent
& rMEvt
)
60 // remember button state for creation of own MouseEvents
61 SetMouseButtonCode(rMEvt
.GetButtons());
63 sal_Bool bReturn
= FuConstruct::MouseButtonDown( rMEvt
);
65 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
67 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
68 // Hack to align object to nearest grid position where object
69 // would be anchored ( if it were cell anchored )
70 // Get grid offset for current position ( note: aPnt is
72 Point aGridOff
= CurrentGridSyncOffsetAndPos( aPnt
);
73 pWindow
->CaptureMouse();
74 pView
->BegCreateObj( aPnt
);
75 pView
->GetCreateObj()->SetGridOffset( aGridOff
);
81 /*************************************************************************
85 \************************************************************************/
87 sal_Bool
FuConstArc::MouseMove( const MouseEvent
& rMEvt
)
89 return FuConstruct::MouseMove(rMEvt
);
92 /*************************************************************************
94 |* MouseButtonUp-event
96 \************************************************************************/
98 sal_Bool
FuConstArc::MouseButtonUp( const MouseEvent
& rMEvt
)
100 // remember button state for creation of own MouseEvents
101 SetMouseButtonCode(rMEvt
.GetButtons());
103 sal_Bool bReturn
= false;
105 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
107 pView
->EndCreateObj( SDRCREATE_NEXTPOINT
);
110 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
113 /*************************************************************************
115 |* Tastaturereignisse bearbeiten
117 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
120 \************************************************************************/
122 sal_Bool
FuConstArc::KeyInput(const KeyEvent
& rKEvt
)
124 sal_Bool bReturn
= FuConstruct::KeyInput(rKEvt
);
128 /*************************************************************************
130 |* Function aktivieren
132 \************************************************************************/
134 void FuConstArc::Activate()
138 switch (aSfxRequest
.GetSlot() )
141 aNewPointer
= Pointer( POINTER_DRAW_ARC
);
146 aNewPointer
= Pointer( POINTER_DRAW_PIE
);
150 case SID_DRAW_CIRCLECUT
:
151 aNewPointer
= Pointer( POINTER_DRAW_CIRCLECUT
);
156 aNewPointer
= Pointer( POINTER_CROSS
);
161 pView
->SetCurrentObj( sal::static_int_cast
<sal_uInt16
>( aObjKind
) );
163 aOldPointer
= pWindow
->GetPointer();
164 pViewShell
->SetActivePointer( aNewPointer
);
169 /*************************************************************************
171 |* Function deaktivieren
173 \************************************************************************/
175 void FuConstArc::Deactivate()
177 FuDraw::Deactivate();
178 pViewShell
->SetActivePointer( aOldPointer
);
181 // Create default drawing objects via keyboard
182 SdrObject
* FuConstArc::CreateDefaultObject(const sal_uInt16 nID
, const Rectangle
& rRectangle
)
184 // case SID_DRAW_ARC:
185 // case SID_DRAW_PIE:
186 // case SID_DRAW_CIRCLECUT:
188 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
189 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
194 if(pObj
->ISA(SdrCircObj
))
196 Rectangle
aRect(rRectangle
);
198 if(SID_DRAW_ARC
== nID
|| SID_DRAW_CIRCLECUT
== nID
)
201 ImpForceQuadratic(aRect
);
204 pObj
->SetLogicRect(aRect
);
206 SfxItemSet
aAttr(pDrDoc
->GetItemPool());
207 aAttr
.Put(SdrCircStartAngleItem(9000));
208 aAttr
.Put(SdrCircEndAngleItem(0));
210 pObj
->SetMergedItemSet(aAttr
);
214 OSL_FAIL("Object is NO circle object");
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */