update dev300-m58
[ooovba.git] / sd / source / ui / view / drbezob.cxx
blob4797fd0c8f73fb23317b6156a03d06cc7d116054
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drbezob.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "BezierObjectBar.hxx"
35 #include <sfx2/app.hxx>
36 #include <sfx2/msg.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/objface.hxx>
41 #include <svx/svxids.hrc>
42 #include <svtools/eitem.hxx>
43 #include <sfx2/request.hxx>
44 #include <svx/svdopath.hxx>
45 #include <svtools/aeitem.hxx>
46 #include <svx/svdundo.hxx>
47 #include <sfx2/dispatch.hxx>
50 #include "sdresid.hxx"
54 #include "res_bmp.hrc"
55 #include "glob.hrc"
56 #include "strings.hrc"
58 #include "DrawDocShell.hxx"
59 #include "ViewShell.hxx"
60 #include "Window.hxx"
61 #include "drawview.hxx"
62 #include "drawdoc.hxx"
63 #include "sdresid.hxx"
64 #include "fusel.hxx"
65 #include "fuconbez.hxx"
68 using namespace sd;
69 #define BezierObjectBar
70 #include "sdslots.hxx"
72 namespace sd {
74 /*************************************************************************
76 |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein)
78 \************************************************************************/
82 SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL))
86 TYPEINIT1(BezierObjectBar, ::SfxShell);
88 /*************************************************************************
90 |* Standard-Konstruktor
92 \************************************************************************/
94 BezierObjectBar::BezierObjectBar(
95 ViewShell* pSdViewShell,
96 ::sd::View* pSdView)
97 : SfxShell(pSdViewShell->GetViewShell()),
98 mpView(pSdView),
99 mpViewSh(pSdViewShell)
101 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
102 SetPool(&pDocShell->GetPool());
103 SetUndoManager(pDocShell->GetUndoManager());
104 SetRepeatTarget(mpView);
106 SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR );
109 /*************************************************************************
111 |* Destruktor
113 \************************************************************************/
115 BezierObjectBar::~BezierObjectBar()
117 SetRepeatTarget(NULL);
121 /*************************************************************************
123 |* Status der Attribut-Items
125 \************************************************************************/
127 void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
129 SfxItemSet aAttrSet( mpView->GetDoc()->GetPool() );
130 mpView->GetAttributes( aAttrSet );
131 rSet.Put(aAttrSet, FALSE); // <- FALSE, damit DontCare-Status uebernommen wird
133 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
135 if(xFunc.is())
137 if(xFunc->ISA(FuSelection))
139 USHORT nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode();
140 rSet.Put(SfxBoolItem(nEditMode, TRUE));
142 else if (xFunc->ISA(FuConstructBezierPolygon))
144 USHORT nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
145 rSet.Put(SfxBoolItem(nEditMode, TRUE));
149 if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed())
151 // #i77187# if object is move and/or size protected, do not allow point editing at all
152 rSet.DisableItem(SID_BEZIER_MOVE);
153 rSet.DisableItem(SID_BEZIER_INSERT);
155 rSet.DisableItem(SID_BEZIER_DELETE);
156 rSet.DisableItem(SID_BEZIER_CUTLINE);
157 rSet.DisableItem(SID_BEZIER_CONVERT);
159 rSet.DisableItem(SID_BEZIER_EDGE);
160 rSet.DisableItem(SID_BEZIER_SMOOTH);
161 rSet.DisableItem(SID_BEZIER_SYMMTR);
163 rSet.DisableItem(SID_BEZIER_CLOSE);
165 rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
167 else
169 IPolyPolygonEditorController* pIPPEC = 0;
170 if( mpView->GetMarkedObjectList().GetMarkCount() )
171 pIPPEC = mpView;
172 else
173 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
175 if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
177 rSet.DisableItem(SID_BEZIER_CUTLINE);
179 if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
181 rSet.DisableItem(SID_BEZIER_DELETE);
183 if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
185 rSet.DisableItem(SID_BEZIER_CONVERT);
187 else
189 SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
190 switch (eSegm)
192 case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
193 case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,FALSE)); break; // Button reingedrueckt = Kurve
194 case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,TRUE)); break;
195 default: break;
198 if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
200 rSet.DisableItem(SID_BEZIER_EDGE);
201 rSet.DisableItem(SID_BEZIER_SMOOTH);
202 rSet.DisableItem(SID_BEZIER_SYMMTR);
204 else
206 SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
207 switch (eSmooth)
209 case SDRPATHSMOOTH_DONTCARE : break;
210 case SDRPATHSMOOTH_ANGULAR : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, TRUE)); break;
211 case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,TRUE)); break;
212 case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,TRUE)); break;
215 if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
217 rSet.DisableItem(SID_BEZIER_CLOSE);
219 else
221 SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
222 switch (eClose)
224 case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
225 case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,FALSE)); break;
226 case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,TRUE)); break;
227 default: break;
231 if(pIPPEC == mpView)
232 rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
233 else
234 rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
239 /*************************************************************************
241 |* Bearbeitung der SfxRequests
243 \************************************************************************/
245 void BezierObjectBar::Execute(SfxRequest& rReq)
247 USHORT nSId = rReq.GetSlot();
249 switch (nSId)
251 case SID_BEZIER_CUTLINE:
252 case SID_BEZIER_CONVERT:
253 case SID_BEZIER_DELETE:
254 case SID_BEZIER_EDGE:
255 case SID_BEZIER_SMOOTH:
256 case SID_BEZIER_SYMMTR:
257 case SID_BEZIER_CLOSE:
259 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
261 IPolyPolygonEditorController* pIPPEC = 0;
262 if( rMarkList.GetMarkCount() )
263 pIPPEC = mpView;
264 else
265 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
267 if( pIPPEC && !mpView->IsAction())
269 switch (nSId)
271 case SID_BEZIER_DELETE:
272 pIPPEC->DeleteMarkedPoints();
273 break;
275 case SID_BEZIER_CUTLINE:
276 pIPPEC->RipUpAtMarkedPoints();
277 break;
279 case SID_BEZIER_CONVERT:
281 pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
282 break;
285 case SID_BEZIER_EDGE:
286 case SID_BEZIER_SMOOTH:
287 case SID_BEZIER_SYMMTR:
289 SdrPathSmoothKind eKind;
291 switch (nSId)
293 default:
294 case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
295 case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
296 case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
299 pIPPEC->SetMarkedPointsSmooth(eKind);
300 break;
303 case SID_BEZIER_CLOSE:
305 SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
306 const bool bUndo = mpView->IsUndoEnabled();
307 if( bUndo )
308 mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
310 mpView->UnmarkAllPoints();
312 if( bUndo )
313 mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
315 pPathObj->ToggleClosed();
317 if( bUndo )
318 mpView->EndUndo();
319 break;
324 if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
325 mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
327 rReq.Ignore();
329 break;
331 case SID_BEZIER_ELIMINATE_POINTS:
333 mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints());
334 Invalidate(SID_BEZIER_ELIMINATE_POINTS);
335 rReq.Done();
337 break;
339 case SID_BEZIER_MOVE:
340 case SID_BEZIER_INSERT:
342 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
344 if(xFunc.is())
346 if(xFunc->ISA(FuSelection))
348 static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
350 else if(xFunc->ISA(FuConstructBezierPolygon))
352 static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
356 rReq.Ignore ();
358 break;
360 default:
361 break;
364 Invalidate();
368 } // end of namespace sd