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 ::sdr::PolyPolygonEditor;
60 : using namespace ::com::sun::star::uno;
61 : using namespace ::com::sun::star::lang;
62 : using namespace ::com::sun::star::util;
63 : using namespace ::com::sun::star::drawing;
64 :
65 : namespace sd
66 : {
67 :
68 : const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
69 : static const int DRGPIX = 2; // Drag MinMove in Pixel
70 :
71 :
72 :
73 0 : class PathDragMove : public SdrDragMove
74 : {
75 : private:
76 : basegfx::B2DPolyPolygon maPathPolyPolygon;
77 :
78 : protected:
79 : virtual void createSdrDragEntries() SAL_OVERRIDE;
80 :
81 : public:
82 0 : PathDragMove(SdrDragView& rNewView,
83 : const rtl::Reference <MotionPathTag >& xTag,
84 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
85 : : SdrDragMove(rNewView),
86 : maPathPolyPolygon(rPathPolyPolygon),
87 0 : mxTag( xTag )
88 0 : {}
89 :
90 0 : PathDragMove(SdrDragView& rNewView,
91 : const rtl::Reference <MotionPathTag >& xTag)
92 : : SdrDragMove(rNewView),
93 : maPathPolyPolygon(),
94 0 : mxTag( xTag )
95 0 : {}
96 :
97 : virtual bool BeginSdrDrag() SAL_OVERRIDE;
98 : virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
99 :
100 : rtl::Reference <MotionPathTag > mxTag;
101 : };
102 :
103 0 : void PathDragMove::createSdrDragEntries()
104 : {
105 : // call parent
106 0 : SdrDragMove::createSdrDragEntries();
107 :
108 0 : if(maPathPolyPolygon.count())
109 : {
110 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
111 : }
112 0 : }
113 :
114 0 : bool PathDragMove::BeginSdrDrag()
115 : {
116 0 : if( mxTag.is() )
117 : {
118 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
119 0 : if( pPathObj )
120 : {
121 0 : DragStat().SetActionRect(pPathObj->GetCurrentBoundRect());
122 : }
123 : }
124 0 : Show();
125 0 : return true;
126 : }
127 :
128 0 : bool PathDragMove::EndSdrDrag(bool /*bCopy*/)
129 : {
130 0 : Hide();
131 0 : if( mxTag.is() )
132 0 : mxTag->MovePath( DragStat().GetDX(), DragStat().GetDY() );
133 0 : return true;
134 : }
135 :
136 :
137 0 : class PathDragResize : public SdrDragResize
138 : {
139 : private:
140 : basegfx::B2DPolyPolygon maPathPolyPolygon;
141 :
142 : protected:
143 : virtual void createSdrDragEntries() SAL_OVERRIDE;
144 :
145 : public:
146 0 : PathDragResize(SdrDragView& rNewView,
147 : const rtl::Reference <MotionPathTag >& xTag,
148 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
149 : : SdrDragResize(rNewView),
150 : maPathPolyPolygon(rPathPolyPolygon),
151 0 : mxTag( xTag )
152 0 : {}
153 :
154 0 : PathDragResize(SdrDragView& rNewView,
155 : const rtl::Reference <MotionPathTag >& xTag)
156 : : SdrDragResize(rNewView),
157 : maPathPolyPolygon(),
158 0 : mxTag( xTag )
159 0 : {}
160 :
161 : virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
162 : rtl::Reference <MotionPathTag > mxTag;
163 : };
164 :
165 0 : void PathDragResize::createSdrDragEntries()
166 : {
167 : // call parent
168 0 : SdrDragResize::createSdrDragEntries();
169 :
170 0 : if(maPathPolyPolygon.count())
171 : {
172 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
173 : }
174 0 : }
175 :
176 0 : bool PathDragResize::EndSdrDrag(bool /*bCopy*/)
177 : {
178 0 : Hide();
179 0 : if( mxTag.is() )
180 : {
181 0 : SdrPathObj* pPathObj = mxTag->getPathObj();
182 0 : if( pPathObj )
183 : {
184 0 : const Point aRef( DragStat().Ref1() );
185 0 : basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aRef.X(), -aRef.Y()));
186 0 : aTrans.scale(double(aXFact), double(aYFact));
187 0 : aTrans.translate(aRef.X(), aRef.Y());
188 0 : basegfx::B2DPolyPolygon aDragPoly(pPathObj->GetPathPoly());
189 0 : aDragPoly.transform(aTrans);
190 0 : pPathObj->SetPathPoly( aDragPoly );
191 : }
192 : }
193 0 : return true;
194 : }
195 :
196 :
197 :
198 0 : class PathDragObjOwn : public SdrDragObjOwn
199 : {
200 : private:
201 : basegfx::B2DPolyPolygon maPathPolyPolygon;
202 :
203 : protected:
204 : virtual void createSdrDragEntries() SAL_OVERRIDE;
205 :
206 : public:
207 0 : PathDragObjOwn(SdrDragView& rNewView,
208 : const basegfx::B2DPolyPolygon& rPathPolyPolygon)
209 : : SdrDragObjOwn(rNewView),
210 0 : maPathPolyPolygon(rPathPolyPolygon)
211 0 : {}
212 :
213 0 : PathDragObjOwn(SdrDragView& rNewView)
214 : : SdrDragObjOwn(rNewView),
215 0 : maPathPolyPolygon()
216 0 : {}
217 :
218 : virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
219 : };
220 :
221 0 : void PathDragObjOwn::createSdrDragEntries()
222 : {
223 : // call parent
224 0 : SdrDragObjOwn::createSdrDragEntries();
225 :
226 0 : if(maPathPolyPolygon.count())
227 : {
228 0 : addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon));
229 : }
230 0 : }
231 :
232 0 : bool PathDragObjOwn::EndSdrDrag(bool /*bCopy*/)
233 : {
234 0 : Hide();
235 :
236 0 : SdrObject* pObj = GetDragObj();
237 :
238 0 : if(pObj)
239 : {
240 0 : return pObj->applySpecialDrag(DragStat());
241 : }
242 : else
243 : {
244 0 : return false;
245 : }
246 : }
247 :
248 :
249 :
250 : class SdPathHdl : public SmartHdl
251 : {
252 : public:
253 : SdPathHdl( const SmartTagReference& xTag, SdrPathObj* mpPathObj );
254 : virtual ~SdPathHdl();
255 : virtual void CreateB2dIAObject() SAL_OVERRIDE;
256 : virtual bool IsFocusHdl() const SAL_OVERRIDE;
257 : virtual Pointer GetSdrDragPointer() const;
258 : virtual bool isMarkable() const SAL_OVERRIDE;
259 :
260 : private:
261 : SdrPathObj* mpPathObj;
262 : rtl::Reference< MotionPathTag > mxTag;
263 : };
264 :
265 :
266 :
267 0 : SdPathHdl::SdPathHdl( const SmartTagReference& xTag, SdrPathObj* pPathObj )
268 0 : : SmartHdl( xTag, pPathObj->GetCurrentBoundRect().TopLeft() )
269 : , mpPathObj( pPathObj )
270 0 : , mxTag( dynamic_cast< MotionPathTag* >( xTag.get() ) )
271 : {
272 0 : }
273 :
274 :
275 :
276 0 : SdPathHdl::~SdPathHdl()
277 : {
278 0 : }
279 :
280 :
281 :
282 0 : void SdPathHdl::CreateB2dIAObject()
283 : {
284 : // first throw away old one
285 0 : GetRidOfIAObject();
286 :
287 0 : if(pHdlList)
288 : {
289 0 : SdrMarkView* pView = pHdlList->GetView();
290 :
291 0 : if(pView && !pView->areMarkHandlesHidden())
292 : {
293 0 : SdrPageView* pPageView = pView->GetSdrPageView();
294 :
295 0 : if(pPageView)
296 : {
297 0 : for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
298 : {
299 0 : const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
300 :
301 0 : if(rPageWindow.GetPaintWindow().OutputToWindow())
302 : {
303 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
304 0 : if (xManager.is() && mpPathObj)
305 : {
306 0 : const sdr::contact::ViewContact& rVC = mpPathObj->GetViewContact();
307 0 : const drawinglayer::primitive2d::Primitive2DSequence aSequence = rVC.getViewIndependentPrimitive2DSequence();
308 0 : sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
309 :
310 0 : xManager->add(*pNew);
311 0 : maOverlayGroup.append(*pNew);
312 0 : }
313 : }
314 : }
315 : }
316 : }
317 : }
318 0 : }
319 :
320 :
321 :
322 0 : bool SdPathHdl::IsFocusHdl() const
323 : {
324 0 : return false;
325 : }
326 :
327 :
328 :
329 0 : bool SdPathHdl::isMarkable() const
330 : {
331 0 : return false;
332 : }
333 :
334 :
335 :
336 0 : Pointer SdPathHdl::GetSdrDragPointer() const
337 : {
338 0 : PointerStyle eStyle = POINTER_NOTALLOWED;
339 0 : if( mxTag.is() )
340 : {
341 0 : if( mxTag->isSelected() )
342 : {
343 0 : if( !mxTag->getView().IsFrameDragSingles() && mxTag->getView().IsInsObjPointMode() )
344 0 : eStyle = POINTER_CROSS;
345 : else
346 0 : eStyle = POINTER_MOVE;
347 : }
348 : else
349 : {
350 0 : eStyle = POINTER_ARROW;
351 :
352 : }
353 : }
354 0 : return Pointer( eStyle );
355 : }
356 :
357 :
358 :
359 0 : MotionPathTag::MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, const CustomAnimationEffectPtr& pEffect )
360 : : SmartTag( rView )
361 : , mrPane( rPane )
362 : , mpEffect( pEffect )
363 : , mxOrigin( pEffect->getTargetShape() )
364 : , msLastPath( pEffect->getPath() )
365 0 : , mbInUpdatePath( false )
366 : {
367 0 : mpPathObj = mpEffect->createSdrPathObjFromPath();
368 0 : mxPolyPoly = mpPathObj->GetPathPoly();
369 0 : if (mxOrigin.is())
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 : 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(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 : 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(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, 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(true);
796 0 : if(bWasSnapEnabled)
797 0 : mrView.SetSnapEnabled(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() ? 1 : 0)==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;
951 0 : if (mxOrigin.is())
952 0 : aPos = mxOrigin->getPosition();
953 0 : if( (aPos.X != maOriginPos.X) || (aPos.Y != maOriginPos.Y) )
954 : {
955 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
956 0 : aPos.X - maOriginPos.X, aPos.Y - maOriginPos.Y));
957 0 : mxPolyPoly.transform( aTransform );
958 0 : mpPathObj->SetPathPoly( mxPolyPoly );
959 0 : maOriginPos = aPos;
960 : }
961 :
962 0 : SmartTagReference xThis( this );
963 0 : SdPathHdl* pHdl = new SdPathHdl( xThis, mpPathObj );
964 0 : pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
965 0 : pHdl->SetPageView( mrView.GetSdrPageView() );
966 :
967 :
968 0 : pHdl->SetObj(mpPathObj);
969 0 : rHandlerList.AddHdl( pHdl );
970 :
971 0 : if( isSelected() )
972 : {
973 0 : mrView.GetSdrPageView()->SetHasMarkedObj(true);
974 :
975 0 : if( !mrView.IsFrameDragSingles() )
976 : {
977 0 : SdrHdlList aTemp( rHandlerList.GetView() );
978 0 : mpPathObj->AddToHdlList( aTemp );
979 0 : const SdrUShortCont* pMrkPnts=mpMark->GetMarkedPoints();
980 :
981 : sal_uInt32 nHandle;
982 0 : for( nHandle = 0; nHandle < aTemp.GetHdlCount(); ++nHandle )
983 : {
984 0 : SdrHdl* pTempHdl = aTemp.GetHdl( nHandle );
985 :
986 0 : SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj, pTempHdl->GetPos(), pTempHdl->GetKind() );
987 0 : pSmartHdl->SetObjHdlNum( nHandle );
988 0 : pSmartHdl->SetPolyNum( pTempHdl->GetPolyNum() );
989 0 : pSmartHdl->SetPointNum( pTempHdl->GetPointNum() );
990 0 : pSmartHdl->SetPlusHdl( pTempHdl->IsPlusHdl() );
991 0 : pSmartHdl->SetSourceHdlNum( pTempHdl->GetSourceHdlNum() );
992 0 : pSmartHdl->SetPageView( mrView.GetSdrPageView() );
993 :
994 0 : rHandlerList.AddHdl( pSmartHdl );
995 :
996 0 : const bool bSelected= pMrkPnts && pMrkPnts->find( sal_uInt16(nHandle) ) != pMrkPnts->end();
997 0 : pSmartHdl->SetSelected(bSelected);
998 :
999 0 : if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
1000 : {
1001 0 : sal_uInt32 nPlusAnz=mpPathObj->GetPlusHdlCount(*pSmartHdl);
1002 0 : for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
1003 : {
1004 0 : SdrHdl* pPlusHdl = mpPathObj->GetPlusHdl(*pSmartHdl,nPlusNum);
1005 0 : if (pPlusHdl!=NULL)
1006 : {
1007 0 : pPlusHdl->SetObj(mpPathObj);
1008 0 : pPlusHdl->SetPageView(mrView.GetSdrPageView());
1009 0 : pPlusHdl->SetPlusHdl(true);
1010 0 : rHandlerList.AddHdl(pPlusHdl);
1011 : }
1012 : }
1013 : }
1014 0 : }
1015 : }
1016 : else
1017 : {
1018 0 : Rectangle aRect(mpPathObj->GetCurrentBoundRect());
1019 :
1020 0 : if(!aRect.IsEmpty())
1021 : {
1022 0 : sal_uLong nCount = rHandlerList.GetHdlCount();
1023 :
1024 0 : sal_Bool bWdt0=aRect.Left()==aRect.Right();
1025 0 : sal_Bool bHgt0=aRect.Top()==aRect.Bottom();
1026 0 : if (bWdt0 && bHgt0)
1027 : {
1028 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft(),HDL_UPLFT));
1029 : }
1030 0 : else if (bWdt0 || bHgt0)
1031 : {
1032 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1033 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight(),HDL_LWRGT));
1034 : }
1035 : else
1036 : {
1037 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1038 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopCenter() ,HDL_UPPER));
1039 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopRight() ,HDL_UPRGT));
1040 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.LeftCenter() ,HDL_LEFT ));
1041 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.RightCenter() ,HDL_RIGHT));
1042 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomLeft() ,HDL_LWLFT));
1043 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomCenter(),HDL_LOWER));
1044 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight() ,HDL_LWRGT));
1045 : }
1046 :
1047 0 : while( nCount < rHandlerList.GetHdlCount() )
1048 : {
1049 0 : rHandlerList.GetHdl(nCount++)->SetPageView( mrView.GetSdrPageView() );
1050 : }
1051 : }
1052 : }
1053 0 : }
1054 : }
1055 0 : }
1056 :
1057 :
1058 :
1059 0 : void MotionPathTag::disposing()
1060 : {
1061 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
1062 0 : if( xNotifier.is() )
1063 : {
1064 0 : Reference< XChangesListener > xListener( this );
1065 0 : xNotifier->removeChangesListener( this );
1066 : }
1067 :
1068 0 : if( mpPathObj )
1069 : {
1070 0 : SdrPathObj* pPathObj = mpPathObj;
1071 0 : mpPathObj = 0;
1072 0 : mrView.updateHandles();
1073 0 : delete pPathObj;
1074 : }
1075 :
1076 0 : if( mpMark )
1077 : {
1078 0 : delete mpMark;
1079 0 : mpMark = 0;
1080 : }
1081 :
1082 0 : SmartTag::disposing();
1083 0 : }
1084 :
1085 :
1086 :
1087 0 : void MotionPathTag::deselect()
1088 : {
1089 0 : SmartTag::deselect();
1090 :
1091 0 : if( mpMark )
1092 : {
1093 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1094 :
1095 0 : if( pPts )
1096 0 : pPts->clear();
1097 : }
1098 :
1099 0 : selectionChanged();
1100 0 : }
1101 :
1102 0 : void MotionPathTag::selectionChanged()
1103 : {
1104 0 : if( mrView.GetViewShell() && mrView.GetViewShell()->GetViewFrame() )
1105 : {
1106 0 : SfxBindings& rBindings = mrView.GetViewShell()->GetViewFrame()->GetBindings();
1107 0 : rBindings.InvalidateAll(true);
1108 : }
1109 0 : }
1110 :
1111 : // IPolyPolygonEditorController
1112 :
1113 :
1114 0 : void MotionPathTag::DeleteMarkedPoints()
1115 : {
1116 0 : if( mpPathObj && IsDeleteMarkedPointsPossible() )
1117 : {
1118 0 : mrView.BrkAction();
1119 :
1120 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1121 :
1122 0 : if( pPts )
1123 : {
1124 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1125 0 : if( aEditor.DeletePoints( *pPts ) )
1126 : {
1127 0 : if( aEditor.GetPolyPolygon().count() )
1128 : {
1129 0 : mpPathObj->SetPathPoly( aEditor.GetPolyPolygon() );
1130 : }
1131 :
1132 0 : mrView.UnmarkAllPoints();
1133 0 : mrView.MarkListHasChanged();
1134 0 : mrView.updateHandles();
1135 0 : }
1136 : }
1137 : }
1138 0 : }
1139 :
1140 0 : bool MotionPathTag::IsDeleteMarkedPointsPossible() const
1141 : {
1142 0 : return mpPathObj && isSelected() && (GetMarkedPointCount() != 0);
1143 : }
1144 :
1145 0 : void MotionPathTag::RipUpAtMarkedPoints()
1146 : {
1147 : // not supported for motion path
1148 0 : }
1149 :
1150 0 : bool MotionPathTag::IsRipUpAtMarkedPointsPossible() const
1151 : {
1152 : // not supported for motion path
1153 0 : return false;
1154 : }
1155 :
1156 0 : bool MotionPathTag::IsSetMarkedSegmentsKindPossible() const
1157 : {
1158 0 : if( mpPathObj )
1159 0 : return mrView.IsSetMarkedSegmentsKindPossible();
1160 : else
1161 0 : return false;
1162 : }
1163 :
1164 0 : SdrPathSegmentKind MotionPathTag::GetMarkedSegmentsKind() const
1165 : {
1166 0 : if( mpPathObj )
1167 0 : return mrView.GetMarkedSegmentsKind();
1168 : else
1169 0 : return SDRPATHSEGMENT_LINE;
1170 : }
1171 :
1172 0 : void MotionPathTag::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
1173 : {
1174 0 : if(mpPathObj && isSelected() && (GetMarkedPointCount() != 0))
1175 : {
1176 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1177 0 : if(pPts)
1178 : {
1179 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1180 0 : if(aEditor.SetSegmentsKind( eKind, *pPts ) )
1181 : {
1182 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1183 0 : mrView.MarkListHasChanged();
1184 0 : mrView.updateHandles();
1185 0 : }
1186 : }
1187 : }
1188 0 : }
1189 :
1190 0 : bool MotionPathTag::IsSetMarkedPointsSmoothPossible() const
1191 : {
1192 0 : if( mpPathObj )
1193 0 : return mrView.IsSetMarkedPointsSmoothPossible();
1194 : else
1195 0 : return false;
1196 : }
1197 :
1198 0 : SdrPathSmoothKind MotionPathTag::GetMarkedPointsSmooth() const
1199 : {
1200 0 : if( mpPathObj )
1201 0 : return mrView.GetMarkedPointsSmooth();
1202 : else
1203 0 : return SDRPATHSMOOTH_ANGULAR;
1204 : }
1205 :
1206 0 : void MotionPathTag::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
1207 : {
1208 : basegfx::B2VectorContinuity eFlags;
1209 :
1210 0 : if(SDRPATHSMOOTH_ANGULAR == eKind)
1211 : {
1212 0 : eFlags = basegfx::CONTINUITY_NONE;
1213 : }
1214 0 : else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
1215 : {
1216 0 : eFlags = basegfx::CONTINUITY_C1;
1217 : }
1218 0 : else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
1219 : {
1220 0 : eFlags = basegfx::CONTINUITY_C2;
1221 : }
1222 : else
1223 : {
1224 0 : return;
1225 : }
1226 :
1227 0 : if(mpPathObj && mpMark && isSelected() && (GetMarkedPointCount() != 0))
1228 : {
1229 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1230 0 : if(pPts)
1231 : {
1232 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1233 0 : if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
1234 : {
1235 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1236 0 : mrView.MarkListHasChanged();
1237 0 : mrView.updateHandles();
1238 0 : }
1239 : }
1240 : }
1241 : }
1242 :
1243 0 : void MotionPathTag::CloseMarkedObjects(bool /*bToggle*/, bool /*bOpen*/ )
1244 : {
1245 : // not supported for motion path
1246 0 : }
1247 :
1248 0 : bool MotionPathTag::IsOpenCloseMarkedObjectsPossible() const
1249 : {
1250 : // not supported for motion path
1251 0 : return false;
1252 : }
1253 :
1254 0 : SdrObjClosedKind MotionPathTag::GetMarkedObjectsClosedState() const
1255 : {
1256 : // not supported for motion path
1257 0 : return SDROBJCLOSED_OPEN;
1258 : }
1259 :
1260 : // XChangesListener
1261 0 : void SAL_CALL MotionPathTag::changesOccurred( const ChangesEvent& /*Event*/ ) throw (RuntimeException, std::exception)
1262 : {
1263 0 : if( mpPathObj && !mbInUpdatePath && (mpEffect->getPath() != msLastPath) )
1264 : {
1265 0 : mbInUpdatePath =true;
1266 0 : msLastPath = mpEffect->getPath();
1267 0 : mpEffect->updateSdrPathObjFromPath( *mpPathObj );
1268 0 : mbInUpdatePath = false;
1269 0 : updatePathAttributes();
1270 0 : mrView.updateHandles();
1271 : }
1272 0 : }
1273 :
1274 0 : void SAL_CALL MotionPathTag::disposing( const EventObject& /*Source*/ ) throw (RuntimeException, std::exception)
1275 : {
1276 0 : if( mpPathObj )
1277 0 : Dispose();
1278 0 : }
1279 :
1280 0 : Any SAL_CALL MotionPathTag::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException, std::exception)
1281 : {
1282 0 : if( aType == cppu::UnoType<XChangesListener>::get() )
1283 0 : return Any( Reference< XChangesListener >( this ) );
1284 0 : if( aType == cppu::UnoType<XEventListener>::get() )
1285 0 : return Any( Reference< XEventListener >( this ) );
1286 0 : if( aType == cppu::UnoType<XInterface>::get() )
1287 0 : return Any( Reference< XInterface >( this ) );
1288 :
1289 0 : return Any();
1290 : }
1291 :
1292 0 : void SAL_CALL MotionPathTag::acquire() throw ()
1293 : {
1294 0 : SimpleReferenceComponent::acquire();
1295 0 : }
1296 :
1297 0 : void SAL_CALL MotionPathTag::release( ) throw ()
1298 : {
1299 0 : SimpleReferenceComponent::release();
1300 0 : }
1301 :
1302 0 : } // end of namespace sd
1303 :
1304 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|