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 : : #include "cmdid.h"
30 : : #include <svx/svdview.hxx>
31 : : #include <svl/srchitem.hxx>
32 : : #include <svl/eitem.hxx>
33 : : #include <svl/whiter.hxx>
34 : : #include <svx/svdopath.hxx>
35 : : #include <sfx2/request.hxx>
36 : : #include <sfx2/dispatch.hxx>
37 : : #include <sfx2/objface.hxx>
38 : :
39 : : #include "wrtsh.hxx"
40 : : #include "view.hxx"
41 : : #include "edtwin.hxx"
42 : : #include "helpid.h"
43 : : #include "globals.hrc"
44 : : #include "drawbase.hxx"
45 : : #include "beziersh.hxx"
46 : : #include "popup.hrc"
47 : : #include "shells.hrc"
48 : : #define SwBezierShell
49 : : #include <sfx2/msg.hxx>
50 : : #include "swslots.hxx"
51 : :
52 : : #include <unomid.h>
53 : :
54 [ + + ][ + - ]: 292 : SFX_IMPL_INTERFACE(SwBezierShell, SwBaseShell, SW_RES(STR_SHELLNAME_BEZIER))
[ + - ][ + - ]
55 : : {
56 [ + - ][ + - ]: 73 : SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRAW_POPUPMENU));
57 [ + - ][ + - ]: 73 : SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_BEZIER_TOOLBOX));
58 : 73 : }
59 : :
60 [ # # ][ # # ]: 0 : TYPEINIT1(SwBezierShell,SwBaseShell)
61 : :
62 : 0 : SwBezierShell::SwBezierShell(SwView &_rView):
63 : 0 : SwBaseShell( _rView )
64 : : {
65 [ # # ][ # # ]: 0 : SetName(rtl::OUString("Bezier"));
[ # # ]
66 [ # # ]: 0 : SetHelpId(SW_BEZIERSHELL);
67 : :
68 [ # # ]: 0 : SwWrtShell *pSh = &GetShell();
69 [ # # ]: 0 : SdrView* pSdrView = pSh->GetDrawView();
70 : 0 : pSdrView->SetEliminatePolyPointLimitAngle(1500L);
71 : 0 : }
72 : :
73 : 0 : void SwBezierShell::Execute(SfxRequest &rReq)
74 : : {
75 [ # # ]: 0 : SwWrtShell *pSh = &GetShell();
76 [ # # ]: 0 : SdrView* pSdrView = pSh->GetDrawView();
77 : 0 : const SfxItemSet *pArgs = rReq.GetArgs();
78 : 0 : sal_uInt16 nSlotId = rReq.GetSlot();
79 : 0 : sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
80 [ # # ]: 0 : pSdrView->GetModel()->SetChanged(sal_False);
81 : : const SfxPoolItem* pItem;
82 [ # # ]: 0 : if(pArgs)
83 [ # # ]: 0 : pArgs->GetItemState(nSlotId, sal_False, &pItem);
84 : :
85 [ # # # # : 0 : switch (nSlotId)
# ]
86 : : {
87 : : case SID_DELETE:
88 : : case FN_BACKSPACE:
89 [ # # ][ # # ]: 0 : if (pSh->IsObjSelected())
90 : : {
91 [ # # ][ # # ]: 0 : if (pSdrView->HasMarkedPoints())
92 [ # # ]: 0 : pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_DELETE, sal_False);
93 : : else
94 : : {
95 [ # # ]: 0 : pSh->DelSelectedObj();
96 [ # # ]: 0 : if (pSh->IsSelFrmMode())
97 : : {
98 [ # # ]: 0 : pSh->LeaveSelFrmMode();
99 [ # # ]: 0 : pSh->NoEdit();
100 : : }
101 [ # # ]: 0 : GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
102 : : }
103 : : }
104 : 0 : break;
105 : :
106 : : case FN_ESCAPE:
107 [ # # ][ # # ]: 0 : if (pSdrView->HasMarkedPoints())
108 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
109 : : else
110 : : {
111 [ # # ][ # # ]: 0 : if ( pSh->IsDrawCreate() )
112 : : {
113 [ # # ]: 0 : GetView().GetDrawFuncPtr()->BreakCreate();
114 [ # # ]: 0 : GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
115 : : }
116 [ # # ][ # # ]: 0 : else if ( pSh->HasSelection() || GetView().IsDrawMode() )
[ # # ][ # # ]
117 : : {
118 [ # # ]: 0 : GetView().LeaveDrawCreate();
119 [ # # ]: 0 : pSh->EnterStdMode();
120 [ # # ]: 0 : GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
121 : : }
122 : : }
123 : 0 : break;
124 : :
125 : : case SID_BEZIER_MOVE:
126 : : case SID_BEZIER_INSERT:
127 : : {
128 : 0 : GetView().GetEditWin().SetBezierMode(nSlotId);
129 : : static sal_uInt16 aInva[] =
130 : : {
131 : : SID_BEZIER_INSERT,
132 : : SID_BEZIER_MOVE,
133 : : 0
134 : : };
135 [ # # ]: 0 : GetView().GetViewFrame()->GetBindings().Invalidate(aInva);
136 : : }
137 : 0 : break;
138 : :
139 : : case SID_BEZIER_DELETE:
140 : : case SID_BEZIER_CUTLINE:
141 : : case SID_BEZIER_CONVERT:
142 : : case SID_BEZIER_EDGE:
143 : : case SID_BEZIER_SMOOTH:
144 : : case SID_BEZIER_SYMMTR:
145 : : case SID_BEZIER_CLOSE:
146 : : case SID_BEZIER_ELIMINATE_POINTS:
147 : : {
148 : 0 : const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
149 : :
150 [ # # ][ # # ]: 0 : if (rMarkList.GetMark(0) && !pSdrView->IsAction())
[ # # ][ # # ]
[ # # ]
151 : : {
152 [ # # # # : 0 : switch (nSlotId)
# # # ]
153 : : {
154 : : case SID_BEZIER_DELETE:
155 [ # # ]: 0 : pSdrView->DeleteMarkedPoints();
156 : 0 : break;
157 : :
158 : : case SID_BEZIER_CUTLINE:
159 : : {
160 [ # # ]: 0 : pSdrView->RipUpAtMarkedPoints();
161 [ # # ]: 0 : pSh->CheckUnboundObjects();
162 : : }
163 : 0 : break;
164 : :
165 : : case SID_BEZIER_CONVERT:
166 : : {
167 [ # # ]: 0 : pSdrView->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
168 : 0 : break;
169 : : }
170 : :
171 : : case SID_BEZIER_EDGE:
172 : : case SID_BEZIER_SMOOTH:
173 : : case SID_BEZIER_SYMMTR:
174 : : {
175 : 0 : SdrPathSmoothKind eKind = SDRPATHSMOOTH_ASYMMETRIC;
176 : :
177 [ # # # # ]: 0 : switch (nSlotId)
178 : : {
179 : 0 : case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
180 : 0 : case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
181 : 0 : case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
182 : : }
183 : :
184 [ # # ]: 0 : SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth();
185 [ # # ]: 0 : if (eKind != eSmooth)
186 : : {
187 [ # # ]: 0 : pSdrView->SetMarkedPointsSmooth(eKind);
188 : :
189 : : static sal_uInt16 aInva[] =
190 : : {
191 : : SID_BEZIER_SMOOTH,
192 : : SID_BEZIER_EDGE,
193 : : SID_BEZIER_SYMMTR,
194 : : 0
195 : : };
196 [ # # ]: 0 : GetView().GetViewFrame()->GetBindings().Invalidate(aInva);
197 : : }
198 : 0 : break;
199 : : }
200 : :
201 : : case SID_BEZIER_CLOSE:
202 : : {
203 [ # # ][ # # ]: 0 : SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
204 [ # # ]: 0 : pSdrView->UnmarkAllPoints();
205 : : // Size aDist(GetView().GetEditWin().PixelToLogic(Size(8,8)));
206 [ # # ]: 0 : pPathObj->ToggleClosed(); // aDist.Width());
207 : 0 : break;
208 : : }
209 : :
210 : : case SID_BEZIER_ELIMINATE_POINTS:
211 : 0 : pSdrView->SetEliminatePolyPoints(!pSdrView->IsEliminatePolyPoints());
212 : 0 : break;
213 : : }
214 : : }
215 : : }
216 : 0 : break;
217 : :
218 : : default:
219 : 0 : break;
220 : : }
221 : :
222 [ # # ]: 0 : if (pSdrView->GetModel()->IsChanged())
223 [ # # ][ # # ]: 0 : GetShell().SetModified();
224 [ # # ]: 0 : else if (bChanged)
225 [ # # ]: 0 : pSdrView->GetModel()->SetChanged(sal_True);
226 : 0 : }
227 : :
228 : 0 : void SwBezierShell::GetState(SfxItemSet &rSet)
229 : : {
230 [ # # ][ # # ]: 0 : SdrView* pSdrView = GetShell().GetDrawView();
231 : :
232 [ # # ]: 0 : SfxWhichIter aIter( rSet );
233 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
234 : :
235 [ # # ]: 0 : while( nWhich )
236 : : {
237 [ # # # # : 0 : switch( nWhich )
# # # # ]
238 : : {
239 : : case SID_BEZIER_MOVE:
240 : : case SID_BEZIER_INSERT:
241 : : {
242 : 0 : sal_uInt16 nEditMode = GetView().GetEditWin().GetBezierMode();
243 : :
244 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(nWhich, nEditMode == nWhich));
[ # # ]
245 : : }
246 : 0 : break;
247 : :
248 : : case SID_BEZIER_CUTLINE:
249 [ # # ][ # # ]: 0 : if (!pSdrView->IsRipUpAtMarkedPointsPossible())
250 : : {
251 [ # # ]: 0 : rSet.DisableItem(SID_BEZIER_CUTLINE);
252 : : }
253 : 0 : break;
254 : :
255 : : case SID_BEZIER_DELETE:
256 [ # # ][ # # ]: 0 : if (!pSdrView->IsDeleteMarkedPointsPossible())
257 : : {
258 [ # # ]: 0 : rSet.DisableItem(SID_BEZIER_DELETE);
259 : : }
260 : 0 : break;
261 : :
262 : : case SID_BEZIER_CONVERT:
263 [ # # ][ # # ]: 0 : if (!pSdrView->IsSetMarkedSegmentsKindPossible())
264 : : {
265 [ # # ]: 0 : rSet.DisableItem(SID_BEZIER_CONVERT);
266 : : }
267 : : else
268 : : {
269 [ # # ]: 0 : SdrPathSegmentKind eSegm = pSdrView->GetMarkedSegmentsKind();
270 [ # # # # ]: 0 : switch (eSegm)
271 : : {
272 [ # # ]: 0 : case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
273 [ # # ][ # # ]: 0 : case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_False)); break; // Button reingedrueckt = Kurve
[ # # ]
274 [ # # ][ # # ]: 0 : case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_True)); break;
[ # # ]
275 : : default:; //prevent warning
276 : : }
277 : : }
278 : 0 : break;
279 : :
280 : : case SID_BEZIER_EDGE:
281 : : case SID_BEZIER_SMOOTH:
282 : : case SID_BEZIER_SYMMTR:
283 [ # # ][ # # ]: 0 : if (!pSdrView->IsSetMarkedPointsSmoothPossible())
284 [ # # ]: 0 : rSet.DisableItem(nWhich);
285 : : else
286 : : {
287 [ # # ]: 0 : SdrPathSmoothKind eSmooth = pSdrView->GetMarkedPointsSmooth();
288 : 0 : sal_Bool bEnable = sal_False;
289 [ # # # # : 0 : switch (eSmooth)
# ]
290 : : {
291 : : case SDRPATHSMOOTH_DONTCARE :
292 : 0 : break;
293 : : case SDRPATHSMOOTH_ANGULAR :
294 : 0 : bEnable = nWhich == SID_BEZIER_EDGE;
295 : 0 : break;
296 : : case SDRPATHSMOOTH_ASYMMETRIC:
297 : 0 : bEnable = nWhich == SID_BEZIER_SMOOTH;
298 : 0 : break;
299 : : case SDRPATHSMOOTH_SYMMETRIC :
300 : 0 : bEnable = nWhich == SID_BEZIER_SYMMTR;
301 : 0 : break;
302 : : }
303 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(nWhich, bEnable));
[ # # ]
304 : : }
305 : 0 : break;
306 : :
307 : : case SID_BEZIER_CLOSE:
308 [ # # ][ # # ]: 0 : if (!pSdrView->IsOpenCloseMarkedObjectsPossible())
309 : : {
310 [ # # ]: 0 : rSet.DisableItem(SID_BEZIER_CLOSE);
311 : : }
312 : : else
313 : : {
314 [ # # ]: 0 : SdrObjClosedKind eClose = pSdrView->GetMarkedObjectsClosedState();
315 [ # # # # ]: 0 : switch (eClose)
316 : : {
317 [ # # ]: 0 : case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
318 [ # # ][ # # ]: 0 : case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_False)); break;
[ # # ]
319 [ # # ][ # # ]: 0 : case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_True)); break;
[ # # ]
320 : : default:; //prevent warning
321 : : }
322 : : }
323 : 0 : break;
324 : :
325 : : case SID_BEZIER_ELIMINATE_POINTS:
326 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, pSdrView->IsEliminatePolyPoints()));
[ # # ]
327 : 0 : break;
328 : :
329 : : default:
330 : 0 : break;
331 : : }
332 [ # # ]: 0 : nWhich = aIter.NextWhich();
333 [ # # ]: 0 : }
334 : 0 : }
335 : :
336 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|