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 #include <osl/diagnose.h>
29 
31  SdrModel* pDoc, const SfxRequest& rReq)
32  : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
33 {
34 }
35 
37 {
38 }
39 
41 {
42  // remember button state for creation of own MouseEvents
44 
45  bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
46 
47  if ( rMEvt.IsLeft() && !pView->IsAction() )
48  {
49  Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
51  pView->BegCreateObj( aPnt );
52  bReturn = true;
53  }
54  return bReturn;
55 }
56 
58 {
59  // remember button state for creation of own MouseEvents
61 
62  bool bReturn = false;
63 
64  if ( pView->IsCreateObj() && rMEvt.IsLeft() )
65  {
66  pView->EndCreateObj( SdrCreateCmd::NextPoint );
67  bReturn = true;
68  }
69  return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
70 }
71 
73 {
74  SdrObjKind aObjKind;
75 
76  switch (aSfxRequest.GetSlot() )
77  {
78  case SID_DRAW_ARC:
79  aNewPointer = PointerStyle::DrawArc;
80  aObjKind = OBJ_CARC;
81  break;
82 
83  case SID_DRAW_PIE:
84  aNewPointer = PointerStyle::DrawPie;
85  aObjKind = OBJ_SECT;
86  break;
87 
88  case SID_DRAW_CIRCLECUT:
89  aNewPointer = PointerStyle::DrawCircleCut;
90  aObjKind = OBJ_CCUT;
91  break;
92 
93  default:
94  aNewPointer = PointerStyle::Cross;
95  aObjKind = OBJ_CARC;
96  break;
97  }
98 
99  pView->SetCurrentObj(aObjKind);
100 
103 
105 }
106 
108 {
111 }
112 
113 // Create default drawing objects via keyboard
115 {
116  // case SID_DRAW_ARC:
117  // case SID_DRAW_PIE:
118  // case SID_DRAW_CIRCLECUT:
119 
121  *pDrDoc,
124 
125  if(pObj)
126  {
127  if(dynamic_cast<const SdrCircObj*>( pObj.get() ) != nullptr)
128  {
129  tools::Rectangle aRect(rRectangle);
130 
131  if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
132  {
133  // force quadratic
134  ImpForceQuadratic(aRect);
135  }
136 
137  pObj->SetLogicRect(aRect);
138 
139  SfxItemSet aAttr(pDrDoc->GetItemPool());
140  aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
141  aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
142 
143  pObj->SetMergedItemSet(aAttr);
144  }
145  else
146  {
147  OSL_FAIL("Object is NO circle object");
148  }
149  }
150 
151  return pObj;
152 }
153 
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CaptureMouse()
bool EndCreateObj(SdrCreateCmd eCmd)
PointerStyle aOldPointer
Definition: fudraw.hxx:31
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:30
static SdrObject * MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
OBJ_CARC
SdrModel * pDrDoc
Definition: fupoor.hxx:45
Draw rectangle.
Definition: fuconstr.hxx:27
SdrObjKind
OBJ_SECT
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
sal_uInt16 GetButtons() const
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:70
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:40
ScTabViewShell & rViewShell
Definition: fupoor.hxx:43
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:46
PointerStyle GetPointer() const
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:894
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:57
SfxRequest aSfxRequest
Definition: fupoor.hxx:47
Point PixelToLogic(const Point &rDevicePt) const
SdrAngleItem makeSdrCircStartAngleItem(Degree100 nAngle)
bool IsCreateObj() const
virtual bool IsAction() const override
sal_uInt16 GetSlot() const
virtual ~FuConstArc() override
Definition: fuconarc.cxx:36
bool IsLeft() const
ScDrawView * pView
Definition: fupoor.hxx:42
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
const Point & GetPosPixel() const
PointerStyle aNewPointer
Definition: fudraw.hxx:30
static void ImpForceQuadratic(tools::Rectangle &rRect)
Definition: fupoor.cxx:223
const SfxItemPool & GetItemPool() const
SdrObjKind GetCurrentObjIdentifier() const
SdrAngleItem makeSdrCircEndAngleItem(Degree100 nAngle)
OBJ_CCUT
virtual void Activate() override
Definition: fuconarc.cxx:72
virtual void Activate()
Definition: fupoor.cxx:59
VclPtr< vcl::Window > pWindow
Definition: fupoor.hxx:44
SdrInventor GetCurrentObjInventor() const
virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle &rRectangle) override
Definition: fuconarc.cxx:114
virtual void Deactivate() override
Definition: fuconarc.cxx:107
virtual void Deactivate()
Definition: fupoor.cxx:63