LibreOffice Module sd (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 <svx/svdpagv.hxx>
22#include <svx/svdocirc.hxx>
23#include <sfx2/request.hxx>
24#include <svl/intitem.hxx>
25#include <sfx2/dispatch.hxx>
26#include <svx/svdobj.hxx>
27#include <sfx2/viewfrm.hxx>
28#include <osl/diagnose.h>
29
30#include <svx/svxids.hrc>
31
32#include <Window.hxx>
33#include <drawdoc.hxx>
34
35#include <View.hxx>
36#include <ViewShell.hxx>
37#include <ViewShellBase.hxx>
38#include <ToolBarManager.hxx>
39
40#include <svx/sxciaitm.hxx>
41#include <svx/xfillit0.hxx>
42
43using namespace com::sun::star;
44
45namespace sd {
46
47
49 ViewShell* pViewSh,
50 ::sd::Window* pWin,
51 ::sd::View* pView,
52 SdDrawDocument* pDoc,
53 SfxRequest& rReq )
54 : FuConstruct( pViewSh, pWin, pView, pDoc, rReq )
55{
56}
57
59{
60 FuConstructArc* pFunc;
61 rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( pViewSh, pWin, pView, pDoc, rReq ) );
62 xFunc->DoExecute(rReq);
64 return xFunc;
65}
66
68{
70
74
75 const SfxItemSet *pArgs = rReq.GetArgs ();
76
77 if (!pArgs)
78 return;
79
80 const SfxUInt32Item* pCenterX = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_X);
81 const SfxUInt32Item* pCenterY = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_Y);
82 const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X);
83 const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y);
84 const SfxUInt32Item* pPhiStart = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLESTART);
85 const SfxUInt32Item* pPhiEnd = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLEEND);
86
87 ::tools::Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
88 pCenterY->GetValue () - pAxisY->GetValue () / 2,
89 pCenterX->GetValue () + pAxisX->GetValue () / 2,
90 pCenterY->GetValue () + pAxisY->GetValue () / 2);
91
92 Activate(); // sets aObjKind
94 new SdrCircObj(
97 aNewRectangle,
98 Degree100(pPhiStart->GetValue() * 10),
99 Degree100(pPhiEnd->GetValue() * 10));
101
102 mpView->InsertObjectAtView(pNewCircle.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
103}
104
106{
107 bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
108
109 if ( rMEvt.IsLeft() && !mpView->IsAction() )
110 {
111 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
112 mpWindow->CaptureMouse();
113 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
114 mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
115
116 SdrObject* pObj = mpView->GetCreateObj();
117
118 if (pObj)
119 {
120 SfxItemSet aAttr(mpDoc->GetPool());
121 SetStyleSheet(aAttr, pObj);
122
123 pObj->SetMergedItemSet(aAttr);
124 }
125
126 bReturn = true;
127 }
128 return bReturn;
129}
130
132{
134 return false;
135
136 bool bReturn = false;
137 bool bCreated = false;
138
139 if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
140 {
141 const size_t nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount();
142
143 if (mpView->EndCreateObj(SdrCreateCmd::NextPoint) )
144 {
146 {
147 bCreated = true;
148 }
149 }
150
151 bReturn = true;
152 }
153
154 bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
155
156 if (!bPermanent && bCreated)
157 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
158
159 return bReturn;
160}
161
163{
164 SdrObjKind aObjKind;
165
166 switch( nSlotId )
167 {
168 case SID_DRAW_ARC :
169 case SID_DRAW_CIRCLEARC:
170 {
171 aObjKind = SdrObjKind::CircleArc;
172 }
173 break;
174
175 case SID_DRAW_PIE :
176 case SID_DRAW_PIE_NOFILL :
177 case SID_DRAW_CIRCLEPIE :
178 case SID_DRAW_CIRCLEPIE_NOFILL:
179 {
180 aObjKind = SdrObjKind::CircleSection;
181 }
182 break;
183
184 case SID_DRAW_ELLIPSECUT :
185 case SID_DRAW_ELLIPSECUT_NOFILL:
186 case SID_DRAW_CIRCLECUT :
187 case SID_DRAW_CIRCLECUT_NOFILL :
188 {
189 aObjKind = SdrObjKind::CircleCut;
190 }
191 break;
192
193 default:
194 {
195 aObjKind = SdrObjKind::CircleArc;
196 }
197 break;
198 }
199
200 mpView->SetCurrentObj(aObjKind);
201
203}
204
205rtl::Reference<SdrObject> FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
206{
207
212
213 if(pObj)
214 {
215 if( dynamic_cast< const SdrCircObj *>( pObj.get() ) != nullptr)
216 {
217 ::tools::Rectangle aRect(rRectangle);
218
219 if(SID_DRAW_ARC == nID ||
220 SID_DRAW_CIRCLEARC == nID ||
221 SID_DRAW_CIRCLEPIE == nID ||
222 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
223 SID_DRAW_CIRCLECUT == nID ||
224 SID_DRAW_CIRCLECUT_NOFILL == nID)
225 {
226 // force quadratic
227 ImpForceQuadratic(aRect);
228 }
229
230 pObj->SetLogicRect(aRect);
231
232 SfxItemSet aAttr(mpDoc->GetPool());
233 aAttr.Put(makeSdrCircStartAngleItem(9000_deg100));
234 aAttr.Put(makeSdrCircEndAngleItem(0_deg100));
235
236 if(SID_DRAW_PIE_NOFILL == nID ||
237 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
238 SID_DRAW_ELLIPSECUT_NOFILL == nID ||
239 SID_DRAW_CIRCLECUT_NOFILL == nID)
240 {
241 aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
242 }
243
244 pObj->SetMergedItemSet(aAttr);
245 }
246 else
247 {
248 OSL_FAIL("Object is NO circle object");
249 }
250 }
251
252 return pObj;
253}
254
255} // end of namespace sd
256
257/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 GetValue() const
const Point & GetPosPixel() const
bool IsLeft() const
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
bool IsCreateObj() const
bool EndCreateObj(SdrCreateCmd eCmd)
SdrInventor GetCurrentObjInventor() const
SdrObjKind GetCurrentObjIdentifier() const
virtual bool IsAction() const override
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
SdrObject * GetCreateObj() const
sal_Int32 GetDragThresholdPixels() const
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
static rtl::Reference< SdrObject > MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
size_t GetObjCount() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrObjList * GetObjList() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
SfxDispatcher * GetDispatcher()
virtual void Activate() override
activates the function
Definition: fuconarc.cxx:162
virtual void DoExecute(SfxRequest &rReq) override
Definition: fuconarc.cxx:67
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:131
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq, bool bPermanent)
Definition: fuconarc.cxx:58
FuConstructArc(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuconarc.cxx:48
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconarc.cxx:105
virtual rtl::Reference< SdrObject > CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle &rRectangle) override
Definition: fuconarc.cxx:205
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:64
virtual void Activate() override
activates the function
Definition: fuconstr.cxx:221
void SetStyleSheet(SfxItemSet &rAttr, SdrObject *pObj)
set style sheet for the object to be created
Definition: fuconstr.cxx:249
bool IsIgnoreUnexpectedMouseButtonUp()
Definition: fuconstr.cxx:233
bool bPermanent
Definition: fudraw.hxx:76
void SetPermanent(bool bSet)
Definition: fudraw.hxx:52
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
static void ImpForceQuadratic(::tools::Rectangle &rRect)
Definition: fupoor.cxx:1018
ViewShell * mpViewShell
Definition: fupoor.hxx:145
sal_uInt16 nSlotId
Definition: fupoor.hxx:150
::sd::View * mpView
Definition: fupoor.hxx:144
virtual void DoExecute(SfxRequest &rReq)
Definition: fupoor.cxx:1129
static constexpr OUStringLiteral msDrawingObjectToolBar
std::shared_ptr< ToolBarManager > const & GetToolBarManager() const
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
int nCount
SdrObjKind
SVXCORE_DLLPUBLIC SdrCircKind ToSdrCircKind(SdrObjKind)
SdrAngleItem makeSdrCircStartAngleItem(Degree100 nAngle)
SdrAngleItem makeSdrCircEndAngleItem(Degree100 nAngle)