xref: /trunk/main/sw/inc/unodraw.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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);
100 
101     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType );
102     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  );
103 
104     //XIndexAccess
105     virtual sal_Int32 SAL_CALL getCount(void);
106     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex);
107 
108     //XElementAccess
109     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  );
110     virtual sal_Bool SAL_CALL hasElements(  );
111 
112     //XShapes
113     virtual void SAL_CALL add(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape);
114     virtual void SAL_CALL remove(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape);
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);
118     virtual void SAL_CALL ungroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > & aGroup);
119 
120     //XServiceInfo
121     virtual rtl::OUString SAL_CALL getImplementationName(void);
122     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName);
123     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void);
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 
251 protected:
252     virtual ~SwXShape();
253     //SwClient
254     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
255 
256 public:
257     SwXShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
258 
259 
260     TYPEINFO();
261     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
262     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType );
263     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  );
264     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  );
265 
266     //XUnoTunnel
267     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier );
268 
269 
270     //XPropertySet
271     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  );
272     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue );
273     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName );
274     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener );
275     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener );
276     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener );
277     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener );
278 
279     //XPropertyState
280     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName );
281     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName );
282     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName );
283     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName );
284 
285     //XTextContent
286     virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange);
287     virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >  SAL_CALL getAnchor(void);
288 
289     //XComponent
290     virtual void SAL_CALL dispose(void);
291     virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener);
292     virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener);
293 
294     //XServiceInfo
295     virtual rtl::OUString SAL_CALL getImplementationName(void);
296     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName);
297     virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void);
298 
299     // --> OD 2004-07-22 #i31698# XShape
300     virtual ::com::sun::star::awt::Point SAL_CALL getPosition(  );
301     virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition );
302     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  );
303     virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize );
304     // <--
305     // --> OD 2004-07-22 #i31698# XShapeDescriptor - superclass of XShape
306     virtual ::rtl::OUString SAL_CALL getShapeType(  );
307     // <--
308 
GetDescImpl()309     SwShapeDescriptor_Impl*     GetDescImpl() {return pImpl;}
GetAggregationInterface()310     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >                 GetAggregationInterface() {return xShapeAgg;}
311 
312     // helper
313     static void AddExistingShapeToFmt( SdrObject& _rObj );
314 };
315 /* -----------------------------31.05.01 09:54--------------------------------
316 
317  ---------------------------------------------------------------------------*/
318 class SwXGroupShape :
319     public SwXShape,
320     public ::com::sun::star::drawing::XShapes
321 {
322 protected:
323     virtual ~SwXGroupShape();
324 public:
325     SwXGroupShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
326 
327 
328     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType );
329     virtual void SAL_CALL acquire(  ) throw();
330     virtual void SAL_CALL release(  ) throw();
331 
332     //XShapes
333     virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
334     virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
335 
336     //XIndexAccess
337     virtual sal_Int32 SAL_CALL getCount(void);
338     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex);
339 
340     //XElementAccess
341     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  );
342     virtual sal_Bool SAL_CALL hasElements(  );
343 };
344 #endif
345