1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "BezierObjectBar.hxx"
21 #include <sfx2/app.hxx>
22 #include <sfx2/msg.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <sfx2/objface.hxx>
26 #include <svx/svxids.hrc>
27 #include <svl/eitem.hxx>
28 #include <sfx2/request.hxx>
29 #include <svx/svdopath.hxx>
30 #include <svl/aeitem.hxx>
31 #include <svx/svdundo.hxx>
32 #include <sfx2/dispatch.hxx>
34 #include "sdresid.hxx"
36 #include "res_bmp.hrc"
38 #include "strings.hrc"
40 #include "DrawDocShell.hxx"
41 #include "ViewShell.hxx"
43 #include "drawview.hxx"
44 #include "drawdoc.hxx"
46 #include "fuconbez.hxx"
49 #define BezierObjectBar
50 #include "sdslots.hxx"
55 * Declare default interface (Slotmap must not be empty)
57 SFX_IMPL_INTERFACE(BezierObjectBar
, ::SfxShell
)
59 void BezierObjectBar::InitInterface_Impl()
63 TYPEINIT1(BezierObjectBar
, ::SfxShell
);
65 BezierObjectBar::BezierObjectBar(
66 ViewShell
* pSdViewShell
,
68 : SfxShell(pSdViewShell
->GetViewShell()),
70 mpViewSh(pSdViewShell
)
72 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
73 SetPool(&pDocShell
->GetPool());
74 SetUndoManager(pDocShell
->GetUndoManager());
75 SetRepeatTarget(mpView
);
77 SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR
);
80 BezierObjectBar::~BezierObjectBar()
82 SetRepeatTarget(NULL
);
86 * Status of attribute items.
89 void BezierObjectBar::GetAttrState(SfxItemSet
& rSet
)
91 SfxItemSet
aAttrSet( mpView
->GetDoc().GetPool() );
92 mpView
->GetAttributes( aAttrSet
);
93 rSet
.Put(aAttrSet
, false); // <- sal_False, so DontCare-Status gets acquired
95 rtl::Reference
<FuPoor
> xFunc( mpViewSh
->GetCurrentFunction() );
99 if(xFunc
->ISA(FuSelection
))
101 sal_uInt16 nEditMode
= static_cast<FuSelection
*>(xFunc
.get())->GetEditMode();
102 rSet
.Put(SfxBoolItem(nEditMode
, true));
104 else if (xFunc
->ISA(FuConstructBezierPolygon
))
106 sal_uInt16 nEditMode
= static_cast<FuConstructBezierPolygon
*>(xFunc
.get())->GetEditMode();
107 rSet
.Put(SfxBoolItem(nEditMode
, true));
111 if(!mpView
->IsMoveAllowed() || !mpView
->IsResizeAllowed())
113 // #i77187# if object is move and/or size protected, do not allow point editing at all
114 rSet
.DisableItem(SID_BEZIER_MOVE
);
115 rSet
.DisableItem(SID_BEZIER_INSERT
);
117 rSet
.DisableItem(SID_BEZIER_DELETE
);
118 rSet
.DisableItem(SID_BEZIER_CUTLINE
);
119 rSet
.DisableItem(SID_BEZIER_CONVERT
);
121 rSet
.DisableItem(SID_BEZIER_EDGE
);
122 rSet
.DisableItem(SID_BEZIER_SMOOTH
);
123 rSet
.DisableItem(SID_BEZIER_SYMMTR
);
125 rSet
.DisableItem(SID_BEZIER_CLOSE
);
127 rSet
.DisableItem(SID_BEZIER_ELIMINATE_POINTS
);
131 IPolyPolygonEditorController
* pIPPEC
= 0;
132 if( mpView
->GetMarkedObjectList().GetMarkCount() )
135 pIPPEC
= dynamic_cast< IPolyPolygonEditorController
* >( mpView
->getSmartTags().getSelected().get() );
137 if ( !pIPPEC
|| !pIPPEC
->IsRipUpAtMarkedPointsPossible())
139 rSet
.DisableItem(SID_BEZIER_CUTLINE
);
141 if (!pIPPEC
|| !pIPPEC
->IsDeleteMarkedPointsPossible())
143 rSet
.DisableItem(SID_BEZIER_DELETE
);
145 if (!pIPPEC
|| !pIPPEC
->IsSetMarkedSegmentsKindPossible())
147 rSet
.DisableItem(SID_BEZIER_CONVERT
);
151 SdrPathSegmentKind eSegm
= pIPPEC
->GetMarkedSegmentsKind();
154 case SDRPATHSEGMENT_DONTCARE
: rSet
.InvalidateItem(SID_BEZIER_CONVERT
); break;
155 case SDRPATHSEGMENT_LINE
: rSet
.Put(SfxBoolItem(SID_BEZIER_CONVERT
,false)); break; // Button down = curve
156 case SDRPATHSEGMENT_CURVE
: rSet
.Put(SfxBoolItem(SID_BEZIER_CONVERT
,true)); break;
160 if (!pIPPEC
|| !pIPPEC
->IsSetMarkedPointsSmoothPossible())
162 rSet
.DisableItem(SID_BEZIER_EDGE
);
163 rSet
.DisableItem(SID_BEZIER_SMOOTH
);
164 rSet
.DisableItem(SID_BEZIER_SYMMTR
);
168 SdrPathSmoothKind eSmooth
= pIPPEC
->GetMarkedPointsSmooth();
171 case SDRPATHSMOOTH_DONTCARE
: break;
172 case SDRPATHSMOOTH_ANGULAR
: rSet
.Put(SfxBoolItem(SID_BEZIER_EDGE
, true)); break;
173 case SDRPATHSMOOTH_ASYMMETRIC
: rSet
.Put(SfxBoolItem(SID_BEZIER_SMOOTH
,true)); break;
174 case SDRPATHSMOOTH_SYMMETRIC
: rSet
.Put(SfxBoolItem(SID_BEZIER_SYMMTR
,true)); break;
177 if (!pIPPEC
|| !pIPPEC
->IsOpenCloseMarkedObjectsPossible())
179 rSet
.DisableItem(SID_BEZIER_CLOSE
);
183 SdrObjClosedKind eClose
= pIPPEC
->GetMarkedObjectsClosedState();
186 case SDROBJCLOSED_DONTCARE
: rSet
.InvalidateItem(SID_BEZIER_CLOSE
); break;
187 case SDROBJCLOSED_OPEN
: rSet
.Put(SfxBoolItem(SID_BEZIER_CLOSE
,false)); break;
188 case SDROBJCLOSED_CLOSED
: rSet
.Put(SfxBoolItem(SID_BEZIER_CLOSE
,true)); break;
194 rSet
.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS
, mpView
->IsEliminatePolyPoints()));
196 rSet
.DisableItem( SID_BEZIER_ELIMINATE_POINTS
); // only works for views
201 * Process SfxRequests
204 void BezierObjectBar::Execute(SfxRequest
& rReq
)
206 sal_uInt16 nSId
= rReq
.GetSlot();
210 case SID_BEZIER_CUTLINE
:
211 case SID_BEZIER_CONVERT
:
212 case SID_BEZIER_DELETE
:
213 case SID_BEZIER_EDGE
:
214 case SID_BEZIER_SMOOTH
:
215 case SID_BEZIER_SYMMTR
:
216 case SID_BEZIER_CLOSE
:
218 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
220 IPolyPolygonEditorController
* pIPPEC
= 0;
221 if( rMarkList
.GetMarkCount() )
224 pIPPEC
= dynamic_cast< IPolyPolygonEditorController
* >( mpView
->getSmartTags().getSelected().get() );
226 if( pIPPEC
&& !mpView
->IsAction())
230 case SID_BEZIER_DELETE
:
231 pIPPEC
->DeleteMarkedPoints();
234 case SID_BEZIER_CUTLINE
:
235 pIPPEC
->RipUpAtMarkedPoints();
238 case SID_BEZIER_CONVERT
:
240 pIPPEC
->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE
);
244 case SID_BEZIER_EDGE
:
245 case SID_BEZIER_SMOOTH
:
246 case SID_BEZIER_SYMMTR
:
248 SdrPathSmoothKind eKind
;
253 case SID_BEZIER_EDGE
: eKind
= SDRPATHSMOOTH_ANGULAR
; break;
254 case SID_BEZIER_SMOOTH
: eKind
= SDRPATHSMOOTH_ASYMMETRIC
; break;
255 case SID_BEZIER_SYMMTR
: eKind
= SDRPATHSMOOTH_SYMMETRIC
; break;
258 pIPPEC
->SetMarkedPointsSmooth(eKind
);
262 case SID_BEZIER_CLOSE
:
264 SdrPathObj
* pPathObj
= static_cast<SdrPathObj
*>( rMarkList
.GetMark(0)->GetMarkedSdrObj() );
265 const bool bUndo
= mpView
->IsUndoEnabled();
267 mpView
->BegUndo(SD_RESSTR(STR_UNDO_BEZCLOSE
));
269 mpView
->UnmarkAllPoints();
272 mpView
->AddUndo(mpView
->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj
));
274 pPathObj
->ToggleClosed();
283 if( (pIPPEC
== mpView
) && !mpView
->AreObjectsMarked() )
284 mpViewSh
->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
290 case SID_BEZIER_ELIMINATE_POINTS
:
292 mpView
->SetEliminatePolyPoints(!mpView
->IsEliminatePolyPoints());
293 Invalidate(SID_BEZIER_ELIMINATE_POINTS
);
298 case SID_BEZIER_MOVE
:
299 case SID_BEZIER_INSERT
:
301 rtl::Reference
<FuPoor
> xFunc( mpViewSh
->GetCurrentFunction() );
305 if(xFunc
->ISA(FuSelection
))
307 static_cast<FuSelection
*>(xFunc
.get())->SetEditMode(rReq
.GetSlot());
309 else if(xFunc
->ISA(FuConstructBezierPolygon
))
311 static_cast<FuConstructBezierPolygon
*>(xFunc
.get())->SetEditMode(rReq
.GetSlot());
326 } // end of namespace sd
328 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */