xref: /trunk/main/basctl/source/inc/dlgedobj.hxx (revision 96821c26)
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 _BASCTL_DLGEDOBJ_HXX
25 #define _BASCTL_DLGEDOBJ_HXX
26 
27 #include <svx/svdouno.hxx>
28 #include <comphelper/processfactory.hxx>
29 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30 #include <com/sun/star/container/XContainerListener.hpp>
31 
32 #include <vector>
33 #include <map>
34 
35 #include <boost/optional.hpp>
36 
37 typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
38 
39 
40 class DlgEdForm;
41 class DlgEditor;
42 
43 //============================================================================
44 // DlgEdObj
45 //============================================================================
46 
47 class DlgEdObj: public SdrUnoObj
48 {
49 	friend class DlgEditor;
50 	friend class DlgEdFactory;
51 	friend class DlgEdPropListenerImpl;
52 	friend class DlgEdForm;
53 
54 private:
55 	sal_Bool		bIsListening;
56 	DlgEdForm*		pDlgEdForm;
57 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
58 	::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener>  m_xContainerListener;
59 
60 protected:
61 	DlgEdObj();
62 	DlgEdObj(const ::rtl::OUString& rModelName,
63 			 const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac);
64 
65 	virtual void NbcMove( const Size& rSize );
66 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
67 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
68 
69 	DECL_LINK(OnCreate, void* );
70 
71 	using SfxListener::StartListening;
72 	void StartListening();
73 	using SfxListener::EndListening;
74 	void EndListening(sal_Bool bRemoveListener = sal_True);
isListening() const75 	sal_Bool	isListening() const { return bIsListening; }
76 
77     virtual bool TransformSdrToControlCoordinates(
78         sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
79         sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
80     virtual bool TransformSdrToFormCoordinates(
81         sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
82         sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
83     virtual bool TransformControlToSdrCoordinates(
84         sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
85         sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
86     virtual bool TransformFormToSdrCoordinates(
87         sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
88         sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
89 
90 public:
91 	TYPEINFO();
92 
93 	virtual ~DlgEdObj();
94 	virtual void SetPage(SdrPage* pNewPage);
95 
SetDlgEdForm(DlgEdForm * pForm)96 	virtual void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
GetDlgEdForm() const97 	virtual DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
98 
99 	virtual sal_uInt32 GetObjInventor() const;
100 	virtual sal_uInt16 GetObjIdentifier() const;
101 
102 	virtual SdrObject*	Clone() const;											// not working yet
103 	virtual void		operator= (const SdrObject& rObj);						// not working yet
104 	virtual void clonedFrom(const DlgEdObj* _pSource);							// not working yet
105 
106     // FullDrag support
107 	virtual SdrObject* getFullDragClone() const;
108 
109     virtual	sal_Bool		supportsService( const sal_Char* _pServiceName ) const;
110 	virtual ::rtl::OUString	GetDefaultName() const;
111 	virtual ::rtl::OUString	GetUniqueName() const;
112 
113 	virtual sal_Int32	GetStep() const;
114 	virtual	void		UpdateStep();
115 
116 	virtual void SetDefaults();
117 	virtual void SetRectFromProps();
118 	virtual void SetPropsFromRect();
119 
120     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > GetControl() const;
121 
122     virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt );
123 	virtual void SAL_CALL NameChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
124 	virtual void SAL_CALL TabIndexChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
125 
126 	// PropertyChangeListener
127 	virtual void SAL_CALL _propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
128 
129 	// ContainerListener
130 	virtual void SAL_CALL _elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
131 	virtual void SAL_CALL _elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
132 	virtual void SAL_CALL _elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
133 
134 	virtual void SetLayer(SdrLayerID nLayer);
135 };
136 
137 
138 //============================================================================
139 // DlgEdForm
140 //============================================================================
141 
142 class DlgEdForm: public DlgEdObj
143 {
144 	friend class DlgEditor;
145 	friend class DlgEdFactory;
146 
147 private:
148 	DlgEditor* pDlgEditor;
149 	::std::vector<DlgEdObj*> pChilds;
150 
151     mutable ::boost::optional< ::com::sun::star::awt::DeviceInfo >   mpDeviceInfo;
152 
153 
154 protected:
155 	DlgEdForm();
156 
157 	virtual void NbcMove( const Size& rSize );
158 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
159 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
160 
161 public:
162 	TYPEINFO();
163 
164 	virtual ~DlgEdForm();
165 
166 	virtual void SetDlgEditor( DlgEditor* pEditor );
GetDlgEditor() const167 	virtual DlgEditor* GetDlgEditor() const { return pDlgEditor; }
168 
169 	virtual void AddChild( DlgEdObj* pDlgEdObj );
170 	virtual void RemoveChild( DlgEdObj* pDlgEdObj );
GetChilds() const171 	virtual ::std::vector<DlgEdObj*> GetChilds() const { return pChilds; }
172 
173 	virtual	void UpdateStep();
174 
175 	virtual void SetRectFromProps();
176 	virtual void SetPropsFromRect();
177 
178     virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt );
179 
180 	virtual void UpdateTabIndices();
181 	virtual void UpdateTabOrder();
182 	virtual void UpdateGroups();
183 	virtual void UpdateTabOrderAndGroups();
184 
185     ::com::sun::star::awt::DeviceInfo getDeviceInfo() const;
186 
187 private:
188     void    ImplInvalidateDeviceInfo();
189 };
190 
191 #endif // _BASCTL_DLGEDOBJ_HXX
192 
193