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();
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();
98 : virtual bool EndSdrDrag(bool bCopy);
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 sal_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 sal_True;
134 : }
135 : // --------------------------------------------------------------------
136 :
137 0 : class PathDragResize : public SdrDragResize
138 : {
139 : private:
140 : basegfx::B2DPolyPolygon maPathPolyPolygon;
141 :
142 : protected:
143 : virtual void createSdrDragEntries();
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);
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 sal_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();
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);
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();
256 : virtual sal_Bool IsFocusHdl() const;
257 : virtual Pointer GetSdrDragPointer() const;
258 : virtual bool isMarkable() const;
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 : sal_Bool SdPathHdl::IsFocusHdl() const
323 : {
324 0 : return sal_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 : maOriginPos = mxOrigin->getPosition();
370 :
371 0 : SdrPage* pPage = mrView.GetSdrPageView()->GetPage();
372 0 : if( pPage )
373 : {
374 0 : mpPathObj->SetPage( pPage );
375 0 : mpPathObj->SetObjList( pPage );
376 : }
377 :
378 0 : XDash aDash( XDASH_RECT, 1, 80, 1, 80, 80);
379 0 : OUString aEmpty( "?" );
380 0 : mpPathObj->SetMergedItem( XLineDashItem( aEmpty, aDash ) );
381 0 : mpPathObj->SetMergedItem( XLineStyleItem( XLINE_DASH ) );
382 0 : mpPathObj->SetMergedItem( XLineColorItem(aEmpty, ::Color(COL_GRAY)) );
383 0 : mpPathObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
384 :
385 0 : ::basegfx::B2DPolygon aStartArrow;
386 0 : aStartArrow.append(::basegfx::B2DPoint(20.0, 0.0));
387 0 : aStartArrow.append(::basegfx::B2DPoint(0.0, 0.0));
388 0 : aStartArrow.append(::basegfx::B2DPoint(10.0, 30.0));
389 0 : aStartArrow.setClosed(true);
390 0 : mpPathObj->SetMergedItem(XLineStartItem(aEmpty,::basegfx::B2DPolyPolygon(aStartArrow)));
391 0 : mpPathObj->SetMergedItem(XLineStartWidthItem(400));
392 0 : mpPathObj->SetMergedItem(XLineStartCenterItem(sal_True));
393 :
394 0 : updatePathAttributes();
395 :
396 0 : mpPathObj->SetMergedItem(XLineTransparenceItem(50));
397 :
398 0 : mpMark = new SdrMark( mpPathObj, mrView.GetSdrPageView() );
399 :
400 0 : mpPathObj->AddListener( *this );
401 :
402 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
403 0 : if( xNotifier.is() )
404 : {
405 0 : Reference< XChangesListener > xListener( this );
406 0 : xNotifier->addChangesListener( this );
407 0 : }
408 0 : }
409 :
410 : // --------------------------------------------------------------------
411 :
412 0 : MotionPathTag::~MotionPathTag()
413 : {
414 : DBG_ASSERT( mpPathObj == 0, "sd::MotionPathTag::~MotionPathTag(), dispose me first!" );
415 0 : Dispose();
416 0 : }
417 :
418 : // --------------------------------------------------------------------
419 :
420 0 : void MotionPathTag::updatePathAttributes()
421 : {
422 0 : OUString aEmpty( "?" );
423 :
424 0 : ::basegfx::B2DPolygon aCandidate;
425 0 : if( mxPolyPoly.count() )
426 : {
427 0 : aCandidate = mxPolyPoly.getB2DPolygon(0);
428 0 : ::basegfx::tools::checkClosed( aCandidate );
429 : }
430 :
431 0 : if( !aCandidate.isClosed() )
432 : {
433 0 : ::basegfx::B2DPolygon aEndArrow;
434 0 : aEndArrow.append(::basegfx::B2DPoint(10.0, 0.0));
435 0 : aEndArrow.append(::basegfx::B2DPoint(0.0, 30.0));
436 0 : aEndArrow.append(::basegfx::B2DPoint(20.0, 30.0));
437 0 : aEndArrow.setClosed(true);
438 0 : mpPathObj->SetMergedItem(XLineEndItem(aEmpty,::basegfx::B2DPolyPolygon(aEndArrow)));
439 0 : mpPathObj->SetMergedItem(XLineEndWidthItem(400));
440 0 : mpPathObj->SetMergedItem(XLineEndCenterItem(sal_True));
441 : }
442 : else
443 : {
444 0 : mpPathObj->SetMergedItem(XLineEndItem());
445 0 : }
446 0 : }
447 :
448 : // --------------------------------------------------------------------
449 :
450 0 : void MotionPathTag::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
451 : {
452 0 : if( mpPathObj && !mbInUpdatePath && dynamic_cast< const SdrHint* >( &rHint ) && (mpEffect.get() != 0) )
453 : {
454 0 : if( mxPolyPoly != mpPathObj->GetPathPoly() )
455 : {
456 0 : mbInUpdatePath = true;
457 0 : mxPolyPoly = mpPathObj->GetPathPoly();
458 0 : rtl::Reference< MotionPathTag > xTag( this );
459 0 : mrPane.updatePathFromMotionPathTag( xTag );
460 0 : msLastPath = mpEffect->getPath();
461 0 : updatePathAttributes();
462 0 : mbInUpdatePath = false;
463 : }
464 : }
465 0 : }
466 :
467 : // --------------------------------------------------------------------
468 :
469 0 : void MotionPathTag::MovePath( int nDX, int nDY )
470 : {
471 0 : if( mpPathObj )
472 : {
473 0 : mpPathObj->Move( Size( nDX, nDY ) );
474 0 : mrView.updateHandles();
475 : }
476 0 : }
477 :
478 : // --------------------------------------------------------------------
479 :
480 : /** returns true if the MotionPathTag handled the event. */
481 0 : bool MotionPathTag::MouseButtonDown( const MouseEvent& rMEvt, SmartHdl& rHdl )
482 : {
483 0 : if( !mpPathObj )
484 0 : return false;
485 :
486 0 : if( !isSelected() )
487 : {
488 0 : SmartTagReference xTag( this );
489 0 : mrView.getSmartTags().select( xTag );
490 0 : selectionChanged();
491 0 : return true;
492 : }
493 : else
494 : {
495 0 : if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
496 : {
497 0 : mrView.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_BEZIER_EDIT, SFX_CALLMODE_ASYNCHRON);
498 0 : return true;
499 : }
500 0 : else if( rMEvt.IsLeft() )
501 : {
502 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
503 0 : Point aMDPos( pOut->PixelToLogic( rMEvt.GetPosPixel() ) );
504 :
505 0 : if( !mrView.IsFrameDragSingles() && mrView.IsInsObjPointMode() && (rHdl.GetObjHdlNum() == SMART_TAG_HDL_NUM) )
506 : {
507 : // insert a point in edit mode
508 0 : const bool bNewObj = rMEvt.IsMod1();
509 :
510 0 : mrView.BrkAction();
511 :
512 0 : Point aPt(aMDPos); // - pMarkedPV->GetOffset());
513 :
514 0 : if(bNewObj)
515 0 : aPt = mrView.GetSnapPos(aPt,mrView.GetSdrPageView());
516 :
517 0 : bool bClosed0(mpPathObj->IsClosedObj());
518 :
519 0 : sal_uInt32 nInsPointNum = mpPathObj->NbcInsPointOld(aPt, bNewObj, sal_True);
520 :
521 0 : if(bClosed0 != mpPathObj->IsClosedObj())
522 : {
523 : // Obj was closed implicit
524 : // object changed
525 0 : mpPathObj->SetChanged();
526 0 : mpPathObj->BroadcastObjectChange();
527 : }
528 :
529 0 : if(0xffffffff != nInsPointNum)
530 : {
531 0 : mrView.UnmarkAllPoints();
532 0 : mrView.updateHandles();
533 :
534 0 : bool bRet = mrView.BegDragObj(aMDPos, pOut, mrView.GetHdl(nInsPointNum+1), 0, new PathDragObjOwn( mrView ) );
535 :
536 0 : if (bRet)
537 : {
538 0 : const_cast< SdrDragStat* >( &mrView.GetDragStat() )->SetMinMoved();
539 0 : mrView.MovDragObj(aMDPos);
540 : }
541 : }
542 0 : return true;
543 : }
544 : else
545 : {
546 0 : SmartHdl* pHdl = &rHdl;
547 0 : if (!mrView.IsPointMarked(*pHdl) || rMEvt.IsShift())
548 : {
549 0 : if (!rMEvt.IsShift())
550 : {
551 0 : mrView.UnmarkAllPoints();
552 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
553 : }
554 : else
555 : {
556 0 : if (mrView.IsPointMarked(*pHdl) )
557 : {
558 0 : mrView.UnmarkPoint(*pHdl);
559 0 : pHdl = NULL;
560 : }
561 : else
562 : {
563 0 : pHdl = dynamic_cast< SmartHdl* >( mrView.PickHandle(aMDPos) );
564 : }
565 : }
566 :
567 0 : if (pHdl)
568 0 : mrView.MarkPoint(*pHdl);
569 : }
570 :
571 :
572 0 : if( pHdl && !rMEvt.IsRight() )
573 : {
574 0 : mrView.BrkAction();
575 0 : const sal_uInt16 nDrgLog = (sal_uInt16)pOut->PixelToLogic(Size(DRGPIX,0)).Width();
576 :
577 0 : rtl::Reference< MotionPathTag > xTag( this );
578 : SdrDragMethod* pDragMethod;
579 :
580 : // #i95646# add DragPoly as geometry to each local SdrDragMethod to be able
581 : // to create the needed local SdrDragEntry for it in createSdrDragEntries()
582 0 : const basegfx::B2DPolyPolygon aDragPoly(mpPathObj->GetPathPoly());
583 :
584 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
585 : {
586 0 : pDragMethod = new PathDragMove( mrView, xTag, aDragPoly );
587 0 : pHdl->SetPos( aMDPos );
588 : }
589 0 : else if( pHdl->GetKind() == HDL_POLY )
590 : {
591 0 : pDragMethod = new PathDragObjOwn( mrView, aDragPoly );
592 : }
593 : else
594 : {
595 0 : pDragMethod = new PathDragResize( mrView, xTag, aDragPoly );
596 : }
597 :
598 0 : mrView.BegDragObj(aMDPos, NULL, pHdl, nDrgLog, pDragMethod );
599 : }
600 0 : return true;
601 : }
602 : }
603 : }
604 :
605 0 : return false;
606 : }
607 :
608 : // --------------------------------------------------------------------
609 :
610 : /** returns true if the SmartTag consumes this event. */
611 0 : bool MotionPathTag::KeyInput( const KeyEvent& rKEvt )
612 : {
613 0 : if( !mpPathObj )
614 0 : return false;
615 :
616 0 : sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
617 0 : switch( nCode )
618 : {
619 : case KEY_DELETE:
620 0 : return OnDelete();
621 :
622 : case KEY_DOWN:
623 : case KEY_UP:
624 : case KEY_LEFT:
625 : case KEY_RIGHT:
626 0 : return OnMove( rKEvt );
627 :
628 : case KEY_ESCAPE:
629 : {
630 0 : SmartTagReference xThis( this );
631 0 : mrView.getSmartTags().deselect();
632 0 : return true;
633 : }
634 :
635 : case KEY_TAB:
636 0 : return OnTabHandles( rKEvt );
637 :
638 : case KEY_SPACE:
639 0 : return OnMarkHandle( rKEvt );
640 :
641 : default:
642 0 : break;
643 : }
644 0 : return false;
645 : }
646 :
647 0 : bool MotionPathTag::OnDelete()
648 : {
649 0 : mrPane.remove( mpEffect );
650 0 : return true;
651 : }
652 :
653 0 : bool MotionPathTag::OnTabHandles( const KeyEvent& rKEvt )
654 : {
655 0 : if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
656 : {
657 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
658 0 : sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
659 :
660 0 : ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
661 :
662 : // guarantee visibility of focused handle
663 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
664 :
665 0 : if(pHdl)
666 : {
667 0 : Window* pWindow = mrView.GetViewShell()->GetActiveWindow();
668 0 : if( pWindow )
669 : {
670 0 : Point aHdlPosition(pHdl->GetPos());
671 0 : Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
672 0 : mrView.MakeVisible(aVisRect, *pWindow);
673 : }
674 : }
675 :
676 0 : return true;
677 : }
678 :
679 0 : return false;
680 : }
681 :
682 0 : bool MotionPathTag::OnMarkHandle( const KeyEvent& rKEvt )
683 : {
684 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
685 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
686 :
687 0 : if(pHdl && pHdl->GetKind() == HDL_POLY )
688 : {
689 : // rescue ID of point with focus
690 0 : sal_uInt32 nPol(pHdl->GetPolyNum());
691 0 : sal_uInt32 nPnt(pHdl->GetPointNum());
692 :
693 0 : if(mrView.IsPointMarked(*pHdl))
694 : {
695 0 : if(rKEvt.GetKeyCode().IsShift())
696 : {
697 0 : mrView.UnmarkPoint(*pHdl);
698 : }
699 : }
700 : else
701 : {
702 0 : if(!rKEvt.GetKeyCode().IsShift())
703 : {
704 0 : mrView.UnmarkAllPoints();
705 : }
706 0 : mrView.MarkPoint(*pHdl);
707 : }
708 :
709 0 : if(0L == rHdlList.GetFocusHdl())
710 : {
711 : // restore point with focus
712 0 : SdrHdl* pNewOne = 0L;
713 :
714 0 : for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
715 : {
716 0 : SdrHdl* pAct = rHdlList.GetHdl(a);
717 :
718 0 : if(pAct && pAct->GetKind() == HDL_POLY && pAct->GetPolyNum() == nPol && pAct->GetPointNum() == nPnt)
719 0 : pNewOne = pAct;
720 : }
721 :
722 0 : if(pNewOne)
723 0 : ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
724 : }
725 : }
726 :
727 0 : return true;
728 : }
729 :
730 0 : bool MotionPathTag::OnMove( const KeyEvent& rKEvt )
731 : {
732 0 : long nX = 0;
733 0 : long nY = 0;
734 :
735 0 : switch( rKEvt.GetKeyCode().GetCode() )
736 : {
737 0 : case KEY_UP: nY = -1; break;
738 0 : case KEY_DOWN: nY = 1; break;
739 0 : case KEY_LEFT: nX = -1; break;
740 0 : case KEY_RIGHT: nX = 1; break;
741 0 : default: break;
742 : }
743 :
744 0 : if(rKEvt.GetKeyCode().IsMod2())
745 : {
746 0 : OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow();
747 0 : Size aLogicSizeOnePixel = (pOut) ? pOut->PixelToLogic(Size(1,1)) : Size(100, 100);
748 0 : nX *= aLogicSizeOnePixel.Width();
749 0 : nY *= aLogicSizeOnePixel.Height();
750 : }
751 : else
752 : {
753 : // old, fixed move distance
754 0 : nX *= 100;
755 0 : nY *= 100;
756 : }
757 :
758 0 : if( nX || nY )
759 : {
760 : // in point edit mode move the handle with the focus
761 0 : const SdrHdlList& rHdlList = mrView.GetHdlList();
762 0 : SdrHdl* pHdl = rHdlList.GetFocusHdl();
763 :
764 0 : if(pHdl)
765 : {
766 : // now move the Handle (nX, nY)
767 0 : Point aStartPoint(pHdl->GetPos());
768 0 : Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
769 :
770 : // start dragging
771 0 : rtl::Reference< MotionPathTag > xTag( this );
772 0 : SdrDragMethod* pDragMethod = 0;
773 0 : if( (pHdl->GetKind() == HDL_MOVE) || (pHdl->GetKind() == HDL_SMARTTAG) )
774 : {
775 0 : pDragMethod = new PathDragMove( mrView, xTag );
776 : }
777 0 : else if( pHdl->GetKind() == HDL_POLY )
778 : {
779 0 : pDragMethod = new PathDragObjOwn( mrView );
780 : }
781 0 : else if( pHdl->GetKind() != HDL_BWGT )
782 : {
783 0 : pDragMethod = new PathDragResize( mrView, xTag );
784 : }
785 0 : mrView.BegDragObj(aStartPoint, 0, pHdl, 0, pDragMethod);
786 :
787 0 : if(mrView.IsDragObj())
788 : {
789 0 : bool bWasNoSnap = mrView.GetDragStat().IsNoSnap();
790 0 : sal_Bool bWasSnapEnabled = mrView.IsSnapEnabled();
791 :
792 : // switch snapping off
793 0 : if(!bWasNoSnap)
794 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(sal_True);
795 0 : if(bWasSnapEnabled)
796 0 : mrView.SetSnapEnabled(sal_False);
797 :
798 0 : mrView.MovAction(aEndPoint);
799 0 : mrView.EndDragObj();
800 :
801 : // restore snap
802 0 : if(!bWasNoSnap)
803 0 : ((SdrDragStat&)mrView.GetDragStat()).SetNoSnap(bWasNoSnap);
804 0 : if(bWasSnapEnabled)
805 0 : mrView.SetSnapEnabled(bWasSnapEnabled);
806 0 : }
807 : }
808 : else
809 : {
810 : // move the path
811 0 : MovePath( nX, nY );
812 : }
813 : }
814 :
815 0 : return true;
816 : }
817 :
818 : // --------------------------------------------------------------------
819 :
820 0 : sal_uLong MotionPathTag::GetMarkablePointCount() const
821 : {
822 0 : if( mpPathObj && isSelected() )
823 : {
824 0 : return mpPathObj->GetPointCount();
825 : }
826 : else
827 : {
828 0 : return 0;
829 : }
830 : }
831 :
832 : // --------------------------------------------------------------------
833 :
834 0 : sal_uLong MotionPathTag::GetMarkedPointCount() const
835 : {
836 0 : if( mpMark )
837 : {
838 0 : const SdrUShortCont* pPts=mpMark->GetMarkedPoints();
839 0 : return pPts ? pPts->size() : 0;
840 : }
841 : else
842 : {
843 0 : return 0;
844 : }
845 : }
846 :
847 : // --------------------------------------------------------------------
848 :
849 0 : sal_Bool MotionPathTag::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
850 : {
851 0 : sal_Bool bRet=sal_False;
852 0 : if( mpPathObj && mrView.IsPointMarkable( rHdl ) && (rHdl.GetKind() != HDL_SMARTTAG) )
853 : {
854 0 : SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( &rHdl );
855 0 : if( pSmartHdl && pSmartHdl->getTag().get() == this )
856 : {
857 0 : mpMark->ForceMarkedPoints();
858 0 : if (mrView.MarkPointHelper(&rHdl,mpMark,bUnmark))
859 : {
860 0 : mrView.MarkListHasChanged();
861 0 : bRet=sal_True;
862 : }
863 : }
864 : }
865 0 : return bRet;
866 : }
867 :
868 : // --------------------------------------------------------------------
869 :
870 0 : sal_Bool MotionPathTag::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark )
871 : {
872 0 : sal_Bool bChgd=sal_False;
873 :
874 0 : if( mpPathObj && isSelected() )
875 : {
876 0 : sal_Int32 nHdlNum = mrView.GetHdlList().GetHdlCount() - 1;
877 0 : while( nHdlNum > 0 )
878 : {
879 0 : SmartHdl* pHdl = dynamic_cast< SmartHdl* >( mrView.GetHdl( sal::static_int_cast< sal_uLong >( nHdlNum-- ) ) );
880 :
881 0 : if( pHdl && (pHdl->getTag().get() == this) && mrView.IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark)
882 : {
883 0 : Point aPos(pHdl->GetPos());
884 0 : if( pRect==NULL || pRect->IsInside(aPos))
885 : {
886 0 : if( mrView.MarkPointHelper(pHdl,mpMark,bUnmark) )
887 0 : bChgd=sal_True;
888 : }
889 : }
890 : }
891 :
892 0 : if(bChgd)
893 0 : mrView.MarkListHasChanged();
894 : }
895 :
896 0 : return bChgd;
897 : }
898 :
899 : // --------------------------------------------------------------------
900 :
901 0 : bool MotionPathTag::getContext( SdrViewContext& rContext )
902 : {
903 0 : if( mpPathObj && isSelected() && !mrView.IsFrameDragSingles() )
904 : {
905 0 : rContext = SDRCONTEXT_POINTEDIT;
906 0 : return true;
907 : }
908 : else
909 : {
910 0 : return false;
911 : }
912 : }
913 :
914 : // --------------------------------------------------------------------
915 :
916 0 : void MotionPathTag::CheckPossibilities()
917 : {
918 0 : if( mpPathObj )
919 : {
920 0 : if( isSelected() )
921 : {
922 0 : mrView.SetMoveAllowed( true );
923 0 : mrView.SetMoveProtected( false );
924 0 : mrView.SetResizeFreeAllowed( true );
925 0 : mrView.SetResizePropAllowed( true );
926 0 : mrView.SetResizeProtected( false );
927 :
928 0 : if( !mrView.IsFrameDragSingles() )
929 : {
930 0 : bool b1stSmooth(true);
931 0 : bool b1stSegm(true);
932 0 : bool bCurve(false);
933 0 : bool bSmoothFuz(false);
934 0 : bool bSegmFuz(false);
935 0 : basegfx::B2VectorContinuity eSmooth = basegfx::CONTINUITY_NONE;
936 :
937 0 : mrView.CheckPolyPossibilitiesHelper( mpMark, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
938 : }
939 : }
940 : }
941 0 : }
942 :
943 : // --------------------------------------------------------------------
944 :
945 0 : void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
946 : {
947 0 : if( mpPathObj )
948 : {
949 0 : ::com::sun::star::awt::Point aPos( mxOrigin->getPosition() );
950 0 : if( (aPos.X != maOriginPos.X) || (aPos.Y != maOriginPos.Y) )
951 : {
952 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(
953 0 : aPos.X - maOriginPos.X, aPos.Y - maOriginPos.Y));
954 0 : mxPolyPoly.transform( aTransform );
955 0 : mpPathObj->SetPathPoly( mxPolyPoly );
956 0 : maOriginPos = aPos;
957 : }
958 :
959 0 : SmartTagReference xThis( this );
960 0 : SdPathHdl* pHdl = new SdPathHdl( xThis, mpPathObj );
961 0 : pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
962 0 : pHdl->SetPageView( mrView.GetSdrPageView() );
963 :
964 :
965 0 : pHdl->SetObj(mpPathObj);
966 0 : rHandlerList.AddHdl( pHdl );
967 :
968 0 : if( isSelected() )
969 : {
970 0 : mrView.GetSdrPageView()->SetHasMarkedObj(sal_True);
971 :
972 0 : if( !mrView.IsFrameDragSingles() )
973 : {
974 0 : SdrHdlList aTemp( rHandlerList.GetView() );
975 0 : mpPathObj->AddToHdlList( aTemp );
976 0 : const SdrUShortCont* pMrkPnts=mpMark->GetMarkedPoints();
977 :
978 : sal_uInt32 nHandle;
979 0 : for( nHandle = 0; nHandle < aTemp.GetHdlCount(); ++nHandle )
980 : {
981 0 : SdrHdl* pTempHdl = aTemp.GetHdl( nHandle );
982 :
983 0 : SmartHdl* pSmartHdl = new SmartHdl( xThis, mpPathObj, pTempHdl->GetPos(), pTempHdl->GetKind() );
984 0 : pSmartHdl->SetObjHdlNum( nHandle );
985 0 : pSmartHdl->SetPolyNum( pTempHdl->GetPolyNum() );
986 0 : pSmartHdl->SetPointNum( pTempHdl->GetPointNum() );
987 0 : pSmartHdl->SetPlusHdl( pTempHdl->IsPlusHdl() );
988 0 : pSmartHdl->SetSourceHdlNum( pTempHdl->GetSourceHdlNum() );
989 0 : pSmartHdl->SetPageView( mrView.GetSdrPageView() );
990 :
991 0 : rHandlerList.AddHdl( pSmartHdl );
992 :
993 0 : const bool bSelected= pMrkPnts && pMrkPnts->find( sal_uInt16(nHandle) ) != pMrkPnts->end();
994 0 : pSmartHdl->SetSelected(bSelected);
995 :
996 0 : if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
997 : {
998 0 : sal_uInt32 nPlusAnz=mpPathObj->GetPlusHdlCount(*pSmartHdl);
999 0 : for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
1000 : {
1001 0 : SdrHdl* pPlusHdl = mpPathObj->GetPlusHdl(*pSmartHdl,nPlusNum);
1002 0 : if (pPlusHdl!=NULL)
1003 : {
1004 0 : pPlusHdl->SetObj(mpPathObj);
1005 0 : pPlusHdl->SetPageView(mrView.GetSdrPageView());
1006 0 : pPlusHdl->SetPlusHdl(sal_True);
1007 0 : rHandlerList.AddHdl(pPlusHdl);
1008 : }
1009 : }
1010 : }
1011 0 : }
1012 : }
1013 : else
1014 : {
1015 0 : Rectangle aRect(mpPathObj->GetCurrentBoundRect());
1016 :
1017 0 : if(!aRect.IsEmpty())
1018 : {
1019 0 : sal_uLong nCount = rHandlerList.GetHdlCount();
1020 :
1021 0 : sal_Bool bWdt0=aRect.Left()==aRect.Right();
1022 0 : sal_Bool bHgt0=aRect.Top()==aRect.Bottom();
1023 0 : if (bWdt0 && bHgt0)
1024 : {
1025 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft(),HDL_UPLFT));
1026 : }
1027 0 : else if (bWdt0 || bHgt0)
1028 : {
1029 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1030 0 : rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight(),HDL_LWRGT));
1031 : }
1032 : else
1033 : {
1034 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopLeft() ,HDL_UPLFT));
1035 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopCenter() ,HDL_UPPER));
1036 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.TopRight() ,HDL_UPRGT));
1037 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.LeftCenter() ,HDL_LEFT ));
1038 0 : if (!bWdt0 ) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.RightCenter() ,HDL_RIGHT));
1039 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomLeft() ,HDL_LWLFT));
1040 0 : if ( !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomCenter(),HDL_LOWER));
1041 0 : if (!bWdt0 && !bHgt0) rHandlerList.AddHdl(new SmartHdl( xThis, mpPathObj, aRect.BottomRight() ,HDL_LWRGT));
1042 : }
1043 :
1044 0 : while( nCount < rHandlerList.GetHdlCount() )
1045 : {
1046 0 : rHandlerList.GetHdl(nCount++)->SetPageView( mrView.GetSdrPageView() );
1047 : }
1048 : }
1049 : }
1050 0 : }
1051 : }
1052 0 : }
1053 :
1054 : // --------------------------------------------------------------------
1055 :
1056 0 : void MotionPathTag::disposing()
1057 : {
1058 0 : Reference< XChangesNotifier > xNotifier( mpEffect->getNode(), UNO_QUERY );
1059 0 : if( xNotifier.is() )
1060 : {
1061 0 : Reference< XChangesListener > xListener( this );
1062 0 : xNotifier->removeChangesListener( this );
1063 : }
1064 :
1065 0 : if( mpPathObj )
1066 : {
1067 0 : SdrPathObj* pPathObj = mpPathObj;
1068 0 : mpPathObj = 0;
1069 0 : mrView.updateHandles();
1070 0 : delete pPathObj;
1071 : }
1072 :
1073 0 : if( mpMark )
1074 : {
1075 0 : delete mpMark;
1076 0 : mpMark = 0;
1077 : }
1078 :
1079 0 : SmartTag::disposing();
1080 0 : }
1081 :
1082 : // --------------------------------------------------------------------
1083 :
1084 0 : void MotionPathTag::deselect()
1085 : {
1086 0 : SmartTag::deselect();
1087 :
1088 0 : if( mpMark )
1089 : {
1090 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1091 :
1092 0 : if( pPts )
1093 0 : pPts->clear();
1094 : }
1095 :
1096 0 : selectionChanged();
1097 0 : }
1098 :
1099 0 : void MotionPathTag::selectionChanged()
1100 : {
1101 0 : if( mrView.GetViewShell() && mrView.GetViewShell()->GetViewFrame() )
1102 : {
1103 0 : SfxBindings& rBindings = mrView.GetViewShell()->GetViewFrame()->GetBindings();
1104 0 : rBindings.InvalidateAll(sal_True);
1105 : }
1106 0 : }
1107 : // --------------------------------------------------------------------
1108 : // IPolyPolygonEditorController
1109 : // --------------------------------------------------------------------
1110 :
1111 0 : void MotionPathTag::DeleteMarkedPoints()
1112 : {
1113 0 : if( mpPathObj && IsDeleteMarkedPointsPossible() )
1114 : {
1115 0 : mrView.BrkAction();
1116 :
1117 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1118 :
1119 0 : if( pPts )
1120 : {
1121 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1122 0 : if( aEditor.DeletePoints( *pPts ) )
1123 : {
1124 0 : if( aEditor.GetPolyPolygon().count() )
1125 : {
1126 0 : mpPathObj->SetPathPoly( aEditor.GetPolyPolygon() );
1127 : }
1128 :
1129 0 : mrView.UnmarkAllPoints();
1130 0 : mrView.MarkListHasChanged();
1131 0 : mrView.updateHandles();
1132 0 : }
1133 : }
1134 : }
1135 0 : }
1136 :
1137 0 : sal_Bool MotionPathTag::IsDeleteMarkedPointsPossible() const
1138 : {
1139 0 : return mpPathObj && isSelected() && (GetMarkedPointCount() != 0);
1140 : }
1141 :
1142 0 : void MotionPathTag::RipUpAtMarkedPoints()
1143 : {
1144 : // not supported for motion path
1145 0 : }
1146 :
1147 0 : bool MotionPathTag::IsRipUpAtMarkedPointsPossible() const
1148 : {
1149 : // not supported for motion path
1150 0 : return false;
1151 : }
1152 :
1153 0 : sal_Bool MotionPathTag::IsSetMarkedSegmentsKindPossible() const
1154 : {
1155 0 : if( mpPathObj )
1156 0 : return mrView.IsSetMarkedSegmentsKindPossible();
1157 : else
1158 0 : return sal_False;
1159 : }
1160 :
1161 0 : SdrPathSegmentKind MotionPathTag::GetMarkedSegmentsKind() const
1162 : {
1163 0 : if( mpPathObj )
1164 0 : return mrView.GetMarkedSegmentsKind();
1165 : else
1166 0 : return SDRPATHSEGMENT_LINE;
1167 : }
1168 :
1169 0 : void MotionPathTag::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
1170 : {
1171 0 : if(mpPathObj && isSelected() && (GetMarkedPointCount() != 0))
1172 : {
1173 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1174 0 : if(pPts)
1175 : {
1176 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1177 0 : if(aEditor.SetSegmentsKind( eKind, *pPts ) )
1178 : {
1179 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1180 0 : mrView.MarkListHasChanged();
1181 0 : mrView.updateHandles();
1182 0 : }
1183 : }
1184 : }
1185 0 : }
1186 :
1187 0 : sal_Bool MotionPathTag::IsSetMarkedPointsSmoothPossible() const
1188 : {
1189 0 : if( mpPathObj )
1190 0 : return mrView.IsSetMarkedPointsSmoothPossible();
1191 : else
1192 0 : return sal_False;
1193 : }
1194 :
1195 0 : SdrPathSmoothKind MotionPathTag::GetMarkedPointsSmooth() const
1196 : {
1197 0 : if( mpPathObj )
1198 0 : return mrView.GetMarkedPointsSmooth();
1199 : else
1200 0 : return SDRPATHSMOOTH_ANGULAR;
1201 : }
1202 :
1203 0 : void MotionPathTag::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
1204 : {
1205 : basegfx::B2VectorContinuity eFlags;
1206 :
1207 0 : if(SDRPATHSMOOTH_ANGULAR == eKind)
1208 : {
1209 0 : eFlags = basegfx::CONTINUITY_NONE;
1210 : }
1211 0 : else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
1212 : {
1213 0 : eFlags = basegfx::CONTINUITY_C1;
1214 : }
1215 0 : else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
1216 : {
1217 0 : eFlags = basegfx::CONTINUITY_C2;
1218 : }
1219 : else
1220 : {
1221 0 : return;
1222 : }
1223 :
1224 0 : if(mpPathObj && mpMark && isSelected() && (GetMarkedPointCount() != 0))
1225 : {
1226 0 : SdrUShortCont* pPts = mpMark->GetMarkedPoints();
1227 0 : if(pPts)
1228 : {
1229 0 : PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
1230 0 : if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
1231 : {
1232 0 : mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
1233 0 : mrView.MarkListHasChanged();
1234 0 : mrView.updateHandles();
1235 0 : }
1236 : }
1237 : }
1238 : }
1239 :
1240 0 : void MotionPathTag::CloseMarkedObjects(sal_Bool /*bToggle*/, sal_Bool /*bOpen*/ )
1241 : {
1242 : // not supported for motion path
1243 0 : }
1244 :
1245 0 : bool MotionPathTag::IsOpenCloseMarkedObjectsPossible() const
1246 : {
1247 : // not supported for motion path
1248 0 : return false;
1249 : }
1250 :
1251 0 : SdrObjClosedKind MotionPathTag::GetMarkedObjectsClosedState() const
1252 : {
1253 : // not supported for motion path
1254 0 : return SDROBJCLOSED_OPEN;
1255 : }
1256 :
1257 : // XChangesListener
1258 0 : void SAL_CALL MotionPathTag::changesOccurred( const ChangesEvent& /*Event*/ ) throw (RuntimeException)
1259 : {
1260 0 : if( mpPathObj && !mbInUpdatePath && (mpEffect->getPath() != msLastPath) )
1261 : {
1262 0 : mbInUpdatePath =true;
1263 0 : msLastPath = mpEffect->getPath();
1264 0 : mpEffect->updateSdrPathObjFromPath( *mpPathObj );
1265 0 : mbInUpdatePath = false;
1266 0 : updatePathAttributes();
1267 0 : mrView.updateHandles();
1268 : }
1269 0 : }
1270 :
1271 0 : void SAL_CALL MotionPathTag::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
1272 : {
1273 0 : if( mpPathObj )
1274 0 : Dispose();
1275 0 : }
1276 :
1277 0 : Any SAL_CALL MotionPathTag::queryInterface( const ::com::sun::star::uno::Type& aType ) throw (RuntimeException)
1278 : {
1279 0 : if( aType == XChangesListener::static_type() )
1280 0 : return Any( Reference< XChangesListener >( this ) );
1281 0 : if( aType == XEventListener::static_type() )
1282 0 : return Any( Reference< XEventListener >( this ) );
1283 0 : if( aType == XInterface::static_type() )
1284 0 : return Any( Reference< XInterface >( this ) );
1285 :
1286 0 : return Any();
1287 : }
1288 :
1289 0 : void SAL_CALL MotionPathTag::acquire() throw ()
1290 : {
1291 0 : SimpleReferenceComponent::acquire();
1292 0 : }
1293 :
1294 0 : void SAL_CALL MotionPathTag::release( ) throw ()
1295 : {
1296 0 : SimpleReferenceComponent::release();
1297 0 : }
1298 :
1299 33 : } // end of namespace sd
1300 :
1301 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|