1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_MOTIONPATHTAG_HXX_
25 #define _SD_MOTIONPATHTAG_HXX_
26 
27 #include <com/sun/star/util/XChangesListener.hpp>
28 #include <com/sun/star/util/XChangesListener.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <basegfx/polygon/b2dpolypolygon.hxx>
31 #include <basegfx/polygon/b2dpolypolygontools.hxx>
32 #include "smarttag.hxx"
33 #include "CustomAnimationEffect.hxx"
34 
35 class SdrPathObj;
36 
37 namespace sd {
38 
39 class View;
40 class CustomAnimationPane;
41 
42 /*************************************************************************
43 |*
44 |* Basisklasse fuer alle Funktionen
45 |*
46 \************************************************************************/
47 
48 class MotionPathTag : public SmartTag, public IPolyPolygonEditorController, public SfxListener, public ::com::sun::star::util::XChangesListener
49 {
50 public:
51 	MotionPathTag( CustomAnimationPane& rPane, ::sd::View& rView, const CustomAnimationEffectPtr& pEffect );
52 	virtual ~MotionPathTag();
53 
getPathObj() const54 	SdrPathObj* getPathObj() const { return mpPathObj; }
55 
56 	/** returns true if the SmartTag handled the event. */
57 	virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
58 
59 	/** returns true if the SmartTag consumes this event. */
60 	virtual bool KeyInput( const KeyEvent& rKEvt );
61 
62 	// callbacks from sdr view
63 	virtual sal_uLong GetMarkablePointCount() const;
64 	virtual sal_uLong GetMarkedPointCount() const;
65 	virtual sal_Bool MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark=sal_False);
66 	virtual void CheckPossibilities();
67 	virtual sal_Bool MarkPoints(const Rectangle* pRect, sal_Bool bUnmark);
68 
getEffect() const69 	const CustomAnimationEffectPtr& getEffect() const { return mpEffect; }
70 
71 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
72 
73 	// IPolyPolygonEditorController
74 	virtual void DeleteMarkedPoints();
75 	virtual sal_Bool IsDeleteMarkedPointsPossible() const;
76 
77 	virtual	void RipUpAtMarkedPoints();
78 	virtual bool IsRipUpAtMarkedPointsPossible() const;
79 
80 	virtual sal_Bool IsSetMarkedSegmentsKindPossible() const;
81 	virtual SdrPathSegmentKind GetMarkedSegmentsKind() const;
82 	virtual void SetMarkedSegmentsKind(SdrPathSegmentKind eKind);
83 
84 	virtual sal_Bool IsSetMarkedPointsSmoothPossible() const;
85 	virtual SdrPathSmoothKind GetMarkedPointsSmooth() const;
86 	virtual void SetMarkedPointsSmooth(SdrPathSmoothKind eKind);
87 
88 	virtual void CloseMarkedObjects(sal_Bool bToggle, sal_Bool bOpen );
89 	virtual bool IsOpenCloseMarkedObjectsPossible() const;
90 	virtual SdrObjClosedKind GetMarkedObjectsClosedState() const;
91 
92 	void MovePath( int nDX, int nDY );
93 	bool OnDelete();
94 	bool OnTabHandles( const KeyEvent& rKEvt );
95 	bool OnMarkHandle( const KeyEvent& rKEvt );
96 	bool OnMove( const KeyEvent& rKEvt );
97 
98     // XChangesListener
99     virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
100     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
101     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL acquire(  ) throw ();
103     virtual void SAL_CALL release(  ) throw ();
104 
105 protected:
106 	virtual void addCustomHandles( SdrHdlList& rHandlerList );
107 	virtual bool getContext( SdrViewContext& rContext );
108 	virtual void disposing();
109 	virtual void deselect();
110 
111 	void updatePathAttributes();
112     void selectionChanged();
113 
114 private:
115 	CustomAnimationPane& mrPane;
116 	CustomAnimationEffectPtr mpEffect;
117 	::basegfx::B2DPolyPolygon mxPolyPoly;
118 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxOrigin;
119 	SdrPathObj* mpPathObj;
120 	::com::sun::star::awt::Point maOriginPos;
121 	SdrMark* mpMark;
122 	rtl::OUString msLastPath;
123 	bool mbInUpdatePath;
124 };
125 
126 } // end of namespace sd
127 
128 #endif		// _SD_MOTIONPATHTAG_HXX_
129 
130