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>
21 #include <tabvwsh.hxx>
22 #include <drawview.hxx>
24 // Create default drawing objects via keyboard
25 #include <svx/svdocirc.hxx>
26 #include <svx/svxids.hrc>
27 #include <svx/sxciaitm.hxx>
28 #include <osl/diagnose.h>
30 FuConstArc::FuConstArc(ScTabViewShell
& rViewSh
, vcl::Window
* pWin
, ScDrawView
* pViewP
,
31 SdrModel
* pDoc
, const SfxRequest
& rReq
)
32 : FuConstruct(rViewSh
, pWin
, pViewP
, pDoc
, rReq
)
36 FuConstArc::~FuConstArc()
40 bool FuConstArc::MouseButtonDown( const MouseEvent
& rMEvt
)
42 // remember button state for creation of own MouseEvents
43 SetMouseButtonCode(rMEvt
.GetButtons());
45 bool bReturn
= FuConstruct::MouseButtonDown( rMEvt
);
47 if ( rMEvt
.IsLeft() && !pView
->IsAction() )
49 Point
aPnt( pWindow
->PixelToLogic( rMEvt
.GetPosPixel() ) );
50 pWindow
->CaptureMouse();
51 pView
->BegCreateObj( aPnt
);
57 bool FuConstArc::MouseButtonUp( const MouseEvent
& rMEvt
)
59 // remember button state for creation of own MouseEvents
60 SetMouseButtonCode(rMEvt
.GetButtons());
64 if ( pView
->IsCreateObj() && rMEvt
.IsLeft() )
66 pView
->EndCreateObj( SdrCreateCmd::NextPoint
);
69 return (FuConstruct::MouseButtonUp(rMEvt
) || bReturn
);
72 void FuConstArc::Activate()
76 switch (aSfxRequest
.GetSlot() )
79 aNewPointer
= PointerStyle::DrawArc
;
80 aObjKind
= SdrObjKind::CircleArc
;
84 aNewPointer
= PointerStyle::DrawPie
;
85 aObjKind
= SdrObjKind::CircleSection
;
88 case SID_DRAW_CIRCLECUT
:
89 aNewPointer
= PointerStyle::DrawCircleCut
;
90 aObjKind
= SdrObjKind::CircleCut
;
94 aNewPointer
= PointerStyle::Cross
;
95 aObjKind
= SdrObjKind::CircleArc
;
99 pView
->SetCurrentObj(aObjKind
);
101 aOldPointer
= pWindow
->GetPointer();
102 rViewShell
.SetActivePointer( aNewPointer
);
107 void FuConstArc::Deactivate()
109 FuDraw::Deactivate();
110 rViewShell
.SetActivePointer( aOldPointer
);
113 // Create default drawing objects via keyboard
114 rtl::Reference
<SdrObject
> FuConstArc::CreateDefaultObject(const sal_uInt16 nID
, const tools::Rectangle
& rRectangle
)
116 // case SID_DRAW_ARC:
117 // case SID_DRAW_PIE:
118 // case SID_DRAW_CIRCLECUT:
120 rtl::Reference
<SdrObject
> pObj(SdrObjFactory::MakeNewObject(
122 pView
->GetCurrentObjInventor(),
123 pView
->GetCurrentObjIdentifier()));
127 if(dynamic_cast<const SdrCircObj
*>( pObj
.get() ) != nullptr)
129 tools::Rectangle
aRect(rRectangle
);
131 if(SID_DRAW_ARC
== nID
|| SID_DRAW_CIRCLECUT
== nID
)
134 ImpForceQuadratic(aRect
);
137 pObj
->SetLogicRect(aRect
);
139 SfxItemSet
aAttr(pDrDoc
->GetItemPool());
140 aAttr
.Put(makeSdrCircStartAngleItem(9000_deg100
));
141 aAttr
.Put(makeSdrCircEndAngleItem(0_deg100
));
143 pObj
->SetMergedItemSet(aAttr
);
147 OSL_FAIL("Object is NO circle object");
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */