1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/presentation/EffectNodeType.hpp>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "fuconbez.hxx"
30cdf0e10cSrcweir #include <svl/aeitem.hxx>
31cdf0e10cSrcweir #include <svx/svdopath.hxx>
32cdf0e10cSrcweir #include <svl/intitem.hxx>
33cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
34cdf0e10cSrcweir #include <svx/svdobj.hxx>
35cdf0e10cSrcweir #include <sfx2/bindings.hxx>
36cdf0e10cSrcweir #include <sfx2/request.hxx>
37cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <svx/svxids.hrc>
41cdf0e10cSrcweir #include <svx/svdpagv.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include "app.hrc"
44cdf0e10cSrcweir #include "ViewShell.hxx"
45cdf0e10cSrcweir #include "ViewShellBase.hxx"
46cdf0e10cSrcweir #include "View.hxx"
47cdf0e10cSrcweir #include "Window.hxx"
48cdf0e10cSrcweir #include "ToolBarManager.hxx"
49cdf0e10cSrcweir #include "drawdoc.hxx"
50cdf0e10cSrcweir #include "res_bmp.hrc"
51cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
52cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir #include "CustomAnimationEffect.hxx"
55cdf0e10cSrcweir
56cdf0e10cSrcweir using namespace ::com::sun::star::uno;
57cdf0e10cSrcweir
58cdf0e10cSrcweir namespace sd {
59cdf0e10cSrcweir
60cdf0e10cSrcweir TYPEINIT1( FuConstructBezierPolygon, FuConstruct );
61cdf0e10cSrcweir
62cdf0e10cSrcweir
63cdf0e10cSrcweir /*************************************************************************
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* Konstruktor
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir \************************************************************************/
68cdf0e10cSrcweir
FuConstructBezierPolygon(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)69cdf0e10cSrcweir FuConstructBezierPolygon::FuConstructBezierPolygon (
70cdf0e10cSrcweir ViewShell* pViewSh,
71cdf0e10cSrcweir ::sd::Window* pWin,
72cdf0e10cSrcweir ::sd::View* pView,
73cdf0e10cSrcweir SdDrawDocument* pDoc,
74cdf0e10cSrcweir SfxRequest& rReq)
75cdf0e10cSrcweir : FuConstruct(pViewSh, pWin, pView, pDoc, rReq),
76cdf0e10cSrcweir nEditMode(SID_BEZIER_MOVE)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq,bool bPermanent)80cdf0e10cSrcweir FunctionReference FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir FuConstructBezierPolygon* pFunc;
83cdf0e10cSrcweir FunctionReference xFunc( pFunc = new FuConstructBezierPolygon( pViewSh, pWin, pView, pDoc, rReq ) );
84cdf0e10cSrcweir xFunc->DoExecute(rReq);
85cdf0e10cSrcweir pFunc->SetPermanent(bPermanent);
86cdf0e10cSrcweir return xFunc;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
DoExecute(SfxRequest & rReq)89cdf0e10cSrcweir void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir FuConstruct::DoExecute( rReq );
92cdf0e10cSrcweir
93cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
94cdf0e10cSrcweir if( pArgs )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL;
97cdf0e10cSrcweir if( SFX_ITEM_SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, sal_True, &pPoolItem ) )
98cdf0e10cSrcweir maTargets = ( ( const SfxUnoAnyItem* ) pPoolItem )->GetValue();
99cdf0e10cSrcweir }
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir /*************************************************************************
103cdf0e10cSrcweir |*
104cdf0e10cSrcweir |* MouseButtonDown-event
105cdf0e10cSrcweir |*
106cdf0e10cSrcweir \************************************************************************/
107cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)108cdf0e10cSrcweir sal_Bool FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
111cdf0e10cSrcweir
112cdf0e10cSrcweir SdrViewEvent aVEvt;
113cdf0e10cSrcweir SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
114cdf0e10cSrcweir
115cdf0e10cSrcweir if (eHit == SDRHIT_HANDLE || rMEvt.IsMod1())
116cdf0e10cSrcweir {
117cdf0e10cSrcweir mpView->SetEditMode(SDREDITMODE_EDIT);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir else
120cdf0e10cSrcweir {
121cdf0e10cSrcweir mpView->SetEditMode(SDREDITMODE_CREATE);
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir if (aVEvt.eEvent == SDREVENT_BEGTEXTEDIT)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir // Texteingabe hier nicht zulassen
127cdf0e10cSrcweir aVEvt.eEvent = SDREVENT_BEGDRAGOBJ;
128cdf0e10cSrcweir mpView->EnableExtendedMouseEventDispatcher(sal_False);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir else
131cdf0e10cSrcweir {
132cdf0e10cSrcweir mpView->EnableExtendedMouseEventDispatcher(sal_True);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir if (eHit == SDRHIT_MARKEDOBJECT && nEditMode == SID_BEZIER_INSERT)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir /******************************************************************
138cdf0e10cSrcweir * Klebepunkt einfuegen
139cdf0e10cSrcweir ******************************************************************/
140cdf0e10cSrcweir mpView->BegInsObjPoint(aMDPos, rMEvt.IsMod1());
141cdf0e10cSrcweir }
142cdf0e10cSrcweir else
143cdf0e10cSrcweir {
144cdf0e10cSrcweir mpView->MouseButtonDown(rMEvt, mpWindow);
145cdf0e10cSrcweir
146cdf0e10cSrcweir SdrObject* pObj = mpView->GetCreateObj();
147cdf0e10cSrcweir
148cdf0e10cSrcweir if (pObj)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir SfxItemSet aAttr(mpDoc->GetPool());
151cdf0e10cSrcweir SetStyleSheet(aAttr, pObj);
152cdf0e10cSrcweir pObj->SetMergedItemSet(aAttr);
153cdf0e10cSrcweir }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir return(bReturn);
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir /*************************************************************************
160cdf0e10cSrcweir |*
161cdf0e10cSrcweir |* MouseMove-event
162cdf0e10cSrcweir |*
163cdf0e10cSrcweir \************************************************************************/
164cdf0e10cSrcweir
MouseMove(const MouseEvent & rMEvt)165cdf0e10cSrcweir sal_Bool FuConstructBezierPolygon::MouseMove(const MouseEvent& rMEvt)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir sal_Bool bReturn = FuConstruct::MouseMove(rMEvt);
168cdf0e10cSrcweir return(bReturn);
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir /*************************************************************************
172cdf0e10cSrcweir |*
173cdf0e10cSrcweir |* MouseButtonUp-event
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir \************************************************************************/
176cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)177cdf0e10cSrcweir sal_Bool FuConstructBezierPolygon::MouseButtonUp(const MouseEvent& rMEvt )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir sal_Bool bReturn = sal_False;
180cdf0e10cSrcweir sal_Bool bCreated = sal_False;
181cdf0e10cSrcweir
182cdf0e10cSrcweir SdrViewEvent aVEvt;
183cdf0e10cSrcweir mpView->PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt);
184cdf0e10cSrcweir
185cdf0e10cSrcweir sal_uLong nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount();
186cdf0e10cSrcweir
187cdf0e10cSrcweir if (mpView->IsInsObjPoint())
188cdf0e10cSrcweir {
189cdf0e10cSrcweir mpView->EndInsObjPoint(SDRCREATE_FORCEEND);
190cdf0e10cSrcweir }
191cdf0e10cSrcweir else
192cdf0e10cSrcweir {
193cdf0e10cSrcweir mpView->MouseButtonUp(rMEvt, mpWindow);
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir if (aVEvt.eEvent == SDREVENT_ENDCREATE)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir bReturn = sal_True;
199cdf0e10cSrcweir
200cdf0e10cSrcweir if (nCount == (mpView->GetSdrPageView()->GetObjList()->GetObjCount() - 1))
201cdf0e10cSrcweir {
202cdf0e10cSrcweir bCreated = sal_True;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir // Trick, um FuDraw::DoubleClick nicht auszuloesen
206cdf0e10cSrcweir bMBDown = sal_False;
207cdf0e10cSrcweir
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
210cdf0e10cSrcweir bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn;
211cdf0e10cSrcweir
212cdf0e10cSrcweir bool bDeleted = false;
213cdf0e10cSrcweir if( bCreated && maTargets.hasValue() )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir SdrPathObj* pPathObj = dynamic_cast< SdrPathObj* >( mpView->GetSdrPageView()->GetObjList()->GetObj( nCount ) );
216cdf0e10cSrcweir SdPage* pPage = dynamic_cast< SdPage* >( pPathObj ? pPathObj->GetPage() : 0 );
217cdf0e10cSrcweir if( pPage )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir boost::shared_ptr< sd::MainSequence > pMainSequence( pPage->getMainSequence() );
220cdf0e10cSrcweir if( pMainSequence.get() )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir Sequence< Any > aTargets;
223cdf0e10cSrcweir maTargets >>= aTargets;
224cdf0e10cSrcweir
225cdf0e10cSrcweir sal_Int32 nTCount = aTargets.getLength();
226cdf0e10cSrcweir if( nTCount > 1 )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir const Any* pTarget = aTargets.getConstArray();
229cdf0e10cSrcweir double fDuration = 0.0;
230cdf0e10cSrcweir *pTarget++ >>= fDuration;
231cdf0e10cSrcweir bool bFirst = true;
232cdf0e10cSrcweir while( --nTCount )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, *pTarget++, fDuration ) );
235cdf0e10cSrcweir if( bFirst )
236cdf0e10cSrcweir bFirst = false;
237cdf0e10cSrcweir else
238cdf0e10cSrcweir pCreated->setNodeType( ::com::sun::star::presentation::EffectNodeType::WITH_PREVIOUS );
239cdf0e10cSrcweir }
240cdf0e10cSrcweir }
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir mpView->DeleteMarked();
244cdf0e10cSrcweir bDeleted = true;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir if ((!bPermanent && bCreated) || bDeleted)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir return(bReturn);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir /*************************************************************************
256cdf0e10cSrcweir |*
257cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
258cdf0e10cSrcweir |*
259cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
260cdf0e10cSrcweir |* sal_False.
261cdf0e10cSrcweir |*
262cdf0e10cSrcweir \************************************************************************/
263cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)264cdf0e10cSrcweir sal_Bool FuConstructBezierPolygon::KeyInput(const KeyEvent& rKEvt)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
267cdf0e10cSrcweir
268cdf0e10cSrcweir return(bReturn);
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir /*************************************************************************
272cdf0e10cSrcweir |*
273cdf0e10cSrcweir |* Function aktivieren
274cdf0e10cSrcweir |*
275cdf0e10cSrcweir \************************************************************************/
276cdf0e10cSrcweir
Activate()277cdf0e10cSrcweir void FuConstructBezierPolygon::Activate()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir mpView->EnableExtendedMouseEventDispatcher(sal_True);
280cdf0e10cSrcweir
281cdf0e10cSrcweir SdrObjKind eKind;
282cdf0e10cSrcweir
283cdf0e10cSrcweir switch (nSlotId)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir case SID_DRAW_POLYGON_NOFILL:
286cdf0e10cSrcweir case SID_DRAW_XPOLYGON_NOFILL:
287cdf0e10cSrcweir {
288cdf0e10cSrcweir eKind = OBJ_PLIN;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir break;
291cdf0e10cSrcweir
292cdf0e10cSrcweir case SID_DRAW_POLYGON:
293cdf0e10cSrcweir case SID_DRAW_XPOLYGON:
294cdf0e10cSrcweir {
295cdf0e10cSrcweir eKind = OBJ_POLY;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir break;
298cdf0e10cSrcweir
299cdf0e10cSrcweir case SID_DRAW_BEZIER_NOFILL:
300cdf0e10cSrcweir {
301cdf0e10cSrcweir eKind = OBJ_PATHLINE;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir break;
304cdf0e10cSrcweir
305cdf0e10cSrcweir case SID_DRAW_BEZIER_FILL:
306cdf0e10cSrcweir {
307cdf0e10cSrcweir eKind = OBJ_PATHFILL;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir break;
310cdf0e10cSrcweir
311cdf0e10cSrcweir case SID_DRAW_FREELINE_NOFILL:
312cdf0e10cSrcweir {
313cdf0e10cSrcweir eKind = OBJ_FREELINE;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir
317cdf0e10cSrcweir case SID_DRAW_FREELINE:
318cdf0e10cSrcweir {
319cdf0e10cSrcweir eKind = OBJ_FREEFILL;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir break;
322cdf0e10cSrcweir
323cdf0e10cSrcweir default:
324cdf0e10cSrcweir {
325cdf0e10cSrcweir eKind = OBJ_PATHLINE;
326cdf0e10cSrcweir }
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir mpView->SetCurrentObj((sal_uInt16)eKind);
331cdf0e10cSrcweir
332cdf0e10cSrcweir FuConstruct::Activate();
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
335cdf0e10cSrcweir /*************************************************************************
336cdf0e10cSrcweir |*
337cdf0e10cSrcweir |* Function deaktivieren
338cdf0e10cSrcweir |*
339cdf0e10cSrcweir \************************************************************************/
340cdf0e10cSrcweir
Deactivate()341cdf0e10cSrcweir void FuConstructBezierPolygon::Deactivate()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir mpView->EnableExtendedMouseEventDispatcher(sal_False);
344cdf0e10cSrcweir
345cdf0e10cSrcweir FuConstruct::Deactivate();
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir
349cdf0e10cSrcweir /*************************************************************************
350cdf0e10cSrcweir |*
351cdf0e10cSrcweir |* Selektion hat sich geaendert
352cdf0e10cSrcweir |*
353cdf0e10cSrcweir \************************************************************************/
354cdf0e10cSrcweir
SelectionHasChanged()355cdf0e10cSrcweir void FuConstructBezierPolygon::SelectionHasChanged()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir FuDraw::SelectionHasChanged();
358cdf0e10cSrcweir
359cdf0e10cSrcweir mpViewShell->GetViewShellBase().GetToolBarManager()->SelectionHasChanged(
360cdf0e10cSrcweir *mpViewShell,
361cdf0e10cSrcweir *mpView);
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
364cdf0e10cSrcweir
365cdf0e10cSrcweir
366cdf0e10cSrcweir /*************************************************************************
367cdf0e10cSrcweir |*
368cdf0e10cSrcweir |* Aktuellen Bezier-Editmodus setzen
369cdf0e10cSrcweir |*
370cdf0e10cSrcweir \************************************************************************/
371cdf0e10cSrcweir
SetEditMode(sal_uInt16 nMode)372cdf0e10cSrcweir void FuConstructBezierPolygon::SetEditMode(sal_uInt16 nMode)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir nEditMode = nMode;
375cdf0e10cSrcweir ForcePointer();
376cdf0e10cSrcweir
377cdf0e10cSrcweir SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
378cdf0e10cSrcweir rBindings.Invalidate(SID_BEZIER_MOVE);
379cdf0e10cSrcweir rBindings.Invalidate(SID_BEZIER_INSERT);
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
382cdf0e10cSrcweir // #97016#
CreateDefaultObject(const sal_uInt16 nID,const Rectangle & rRectangle)383cdf0e10cSrcweir SdrObject* FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir // case SID_DRAW_POLYGON:
386cdf0e10cSrcweir // case SID_DRAW_POLYGON_NOFILL:
387cdf0e10cSrcweir // case SID_DRAW_XPOLYGON:
388cdf0e10cSrcweir // case SID_DRAW_XPOLYGON_NOFILL:
389cdf0e10cSrcweir // case SID_DRAW_FREELINE:
390cdf0e10cSrcweir // case SID_DRAW_FREELINE_NOFILL:
391cdf0e10cSrcweir // case SID_DRAW_BEZIER_FILL: // BASIC
392cdf0e10cSrcweir // case SID_DRAW_BEZIER_NOFILL: // BASIC
393cdf0e10cSrcweir
394cdf0e10cSrcweir SdrObject* pObj = SdrObjFactory::MakeNewObject(
395cdf0e10cSrcweir mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
396cdf0e10cSrcweir 0L, mpDoc);
397cdf0e10cSrcweir
398cdf0e10cSrcweir if(pObj)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir if(pObj->ISA(SdrPathObj))
401cdf0e10cSrcweir {
402cdf0e10cSrcweir basegfx::B2DPolyPolygon aPoly;
403cdf0e10cSrcweir
404cdf0e10cSrcweir switch(nID)
405cdf0e10cSrcweir {
406cdf0e10cSrcweir case SID_DRAW_BEZIER_FILL:
407cdf0e10cSrcweir {
408cdf0e10cSrcweir const sal_Int32 nWdt(rRectangle.GetWidth() / 2);
409cdf0e10cSrcweir const sal_Int32 nHgt(rRectangle.GetHeight() / 2);
410cdf0e10cSrcweir const basegfx::B2DPolygon aInnerPoly(basegfx::tools::createPolygonFromEllipse(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()), nWdt, nHgt));
411cdf0e10cSrcweir
412cdf0e10cSrcweir aPoly.append(aInnerPoly);
413cdf0e10cSrcweir break;
414cdf0e10cSrcweir }
415cdf0e10cSrcweir case SID_DRAW_BEZIER_NOFILL:
416cdf0e10cSrcweir {
417cdf0e10cSrcweir basegfx::B2DPolygon aInnerPoly;
418cdf0e10cSrcweir
419cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
420cdf0e10cSrcweir
421cdf0e10cSrcweir const basegfx::B2DPoint aCenterBottom(rRectangle.Center().X(), rRectangle.Bottom());
422cdf0e10cSrcweir aInnerPoly.appendBezierSegment(
423cdf0e10cSrcweir aCenterBottom,
424cdf0e10cSrcweir aCenterBottom,
425cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
426cdf0e10cSrcweir
427cdf0e10cSrcweir const basegfx::B2DPoint aCenterTop(rRectangle.Center().X(), rRectangle.Top());
428cdf0e10cSrcweir aInnerPoly.appendBezierSegment(
429cdf0e10cSrcweir aCenterTop,
430cdf0e10cSrcweir aCenterTop,
431cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
432cdf0e10cSrcweir
433cdf0e10cSrcweir aPoly.append(aInnerPoly);
434cdf0e10cSrcweir break;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir case SID_DRAW_FREELINE:
437cdf0e10cSrcweir case SID_DRAW_FREELINE_NOFILL:
438cdf0e10cSrcweir {
439cdf0e10cSrcweir basegfx::B2DPolygon aInnerPoly;
440cdf0e10cSrcweir
441cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
442cdf0e10cSrcweir
443cdf0e10cSrcweir aInnerPoly.appendBezierSegment(
444cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()),
445cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()),
446cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
447cdf0e10cSrcweir
448cdf0e10cSrcweir aInnerPoly.appendBezierSegment(
449cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()),
450cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()),
451cdf0e10cSrcweir basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
452cdf0e10cSrcweir
453cdf0e10cSrcweir if(SID_DRAW_FREELINE == nID)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()));
456cdf0e10cSrcweir }
457cdf0e10cSrcweir else
458cdf0e10cSrcweir {
459cdf0e10cSrcweir aInnerPoly.setClosed(true);
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
462cdf0e10cSrcweir aPoly.append(aInnerPoly);
463cdf0e10cSrcweir break;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir case SID_DRAW_XPOLYGON:
466cdf0e10cSrcweir case SID_DRAW_XPOLYGON_NOFILL:
467cdf0e10cSrcweir {
468cdf0e10cSrcweir basegfx::B2DPolygon aInnerPoly;
469cdf0e10cSrcweir
470cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
471cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()));
472cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()));
473cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
474cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Center().Y()));
475cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()));
476cdf0e10cSrcweir
477cdf0e10cSrcweir if(SID_DRAW_XPOLYGON_NOFILL == nID)
478cdf0e10cSrcweir {
479cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()));
480cdf0e10cSrcweir }
481cdf0e10cSrcweir else
482cdf0e10cSrcweir {
483cdf0e10cSrcweir aInnerPoly.setClosed(true);
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
486cdf0e10cSrcweir aPoly.append(aInnerPoly);
487cdf0e10cSrcweir break;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir case SID_DRAW_POLYGON:
490cdf0e10cSrcweir case SID_DRAW_POLYGON_NOFILL:
491cdf0e10cSrcweir {
492cdf0e10cSrcweir basegfx::B2DPolygon aInnerPoly;
493cdf0e10cSrcweir const sal_Int32 nWdt(rRectangle.GetWidth());
494cdf0e10cSrcweir const sal_Int32 nHgt(rRectangle.GetHeight());
495cdf0e10cSrcweir
496cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
497cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 30) / 100, rRectangle.Top() + (nHgt * 70) / 100));
498cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top() + (nHgt * 15) / 100));
499cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 65) / 100, rRectangle.Top()));
500cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + nWdt, rRectangle.Top() + (nHgt * 30) / 100));
501cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 50) / 100));
502cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 75) / 100));
503cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Bottom(), rRectangle.Right()));
504cdf0e10cSrcweir
505cdf0e10cSrcweir if(SID_DRAW_POLYGON_NOFILL == nID)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()));
508cdf0e10cSrcweir }
509cdf0e10cSrcweir else
510cdf0e10cSrcweir {
511cdf0e10cSrcweir aInnerPoly.setClosed(true);
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
514cdf0e10cSrcweir aPoly.append(aInnerPoly);
515cdf0e10cSrcweir break;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
519cdf0e10cSrcweir ((SdrPathObj*)pObj)->SetPathPoly(aPoly);
520cdf0e10cSrcweir }
521cdf0e10cSrcweir else
522cdf0e10cSrcweir {
523cdf0e10cSrcweir DBG_ERROR("Object is NO path object");
524cdf0e10cSrcweir }
525cdf0e10cSrcweir
526cdf0e10cSrcweir pObj->SetLogicRect(rRectangle);
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
529cdf0e10cSrcweir return pObj;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir } // end of namespace sd
533cdf0e10cSrcweir
534cdf0e10cSrcweir // eof
535