fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / drbezob.cxx
blob4abd08f6631fb6316b84deab429b98d141cb1b28
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
37 #include "glob.hrc"
38 #include "strings.hrc"
40 #include "DrawDocShell.hxx"
41 #include "ViewShell.hxx"
42 #include "Window.hxx"
43 #include "drawview.hxx"
44 #include "drawdoc.hxx"
45 #include "fusel.hxx"
46 #include "fuconbez.hxx"
49 using namespace sd;
50 #define BezierObjectBar
51 #include "sdslots.hxx"
53 namespace sd {
55 /**
56 * Declare default interface (Slotmap must not be empty)
59 SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL))
63 TYPEINIT1(BezierObjectBar, ::SfxShell);
66 BezierObjectBar::BezierObjectBar(
67 ViewShell* pSdViewShell,
68 ::sd::View* pSdView)
69 : SfxShell(pSdViewShell->GetViewShell()),
70 mpView(pSdView),
71 mpViewSh(pSdViewShell)
73 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
74 SetPool(&pDocShell->GetPool());
75 SetUndoManager(pDocShell->GetUndoManager());
76 SetRepeatTarget(mpView);
78 SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR );
82 BezierObjectBar::~BezierObjectBar()
84 SetRepeatTarget(NULL);
88 /**
89 * Status of attribute items.
92 void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
94 SfxItemSet aAttrSet( mpView->GetDoc().GetPool() );
95 mpView->GetAttributes( aAttrSet );
96 rSet.Put(aAttrSet, sal_False); // <- sal_False, so DontCare-Status gets aquired
98 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
100 if(xFunc.is())
102 if(xFunc->ISA(FuSelection))
104 sal_uInt16 nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode();
105 rSet.Put(SfxBoolItem(nEditMode, sal_True));
107 else if (xFunc->ISA(FuConstructBezierPolygon))
109 sal_uInt16 nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
110 rSet.Put(SfxBoolItem(nEditMode, sal_True));
114 if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed())
116 // #i77187# if object is move and/or size protected, do not allow point editing at all
117 rSet.DisableItem(SID_BEZIER_MOVE);
118 rSet.DisableItem(SID_BEZIER_INSERT);
120 rSet.DisableItem(SID_BEZIER_DELETE);
121 rSet.DisableItem(SID_BEZIER_CUTLINE);
122 rSet.DisableItem(SID_BEZIER_CONVERT);
124 rSet.DisableItem(SID_BEZIER_EDGE);
125 rSet.DisableItem(SID_BEZIER_SMOOTH);
126 rSet.DisableItem(SID_BEZIER_SYMMTR);
128 rSet.DisableItem(SID_BEZIER_CLOSE);
130 rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
132 else
134 IPolyPolygonEditorController* pIPPEC = 0;
135 if( mpView->GetMarkedObjectList().GetMarkCount() )
136 pIPPEC = mpView;
137 else
138 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
140 if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
142 rSet.DisableItem(SID_BEZIER_CUTLINE);
144 if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
146 rSet.DisableItem(SID_BEZIER_DELETE);
148 if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
150 rSet.DisableItem(SID_BEZIER_CONVERT);
152 else
154 SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
155 switch (eSegm)
157 case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
158 case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_False)); break; // Button down = curve
159 case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_True)); break;
160 default: break;
163 if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
165 rSet.DisableItem(SID_BEZIER_EDGE);
166 rSet.DisableItem(SID_BEZIER_SMOOTH);
167 rSet.DisableItem(SID_BEZIER_SYMMTR);
169 else
171 SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
172 switch (eSmooth)
174 case SDRPATHSMOOTH_DONTCARE : break;
175 case SDRPATHSMOOTH_ANGULAR : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, sal_True)); break;
176 case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,sal_True)); break;
177 case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,sal_True)); break;
180 if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
182 rSet.DisableItem(SID_BEZIER_CLOSE);
184 else
186 SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
187 switch (eClose)
189 case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
190 case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_False)); break;
191 case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_True)); break;
192 default: break;
196 if(pIPPEC == mpView)
197 rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
198 else
199 rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
204 * Process SfxRequests
207 void BezierObjectBar::Execute(SfxRequest& rReq)
209 sal_uInt16 nSId = rReq.GetSlot();
211 switch (nSId)
213 case SID_BEZIER_CUTLINE:
214 case SID_BEZIER_CONVERT:
215 case SID_BEZIER_DELETE:
216 case SID_BEZIER_EDGE:
217 case SID_BEZIER_SMOOTH:
218 case SID_BEZIER_SYMMTR:
219 case SID_BEZIER_CLOSE:
221 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
223 IPolyPolygonEditorController* pIPPEC = 0;
224 if( rMarkList.GetMarkCount() )
225 pIPPEC = mpView;
226 else
227 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
229 if( pIPPEC && !mpView->IsAction())
231 switch (nSId)
233 case SID_BEZIER_DELETE:
234 pIPPEC->DeleteMarkedPoints();
235 break;
237 case SID_BEZIER_CUTLINE:
238 pIPPEC->RipUpAtMarkedPoints();
239 break;
241 case SID_BEZIER_CONVERT:
243 pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
244 break;
247 case SID_BEZIER_EDGE:
248 case SID_BEZIER_SMOOTH:
249 case SID_BEZIER_SYMMTR:
251 SdrPathSmoothKind eKind;
253 switch (nSId)
255 default:
256 case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
257 case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
258 case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
261 pIPPEC->SetMarkedPointsSmooth(eKind);
262 break;
265 case SID_BEZIER_CLOSE:
267 SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
268 const bool bUndo = mpView->IsUndoEnabled();
269 if( bUndo )
270 mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
272 mpView->UnmarkAllPoints();
274 if( bUndo )
275 mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
277 pPathObj->ToggleClosed();
279 if( bUndo )
280 mpView->EndUndo();
281 break;
286 if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
287 mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
289 rReq.Ignore();
291 break;
293 case SID_BEZIER_ELIMINATE_POINTS:
295 mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints());
296 Invalidate(SID_BEZIER_ELIMINATE_POINTS);
297 rReq.Done();
299 break;
301 case SID_BEZIER_MOVE:
302 case SID_BEZIER_INSERT:
304 FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
306 if(xFunc.is())
308 if(xFunc->ISA(FuSelection))
310 static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
312 else if(xFunc->ISA(FuConstructBezierPolygon))
314 static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
318 rReq.Ignore ();
320 break;
322 default:
323 break;
326 Invalidate();
330 } // end of namespace sd
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */