lok: Hide file linking in section
[LibreOffice.git] / sw / inc / unodraw.hxx
blob599a3308e252aaa7b89895504048a833ee2e1dcd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_UNODRAW_HXX
20 #define INCLUDED_SW_INC_UNODRAW_HXX
22 #include <svl/itemprop.hxx>
23 #include <svl/listener.hxx>
24 #include <svx/fmdpage.hxx>
25 #include "calbck.hxx"
26 #include "frmfmt.hxx"
27 #include <com/sun/star/text/XTextContent.hpp>
28 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/beans/XPropertyState.hpp>
33 #include <com/sun/star/drawing/XShapes.hpp>
34 #include <cppuhelper/implbase4.hxx>
35 #include <cppuhelper/implbase6.hxx>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
39 class SdrMarkList;
40 class SdrView;
41 class SwDoc;
42 class SwXShape;
44 class SwFmDrawPage final : public SvxFmDrawPage
46 SdrPageView* pPageView;
47 std::vector<SwXShape*> m_vShapes;
48 public:
49 SwFmDrawPage( SdrPage* pPage );
50 virtual ~SwFmDrawPage() throw () override;
52 const SdrMarkList& PreGroup(const css::uno::Reference< css::drawing::XShapes >& rShapes);
53 void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup >& rShapeGroup);
55 SdrView* GetDrawView() {return mpView.get();}
56 SdrPageView* GetPageView();
57 void RemovePageView();
58 static css::uno::Reference<css::drawing::XShape> GetShape(SdrObject* pObj);
59 static css::uno::Reference<css::drawing::XShapeGroup> GetShapeGroup(SdrObject* pObj);
61 // The following method is called when a SvxShape-object is to be created.
62 // Derived classes may obtain at this point a derivation or an object
63 // that is aggregating a SvxShape.
64 virtual css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override;
65 void RemoveShape(const SwXShape* pShape)
67 auto ppShape = find(m_vShapes.begin(), m_vShapes.end(), pShape);
68 if(ppShape != m_vShapes.end())
69 m_vShapes.erase(ppShape);
73 typedef cppu::WeakAggImplHelper4
75 css::container::XEnumerationAccess,
76 css::drawing::XDrawPage,
77 css::lang::XServiceInfo,
78 css::drawing::XShapeGrouper
80 SwXDrawPageBaseClass;
81 class SwXDrawPage final : public SwXDrawPageBaseClass
83 SwDoc* pDoc;
84 css::uno::Reference< css::uno::XAggregation > xPageAgg;
85 SwFmDrawPage* pDrawPage;
86 public:
87 SwXDrawPage(SwDoc* pDoc);
88 virtual ~SwXDrawPage() override;
90 //XEnumerationAccess
91 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
93 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
94 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
96 //XIndexAccess
97 virtual sal_Int32 SAL_CALL getCount() override;
98 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
100 //XElementAccess
101 virtual css::uno::Type SAL_CALL getElementType( ) override;
102 virtual sal_Bool SAL_CALL hasElements( ) override;
104 //XShapes
105 virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > & xShape) override;
106 virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > & xShape) override;
108 //XShapeGrouper
109 virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > & xShapes) override;
110 virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > & aGroup) override;
112 //XServiceInfo
113 virtual OUString SAL_CALL getImplementationName() override;
114 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
115 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
117 SwFmDrawPage* GetSvxPage();
118 // renamed and outlined to detect where it's called
119 void InvalidateSwDoc(); // {pDoc = 0;}
122 class SwShapeDescriptor_Impl;
123 typedef
124 cppu::WeakAggImplHelper6
126 css::beans::XPropertySet,
127 css::beans::XPropertyState,
128 css::text::XTextContent,
129 css::lang::XServiceInfo,
130 css::lang::XUnoTunnel,
131 css::drawing::XShape
133 SwXShapeBaseClass;
134 class SwXShape : public SwXShapeBaseClass, public SvtListener
136 friend class SwXGroupShape;
137 friend class SwXDrawPage;
138 friend class SwFmDrawPage;
139 const SwFmDrawPage* m_pPage;
140 SwFrameFormat* m_pFormat;
142 css::uno::Reference< css::uno::XAggregation > xShapeAgg;
143 // reference to <XShape>, determined in the
144 // constructor by <queryAggregation> at <xShapeAgg>.
145 css::uno::Reference< css::drawing::XShape > mxShape;
147 const SfxItemPropertySet* m_pPropSet;
148 const SfxItemPropertyMapEntry* m_pPropertyMapEntries;
150 std::unique_ptr<SwShapeDescriptor_Impl> pImpl;
152 bool m_bDescriptor;
154 SvxShape* GetSvxShape();
156 /** method to determine top group object */
157 SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr );
159 /** method to determine position according to the positioning attributes */
160 css::awt::Point GetAttrPosition();
162 /** method to convert the position (translation) of the drawing object to
163 the layout direction horizontal left-to-right. */
164 css::awt::Point ConvertPositionToHoriL2R(
165 const css::awt::Point& rObjPos,
166 const css::awt::Size& rObjSize );
168 /** method to convert the transformation of the drawing object to the layout
169 direction, the drawing object is in
171 css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(
172 const css::drawing::HomogenMatrix3& rMatrixInHoriL2R );
174 /** method to adjust the positioning properties
176 @param _aPosition
177 input parameter - point representing the new shape position. The position
178 has to be given in the layout direction the shape is in and relative to
179 its position alignment areas.
181 void AdjustPositionProperties(const css::awt::Point& rPosition);
183 /** method to convert start or end position of the drawing object to the
184 Writer specific position, which is the attribute position in layout direction
186 css::awt::Point ConvertStartOrEndPosToLayoutDir(
187 const css::awt::Point& aStartOrEndPos );
189 /** method to convert PolyPolygonBezier of the drawing object to the
190 Writer specific position, which is the attribute position in layout direction
192 css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(
193 const css::drawing::PolyPolygonBezierCoords& aPath );
195 /** method to get property from aggregation object
197 @throws css::beans::UnknownPropertyException
198 @throws css::lang::WrappedTargetException
199 @throws css::uno::RuntimeException
201 css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName );
202 void SetFrameFormat(SwFrameFormat* pFormat)
204 EndListeningAll();
205 StartListening(pFormat->GetNotifier());
206 m_pFormat = pFormat;
209 protected:
210 virtual ~SwXShape() override;
211 public:
212 SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const*const pDoc);
214 virtual void Notify(const SfxHint&) override;
215 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
216 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
217 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
218 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
220 //XUnoTunnel
221 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
223 //XPropertySet
224 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
225 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
226 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
227 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
228 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
229 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
230 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
232 //XPropertyState
233 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
234 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
235 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
236 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
238 //XTextContent
239 virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
240 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
242 //XComponent
243 virtual void SAL_CALL dispose() override;
244 virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
245 virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
247 //XServiceInfo
248 virtual OUString SAL_CALL getImplementationName() override;
249 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
250 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
252 virtual css::awt::Point SAL_CALL getPosition( ) override;
253 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
254 virtual css::awt::Size SAL_CALL getSize( ) override;
255 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
256 virtual OUString SAL_CALL getShapeType( ) override;
258 SwShapeDescriptor_Impl* GetDescImpl() {return pImpl.get();}
259 SwFrameFormat* GetFrameFormat() const { return m_pFormat; }
260 const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() const {return xShapeAgg;}
262 // helper
263 static void AddExistingShapeToFormat( SdrObject const & _rObj );
266 class SwXGroupShape :
267 public SwXShape,
268 public css::drawing::XShapes
270 protected:
271 virtual ~SwXGroupShape() override;
272 public:
273 SwXGroupShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
275 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
276 virtual void SAL_CALL acquire( ) throw() override;
277 virtual void SAL_CALL release( ) throw() override;
279 //XShapes
280 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
281 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
283 //XIndexAccess
284 virtual sal_Int32 SAL_CALL getCount() override;
285 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
287 //XElementAccess
288 virtual css::uno::Type SAL_CALL getElementType( ) override;
289 virtual sal_Bool SAL_CALL hasElements( ) override;
291 #endif
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */