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