LibreOffice Module sc (master)  1
fuconarc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <fuconarc.hxx>
21 #include <tabvwsh.hxx>
22 #include <drawview.hxx>
23 
24 // Create default drawing objects via keyboard
25 #include <svx/svdocirc.hxx>
26 #include <svx/svxids.hrc>
27 #include <svx/sxciaitm.hxx>
28 
30  SdrModel* pDoc, const SfxRequest& rReq)
31  : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
32 {
33 }
34 
36 {
37 }
38 
40 {
41  // remember button state for creation of own MouseEvents
43 
44  bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
45 
46  if ( rMEvt.IsLeft() && !pView->IsAction() )
47  {
48  Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
50  pView->BegCreateObj( aPnt );
51  bReturn = true;
52  }
53  return bReturn;
54 }
55 
57 {
58  // remember button state for creation of own MouseEvents
60 
61  bool bReturn = false;
62 
63  if ( pView->IsCreateObj() && rMEvt.IsLeft() )
64  {
65  pView->EndCreateObj( SdrCreateCmd::NextPoint );
66  bReturn = true;
67  }
68  return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
69 }
70 
72 {
73  SdrObjKind aObjKind;
74 
75  switch (aSfxRequest.GetSlot() )
76  {
77  case SID_DRAW_ARC:
78  aNewPointer = PointerStyle::DrawArc;
79  aObjKind = OBJ_CARC;
80  break;
81 
82  case SID_DRAW_PIE:
83  aNewPointer = PointerStyle::DrawPie;
84  aObjKind = OBJ_SECT;
85  break;
86 
87  case SID_DRAW_CIRCLECUT:
88  aNewPointer = PointerStyle::DrawCircleCut;
89  aObjKind = OBJ_CCUT;
90  break;
91 
92  default:
93  aNewPointer = PointerStyle::Cross;
94  aObjKind = OBJ_CARC;
95  break;
96  }
97 
98  pView->SetCurrentObj( sal::static_int_cast<sal_uInt16>( aObjKind ) );
99 
102 
104 }
105 
107 {
110 }
111 
112 // Create default drawing objects via keyboard
114 {
115  // case SID_DRAW_ARC:
116  // case SID_DRAW_PIE:
117  // case SID_DRAW_CIRCLECUT:
118 
120  *pDrDoc,
123 
124  if(pObj)
125  {
126  if(dynamic_cast<const SdrCircObj*>( pObj.get() ) != nullptr)
127  {
128  tools::Rectangle aRect(rRectangle);
129 
130  if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
131  {
132  // force quadratic
133  ImpForceQuadratic(aRect);
134  }
135 
136  pObj->SetLogicRect(aRect);
137 
138  SfxItemSet aAttr(pDrDoc->GetItemPool());
139  aAttr.Put(makeSdrCircStartAngleItem(9000));
140  aAttr.Put(makeSdrCircEndAngleItem(0));
141 
142  pObj->SetMergedItemSet(aAttr);
143  }
144  else
145  {
146  OSL_FAIL("Object is NO circle object");
147  }
148  }
149 
150  return pObj;
151 }
152 
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CaptureMouse()
bool EndCreateObj(SdrCreateCmd eCmd)
PointerStyle aOldPointer
Definition: fudraw.hxx:32
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
FuConstArc(ScTabViewShell &rViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, const SfxRequest &rReq)
Definition: fuconarc.cxx:29
SdrModel * pDrDoc
Definition: fupoor.hxx:46
Draw rectangle.
Definition: fuconstr.hxx:26
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
sal_uInt16 GetButtons() const
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:71
sal_uInt16 GetCurrentObjIdentifier() const
SdrAngleItem makeSdrCircEndAngleItem(long nAngle)
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:39
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, sal_uInt16 nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
ScTabViewShell & rViewShell
Definition: fupoor.hxx:44
OBJ_SECT
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:46
PointerStyle GetPointer() const
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:891
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:56
SfxRequest aSfxRequest
Definition: fupoor.hxx:48
SdrAngleItem makeSdrCircStartAngleItem(long nAngle)
bool IsCreateObj() const
Point PixelToLogic(const Point &rDevicePt) const
virtual bool IsAction() const override
OBJ_CARC
sal_uInt16 GetSlot() const
virtual ~FuConstArc() override
Definition: fuconarc.cxx:35
OBJ_CCUT
SdrObjKind
void SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent=SdrInventor::Default)
bool IsLeft() const
ScDrawView * pView
Definition: fupoor.hxx:43
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
const Point & GetPosPixel() const
PointerStyle aNewPointer
Definition: fudraw.hxx:31
static void ImpForceQuadratic(tools::Rectangle &rRect)
Definition: fupoor.cxx:223
const SfxItemPool & GetItemPool() const
virtual void Activate() override
Definition: fuconarc.cxx:71
virtual void Activate()
Definition: fupoor.cxx:59
VclPtr< vcl::Window > pWindow
Definition: fupoor.hxx:45
SdrInventor GetCurrentObjInventor() const
virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle &rRectangle) override
Definition: fuconarc.cxx:113
virtual void Deactivate() override
Definition: fuconarc.cxx:106
virtual void Deactivate()
Definition: fupoor.cxx:63