LibreOffice Module sd (master) 1
drbezob.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 <BezierObjectBar.hxx>
21#include <sfx2/msg.hxx>
22#include <sfx2/viewfrm.hxx>
23#include <sfx2/objface.hxx>
24
25#include <svx/svxids.hrc>
26#include <svl/eitem.hxx>
27#include <sfx2/request.hxx>
28#include <svx/svdopath.hxx>
29#include <svx/svdundo.hxx>
30#include <sfx2/dispatch.hxx>
31
32#include <sdresid.hxx>
33
34
35#include <strings.hrc>
36
37#include <DrawDocShell.hxx>
38#include <ViewShell.hxx>
39#include <drawdoc.hxx>
40#include <fusel.hxx>
41#include <fuconbez.hxx>
42
43using namespace sd;
44#define ShellClass_BezierObjectBar
45#include <sdslots.hxx>
46
47namespace sd {
48
53
54void BezierObjectBar::InitInterface_Impl()
55{
56}
57
58
60 ViewShell* pSdViewShell,
61 ::sd::View* pSdView)
62 : SfxShell(pSdViewShell->GetViewShell()),
63 mpView(pSdView),
64 mpViewSh(pSdViewShell)
65{
66 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
67 SetPool(&pDocShell->GetPool());
68 SetUndoManager(pDocShell->GetUndoManager());
70}
71
73{
74 SetRepeatTarget(nullptr);
75}
76
82{
83 SfxItemSet aAttrSet( mpView->GetDoc().GetPool() );
84 mpView->GetAttributes( aAttrSet );
85 rSet.Put(aAttrSet, false); // <- sal_False, so DontCare-Status gets acquired
86
88
89 if(xFunc.is())
90 {
91 if( auto pFuSelection = dynamic_cast< const FuSelection *>( xFunc.get() ))
92 {
93 sal_uInt16 nEditMode = pFuSelection->GetEditMode();
94 rSet.Put(SfxBoolItem(nEditMode, true));
95 }
96 else if( auto pFuPolygon = dynamic_cast< const FuConstructBezierPolygon *>( xFunc.get() ))
97 {
98 sal_uInt16 nEditMode = pFuPolygon->GetEditMode();
99 rSet.Put(SfxBoolItem(nEditMode, true));
100 }
101 }
102
104 {
105 // #i77187# if object is move and/or size protected, do not allow point editing at all
106 rSet.DisableItem(SID_BEZIER_MOVE);
107 rSet.DisableItem(SID_BEZIER_INSERT);
108
109 rSet.DisableItem(SID_BEZIER_DELETE);
110 rSet.DisableItem(SID_BEZIER_CUTLINE);
111 rSet.DisableItem(SID_BEZIER_CONVERT);
112
113 rSet.DisableItem(SID_BEZIER_EDGE);
114 rSet.DisableItem(SID_BEZIER_SMOOTH);
115 rSet.DisableItem(SID_BEZIER_SYMMTR);
116
117 rSet.DisableItem(SID_BEZIER_CLOSE);
118
119 rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
120 }
121 else
122 {
123 IPolyPolygonEditorController* pIPPEC = nullptr;
125 pIPPEC = mpView;
126 else
127 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
128
129 if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
130 {
131 rSet.DisableItem(SID_BEZIER_CUTLINE);
132 }
133 if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
134 {
135 rSet.DisableItem(SID_BEZIER_DELETE);
136 }
137 if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
138 {
139 rSet.DisableItem(SID_BEZIER_CONVERT);
140 }
141 else
142 {
143 SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
144 switch (eSegm)
145 {
146 case SdrPathSegmentKind::DontCare: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
147 case SdrPathSegmentKind::Line : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,false)); break; // Button down = curve
148 case SdrPathSegmentKind::Curve : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,true)); break;
149 default: break;
150 }
151 }
152 if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
153 {
154 rSet.DisableItem(SID_BEZIER_EDGE);
155 rSet.DisableItem(SID_BEZIER_SMOOTH);
156 rSet.DisableItem(SID_BEZIER_SYMMTR);
157 }
158 else
159 {
160 SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
161 switch (eSmooth)
162 {
163 case SdrPathSmoothKind::DontCare : break;
164 case SdrPathSmoothKind::Angular : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, true)); break;
165 case SdrPathSmoothKind::Asymmetric: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,true)); break;
166 case SdrPathSmoothKind::Symmetric : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,true)); break;
167 }
168 }
169 if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
170 {
171 rSet.DisableItem(SID_BEZIER_CLOSE);
172 }
173 else
174 {
175 SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
176 switch (eClose)
177 {
178 case SdrObjClosedKind::DontCare: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
179 case SdrObjClosedKind::Open : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,false)); break;
180 case SdrObjClosedKind::Closed : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,true)); break;
181 default: break;
182 }
183 }
184
185 if(pIPPEC == mpView)
186 rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
187 else
188 rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
189 }
190}
191
197{
198 sal_uInt16 nSId = rReq.GetSlot();
199
200 switch (nSId)
201 {
202 case SID_BEZIER_CUTLINE:
203 case SID_BEZIER_CONVERT:
204 case SID_BEZIER_DELETE:
205 case SID_BEZIER_EDGE:
206 case SID_BEZIER_SMOOTH:
207 case SID_BEZIER_SYMMTR:
208 case SID_BEZIER_CLOSE:
209 {
210 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
211
212 IPolyPolygonEditorController* pIPPEC = nullptr;
213 if( rMarkList.GetMarkCount() )
214 pIPPEC = mpView;
215 else
216 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
217
218 if( pIPPEC && !mpView->IsAction())
219 {
220 switch (nSId)
221 {
222 case SID_BEZIER_DELETE:
223 pIPPEC->DeleteMarkedPoints();
224 break;
225
226 case SID_BEZIER_CUTLINE:
227 pIPPEC->RipUpAtMarkedPoints();
228 break;
229
230 case SID_BEZIER_CONVERT:
231 {
232 pIPPEC->SetMarkedSegmentsKind(SdrPathSegmentKind::Toggle);
233 break;
234 }
235
236 case SID_BEZIER_EDGE:
237 case SID_BEZIER_SMOOTH:
238 case SID_BEZIER_SYMMTR:
239 {
240 SdrPathSmoothKind eKind;
241
242 switch (nSId)
243 {
244 default:
245 case SID_BEZIER_EDGE: eKind = SdrPathSmoothKind::Angular; break;
246 case SID_BEZIER_SMOOTH: eKind = SdrPathSmoothKind::Asymmetric; break;
247 case SID_BEZIER_SYMMTR: eKind = SdrPathSmoothKind::Symmetric; break;
248 }
249
250 pIPPEC->SetMarkedPointsSmooth(eKind);
251 break;
252 }
253
254 case SID_BEZIER_CLOSE:
255 {
256 SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rMarkList.GetMark(0)->GetMarkedSdrObj() );
257 const bool bUndo = mpView->IsUndoEnabled();
258 if( bUndo )
259 mpView->BegUndo(SdResId(STR_UNDO_BEZCLOSE));
260
262
263 if( bUndo )
265
266 pPathObj->ToggleClosed();
267
268 if( bUndo )
269 mpView->EndUndo();
270 break;
271 }
272 }
273 }
274
275 if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
276 mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
277
278 rReq.Ignore();
279 }
280 break;
281
282 case SID_BEZIER_ELIMINATE_POINTS:
283 {
285 Invalidate(SID_BEZIER_ELIMINATE_POINTS);
286 rReq.Done();
287 }
288 break;
289
290 case SID_BEZIER_MOVE:
291 case SID_BEZIER_INSERT:
292 {
294
295 if(xFunc.is())
296 {
297 if( auto pFuSelection = dynamic_cast<FuSelection *>( xFunc.get() ))
298 {
299 pFuSelection->SetEditMode(rReq.GetSlot());
300 }
301 else if( auto pFuPolygon = dynamic_cast<FuConstructBezierPolygon *>( xFunc.get() ))
302 {
303 pFuPolygon->SetEditMode(rReq.GetSlot());
304 }
305 }
306
307 rReq.Ignore ();
308 }
309 break;
310
311 default:
312 break;
313 }
314
315 Invalidate();
316}
317
318} // end of namespace sd
319
320/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
virtual bool IsAction() const override
bool IsResizeAllowed(bool bProp=false) const
bool IsUndoEnabled() const
bool IsMoveAllowed() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void BegUndo()
void EndUndo()
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
bool UnmarkAllPoints()
SdrObject * GetMarkedSdrObj() const
SdrUndoFactory & GetSdrUndoFactory() const
SdrModel & GetModel() const
void ToggleClosed()
void DeleteMarkedPoints() override
void SetEliminatePolyPoints(bool bOn)
bool IsEliminatePolyPoints() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoGeoObject(SdrObject &rObject)
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)
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void Ignore()
void Done(bool bRemove=false)
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
void SetRepeatTarget(SfxRepeatTarget *pTarget)
virtual void Invalidate(sal_uInt16 nId=0)
void SetPool(SfxItemPool *pNewPool)
SfxDispatcher * GetDispatcher()
void GetAttrState(SfxItemSet &rSet)
Status of attribute items.
Definition: drbezob.cxx:81
virtual ~BezierObjectBar() override
Definition: drbezob.cxx:72
BezierObjectBar(ViewShell *pSdViewShell, View *pSdView)
Definition: drbezob.cxx:59
void Execute(SfxRequest &rReq)
Process SfxRequests.
Definition: drbezob.cxx:196
virtual SfxUndoManager * GetUndoManager() override
Definition: docshell.cxx:363
const SmartTagReference & getSelected() const
returns the currently selected tag or an empty reference.
Definition: smarttag.hxx:105
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
const rtl::Reference< FuPoor > & GetCurrentFunction() const
Definition: ViewShell.hxx:250
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
virtual void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: sdview.cxx:515
SmartTagSet & getSmartTags()
Definition: View.hxx:207
SdDrawDocument & GetDoc() const
Definition: View.hxx:293
SdrPathSmoothKind
SdrObjClosedKind
SdrPathSegmentKind
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
UnoViewSharedPtr mpView