/src/libreoffice/sw/inc/unodraw.hxx
Line | Count | Source |
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 <svl/itemprop.hxx> |
23 | | #include <svl/listener.hxx> |
24 | | #include <svx/unopage.hxx> |
25 | | #include "frmfmt.hxx" |
26 | | #include <com/sun/star/text/XTextContent.hpp> |
27 | | #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> |
28 | | #include <com/sun/star/drawing/XShape.hpp> |
29 | | #include <com/sun/star/lang/XUnoTunnel.hpp> |
30 | | #include <com/sun/star/beans/XPropertySet.hpp> |
31 | | #include <com/sun/star/beans/XPropertyState.hpp> |
32 | | #include <com/sun/star/drawing/XShapes.hpp> |
33 | | #include <com/sun/star/container/XEnumerationAccess.hpp> |
34 | | #include <com/sun/star/drawing/HomogenMatrix3.hpp> |
35 | | #include <com/sun/star/uno/XAggregation.hpp> |
36 | | #include <cppuhelper/implbase.hxx> |
37 | | |
38 | | class SdrMarkList; |
39 | | class SdrView; |
40 | | class SwDoc; |
41 | | class SwXShape; |
42 | | |
43 | | typedef cppu::ImplInheritanceHelper |
44 | | < |
45 | | SvxDrawPage, |
46 | | css::container::XEnumerationAccess, |
47 | | css::beans::XPropertySet> |
48 | | SwFmDrawPage_Base; |
49 | | |
50 | | class SW_DLLPUBLIC SwFmDrawPage final : public SwFmDrawPage_Base |
51 | | { |
52 | | SwDoc* m_pDoc; |
53 | | SdrPageView* m_pPageView; |
54 | | std::vector<rtl::Reference<SwXShape>> m_vShapes; |
55 | | const SfxItemPropertySet* m_pPropertySet; |
56 | | |
57 | | public: |
58 | | SwFmDrawPage( SwDoc* pDoc, SdrPage* pPage ); |
59 | | virtual ~SwFmDrawPage() noexcept override; |
60 | | |
61 | | const SdrMarkList& PreGroup(const css::uno::Reference< css::drawing::XShapes >& rShapes); |
62 | | void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup >& rShapeGroup); |
63 | | |
64 | 0 | SdrView* GetDrawView() {return mpView.get();} |
65 | | SdrPageView* GetPageView(); |
66 | | void RemovePageView(); |
67 | | static css::uno::Reference<css::drawing::XShape> GetShape(SdrObject* pObj); |
68 | | static css::uno::Reference<css::drawing::XShapeGroup> GetShapeGroup(SdrObject* pObj); |
69 | | |
70 | | // The following method is called when a SvxShape-object is to be created. |
71 | | // Derived classes may obtain at this point a derivation or an object |
72 | | // that is aggregating a SvxShape. |
73 | | virtual css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override; |
74 | | void RemoveShape(const SwXShape* pShape) |
75 | 2.13k | { |
76 | 2.13k | auto ppShape = find(m_vShapes.begin(), m_vShapes.end(), pShape); |
77 | 2.13k | if(ppShape != m_vShapes.end()) |
78 | 2.13k | m_vShapes.erase(ppShape); |
79 | 2.13k | }; |
80 | | |
81 | | //XEnumerationAccess |
82 | | virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; |
83 | | |
84 | | //XIndexAccess |
85 | | virtual sal_Int32 SAL_CALL getCount() override; |
86 | | virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; |
87 | | |
88 | | //XElementAccess |
89 | | virtual css::uno::Type SAL_CALL getElementType( ) override; |
90 | | virtual sal_Bool SAL_CALL hasElements( ) override; |
91 | | |
92 | | //XShapes |
93 | | virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > & xShape) override; |
94 | | virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > & xShape) override; |
95 | | |
96 | | //XShapeGrouper |
97 | | virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > & xShapes) override; |
98 | | virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > & aGroup) override; |
99 | | |
100 | | //XServiceInfo |
101 | | virtual OUString SAL_CALL getImplementationName() override; |
102 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
103 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
104 | | |
105 | | //XPropertySet |
106 | | virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; |
107 | | virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const css::uno::Any& aValue) override; |
108 | | virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override; |
109 | | virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override; |
110 | | virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& aListener) override; |
111 | | virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override; |
112 | | virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) override; |
113 | | |
114 | | // renamed and outlined to detect where it's called |
115 | | void InvalidateSwDoc(); // {pDoc = 0;} |
116 | | }; |
117 | | |
118 | | class SwShapeDescriptor_Impl; |
119 | | typedef |
120 | | cppu::WeakImplHelper |
121 | | < |
122 | | css::beans::XPropertySet, |
123 | | css::beans::XPropertyState, |
124 | | css::text::XTextContent, |
125 | | css::lang::XServiceInfo, |
126 | | css::lang::XUnoTunnel, |
127 | | css::drawing::XShape |
128 | | > |
129 | | SwXShapeBaseClass; |
130 | | class SwXShape : public SwXShapeBaseClass |
131 | | { |
132 | | friend class SwXGroupShape; |
133 | | friend class SwFmDrawPage; |
134 | | const SwFmDrawPage* m_pPage; |
135 | | |
136 | | css::uno::Reference< css::uno::XAggregation > m_xShapeAgg; |
137 | | // reference to <XShape>, determined in the |
138 | | // constructor by <queryAggregation> at <xShapeAgg>. |
139 | | css::uno::Reference< css::drawing::XShape > mxShape; |
140 | | |
141 | | const SfxItemPropertySet* m_pPropSet; |
142 | | std::span<const SfxItemPropertyMapEntry> m_pPropertyMapEntries; |
143 | | css::uno::Reference< css::beans::XPropertySetInfo > mxPropertySetInfo; |
144 | | |
145 | | std::unique_ptr<SwShapeDescriptor_Impl> m_pImpl; |
146 | | |
147 | | bool m_bDescriptor; |
148 | | |
149 | | /** method to determine top group object */ |
150 | | SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr ); |
151 | | |
152 | | /** method to determine position according to the positioning attributes */ |
153 | | css::awt::Point GetAttrPosition(); |
154 | | |
155 | | /** method to convert the position (translation) of the drawing object to |
156 | | the layout direction horizontal left-to-right. */ |
157 | | css::awt::Point ConvertPositionToHoriL2R( |
158 | | const css::awt::Point& rObjPos, |
159 | | const css::awt::Size& rObjSize ); |
160 | | |
161 | | /** method to convert the transformation of the drawing object to the layout |
162 | | direction, the drawing object is in |
163 | | */ |
164 | | css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir( |
165 | | const css::drawing::HomogenMatrix3& rMatrixInHoriL2R ); |
166 | | |
167 | | /** method to adjust the positioning properties |
168 | | |
169 | | @param _aPosition |
170 | | input parameter - point representing the new shape position. The position |
171 | | has to be given in the layout direction the shape is in and relative to |
172 | | its position alignment areas. |
173 | | */ |
174 | | void AdjustPositionProperties(const css::awt::Point& rPosition); |
175 | | |
176 | | /** method to convert start or end position of the drawing object to the |
177 | | Writer specific position, which is the attribute position in layout direction |
178 | | */ |
179 | | css::awt::Point ConvertStartOrEndPosToLayoutDir( |
180 | | const css::awt::Point& aStartOrEndPos ); |
181 | | |
182 | | /** method to convert PolyPolygonBezier of the drawing object to the |
183 | | Writer specific position, which is the attribute position in layout direction |
184 | | */ |
185 | | css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir( |
186 | | const css::drawing::PolyPolygonBezierCoords& aPath ); |
187 | | |
188 | | /** method to get property from aggregation object |
189 | | |
190 | | @throws css::beans::UnknownPropertyException |
191 | | @throws css::lang::WrappedTargetException |
192 | | @throws css::uno::RuntimeException |
193 | | */ |
194 | | css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName ); |
195 | | |
196 | | protected: |
197 | | virtual ~SwXShape() override; |
198 | | public: |
199 | | SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const*const pDoc); |
200 | | |
201 | | static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); |
202 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; |
203 | | virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; |
204 | | virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; |
205 | | |
206 | | //XUnoTunnel |
207 | | virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; |
208 | | |
209 | | //XPropertySet |
210 | | virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; |
211 | | virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; |
212 | | virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; |
213 | | virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; |
214 | | virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; |
215 | | virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
216 | | virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; |
217 | | |
218 | | //XPropertyState |
219 | | virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; |
220 | | virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; |
221 | | virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; |
222 | | virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; |
223 | | |
224 | | //XTextContent |
225 | | virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override; |
226 | | virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override; |
227 | | |
228 | | //XComponent |
229 | | virtual void SAL_CALL dispose() override; |
230 | | virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; |
231 | | virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; |
232 | | |
233 | | //XServiceInfo |
234 | | virtual OUString SAL_CALL getImplementationName() override; |
235 | | virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; |
236 | | virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
237 | | |
238 | | virtual css::awt::Point SAL_CALL getPosition( ) override; |
239 | | virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override; |
240 | | virtual css::awt::Size SAL_CALL getSize( ) override; |
241 | | virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override; |
242 | | virtual OUString SAL_CALL getShapeType( ) override; |
243 | | |
244 | 7.43k | SwShapeDescriptor_Impl* GetDescImpl() {return m_pImpl.get();} |
245 | | SwFrameFormat* GetFrameFormat() const; |
246 | | SvxShape* GetSvxShape(); |
247 | | |
248 | | // helper |
249 | | static void AddExistingShapeToFormat( SdrObject const & _rObj ); |
250 | | }; |
251 | | |
252 | | class SwXGroupShape final : |
253 | | public SwXShape, |
254 | | public css::drawing::XShapes |
255 | | { |
256 | | virtual ~SwXGroupShape() override; |
257 | | public: |
258 | | SwXGroupShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc); |
259 | | |
260 | | virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; |
261 | | virtual void SAL_CALL acquire( ) noexcept override; |
262 | | virtual void SAL_CALL release( ) noexcept override; |
263 | | |
264 | | //XShapes |
265 | | virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override; |
266 | | virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override; |
267 | | |
268 | | //XIndexAccess |
269 | | virtual sal_Int32 SAL_CALL getCount() override; |
270 | | virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; |
271 | | |
272 | | //XElementAccess |
273 | | virtual css::uno::Type SAL_CALL getElementType( ) override; |
274 | | virtual sal_Bool SAL_CALL hasElements( ) override; |
275 | | }; |
276 | | #endif |
277 | | |
278 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |