1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include "BezierObjectBar.hxx"
28 #include <sfx2/app.hxx>
29 #include <sfx2/msg.hxx>
30
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/objface.hxx>
33
34 #include <svx/svxids.hrc>
35 #include <svl/eitem.hxx>
36 #include <sfx2/request.hxx>
37 #include <svx/svdopath.hxx>
38 #include <svl/aeitem.hxx>
39 #include <svx/svdundo.hxx>
40 #include <sfx2/dispatch.hxx>
41
42
43 #include "sdresid.hxx"
44
45
46
47 #include "res_bmp.hrc"
48 #include "glob.hrc"
49 #include "strings.hrc"
50
51 #include "DrawDocShell.hxx"
52 #include "ViewShell.hxx"
53 #include "Window.hxx"
54 #include "drawview.hxx"
55 #include "drawdoc.hxx"
56 #include "sdresid.hxx"
57 #include "fusel.hxx"
58 #include "fuconbez.hxx"
59
60
61 using namespace sd;
62 #define BezierObjectBar
63 #include "sdslots.hxx"
64
65 namespace sd {
66
67 /*************************************************************************
68 |*
69 |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein)
70 |*
71 \************************************************************************/
72
73
74
SFX_IMPL_INTERFACE(BezierObjectBar,::SfxShell,SdResId (STR_BEZIEROBJECTBARSHELL))75 SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL))
76 {
77 }
78
79 TYPEINIT1(BezierObjectBar, ::SfxShell);
80
81 /*************************************************************************
82 |*
83 |* Standard-Konstruktor
84 |*
85 \************************************************************************/
86
BezierObjectBar(ViewShell * pSdViewShell,::sd::View * pSdView)87 BezierObjectBar::BezierObjectBar(
88 ViewShell* pSdViewShell,
89 ::sd::View* pSdView)
90 : SfxShell(pSdViewShell->GetViewShell()),
91 mpView(pSdView),
92 mpViewSh(pSdViewShell)
93 {
94 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
95 SetPool(&pDocShell->GetPool());
96 SetUndoManager(pDocShell->GetUndoManager());
97 SetRepeatTarget(mpView);
98
99 SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR );
100 }
101
102 /*************************************************************************
103 |*
104 |* Destruktor
105 |*
106 \************************************************************************/
107
~BezierObjectBar()108 BezierObjectBar::~BezierObjectBar()
109 {
110 SetRepeatTarget(NULL);
111 }
112
113
114 /*************************************************************************
115 |*
116 |* Status der Attribut-Items
117 |*
118 \************************************************************************/
119
GetAttrState(SfxItemSet & rSet)120 void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
121 {
122 SfxItemSet aAttrSet( mpView->GetDoc()->GetPool() );
123 mpView->GetAttributes( aAttrSet );
124 rSet.Put(aAttrSet, sal_False); // <- sal_False, damit DontCare-Status uebernommen wird
125
126 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
127
128 if(xFunc.is())
129 {
130 if(xFunc->ISA(FuSelection))
131 {
132 sal_uInt16 nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode();
133 rSet.Put(SfxBoolItem(nEditMode, sal_True));
134 }
135 else if (xFunc->ISA(FuConstructBezierPolygon))
136 {
137 sal_uInt16 nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
138 rSet.Put(SfxBoolItem(nEditMode, sal_True));
139 }
140 }
141
142 if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed())
143 {
144 // #i77187# if object is move and/or size protected, do not allow point editing at all
145 rSet.DisableItem(SID_BEZIER_MOVE);
146 rSet.DisableItem(SID_BEZIER_INSERT);
147
148 rSet.DisableItem(SID_BEZIER_DELETE);
149 rSet.DisableItem(SID_BEZIER_CUTLINE);
150 rSet.DisableItem(SID_BEZIER_CONVERT);
151
152 rSet.DisableItem(SID_BEZIER_EDGE);
153 rSet.DisableItem(SID_BEZIER_SMOOTH);
154 rSet.DisableItem(SID_BEZIER_SYMMTR);
155
156 rSet.DisableItem(SID_BEZIER_CLOSE);
157
158 rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
159 }
160 else
161 {
162 IPolyPolygonEditorController* pIPPEC = 0;
163 if( mpView->GetMarkedObjectList().GetMarkCount() )
164 pIPPEC = mpView;
165 else
166 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
167
168 if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
169 {
170 rSet.DisableItem(SID_BEZIER_CUTLINE);
171 }
172 if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
173 {
174 rSet.DisableItem(SID_BEZIER_DELETE);
175 }
176 if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
177 {
178 rSet.DisableItem(SID_BEZIER_CONVERT);
179 }
180 else
181 {
182 SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
183 switch (eSegm)
184 {
185 case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
186 case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_False)); break; // Button reingedrueckt = Kurve
187 case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_True)); break;
188 default: break;
189 }
190 }
191 if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
192 {
193 rSet.DisableItem(SID_BEZIER_EDGE);
194 rSet.DisableItem(SID_BEZIER_SMOOTH);
195 rSet.DisableItem(SID_BEZIER_SYMMTR);
196 }
197 else
198 {
199 SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
200 switch (eSmooth)
201 {
202 case SDRPATHSMOOTH_DONTCARE : break;
203 case SDRPATHSMOOTH_ANGULAR : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, sal_True)); break;
204 case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,sal_True)); break;
205 case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,sal_True)); break;
206 }
207 }
208 if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
209 {
210 rSet.DisableItem(SID_BEZIER_CLOSE);
211 }
212 else
213 {
214 SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
215 switch (eClose)
216 {
217 case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
218 case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_False)); break;
219 case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_True)); break;
220 default: break;
221 }
222 }
223
224 if(pIPPEC == mpView)
225 rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
226 else
227 rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
228 }
229 }
230
231
232 /*************************************************************************
233 |*
234 |* Bearbeitung der SfxRequests
235 |*
236 \************************************************************************/
237
Execute(SfxRequest & rReq)238 void BezierObjectBar::Execute(SfxRequest& rReq)
239 {
240 sal_uInt16 nSId = rReq.GetSlot();
241
242 switch (nSId)
243 {
244 case SID_BEZIER_CUTLINE:
245 case SID_BEZIER_CONVERT:
246 case SID_BEZIER_DELETE:
247 case SID_BEZIER_EDGE:
248 case SID_BEZIER_SMOOTH:
249 case SID_BEZIER_SYMMTR:
250 case SID_BEZIER_CLOSE:
251 {
252 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
253
254 IPolyPolygonEditorController* pIPPEC = 0;
255 if( rMarkList.GetMarkCount() )
256 pIPPEC = mpView;
257 else
258 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
259
260 if( pIPPEC && !mpView->IsAction())
261 {
262 switch (nSId)
263 {
264 case SID_BEZIER_DELETE:
265 pIPPEC->DeleteMarkedPoints();
266 break;
267
268 case SID_BEZIER_CUTLINE:
269 pIPPEC->RipUpAtMarkedPoints();
270 break;
271
272 case SID_BEZIER_CONVERT:
273 {
274 pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
275 break;
276 }
277
278 case SID_BEZIER_EDGE:
279 case SID_BEZIER_SMOOTH:
280 case SID_BEZIER_SYMMTR:
281 {
282 SdrPathSmoothKind eKind;
283
284 switch (nSId)
285 {
286 default:
287 case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
288 case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
289 case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
290 }
291
292 pIPPEC->SetMarkedPointsSmooth(eKind);
293 break;
294 }
295
296 case SID_BEZIER_CLOSE:
297 {
298 SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
299 const bool bUndo = mpView->IsUndoEnabled();
300 if( bUndo )
301 mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
302
303 mpView->UnmarkAllPoints();
304
305 if( bUndo )
306 mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
307
308 pPathObj->ToggleClosed();
309
310 if( bUndo )
311 mpView->EndUndo();
312 break;
313 }
314 }
315 }
316
317 if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
318 mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
319
320 rReq.Ignore();
321 }
322 break;
323
324 case SID_BEZIER_ELIMINATE_POINTS:
325 {
326 mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints());
327 Invalidate(SID_BEZIER_ELIMINATE_POINTS);
328 rReq.Done();
329 }
330 break;
331
332 case SID_BEZIER_MOVE:
333 case SID_BEZIER_INSERT:
334 {
335 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
336
337 if(xFunc.is())
338 {
339 if(xFunc->ISA(FuSelection))
340 {
341 static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
342 }
343 else if(xFunc->ISA(FuConstructBezierPolygon))
344 {
345 static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
346 }
347 }
348
349 rReq.Ignore ();
350 }
351 break;
352
353 default:
354 break;
355 }
356
357 Invalidate();
358 }
359
360
361 } // end of namespace sd
362