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 INCLUDED_SW_INC_UNODRAW_HXX
20 : #define INCLUDED_SW_INC_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>
32 : #include <cppuhelper/implbase4.hxx>
33 : #include <cppuhelper/implbase6.hxx>
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 (std::exception) SAL_OVERRIDE;
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 (std::exception) SAL_OVERRIDE;
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 : virtual ~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, std::exception ) SAL_OVERRIDE;
88 :
89 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 :
92 : //XIndexAccess
93 : virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
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, std::exception ) SAL_OVERRIDE;
95 :
96 : //XElementAccess
97 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception ) SAL_OVERRIDE;
102 : virtual void SAL_CALL remove(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
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)
106 : throw (::com::sun::star::uno::RuntimeException,
107 : std::exception) SAL_OVERRIDE;
108 : virtual void SAL_CALL ungroup(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapeGroup > & aGroup) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
109 :
110 : //XServiceInfo
111 : virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
112 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
113 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
114 :
115 : SwFmDrawPage* GetSvxPage();
116 : // renamed and outlined to detect where it's called
117 : void InvalidateSwDoc(); // {pDoc = 0;}
118 : };
119 :
120 : class SwShapeDescriptor_Impl;
121 : class SwXGroupShape;
122 : typedef
123 : cppu::WeakAggImplHelper6
124 : <
125 : ::com::sun::star::beans::XPropertySet,
126 : ::com::sun::star::beans::XPropertyState,
127 : ::com::sun::star::text::XTextContent,
128 : ::com::sun::star::lang::XServiceInfo,
129 : ::com::sun::star::lang::XUnoTunnel,
130 : ::com::sun::star::drawing::XShape
131 : >
132 : SwXShapeBaseClass;
133 : class SwXShape : public SwXShapeBaseClass,
134 : public SwClient
135 : {
136 : friend class SwXGroupShape;
137 : friend class SwXDrawPage;
138 :
139 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > xShapeAgg;
140 : // reference to <XShape>, determined in the
141 : // constructor by <queryAggregation> at <xShapeAgg>.
142 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape;
143 :
144 : const SfxItemPropertySet* m_pPropSet;
145 : const SfxItemPropertyMapEntry* m_pPropertyMapEntries;
146 :
147 : SwShapeDescriptor_Impl* pImpl;
148 :
149 : sal_Bool m_bDescriptor;
150 :
151 : SvxShape* GetSvxShape();
152 :
153 : /** method to determine top group object
154 :
155 : @author OD
156 : */
157 : SdrObject* _GetTopGroupObj( SvxShape* _pSvxShape = 0L );
158 :
159 : /** method to determine position according to the positioning attributes
160 :
161 : @author OD
162 : */
163 : com::sun::star::awt::Point _GetAttrPosition();
164 :
165 : /** method to convert the position (translation) of the drawing object to
166 : the layout direction horizontal left-to-right.
167 :
168 : @author OD
169 : */
170 : ::com::sun::star::awt::Point _ConvertPositionToHoriL2R(
171 : const ::com::sun::star::awt::Point _aObjPos,
172 : const ::com::sun::star::awt::Size _aObjSize );
173 :
174 : /** method to convert the transformation of the drawing object to the layout
175 : direction, the drawing object is in
176 :
177 : @author OD
178 : */
179 : ::com::sun::star::drawing::HomogenMatrix3 _ConvertTransformationToLayoutDir(
180 : ::com::sun::star::drawing::HomogenMatrix3 _aMatrixInHoriL2R );
181 :
182 : /** method to adjust the positioning properties
183 :
184 : @author OD
185 :
186 : @param _aPosition
187 : input parameter - point representing the new shape position. The position
188 : has to be given in the layout direction the shape is in and relative to
189 : its position alignment areas.
190 : */
191 : void _AdjustPositionProperties( const ::com::sun::star::awt::Point _aPosition );
192 :
193 : /** method to convert start or end position of the drawing object to the
194 : Writer specific position, which is the attribute position in layout direction
195 :
196 : @author OD
197 : */
198 : ::com::sun::star::awt::Point _ConvertStartOrEndPosToLayoutDir(
199 : const ::com::sun::star::awt::Point& aStartOrEndPos );
200 :
201 : /** method to convert PolyPolygonBezier of the drawing object to the
202 : Writer specific position, which is the attribute position in layout direction
203 :
204 : @author OD
205 : */
206 : ::com::sun::star::drawing::PolyPolygonBezierCoords _ConvertPolyPolygonBezierToLayoutDir(
207 : const ::com::sun::star::drawing::PolyPolygonBezierCoords& aPath );
208 :
209 : /** method to get property from aggregation object
210 :
211 : @author OD
212 : */
213 : ::com::sun::star::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName )
214 : throw( ::com::sun::star::beans::UnknownPropertyException,
215 : ::com::sun::star::lang::WrappedTargetException,
216 : ::com::sun::star::uno::RuntimeException);
217 :
218 : protected:
219 : virtual ~SwXShape();
220 : //SwClient
221 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
222 :
223 : public:
224 : SwXShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
225 :
226 : TYPEINFO_OVERRIDE();
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, std::exception) SAL_OVERRIDE;
229 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
234 :
235 : //XPropertySet
236 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
237 : 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, std::exception) SAL_OVERRIDE;
238 : 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, std::exception) SAL_OVERRIDE;
239 : 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, std::exception) SAL_OVERRIDE;
240 : 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, std::exception) SAL_OVERRIDE;
241 : 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, std::exception) SAL_OVERRIDE;
242 : 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, std::exception) SAL_OVERRIDE;
243 :
244 : //XPropertyState
245 : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 : 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, std::exception) SAL_OVERRIDE;
247 : virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
248 : 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, std::exception) SAL_OVERRIDE;
249 :
250 : //XTextContent
251 : 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, std::exception ) SAL_OVERRIDE;
252 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
253 :
254 : //XComponent
255 : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
256 : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
257 : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
258 :
259 : //XServiceInfo
260 : virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
261 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
262 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
263 :
264 : virtual ::com::sun::star::awt::Point SAL_CALL getPosition( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
265 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 : virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
267 : virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
268 : virtual OUString SAL_CALL getShapeType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
269 :
270 0 : SwShapeDescriptor_Impl* GetDescImpl() {return pImpl;}
271 0 : SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); }
272 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > GetAggregationInterface() {return xShapeAgg;}
273 :
274 : // helper
275 : static void AddExistingShapeToFmt( SdrObject& _rObj );
276 : };
277 :
278 : class SwXGroupShape :
279 : public SwXShape,
280 : public ::com::sun::star::drawing::XShapes
281 : {
282 : protected:
283 : virtual ~SwXGroupShape();
284 : public:
285 : SwXGroupShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xShape);
286 :
287 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
288 : virtual void SAL_CALL acquire( ) throw() SAL_OVERRIDE;
289 : virtual void SAL_CALL release( ) throw() SAL_OVERRIDE;
290 :
291 : //XShapes
292 : virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
293 : virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
294 :
295 : //XIndexAccess
296 : virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
297 : 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, std::exception ) SAL_OVERRIDE;
298 :
299 : //XElementAccess
300 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 : };
303 : #endif
304 :
305 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|