LCOV - code coverage report
Current view: top level - sd/source/ui/animations - motionpathtag.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 582 0.2 %
Date: 2014-11-03 Functions: 2 68 2.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10