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