xref: /trunk/main/sw/inc/unodraw.hxx (revision 1d2dbeb0)
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 #ifndef _UNODRAW_HXX
24 #define _UNODRAW_HXX
25 
26 #include <svx/fmdpage.hxx>
27 #include <calbck.hxx>
28 #include <frmfmt.hxx>
29 #include <com/sun/star/text/XTextContent.hpp>
30 // --> OD 2009-01-13 #i59051#
31 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
32 // <--
33 #include <com/sun/star/drawing/XShape.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <com/sun/star/beans/XPropertyState.hpp>
36 #include <com/sun/star/drawing/XShapes.hpp>
37 #include <cppuhelper/implbase3.hxx> // helper for implementations
38 #include <cppuhelper/implbase4.hxx> // helper for implementations
39 // --> OD 2004-07-22 #i31698#
40 #include <cppuhelper/implbase6.hxx> // helper for implementations
41 #include <com/sun/star/container/XEnumerationAccess.hpp>
42 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
43 // <--
44 #include <svl/itemprop.hxx>
45 
46 class SdrMarkList;
47 class SdrView;
48 class SwDoc;
49 /******************************************************************************
50  *
51  ******************************************************************************/
52 class SwFmDrawPage : public SvxFmDrawPage
53 {
54 	SdrPageView*		pPageView;
55 protected:
56 
57 	// Erzeugen eines SdrObjects anhand einer Description. Kann von
58 	// abgeleiteten Klassen dazu benutzt werden, eigene ::com::sun::star::drawing::Shapes zu
59 	// unterstuetzen (z.B. Controls)
60 	virtual SdrObject *_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape ) throw ();
61 
62 public:
63 	SwFmDrawPage( SdrPage* pPage );
64 	virtual ~SwFmDrawPage() throw ();
65 
66 	const SdrMarkList& 	PreGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > & xShapes);
67 	void 				PreUnGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup >   xShapeGroup);
68 //	void 				PostGroup(); ?? wird es noch gebraucht ??
69 
GetDrawView()70 	SdrView* 			GetDrawView() {return mpView;}
71 	SdrPageView*		GetPageView();
72 	void				RemovePageView();
73 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  		GetInterface( SdrObject* pObj );
74 
75 	// Die folgende Methode wird gerufen, wenn ein SvxShape-Objekt angelegt
76 	// werden soll. abgeleitete Klassen koennen hier eine Ableitung oder
77 	// ein ein SvxShape aggregierendes Objekt anlegen.
78 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >  _CreateShape( SdrObject *pObj ) const throw ();
79 };
80 
81 typedef cppu::WeakAggImplHelper4
82 <
83 	::com::sun::star::container::XEnumerationAccess,
84     ::com::sun::star::drawing::XDrawPage,
85 	::com::sun::star::lang::XServiceInfo,
86     ::com::sun::star::drawing::XShapeGrouper
87 >
88 SwXDrawPageBaseClass;
89 class SwXDrawPage : public SwXDrawPageBaseClass
90 {
91 	SwDoc* 			pDoc;
92 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > 	xPageAgg;
93     SwFmDrawPage*   pDrawPage;
94 public:
95 	SwXDrawPage(SwDoc* pDoc);
96 	~SwXDrawPage();
97 
98     //XEnumerationAccess
99     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException );
100 
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 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
103 
104 	//XIndexAccess
105 	virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
106 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
107 
108 	//XElementAccess
109     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
110     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
111 
112 	//XShapes
113 	virtual void SAL_CALL add(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape) throw( ::com::sun::star::uno::RuntimeException );
114 	virtual void SAL_CALL remove(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape) throw( ::com::sun::star::uno::RuntimeException );
115 
116 	//XShapeGrouper
117 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup >  SAL_CALL group(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > & xShapes) throw( ::com::sun::star::uno::RuntimeException );
118 	virtual void SAL_CALL ungroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > & aGroup) throw( ::com::sun::star::uno::RuntimeException );
119 
120     //XServiceInfo
121 	virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
122 	virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
123 	virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
124 
125 	SwFmDrawPage* 	GetSvxPage();
126     // renamed and outlined to detect where it's called
127     void	InvalidateSwDoc(); // {pDoc = 0;}
128 };
129 /* -----------------22.01.99 10:20-------------------
130  *
131  * --------------------------------------------------*/
132 class SwShapeDescriptor_Impl;
133 class SwXGroupShape;
134 typedef
135 cppu::WeakAggImplHelper6
136 <
137 	::com::sun::star::beans::XPropertySet,
138 	::com::sun::star::beans::XPropertyState,
139 	::com::sun::star::text::XTextContent,
140 	::com::sun::star::lang::XServiceInfo,
141     ::com::sun::star::lang::XUnoTunnel,
142     // --> OD 2004-07-22 #i31698#
143     ::com::sun::star::drawing::XShape
144     // <--
145 >
146 SwXShapeBaseClass;
147 class SwXShape : public SwXShapeBaseClass,
148 	public SwClient
149 {
150 	friend class SwHTMLImageWatcher;
151     friend class SwHTMLParser;
152     friend class SwXGroupShape;
153     friend class SwXDrawPage;
154 
155     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xShapeAgg;
156     // --> OD 2004-07-23 #i31698# - reference to <XShape>, determined in the
157     // constructor by <queryAggregation> at <xShapeAgg>.
158     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
159     // <--
160 
161     const SfxItemPropertySet*           m_pPropSet;
162     const SfxItemPropertyMapEntry*      m_pPropertyMapEntries;
163     com::sun::star::uno::Sequence< sal_Int8 >* pImplementationId;
164 
165 	SwShapeDescriptor_Impl*		pImpl;
166 
167 	sal_Bool 						m_bDescriptor;
168 
GetFrmFmt() const169 	SwFrmFmt* 				GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); }
170 
171 	SvxShape*				GetSvxShape();
172 
173     /** method to determine top group object
174 
175         OD 2004-08-03 #i31698#
176 
177         @author OD
178     */
179     SdrObject* _GetTopGroupObj( SvxShape* _pSvxShape = 0L );
180 
181     /** method to determine position according to the positioning attributes
182 
183         OD 2004-08-03 #i31698#
184 
185         @author OD
186     */
187     com::sun::star::awt::Point _GetAttrPosition();
188 
189     /** method to convert the position (translation) of the drawing object to
190         the layout direction horizontal left-to-right.
191 
192         OD 2004-07-27 #i31698#
193 
194         @author OD
195     */
196     ::com::sun::star::awt::Point _ConvertPositionToHoriL2R(
197                                     const ::com::sun::star::awt::Point _aObjPos,
198                                     const ::com::sun::star::awt::Size _aObjSize );
199 
200     /** method to convert the transformation of the drawing object to the layout
201         direction, the drawing object is in
202 
203         OD 2004-07-27 #i31698#
204 
205         @author OD
206     */
207     ::com::sun::star::drawing::HomogenMatrix3 _ConvertTransformationToLayoutDir(
208                 ::com::sun::star::drawing::HomogenMatrix3 _aMatrixInHoriL2R );
209 
210     /** method to adjust the positioning properties
211 
212         OD 2004-08-02 #i31698#
213 
214         @author OD
215 
216         @param _aPosition
217         input parameter - point representing the new shape position. The position
218         has to be given in the layout direction the shape is in and relative to
219         its position alignment areas.
220     */
221     void _AdjustPositionProperties( const ::com::sun::star::awt::Point _aPosition );
222 
223     /** method to convert start or end position of the drawing object to the
224         Writer specific position, which is the attribute position in layout direction
225 
226         OD 2009-01-12 #i59051#
227 
228         @author OD
229     */
230     ::com::sun::star::awt::Point _ConvertStartOrEndPosToLayoutDir(
231                             const ::com::sun::star::awt::Point& aStartOrEndPos );
232 
233     /** method to convert PolyPolygonBezier of the drawing object to the
234         Writer specific position, which is the attribute position in layout direction
235 
236         OD 2009-01-13 #i59051#
237 
238         @author OD
239     */
240     ::com::sun::star::drawing::PolyPolygonBezierCoords _ConvertPolyPolygonBezierToLayoutDir(
241                     const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath );
242 
243     /** method to get property from aggregation object
244 
245         OD 2004-10-28 #i36248#
246 
247         @author OD
248     */
249     ::com::sun::star::uno::Any _getPropAtAggrObj( const ::rtl::OUString& _rPropertyName )
250             throw( ::com::sun::star::beans::UnknownPropertyException,
251                    ::com::sun::star::lang::WrappedTargetException,
252                    ::com::sun::star::uno::RuntimeException);
253 
254 protected:
255 	virtual ~SwXShape();
256     //SwClient
257     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
258 
259 public:
260 	SwXShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
261 
262 
263 	TYPEINFO();
264 	static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
265     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
266 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
267     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
268 
269 	//XUnoTunnel
270 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
271 
272 
273 	//XPropertySet
274     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
275     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
276     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
277     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
278     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
279     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
280     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
281 
282 	//XPropertyState
283     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
284     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
285     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
286     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
287 
288 	//XTextContent
289 	virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
290 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException );
291 
292 	//XComponent
293 	virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
294 	virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
295 	virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
296 
297 	//XServiceInfo
298 	virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
299 	virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
300 	virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
301 
302     // --> OD 2004-07-22 #i31698# XShape
303     virtual ::com::sun::star::awt::Point SAL_CALL getPosition(  ) throw (::com::sun::star::uno::RuntimeException);
304     virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw (::com::sun::star::uno::RuntimeException);
305     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
306     virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
307     // <--
308     // --> OD 2004-07-22 #i31698# XShapeDescriptor - superclass of XShape
309     virtual ::rtl::OUString SAL_CALL getShapeType(  ) throw (::com::sun::star::uno::RuntimeException);
310     // <--
311 
GetDescImpl()312 	SwShapeDescriptor_Impl*		GetDescImpl() {return pImpl;}
GetAggregationInterface()313 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > 				GetAggregationInterface() {return xShapeAgg;}
314 
315     // helper
316     static void AddExistingShapeToFmt( SdrObject& _rObj );
317 };
318 /* -----------------------------31.05.01 09:54--------------------------------
319 
320  ---------------------------------------------------------------------------*/
321 class SwXGroupShape :
322     public SwXShape,
323     public ::com::sun::star::drawing::XShapes
324 {
325 protected:
326 	virtual ~SwXGroupShape();
327 public:
328     SwXGroupShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
329 
330 
331     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
332     virtual void SAL_CALL acquire(  ) throw();
333     virtual void SAL_CALL release(  ) throw();
334 
335     //XShapes
336     virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
337     virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
338 
339     //XIndexAccess
340 	virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
341 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
342 
343 	//XElementAccess
344     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
345     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
346 };
347 #endif
348 
349 
350