nss: upgrade to release 3.73
[LibreOffice.git] / sc / source / ui / drawfunc / fuconarc.cxx
blob368a1fd68c06ae1decc20e44ec90d2bfb09c1bf9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 FuConstArc::FuConstArc(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP,
30 SdrModel* pDoc, const SfxRequest& rReq)
31 : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
35 FuConstArc::~FuConstArc()
39 bool FuConstArc::MouseButtonDown( const MouseEvent& rMEvt )
41 // remember button state for creation of own MouseEvents
42 SetMouseButtonCode(rMEvt.GetButtons());
44 bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
46 if ( rMEvt.IsLeft() && !pView->IsAction() )
48 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
49 pWindow->CaptureMouse();
50 pView->BegCreateObj( aPnt );
51 bReturn = true;
53 return bReturn;
56 bool FuConstArc::MouseButtonUp( const MouseEvent& rMEvt )
58 // remember button state for creation of own MouseEvents
59 SetMouseButtonCode(rMEvt.GetButtons());
61 bool bReturn = false;
63 if ( pView->IsCreateObj() && rMEvt.IsLeft() )
65 pView->EndCreateObj( SdrCreateCmd::NextPoint );
66 bReturn = true;
68 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
71 void FuConstArc::Activate()
73 SdrObjKind aObjKind;
75 switch (aSfxRequest.GetSlot() )
77 case SID_DRAW_ARC:
78 aNewPointer = PointerStyle::DrawArc;
79 aObjKind = OBJ_CARC;
80 break;
82 case SID_DRAW_PIE:
83 aNewPointer = PointerStyle::DrawPie;
84 aObjKind = OBJ_SECT;
85 break;
87 case SID_DRAW_CIRCLECUT:
88 aNewPointer = PointerStyle::DrawCircleCut;
89 aObjKind = OBJ_CCUT;
90 break;
92 default:
93 aNewPointer = PointerStyle::Cross;
94 aObjKind = OBJ_CARC;
95 break;
98 pView->SetCurrentObj(aObjKind);
100 aOldPointer = pWindow->GetPointer();
101 rViewShell.SetActivePointer( aNewPointer );
103 FuDraw::Activate();
106 void FuConstArc::Deactivate()
108 FuDraw::Deactivate();
109 rViewShell.SetActivePointer( aOldPointer );
112 // Create default drawing objects via keyboard
113 SdrObjectUniquePtr FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
115 // case SID_DRAW_ARC:
116 // case SID_DRAW_PIE:
117 // case SID_DRAW_CIRCLECUT:
119 SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
120 *pDrDoc,
121 pView->GetCurrentObjInventor(),
122 pView->GetCurrentObjIdentifier()));
124 if(pObj)
126 if(dynamic_cast<const SdrCircObj*>( pObj.get() ) != nullptr)
128 tools::Rectangle aRect(rRectangle);
130 if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
132 // force quadratic
133 ImpForceQuadratic(aRect);
136 pObj->SetLogicRect(aRect);
138 SfxItemSet aAttr(pDrDoc->GetItemPool());
139 aAttr.Put(makeSdrCircStartAngleItem(9000));
140 aAttr.Put(makeSdrCircEndAngleItem(0));
142 pObj->SetMergedItemSet(aAttr);
144 else
146 OSL_FAIL("Object is NO circle object");
150 return pObj;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */