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 : #ifndef _UNODRAW_HXX
20 : #define _UNODRAW_HXX
21 :
22 : #include <svx/fmdpage.hxx>
23 : #include <calbck.hxx>
24 : #include <frmfmt.hxx>
25 : #include <com/sun/star/text/XTextContent.hpp>
26 : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
27 : #include <com/sun/star/drawing/XShape.hpp>
28 : #include <com/sun/star/lang/XUnoTunnel.hpp>
29 : #include <com/sun/star/beans/XPropertyState.hpp>
30 : #include <com/sun/star/drawing/XShapes.hpp>
31 : #include <cppuhelper/implbase3.hxx> // helper for implementations
32 : #include <cppuhelper/implbase4.hxx> // helper for implementations
33 : #include <cppuhelper/implbase6.hxx> // helper for implementations
34 : #include <com/sun/star/container/XEnumerationAccess.hpp>
35 : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
36 : #include <svl/itemprop.hxx>
37 :
38 : class SdrMarkList;
39 : class SdrView;
40 : class SwDoc;
41 :
42 : class SwFmDrawPage : public SvxFmDrawPage
43 : {
44 : SdrPageView* pPageView;
45 : protected:
46 :
47 : // Create a SdrObject according to a description. Can be used by derived classes to
48 : // support own ::com::sun::star::drawing::Shapes (e.g. controls).
49 : virtual SdrObject *_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape ) throw ();
50 :
51 : public:
52 : SwFmDrawPage( SdrPage* pPage );
53 : virtual ~SwFmDrawPage() throw ();
54 :
55 : const SdrMarkList& PreGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > & xShapes);
56 : void PreUnGroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > xShapeGroup);
57 :
58 0 : SdrView* GetDrawView() {return mpView;}
59 : SdrPageView* GetPageView();
60 : void RemovePageView();
61 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetInterface( SdrObject* pObj );
62 :
63 : // The following method is called when a SvxShape-object is to be created.
64 : // Derived classes may obtain at this point a derivation or an object
65 : // that is aggregating a SvxShape.
66 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > _CreateShape( SdrObject *pObj ) const throw ();
67 : };
68 :
69 : typedef cppu::WeakAggImplHelper4
70 : <
71 : ::com::sun::star::container::XEnumerationAccess,
72 : ::com::sun::star::drawing::XDrawPage,
73 : ::com::sun::star::lang::XServiceInfo,
74 : ::com::sun::star::drawing::XShapeGrouper
75 : >
76 : SwXDrawPageBaseClass;
77 : class SwXDrawPage : public SwXDrawPageBaseClass
78 : {
79 : SwDoc* pDoc;
80 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xPageAgg;
81 : SwFmDrawPage* pDrawPage;
82 : public:
83 : SwXDrawPage(SwDoc* pDoc);
84 : ~SwXDrawPage();
85 :
86 : //XEnumerationAccess
87 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException );
88 :
89 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
90 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
91 :
92 : //XIndexAccess
93 : virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
94 : 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 );
95 :
96 : //XElementAccess
97 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
98 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
99 :
100 : //XShapes
101 : virtual void SAL_CALL add(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape) throw( ::com::sun::star::uno::RuntimeException );
102 : virtual void SAL_CALL remove(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape) throw( ::com::sun::star::uno::RuntimeException );
103 :
104 : //XShapeGrouper
105 : 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 );
106 : virtual void SAL_CALL ungroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > & aGroup) throw( ::com::sun::star::uno::RuntimeException );
107 :
108 : //XServiceInfo
109 : virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
110 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
111 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
112 :
113 : SwFmDrawPage* GetSvxPage();
114 : // renamed and outlined to detect where it's called
115 : void InvalidateSwDoc(); // {pDoc = 0;}
116 : };
117 :
118 : class SwShapeDescriptor_Impl;
119 : class SwXGroupShape;
120 : typedef
121 : cppu::WeakAggImplHelper6
122 : <
123 : ::com::sun::star::beans::XPropertySet,
124 : ::com::sun::star::beans::XPropertyState,
125 : ::com::sun::star::text::XTextContent,
126 : ::com::sun::star::lang::XServiceInfo,
127 : ::com::sun::star::lang::XUnoTunnel,
128 : ::com::sun::star::drawing::XShape
129 : >
130 : SwXShapeBaseClass;
131 : class SwXShape : public SwXShapeBaseClass,
132 : public SwClient
133 : {
134 : friend class SwXGroupShape;
135 : friend class SwXDrawPage;
136 :
137 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xShapeAgg;
138 : // reference to <XShape>, determined in the
139 : // constructor by <queryAggregation> at <xShapeAgg>.
140 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
141 :
142 : const SfxItemPropertySet* m_pPropSet;
143 : const SfxItemPropertyMapEntry* m_pPropertyMapEntries;
144 : com::sun::star::uno::Sequence< sal_Int8 >* pImplementationId;
145 :
146 : SwShapeDescriptor_Impl* pImpl;
147 :
148 : sal_Bool m_bDescriptor;
149 :
150 : SvxShape* GetSvxShape();
151 :
152 : /** method to determine top group object
153 :
154 : @author OD
155 : */
156 : SdrObject* _GetTopGroupObj( SvxShape* _pSvxShape = 0L );
157 :
158 : /** method to determine position according to the positioning attributes
159 :
160 : @author OD
161 : */
162 : com::sun::star::awt::Point _GetAttrPosition();
163 :
164 : /** method to convert the position (translation) of the drawing object to
165 : the layout direction horizontal left-to-right.
166 :
167 : @author OD
168 : */
169 : ::com::sun::star::awt::Point _ConvertPositionToHoriL2R(
170 : const ::com::sun::star::awt::Point _aObjPos,
171 : const ::com::sun::star::awt::Size _aObjSize );
172 :
173 : /** method to convert the transformation of the drawing object to the layout
174 : direction, the drawing object is in
175 :
176 : @author OD
177 : */
178 : ::com::sun::star::drawing::HomogenMatrix3 _ConvertTransformationToLayoutDir(
179 : ::com::sun::star::drawing::HomogenMatrix3 _aMatrixInHoriL2R );
180 :
181 : /** method to adjust the positioning properties
182 :
183 : @author OD
184 :
185 : @param _aPosition
186 : input parameter - point representing the new shape position. The position
187 : has to be given in the layout direction the shape is in and relative to
188 : its position alignment areas.
189 : */
190 : void _AdjustPositionProperties( const ::com::sun::star::awt::Point _aPosition );
191 :
192 : /** method to convert start or end position of the drawing object to the
193 : Writer specific position, which is the attribute position in layout direction
194 :
195 : @author OD
196 : */
197 : ::com::sun::star::awt::Point _ConvertStartOrEndPosToLayoutDir(
198 : const ::com::sun::star::awt::Point& aStartOrEndPos );
199 :
200 : /** method to convert PolyPolygonBezier of the drawing object to the
201 : Writer specific position, which is the attribute position in layout direction
202 :
203 : @author OD
204 : */
205 : ::com::sun::star::drawing::PolyPolygonBezierCoords _ConvertPolyPolygonBezierToLayoutDir(
206 : const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath );
207 :
208 : /** method to get property from aggregation object
209 :
210 : @author OD
211 : */
212 : ::com::sun::star::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName )
213 : throw( ::com::sun::star::beans::UnknownPropertyException,
214 : ::com::sun::star::lang::WrappedTargetException,
215 : ::com::sun::star::uno::RuntimeException);
216 :
217 : protected:
218 : virtual ~SwXShape();
219 : //SwClient
220 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
221 :
222 : public:
223 : SwXShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
224 :
225 :
226 : TYPEINFO();
227 : static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
228 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
229 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
230 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
231 :
232 : //XUnoTunnel
233 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
234 :
235 :
236 : //XPropertySet
237 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
238 : virtual void SAL_CALL setPropertyValue( const 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);
239 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
240 : virtual void SAL_CALL addPropertyChangeListener( const 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);
241 : virtual void SAL_CALL removePropertyChangeListener( const 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);
242 : virtual void SAL_CALL addVetoableChangeListener( const 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);
243 : virtual void SAL_CALL removeVetoableChangeListener( const 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);
244 :
245 : //XPropertyState
246 : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
247 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
248 : virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
249 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
250 :
251 : //XTextContent
252 : 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 );
253 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException );
254 :
255 : //XComponent
256 : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
257 : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
258 : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
259 :
260 : //XServiceInfo
261 : virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
262 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
263 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
264 :
265 : virtual ::com::sun::star::awt::Point SAL_CALL getPosition( ) throw (::com::sun::star::uno::RuntimeException);
266 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw (::com::sun::star::uno::RuntimeException);
267 : virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
268 : virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
269 : virtual OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException);
270 :
271 335 : SwShapeDescriptor_Impl* GetDescImpl() {return pImpl;}
272 2745 : SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); }
273 335 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > GetAggregationInterface() {return xShapeAgg;}
274 :
275 : // helper
276 : static void AddExistingShapeToFmt( SdrObject& _rObj );
277 : };
278 :
279 : class SwXGroupShape :
280 : public SwXShape,
281 : public ::com::sun::star::drawing::XShapes
282 : {
283 : protected:
284 : virtual ~SwXGroupShape();
285 : public:
286 : SwXGroupShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
287 :
288 :
289 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
290 : virtual void SAL_CALL acquire( ) throw();
291 : virtual void SAL_CALL release( ) throw();
292 :
293 : //XShapes
294 : virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
295 : virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
296 :
297 : //XIndexAccess
298 : virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
299 : 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 );
300 :
301 : //XElementAccess
302 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
303 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
304 : };
305 : #endif
306 :
307 :
308 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|