Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <com/sun/star/util/XChangesNotifier.hpp>
21 :
22 : #include <basegfx/matrix/b2dhommatrix.hxx>
23 : #include <basegfx/polygon/b2dpolygontools.hxx>
24 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
25 :
26 : #include <sfx2/viewfrm.hxx>
27 : #include <sfx2/dispatch.hxx>
28 :
29 : #include <svx/sdr/overlay/overlaymanager.hxx>
30 : #include <svx/sdr/overlay/overlaypolypolygon.hxx>
31 : #include <svx/svdpagv.hxx>
32 : #include <svx/sdrpagewindow.hxx>
33 : #include <svx/sdrpaintwindow.hxx>
34 : #include <svx/svdopath.hxx>
35 : #include <svx/xlndsit.hxx>
36 : #include <svx/xlnclit.hxx>
37 : #include <svx/xlnstit.hxx>
38 : #include <svx/xlnedit.hxx>
39 : #include <svx/xlnstwit.hxx>
40 : #include <svx/xlnedwit.hxx>
41 : #include <svx/xlnstcit.hxx>
42 : #include <svx/xlnedcit.hxx>
43 : #include <svx/xlntrit.hxx>
44 : #include <svx/svxids.hrc>
45 : #include <svx/polypolygoneditor.hxx>
46 : #include <svx/svddrgmt.hxx>
47 :
48 : #include "CustomAnimationPane.hxx"
49 : #include "View.hxx"
50 : #include "motionpathtag.hxx"
51 : #include "sdpage.hxx"
52 : #include "ViewShell.hxx"
53 : #include "app.hrc"
54 : #include "Window.hxx"
55 :
56 : #include <svx/sdr/contact/viewcontact.hxx>
57 : #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
58 :
59 : using ::rtl::OUString;
60 : using ::sdr::PolyPolygonEditor;
61 : using namespace ::com::sun::star::uno;
62 : using namespace ::com::sun::star::lang;
63 : using namespace ::com::sun::star::util;
64 : using namespace ::com::sun::star::drawing;
65 :
66 : namespace sd
67 : {
68 :
69 : const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
70 : static const int DRGPIX = 2; // Drag MinMove in Pixel
71 :
72 : // --------------------------------------------------------------------
73 :
74 0 : class PathDragMove : public SdrDragMove
75 : {
76 : private:
77 : basegfx::B2DPolyPolygon maPathPolyPolygon;
78 :
79 : protected:
80 : virtual void createSdrDragEntries();
81 :
82 : public:
83 0 : PathDragMove(SdrDragView& rNewView,
84 : const rtl::Reference <MotionPathTag >& xTag,
85 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
86 : : SdrDragMove(rNewView),
87 : maPathPolyPolygon(rPathPolyPolygon),
88 0 : mxTag( xTag )
89 0 : {}
90 :
91 0 : PathDragMove(SdrDragView& rNewView,
92 : const rtl::Reference <MotionPathTag >& xTag)
93 : : SdrDragMove(rNewView),
94 : maPathPolyPolygon(),
95 0 : mxTag( xTag )
96 0 : {}
97 :
98 : virtual bool BeginSdrDrag();
99 : virtual bool EndSdrDrag(bool bCopy);
100 :
101 : rtl::Reference <MotionPathTag > mxTag;
102 : };
103 :
104 0 : void PathDragMove::createSdrDragEntries()
105 : {
106 : // call parent
107 0 : SdrDragMove::createSdrDragEntries();
108 :
109 0 : if(maPathPolyPolygon.count())
110 : {
111 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
112 : }
113 0 : }
114 :
115 0 : bool PathDragMove::BeginSdrDrag()
116 : {
117 0 : if( mxTag.is() )
118 : {
119 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
120 0 : if( pPathObj )
121 : {
122 0 : DragStat().SetActionRect(pPathObj->GetCurrentBoundRect());
123 : }
124 : }
125 0 : Show();
126 0 : return sal_True;
127 : }
128 :
129 0 : bool PathDragMove::EndSdrDrag(bool /*bCopy*/)
130 : {
131 0 : Hide();
132 0 : if( mxTag.is() )
133 0 : mxTag->MovePath( DragStat().GetDX(), DragStat().GetDY() );
134 0 : return sal_True;
135 : }
136 : // --------------------------------------------------------------------
137 :
138 0 : class PathDragResize : public SdrDragResize
139 : {
140 : private:
141 : basegfx::B2DPolyPolygon maPathPolyPolygon;
142 :
143 : protected:
144 : virtual void createSdrDragEntries();
145 :
146 : public:
147 0 : PathDragResize(SdrDragView& rNewView,
148 : const rtl::Reference <MotionPathTag >& xTag,
149 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
150 : : SdrDragResize(rNewView),
151 : maPathPolyPolygon(rPathPolyPolygon),
152 0 : mxTag( xTag )
153 0 : {}
154 :
155 0 : PathDragResize(SdrDragView& rNewView,
156 : const rtl::Reference <MotionPathTag >& xTag)
157 : : SdrDragResize(rNewView),
158 : maPathPolyPolygon(),
159 0 : mxTag( xTag )
160 0 : {}
161 :
162 : virtual bool EndSdrDrag(bool bCopy);
163 : rtl::Reference <MotionPathTag > mxTag;
164 : };
165 :
166 0 : void PathDragResize::createSdrDragEntries()
167 : {
168 : // call parent
169 0 : SdrDragResize::createSdrDragEntries();
170 :
171 0 : if(maPathPolyPolygon.count())
172 : {
173 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
174 : }
175 0 : }
176 :
177 0 : bool PathDragResize::EndSdrDrag(bool /*bCopy*/)
178 : {
179 0 : Hide();
180 0 : if( mxTag.is() )
181 : {
182 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
183 0 : if( pPathObj )
184 : {
185 0 : const Point aRef( DragStat().Ref1() );
186 0 : basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aRef.X(), -aRef.Y()));
187 0 : aTrans.scale(double(aXFact), double(aYFact));
188 0 : aTrans.translate(aRef.X(), aRef.Y());
189 0 : basegfx::B2DPolyPolygon aDragPoly(pPathObj->GetPathPoly());
190 0 : aDragPoly.transform(aTrans);
191 0 : pPathObj->SetPathPoly( aDragPoly );
192 : }
193 : }
194 0 : return sal_True;
195 : }
196 :
197 : // --------------------------------------------------------------------
198 :
199 0 : class PathDragObjOwn : public SdrDragObjOwn
200 : {
201 : private:
202 : basegfx::B2DPolyPolygon maPathPolyPolygon;
203 :
204 : protected:
205 : virtual void createSdrDragEntries();
206 :
207 : public:
208 0 : PathDragObjOwn(SdrDragView& rNewView,
209 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
210 : : SdrDragObjOwn(rNewView),
211 0 : maPathPolyPolygon(rPathPolyPolygon)
212 0 : {}
213 :
214 0 : PathDragObjOwn(SdrDragView& rNewView)
215 : : SdrDragObjOwn(rNewView),
216 0 : maPathPolyPolygon()
217 0 : {}
218 :
219 : virtual bool EndSdrDrag(bool bCopy);
220 : };
221 :
222 0 : void PathDragObjOwn::createSdrDragEntries()
223 : {
224 : // call parent
225 0 : SdrDragObjOwn::createSdrDragEntries();
226 :
227 0 : if(maPathPolyPolygon.count())
228 : {
229 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
230 : }
231 0 : }
232 :
233 0 : bool PathDragObjOwn::EndSdrDrag(bool /*bCopy*/)
234 : {
235 0 : Hide();
236 :
237 0 : SdrObject* pObj = GetDragObj();
238 :
239 0 : if(pObj)
240 : {
241 0 : return pObj->applySpecialDrag(DragStat());
242 : }
243 : else
244 : {
245 0 : return false;
246 : }
247 : }
248 :
249 : // --------------------------------------------------------------------
250 :
251 : class SdPathHdl : public SmartHdl
252 : {
253 : public:
254 : SdPathHdl( const SmartTagReference& xTag, SdrPathObj* mpPathObj );
255 : virtual ~SdPathHdl();
256 : virtual void CreateB2dIAObject();
257 : virtual sal_Bool IsFocusHdl() const;
258 : virtual Pointer GetSdrDragPointer() const;
259 : virtual bool isMarkable() const;
260 :
261 : private:
262 : SdrPathObj* mpPathObj;
263 : rtl::Reference< MotionPathTag > mxTag;
264 : };
265 :
266 : // --------------------------------------------------------------------
267 :
268 0 : SdPathHdl::SdPathHdl( const SmartTagReference& xTag, SdrPathObj* pPathObj )
269 0 : : SmartHdl( xTag, pPathObj->GetCurrentBoundRect().TopLeft() )
270 : , mpPathObj( pPathObj )
271 0 : , mxTag( dynamic_cast< MotionPathTag* >( xTag.get() ) )
272 : {
273 0 : }
274 :
275 : // --------------------------------------------------------------------
276 :
277 0 : SdPathHdl::~SdPathHdl()
278 : {
279 0 : }
280 :
281 : // --------------------------------------------------------------------
282 :
283 0 : void SdPathHdl::CreateB2dIAObject()
284 : {
285 : // first throw away old one
286 0 : GetRidOfIAObject();
287 :
288 0 : if(pHdlList)
289 : {
290 0 : SdrMarkView* pView = pHdlList->GetView();
291 :
292 0 : if(pView && !pView->areMarkHandlesHidden())
293 : {
294 0 : SdrPageView* pPageView = pView->GetSdrPageView();
295 :
296 0 : if(pPageView)
297 : {
298 0 : for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
299 : {
300 0 : const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
301 :
302 0 : if(rPageWindow.GetPaintWindow().OutputToWindow())
303 : {
304 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
305 0 : if (xManager.is() && mpPathObj)
306 : {
307 0 : const sdr::contact::ViewContact& rVC = mpPathObj->GetViewContact();
308 0 : const drawinglayer::primitive2d::Primitive2DSequence aSequence = rVC.getViewIndependentPrimitive2DSequence();
309 0 : sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
310 :
311 0 : xManager->add(*pNew);
312 0 : maOverlayGroup.append(*pNew);
313 0 : }
314 : }
315 : }
316 : }
317 : }
318 : }
319 0 : }
320 :
321 : // --------------------------------------------------------------------
322 :
323 0 : sal_Bool SdPathHdl::IsFocusHdl() const
324 : {
325 0 : return sal_False;
326 : }
327 :
328 : // --------------------------------------------------------------------
329 :
330 0 : bool SdPathHdl::isMarkable() const
331 : {
332 0 : return false;
333 : }
334 :
335 : // --------------------------------------------------------------------
336 :
337 0 : Pointer SdPathHdl::GetSdrDragPointer() const
338 : {
339 0 : PointerStyle eStyle = POINTER_NOTALLOWED;
340 0 : if( mxTag.is() )
341 : {
342 0 : if( mxTag->isSelected() )
343 : {
344 0 : if( !mxTag->getView().IsFrameDragSingles() && mxTag->getView().IsInsObjPointMode() )
345 0 : eStyle = POINTER_CROSS;
346 : else
347 0 : eStyle = POINTER_MOVE;
348 : }
349 : else
350 : {
351 0 : eStyle = POINTER_ARROW;
352 :
353 : }
354 : }
355 0 : return Pointer( eStyle );
356 : }
357 :
358 : // ====================================================================
359 :
360 0 : MotionPathTag::MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, const CustomAnimationEffectPtr& pEffect )
361 : : SmartTag( rView )
362 : , mrPane( rPane )
363 : , mpEffect( pEffect )
364 : , mxOrigin( pEffect->getTargetShape() )
365 : , msLastPath( pEffect->getPath() )
366 0 : , mbInUpdatePath( false )
367 : {
368 0 : mpPathObj = mpEffect->createSdrPathObjFromPath();
369 0 : mxPolyPoly = mpPathObj->GetPathPoly();
370 0 : maOriginPos = mxOrigin->getPosition();
371 :
372 0 : SdrPage* pPage = mrView.GetSdrPageView()->GetPage();
373 0 : if( pPage )
374 : {
375 0 : mpPathObj->SetPage( pPage );
376 0 : mpPathObj->SetObjList( pPage );
377 : }
378 :
379 0 : XDash aDash( XDASH_RECT, 1, 80, 1, 80, 80);
380 0 : rtl::OUString aEmpty( "?" );
381 0 : mpPathObj->SetMergedItem( XLineDashItem( aEmpty, aDash ) );
382 0 : mpPathObj->SetMergedItem( XLineStyleItem( XLINE_DASH ) );
383 0 : mpPathObj->SetMergedItem( XLineColorItem(aEmpty, ::Color(COL_GRAY)) );
384 0 : mpPathObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
385 :
386 0 : ::basegfx::B2DPolygon aStartArrow;
387 0 : aStartArrow.append(::basegfx::B2DPoint(20.0, 0.0));
388 0 : aStartArrow.append(::basegfx::B2DPoint(0.0, 0.0));
389 0 : aStartArrow.append(::basegfx::B2DPoint(10.0, 30.0));
390 0 : aStartArrow.setClosed(true);
391 0 : mpPathObj->SetMergedItem(XLineStartItem(aEmpty,::basegfx::B2DPolyPolygon(aStartArrow)));
392 0 : mpPathObj->SetMergedItem(XLineStartWidthItem(400));
393 0 : mpPathObj->SetMergedItem(XLineStartCenterItem(sal_True));
394 :
395 0 : updatePathAttributes();
396 :
397 0 : mpPathObj->SetMergedItem(XLineTransparenceItem(50));
398 :
399 0 : mpMark = new SdrMark( mpPathObj, mrView.GetSdrPageView() );
400 :
401 0 : mpPathObj->AddListener( *this );
402 :
403 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
404 0 : if( xNotifier.is() )
405 : {
406 0 : Reference< XChangesListener > xListener( this );
407 0 : xNotifier->addChangesListener( this );
408 0 : }
409 0 : }
410 :
411 : // --------------------------------------------------------------------
412 :
413 0 : MotionPathTag::~MotionPathTag()
414 : {
415 : DBG_ASSERT( mpPathObj == 0, "sd::MotionPathTag::~MotionPathTag(), dispose me first!" );
416 0 : Dispose();
417 0 : }
418 :
419 : // --------------------------------------------------------------------
420 :
421 0 : void MotionPathTag::updatePathAttributes()
422 : {
423 0 : rtl::OUString aEmpty( "?" );
424 :
425 0 : ::basegfx::B2DPolygon aCandidate;
426 0 : if( mxPolyPoly.count() )
427 : {
428 0 : aCandidate = mxPolyPoly.getB2DPolygon(0);
429 0 : ::basegfx::tools::checkClosed( aCandidate );
430 : }
431 :
432 0 : if( !aCandidate.isClosed() )
433 : {
434 0 : ::basegfx::B2DPolygon aEndArrow;
435 0 : aEndArrow.append(::basegfx::B2DPoint(10.0, 0.0));
436 0 : aEndArrow.append(::basegfx::B2DPoint(0.0, 30.0));
437 0 : aEndArrow.append(::basegfx::B2DPoint(20.0, 30.0));
438 0 : aEndArrow.setClosed(true);
439 0 : mpPathObj->SetMergedItem(XLineEndItem(aEmpty,::basegfx::B2DPolyPolygon(aEndArrow)));
440 0 : mpPathObj->SetMergedItem(XLineEndWidthItem(400));
441 0 : mpPathObj->SetMergedItem(XLineEndCenterItem(sal_True));
442 : }
443 : else
444 : {
445 0 : mpPathObj->SetMergedItem(XLineEndItem());
446 0 : }
447 0 : }
448 :
449 : // --------------------------------------------------------------------
450 :
451 0 : void MotionPathTag::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
452 : {
453 0 : if( mpPathObj && !mbInUpdatePath && dynamic_cast< const SdrHint* >( &rHint ) && (mpEffect.get() != 0) )
454 : {
455 0 : if( mxPolyPoly != mpPathObj->GetPathPoly() )
456 : {
457 0 : mbInUpdatePath = true;
458 0 : mxPolyPoly = mpPathObj->GetPathPoly();
459 0 : rtl::Reference< MotionPathTag > xTag( this );
460 0 : mrPane.updatePathFromMotionPathTag( xTag );
461 0 : msLastPath = mpEffect->getPath();
462 0 : updatePathAttributes();
463 0 : mbInUpdatePath = false;
464 : }
465 : }
466 0 : }
467 :
468 : // --------------------------------------------------------------------
469 :
470 0 : void MotionPathTag::MovePath( int nDX, int nDY )
471 : {
472 0 : if( mpPathObj )
473 : {
474 0 : mpPathObj->Move( Size( nDX, nDY ) );
475 0 : mrView.updateHandles();
476 : }
477 0 : }
478 :
479 : // --------------------------------------------------------------------
480 :
481 : /** returns true if the MotionPathTag handled the event. */
482 0 : bool MotionPathTag::MouseButtonDown( const MouseEvent& rMEvt, SmartHdl& rHdl )
483 : {
484 0 : if( !mpPathObj )
485 0 : return false;
486 :
487 0 : if( !isSelected() )
488 : {
489 0 : SmartTagReference xTag( this );
490 0 : mrView.getSmartTags().select( xTag );
491 0 : selectionChanged();
492 0 : return true;
493 : }
494 : else
495 : {
496 0 : if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
497 : {
498 0 : mrView.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_EDIT, SFX_CALLMODE_ASYNCHRON);
499 0 : return true;
500 : }
501 0 : else if( rMEvt.IsLeft() )
502 : {
503 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
504 0 : Point aMDPos( pOut->PixelToLogic( rMEvt.GetPosPixel() ) );
505 :
506 0 : if( !mrView.IsFrameDragSingles() && mrView.IsInsObjPointMode() && (rHdl.GetObjHdlNum() == SMART_TAG_HDL_NUM) )
507 : {
508 : // insert a point in edit mode
509 0 : const bool bNewObj = rMEvt.IsMod1();
510 :
511 0 : mrView.BrkAction();
512 :
513 0 : Point aPt(aMDPos); // - pMarkedPV->GetOffset());
514 :
515 0 : if(bNewObj)
516 0 : aPt = mrView.GetSnapPos(aPt,mrView.GetSdrPageView());
517 :
518 0 : bool bClosed0(mpPathObj->IsClosedObj());
519 :
520 0 : sal_uInt32 nInsPointNum = mpPathObj->NbcInsPointOld(aPt, bNewObj, sal_True);
521 :
522 0 : if(bClosed0 != mpPathObj->IsClosedObj())
523 : {
524 : // Obj was closed implicit
525 : // object changed
526 0 : mpPathObj->SetChanged();
527 0 : mpPathObj->BroadcastObjectChange();
528 : }
529 :
530 0 : if(0xffffffff != nInsPointNum)
531 : {
532 0 : mrView.UnmarkAllPoints();
533 0 : mrView.updateHandles();
534 :
535 0 : bool bRet = mrView.BegDragObj(aMDPos, pOut, mrView.GetHdl(nInsPointNum+1), 0, new PathDragObjOwn( mrView ) );
536 :
537 0 : if (bRet)
538 : {
539 0 : const_cast< SdrDragStat* >( &mrView.GetDragStat() )->SetMinMoved();
540 0 : mrView.MovDragObj(aMDPos);
541 : }
542 : }
543 0 : return true;
544 : }
545 : else
546 : {
547 0 : SmartHdl* pHdl = &rHdl;
548 0 : if (!mrView.IsPointMarked(*pHdl) || rMEvt.IsShift())
549 : {
550 0 : if (!rMEvt.IsShift())
551 : {
552 0 : mrView.UnmarkAllPoints();
553 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
554 : }
555 : else
556 : {
557 0 : if (mrView.IsPointMarked(*pHdl) )
558 : {
559 0 : mrView.UnmarkPoint(*pHdl);
560 0 : pHdl = NULL;
561 : }
562 : else
563 : {
564 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
565 : }
566 : }
567 :
568 0 : if (pHdl)
569 0 : mrView.MarkPoint(*pHdl);
570 : }
571 :
572 :
573 0 : if( pHdl && !rMEvt.IsRight() )
574 : {
575 0 : mrView.BrkAction();
576 0 : const sal_uInt16 nDrgLog = (sal_uInt16)pOut->PixelToLogic(Size(DRGPIX,0)).Width();
577 :
578 0 : rtl::Reference< MotionPathTag > xTag( this );
579 : SdrDragMethod* pDragMethod;
580 :
581 : // #i95646# add DragPoly as geometry to each local SdrDragMethod to be able
582 : // to create the needed local SdrDragEntry for it in createSdrDragEntries()
583 0 : const basegfx::B2DPolyPolygon aDragPoly(mpPathObj->GetPathPoly());
584 :
585 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
586 : {
587 0 : pDragMethod = new PathDragMove( mrView, xTag, aDragPoly );
588 0 : pHdl->SetPos( aMDPos );
589 : }
590 0 : else if( pHdl->GetKind() == HDL_POLY )
591 : {
592 0 : pDragMethod = new PathDragObjOwn( mrView, aDragPoly );
593 : }
594 : else
595 : {
596 0 : pDragMethod = new PathDragResize( mrView, xTag, aDragPoly );
597 : }
598 :
599 0 : mrView.BegDragObj(aMDPos, NULL, pHdl, nDrgLog, pDragMethod );
600 : }
601 0 : return true;
602 : }
603 : }
604 : }
605 :
606 0 : return false;
607 : }
608 :
609 : // --------------------------------------------------------------------
610 :
611 : /** returns true if the SmartTag consumes this event. */
612 0 : bool MotionPathTag::KeyInput( const KeyEvent& rKEvt )
613 : {
614 0 : if( !mpPathObj )
615 0 : return false;
616 :
617 0 : sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
618 0 : switch( nCode )
619 : {
620 : case KEY_DELETE:
621 0 : return OnDelete();
622 :
623 : case KEY_DOWN:
624 : case KEY_UP:
625 : case KEY_LEFT:
626 : case KEY_RIGHT:
627 0 : return OnMove( rKEvt );
628 :
629 : case KEY_ESCAPE:
630 : {
631 0 : SmartTagReference xThis( this );
632 0 : mrView.getSmartTags().deselect();
633 0 : return true;
634 : }
635 :
636 : case KEY_TAB:
637 0 : return OnTabHandles( rKEvt );
638 :
639 : case KEY_SPACE:
640 0 : return OnMarkHandle( rKEvt );
641 :
642 : default:
643 0 : break;
644 : }
645 0 : return false;
646 : }
647 :
648 0 : bool MotionPathTag::OnDelete()
649 : {
650 0 : mrPane.remove( mpEffect );
651 0 : return true;
652 : }
653 :
654 0 : bool MotionPathTag::OnTabHandles( const KeyEvent& rKEvt )
655 : {
656 0 : if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
657 : {
658 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
659 0 : sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
660 :
661 0 : ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
662 :
663 : // guarantee visibility of focused handle
664 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
665 :
666 0 : if(pHdl)
667 : {
668 0 : Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
669 0 : if( pWindow )
670 : {
671 0 : Point aHdlPosition(pHdl->GetPos());
672 0 : Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
673 0 : mrView.MakeVisible(aVisRect, *pWindow);
674 : }
675 : }
676 :
677 0 : return true;
678 : }
679 :
680 0 : return false;
681 : }
682 :
683 0 : bool MotionPathTag::OnMarkHandle( const KeyEvent& rKEvt )
684 : {
685 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
686 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
687 :
688 0 : if(pHdl && pHdl->GetKind() == HDL_POLY )
689 : {
690 : // rescue ID of point with focus
691 0 : sal_uInt32 nPol(pHdl->GetPolyNum());
692 0 : sal_uInt32 nPnt(pHdl->GetPointNum());
693 :
694 0 : if(mrView.IsPointMarked(*pHdl))
695 : {
696 0 : if(rKEvt.GetKeyCode().IsShift())
697 : {
698 0 : mrView.UnmarkPoint(*pHdl);
699 : }
700 : }
701 : else
702 : {
703 0 : if(!rKEvt.GetKeyCode().IsShift())
704 : {
705 0 : mrView.UnmarkAllPoints();
706 : }
707 0 : mrView.MarkPoint(*pHdl);
708 : }
709 :
710 0 : if(0L == rHdlList.GetFocusHdl())
711 : {
712 : // restore point with focus
713 0 : SdrHdl* pNewOne = 0L;
714 :
715 0 : for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
716 : {
717 0 : SdrHdl* pAct = rHdlList.GetHdl(a);
718 :
719 0 : if(pAct && pAct->GetKind() == HDL_POLY && pAct->GetPolyNum() == nPol && pAct->GetPointNum() == nPnt)
720 0 : pNewOne = pAct;
721 : }
722 :
723 0 : if(pNewOne)
724 0 : ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
725 : }
726 : }
727 :
728 0 : return true;
729 : }
730 :
731 0 : bool MotionPathTag::OnMove( const KeyEvent& rKEvt )
732 : {
733 0 : long nX = 0;
734 0 : long nY = 0;
735 :
736 0 : switch( rKEvt.GetKeyCode().GetCode() )
737 : {
738 0 : case KEY_UP: nY = -1; break;
739 0 : case KEY_DOWN: nY = 1; break;
740 0 : case KEY_LEFT: nX = -1; break;
741 0 : case KEY_RIGHT: nX = 1; break;
742 0 : default: break;
743 : }
744 :
745 0 : if(rKEvt.GetKeyCode().IsMod2())
746 : {
747 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
748 0 : Size aLogicSizeOnePixel = (pOut) ? pOut->PixelToLogic(Size(1,1)) : Size(100, 100);
749 0 : nX *= aLogicSizeOnePixel.Width();
750 0 : nY *= aLogicSizeOnePixel.Height();
751 : }
752 : else
753 : {
754 : // old, fixed move distance
755 0 : nX *= 100;
756 0 : nY *= 100;
757 : }
758 :
759 0 : if( nX || nY )
760 : {
761 : // in point edit mode move the handle with the focus
762 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
763 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
764 :
765 0 : if(pHdl)
766 : {
767 : // now move the Handle (nX, nY)
768 0 : Point aStartPoint(pHdl->GetPos());
769 0 : Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
770 :
771 : // start dragging
772 0 : rtl::Reference< MotionPathTag > xTag( this );
773 0 : SdrDragMethod* pDragMethod = 0;
774 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
775 : {
776 0 : pDragMethod = new PathDragMove( mrView, xTag );
777 : }
778 0 : else if( pHdl->GetKind() == HDL_POLY )
779 : {
780 0 : pDragMethod = new PathDragObjOwn( mrView );
781 : }
782 0 : else if( pHdl->GetKind() != HDL_BWGT )
783 : {
784 0 : pDragMethod = new PathDragResize( mrView, xTag );
785 : }
786 0 : mrView.BegDragObj(aStartPoint, 0, pHdl, 0, pDragMethod);
787 :
788 0 : if(mrView.IsDragObj())
789 : {
790 0 : bool bWasNoSnap = mrView.GetDragStat().IsNoSnap();
791 0 : sal_Bool bWasSnapEnabled = mrView.IsSnapEnabled();
792 :
793 : // switch snapping off
794 0 : if(!bWasNoSnap)
795 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(sal_True);
796 0 : if(bWasSnapEnabled)
797 0 : mrView.SetSnapEnabled(sal_False);
798 :
799 0 : mrView.MovAction(aEndPoint);
800 0 : mrView.EndDragObj();
801 :
802 : // restore snap
803 0 : if(!bWasNoSnap)
804 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(bWasNoSnap);
805 0 : if(bWasSnapEnabled)
806 0 : mrView.SetSnapEnabled(bWasSnapEnabled);
807 0 : }
808 : }
809 : else
810 : {
811 : // move the path
812 0 : MovePath( nX, nY );
813 : }
814 : }
815 :
816 0 : return true;
817 : }
818 :
819 : // --------------------------------------------------------------------
820 :
821 0 : sal_uLong MotionPathTag::GetMarkablePointCount() const
822 : {
823 0 : if( mpPathObj && isSelected() )
824 : {
825 0 : return mpPathObj->GetPointCount();
826 : }
827 : else
828 : {
829 0 : return 0;
830 : }
831 : }
832 :
833 : // --------------------------------------------------------------------
834 :
835 0 : sal_uLong MotionPathTag::GetMarkedPointCount() const
836 : {
837 0 : if( mpMark )
838 : {
839 0 : const SdrUShortCont* pPts=mpMark->GetMarkedPoints();
840 0 : return pPts ? pPts->size() : 0;
841 : }
842 : else
843 : {
844 0 : return 0;
845 : }
846 : }
847 :
848 : // --------------------------------------------------------------------
849 :
850 0 : sal_Bool MotionPathTag::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
851 : {
852 0 : sal_Bool bRet=sal_False;
853 0 : if( mpPathObj && mrView.IsPointMarkable( rHdl ) && (rHdl.GetKind() != HDL_SMARTTAG) )
854 : {
855 0 : SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( &rHdl );
856 0 : if( pSmartHdl && pSmartHdl->getTag().get() == this )
857 : {
858 0 : mpMark->ForceMarkedPoints();
859 0 : if (mrView.MarkPointHelper(&rHdl,mpMark,bUnmark))
860 : {
861 0 : mrView.MarkListHasChanged();
862 0 : bRet=sal_True;
863 : }
864 : }
865 : }
866 0 : return bRet;
867 : }
868 :
869 : // --------------------------------------------------------------------
870 :
871 0 : sal_Bool MotionPathTag::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark )
872 : {
873 0 : sal_Bool bChgd=sal_False;
874 :
875 0 : if( mpPathObj && isSelected() )
876 : {
877 0 : sal_Int32 nHdlNum = mrView.GetHdlList().GetHdlCount() - 1;
878 0 : while( nHdlNum > 0 )
879 : {
880 0 : SmartHdl* pHdl = dynamic_cast< SmartHdl* >( mrView.GetHdl( sal::static_int_cast< sal_uLong >( nHdlNum-- ) ) );
881 :
882 0 : if( pHdl && (pHdl->getTag().get() == this) && mrView.IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark)
883 : {
884 0 : Point aPos(pHdl->GetPos());
885 0 : if( pRect==NULL || pRect->IsInside(aPos))
886 : {
887 0 : if( mrView.MarkPointHelper(pHdl,mpMark,bUnmark) )
888 0 : bChgd=sal_True;
889 : }
890 : }
891 : }
892 :
893 0 : if(bChgd)
894 0 : mrView.MarkListHasChanged();
895 : }
896 :
897 0 : return bChgd;
898 : }
899 :
900 : // --------------------------------------------------------------------
901 :
902 0 : bool MotionPathTag::getContext( SdrViewContext& rContext )
903 : {
904 0 : if( mpPathObj && isSelected() && !mrView.IsFrameDragSingles() )
905 : {
906 0 : rContext = SDRCONTEXT_POINTEDIT;
907 0 : return true;
908 : }
909 : else
910 : {
911 0 : return false;
912 : }
913 : }
914 :
915 : // --------------------------------------------------------------------
916 :
917 0 : void MotionPathTag::CheckPossibilities()
918 : {
919 0 : if( mpPathObj )
920 : {
921 0 : if( isSelected() )
922 : {
923 0 : mrView.SetMoveAllowed( true );
924 0 : mrView.SetMoveProtected( false );
925 0 : mrView.SetResizeFreeAllowed( true );
926 0 : mrView.SetResizePropAllowed( true );
927 0 : mrView.SetResizeProtected( false );
928 :
929 0 : if( !mrView.IsFrameDragSingles() )
930 : {
931 0 : bool b1stSmooth(true);
932 0 : bool b1stSegm(true);
933 0 : bool bCurve(false);
934 0 : bool bSmoothFuz(false);
935 0 : bool bSegmFuz(false);
936 0 : basegfx::B2VectorContinuity eSmooth = basegfx::CONTINUITY_NONE;
937 :
938 0 : mrView.CheckPolyPossibilitiesHelper( mpMark, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
939 : }
940 : }
941 : }
942 0 : }
943 :
944 : // --------------------------------------------------------------------
945 :
946 0 : void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
947 : {
948 0 : if( mpPathObj )
949 : {
950 0 : ::com::sun::star::awt::Point aPos( mxOrigin->getPosition() );
951 0 : if( (aPos.X != maOriginPos.X) || (aPos.Y != maOriginPos.Y) )
952 : {
953 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
954 0 : aPos.X - maOriginPos.X, aPos.Y - maOriginPos.Y));
955 0 : mxPolyPoly.transform( aTransform );
956 0 : mpPathObj->SetPathPoly( mxPolyPoly );
957 0 : maOriginPos = aPos;
958 : }
959 :
960 0 : SmartTagReference xThis( this );
961 0 : SdPathHdl* pHdl = new SdPathHdl( xThis, mpPathObj );
962 0 : pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
963 0 : pHdl->SetPageView( mrView.GetSdrPageView() );
964 :
965 :
966 0 : pHdl->SetObj(mpPathObj);
967 0 : rHandlerList.AddHdl( pHdl );
968 :
969 0 : if( isSelected() )
970 : {
971 0 : mrView.GetSdrPageView()->SetHasMarkedObj(sal_True);
972 :
973 0 : if( !mrView.IsFrameDragSingles() )
974 : {
975 0 : SdrHdlList aTemp( rHandlerList.GetView() );
976 0 : mpPathObj->AddToHdlList( aTemp );
977 0 : const SdrUShortCont* pMrkPnts=mpMark->GetMarkedPoints();
978 :
979 : sal_uInt32 nHandle;
980 0 : for( nHandle = 0; nHandle < aTemp.GetHdlCount(); ++nHandle )
981 : {
982 0 : SdrHdl* pTempHdl = aTemp.GetHdl( nHandle );
983 :
984 0 : SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj, pTempHdl->GetPos(), pTempHdl->GetKind() );
985 0 : pSmartHdl->SetObjHdlNum( nHandle );
986 0 : pSmartHdl->SetPolyNum( pTempHdl->GetPolyNum() );
987 0 : pSmartHdl->SetPointNum( pTempHdl->GetPointNum() );
988 0 : pSmartHdl->SetPlusHdl( pTempHdl->IsPlusHdl() );
989 0 : pSmartHdl->SetSourceHdlNum( pTempHdl->GetSourceHdlNum() );
990 0 : pSmartHdl->SetPageView( mrView.GetSdrPageView() );
991 :
992 0 : rHandlerList.AddHdl( pSmartHdl );
993 :
994 0 : const bool bSelected= pMrkPnts && pMrkPnts->find( sal_uInt16(nHandle) ) != pMrkPnts->end();
995 0 : pSmartHdl->SetSelected(bSelected);
996 :
997 0 : if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
998 : {
999 0 : sal_uInt32 nPlusAnz=mpPathObj->GetPlusHdlCount(*pSmartHdl);
1000 0 : for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
1001 : {
1002 0 : SdrHdl* pPlusHdl = mpPathObj->GetPlusHdl(*pSmartHdl,nPlusNum);
1003 0 : if (pPlusHdl!=NULL)
1004 : {
1005 0 : pPlusHdl->SetObj(mpPathObj);
1006 0 : pPlusHdl->SetPageView(mrView.GetSdrPageView());
1007 0 : pPlusHdl->SetPlusHdl(sal_True);
1008 0 : rHandlerList.AddHdl(pPlusHdl);
1009 : }
1010 : }
1011 : }
1012 0 : }
1013 : }
1014 : else
1015 : {
1016 0 : Rectangle aRect(mpPathObj->GetCurrentBoundRect());
1017 :
1018 0 : if(!aRect.IsEmpty())
1019 : {
1020 0 : sal_uLong nCount = rHandlerList.GetHdlCount();
1021 :
1022 0 : sal_Bool bWdt0=aRect.Left()==aRect.Right();
1023 0 : sal_Bool bHgt0=aRect.Top()==aRect.Bottom();
1024 0 : if (bWdt0 && bHgt0)
1025 : {
1026 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft(),HDL_UPLFT));
1027 : }
1028 0 : else if (bWdt0 || bHgt0)
1029 : {
1030 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1031 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight(),HDL_LWRGT));
1032 : }
1033 : else
1034 : {
1035 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1036 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopCenter() ,HDL_UPPER));
1037 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopRight() ,HDL_UPRGT));
1038 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.LeftCenter() ,HDL_LEFT ));
1039 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.RightCenter() ,HDL_RIGHT));
1040 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomLeft() ,HDL_LWLFT));
1041 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomCenter(),HDL_LOWER));
1042 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight() ,HDL_LWRGT));
1043 : }
1044 :
1045 0 : while( nCount < rHandlerList.GetHdlCount() )
1046 : {
1047 0 : rHandlerList.GetHdl(nCount++)->SetPageView( mrView.GetSdrPageView() );
1048 : }
1049 : }
1050 : }
1051 0 : }
1052 : }
1053 0 : }
1054 :
1055 : // --------------------------------------------------------------------
1056 :
1057 0 : void MotionPathTag::disposing()
1058 : {
1059 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
1060 0 : if( xNotifier.is() )
1061 : {
1062 0 : Reference< XChangesListener > xListener( this );
1063 0 : xNotifier->removeChangesListener( this );
1064 : }
1065 :
1066 0 : if( mpPathObj )
1067 : {
1068 0 : SdrPathObj* pPathObj = mpPathObj;
1069 0 : mpPathObj = 0;
1070 0 : mrView.updateHandles();
1071 0 : delete pPathObj;
1072 : }
1073 :
1074 0 : if( mpMark )
1075 : {
1076 0 : delete mpMark;
1077 0 : mpMark = 0;
1078 : }
1079 :
1080 0 : SmartTag::disposing();
1081 0 : }
1082 :
1083 : // --------------------------------------------------------------------
1084 :
1085 0 : void MotionPathTag::deselect()
1086 : {
1087 0 : SmartTag::deselect();
1088 :
1089 0 : if( mpMark )
1090 : {
1091 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1092 :
1093 0 : if( pPts )
1094 0 : pPts->clear();
1095 : }
1096 :
1097 0 : selectionChanged();
1098 0 : }
1099 :
1100 0 : void MotionPathTag::selectionChanged()
1101 : {
1102 0 : if( mrView.GetViewShell() && mrView.GetViewShell()->GetViewFrame() )
1103 : {
1104 0 : SfxBindings& rBindings = mrView.GetViewShell()->GetViewFrame()->GetBindings();
1105 0 : rBindings.InvalidateAll(sal_True);
1106 : }
1107 0 : }
1108 : // --------------------------------------------------------------------
1109 : // IPolyPolygonEditorController
1110 : // --------------------------------------------------------------------
1111 :
1112 0 : void MotionPathTag::DeleteMarkedPoints()
1113 : {
1114 0 : if( mpPathObj && IsDeleteMarkedPointsPossible() )
1115 : {
1116 0 : mrView.BrkAction();
1117 :
1118 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1119 :
1120 0 : if( pPts )
1121 : {
1122 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1123 0 : if( aEditor.DeletePoints( *pPts ) )
1124 : {
1125 0 : if( aEditor.GetPolyPolygon().count() )
1126 : {
1127 0 : mpPathObj->SetPathPoly( aEditor.GetPolyPolygon() );
1128 : }
1129 :
1130 0 : mrView.UnmarkAllPoints();
1131 0 : mrView.MarkListHasChanged();
1132 0 : mrView.updateHandles();
1133 0 : }
1134 : }
1135 : }
1136 0 : }
1137 :
1138 0 : sal_Bool MotionPathTag::IsDeleteMarkedPointsPossible() const
1139 : {
1140 0 : return mpPathObj && isSelected() && (GetMarkedPointCount() != 0);
1141 : }
1142 :
1143 0 : void MotionPathTag::RipUpAtMarkedPoints()
1144 : {
1145 : // not supported for motion path
1146 0 : }
1147 :
1148 0 : bool MotionPathTag::IsRipUpAtMarkedPointsPossible() const
1149 : {
1150 : // not supported for motion path
1151 0 : return false;
1152 : }
1153 :
1154 0 : sal_Bool MotionPathTag::IsSetMarkedSegmentsKindPossible() const
1155 : {
1156 0 : if( mpPathObj )
1157 0 : return mrView.IsSetMarkedSegmentsKindPossible();
1158 : else
1159 0 : return sal_False;
1160 : }
1161 :
1162 0 : SdrPathSegmentKind MotionPathTag::GetMarkedSegmentsKind() const
1163 : {
1164 0 : if( mpPathObj )
1165 0 : return mrView.GetMarkedSegmentsKind();
1166 : else
1167 0 : return SDRPATHSEGMENT_LINE;
1168 : }
1169 :
1170 0 : void MotionPathTag::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
1171 : {
1172 0 : if(mpPathObj && isSelected() && (GetMarkedPointCount() != 0))
1173 : {
1174 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1175 0 : if(pPts)
1176 : {
1177 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1178 0 : if(aEditor.SetSegmentsKind( eKind, *pPts ) )
1179 : {
1180 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1181 0 : mrView.MarkListHasChanged();
1182 0 : mrView.updateHandles();
1183 0 : }
1184 : }
1185 : }
1186 0 : }
1187 :
1188 0 : sal_Bool MotionPathTag::IsSetMarkedPointsSmoothPossible() const
1189 : {
1190 0 : if( mpPathObj )
1191 0 : return mrView.IsSetMarkedPointsSmoothPossible();
1192 : else
1193 0 : return sal_False;
1194 : }
1195 :
1196 0 : SdrPathSmoothKind MotionPathTag::GetMarkedPointsSmooth() const
1197 : {
1198 0 : if( mpPathObj )
1199 0 : return mrView.GetMarkedPointsSmooth();
1200 : else
1201 0 : return SDRPATHSMOOTH_ANGULAR;
1202 : }
1203 :
1204 0 : void MotionPathTag::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
1205 : {
1206 : basegfx::B2VectorContinuity eFlags;
1207 :
1208 0 : if(SDRPATHSMOOTH_ANGULAR == eKind)
1209 : {
1210 0 : eFlags = basegfx::CONTINUITY_NONE;
1211 : }
1212 0 : else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
1213 : {
1214 0 : eFlags = basegfx::CONTINUITY_C1;
1215 : }
1216 0 : else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
1217 : {
1218 0 : eFlags = basegfx::CONTINUITY_C2;
1219 : }
1220 : else
1221 : {
1222 0 : return;
1223 : }
1224 :
1225 0 : if(mpPathObj && mpMark && isSelected() && (GetMarkedPointCount() != 0))
1226 : {
1227 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1228 0 : if(pPts)
1229 : {
1230 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1231 0 : if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
1232 : {
1233 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1234 0 : mrView.MarkListHasChanged();
1235 0 : mrView.updateHandles();
1236 0 : }
1237 : }
1238 : }
1239 : }
1240 :
1241 0 : void MotionPathTag::CloseMarkedObjects(sal_Bool /*bToggle*/, sal_Bool /*bOpen*/ )
1242 : {
1243 : // not supported for motion path
1244 0 : }
1245 :
1246 0 : bool MotionPathTag::IsOpenCloseMarkedObjectsPossible() const
1247 : {
1248 : // not supported for motion path
1249 0 : return false;
1250 : }
1251 :
1252 0 : SdrObjClosedKind MotionPathTag::GetMarkedObjectsClosedState() const
1253 : {
1254 : // not supported for motion path
1255 0 : return SDROBJCLOSED_OPEN;
1256 : }
1257 :
1258 : // XChangesListener
1259 0 : void SAL_CALL MotionPathTag::changesOccurred( const ChangesEvent& /*Event*/ ) throw (RuntimeException)
1260 : {
1261 0 : if( mpPathObj && !mbInUpdatePath && (mpEffect->getPath() != msLastPath) )
1262 : {
1263 0 : mbInUpdatePath =true;
1264 0 : msLastPath = mpEffect->getPath();
1265 0 : mpEffect->updateSdrPathObjFromPath( *mpPathObj );
1266 0 : mbInUpdatePath = false;
1267 0 : updatePathAttributes();
1268 0 : mrView.updateHandles();
1269 : }
1270 0 : }
1271 :
1272 0 : void SAL_CALL MotionPathTag::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
1273 : {
1274 0 : if( mpPathObj )
1275 0 : Dispose();
1276 0 : }
1277 :
1278 0 : Any SAL_CALL MotionPathTag::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException)
1279 : {
1280 0 : if( aType == XChangesListener::static_type() )
1281 0 : return Any( Reference< XChangesListener >( this ) );
1282 0 : if( aType == XEventListener::static_type() )
1283 0 : return Any( Reference< XEventListener >( this ) );
1284 0 : if( aType == XInterface::static_type() )
1285 0 : return Any( Reference< XInterface >( this ) );
1286 :
1287 0 : return Any();
1288 : }
1289 :
1290 0 : void SAL_CALL MotionPathTag::acquire() throw ()
1291 : {
1292 0 : SimpleReferenceComponent::acquire();
1293 0 : }
1294 :
1295 0 : void SAL_CALL MotionPathTag::release( ) throw ()
1296 : {
1297 0 : SimpleReferenceComponent::release();
1298 0 : }
1299 :
1300 : } // end of namespace sd
1301 :
1302 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|