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 .
20 #include "fuconarc.hxx"
22 #include "tabvwsh.hxx"
23 #include "drawview.hxx"
25 // Create default drawing objects via keyboard
26 #include <svx/svdocirc.hxx>
27 #include <svx/sxciaitm.hxx>
29 /*************************************************************************
33 \************************************************************************/
35 FuConstArc::FuConstArc( ScTabViewShell
* pViewSh
, vcl::Window
* pWin
, ScDrawView
* pViewP
,
36 SdrModel
* pDoc
, SfxRequest
& rReq
)
37 : FuConstruct( pViewSh
, pWin
, pViewP
, pDoc
, rReq
)
41 /*************************************************************************
45 \************************************************************************/
47 FuConstArc::~FuConstArc()
51 /*************************************************************************
53 |* MouseButtonDown-event
55 \************************************************************************/
57 bool FuConstArc::MouseButtonDown( const MouseEvent
& rMEvt
)
59 // remember button state for creation of own MouseEvents
60 SetMouseButtonCode(rMEvt
.GetButtons());
62 bool bReturn
= FuConstruct::MouseButtonDown( rMEvt
);
64 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
66 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
67 // Hack to align object to nearest grid position where object
68 // would be anchored ( if it were cell anchored )
69 // Get grid offset for current position ( note: aPnt is
71 Point aGridOff
= CurrentGridSyncOffsetAndPos( aPnt
);
72 pWindow
->CaptureMouse();
73 pView
->BegCreateObj( aPnt
);
74 pView
->GetCreateObj()->SetGridOffset( aGridOff
);
80 /*************************************************************************
84 \************************************************************************/
86 bool FuConstArc::MouseMove( const MouseEvent
& rMEvt
)
88 return FuConstruct::MouseMove(rMEvt
);
91 /*************************************************************************
93 |* MouseButtonUp-event
95 \************************************************************************/
97 bool FuConstArc::MouseButtonUp( const MouseEvent
& rMEvt
)
99 // remember button state for creation of own MouseEvents
100 SetMouseButtonCode(rMEvt
.GetButtons());
102 bool bReturn
= false;
104 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
106 pView
->EndCreateObj( SDRCREATE_NEXTPOINT
);
109 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
112 /*************************************************************************
114 |* Tastaturereignisse bearbeiten
116 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
119 \************************************************************************/
121 bool FuConstArc::KeyInput(const KeyEvent
& rKEvt
)
123 return FuConstruct::KeyInput(rKEvt
);
126 /*************************************************************************
128 |* Function aktivieren
130 \************************************************************************/
132 void FuConstArc::Activate()
136 switch (aSfxRequest
.GetSlot() )
139 aNewPointer
= Pointer( PointerStyle::DrawArc
);
144 aNewPointer
= Pointer( PointerStyle::DrawPie
);
148 case SID_DRAW_CIRCLECUT
:
149 aNewPointer
= Pointer( PointerStyle::DrawCircleCut
);
154 aNewPointer
= Pointer( PointerStyle::Cross
);
159 pView
->SetCurrentObj( sal::static_int_cast
<sal_uInt16
>( aObjKind
) );
161 aOldPointer
= pWindow
->GetPointer();
162 pViewShell
->SetActivePointer( aNewPointer
);
167 /*************************************************************************
169 |* Function deaktivieren
171 \************************************************************************/
173 void FuConstArc::Deactivate()
175 FuDraw::Deactivate();
176 pViewShell
->SetActivePointer( aOldPointer
);
179 // Create default drawing objects via keyboard
180 SdrObject
* FuConstArc::CreateDefaultObject(const sal_uInt16 nID
, const Rectangle
& rRectangle
)
182 // case SID_DRAW_ARC:
183 // case SID_DRAW_PIE:
184 // case SID_DRAW_CIRCLECUT:
186 SdrObject
* pObj
= SdrObjFactory::MakeNewObject(
187 pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(),
192 if(pObj
->ISA(SdrCircObj
))
194 Rectangle
aRect(rRectangle
);
196 if(SID_DRAW_ARC
== nID
|| SID_DRAW_CIRCLECUT
== nID
)
199 ImpForceQuadratic(aRect
);
202 pObj
->SetLogicRect(aRect
);
204 SfxItemSet
aAttr(pDrDoc
->GetItemPool());
205 aAttr
.Put(makeSdrCircStartAngleItem(9000));
206 aAttr
.Put(makeSdrCircEndAngleItem(0));
208 pObj
->SetMergedItemSet(aAttr
);
212 OSL_FAIL("Object is NO circle object");
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */