LibreOffice Module sw (master) 1
unodraw.hxx
Go to the documentation of this file.
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/fmdpage.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>
34#include <com/sun/star/container/XEnumerationAccess.hpp>
35#include <com/sun/star/drawing/HomogenMatrix3.hpp>
36
37class SdrMarkList;
38class SdrView;
39class SwDoc;
40class SwXShape;
41
42typedef cppu::ImplInheritanceHelper
43<
45 css::container::XEnumerationAccess
47class SwFmDrawPage final : public SwFmDrawPage_Base
48{
51 std::vector<rtl::Reference<SwXShape>> m_vShapes;
52public:
53 SwFmDrawPage( SwDoc* pDoc, SdrPage* pPage );
54 virtual ~SwFmDrawPage() noexcept override;
55
56 const SdrMarkList& PreGroup(const css::uno::Reference< css::drawing::XShapes >& rShapes);
57 void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup >& rShapeGroup);
58
59 SdrView* GetDrawView() {return mpView.get();}
61 void RemovePageView();
62 static css::uno::Reference<css::drawing::XShape> GetShape(SdrObject* pObj);
63 static css::uno::Reference<css::drawing::XShapeGroup> GetShapeGroup(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 css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override;
69 void RemoveShape(const SwXShape* pShape)
70 {
71 auto ppShape = find(m_vShapes.begin(), m_vShapes.end(), pShape);
72 if(ppShape != m_vShapes.end())
73 m_vShapes.erase(ppShape);
74 };
75
76 //XEnumerationAccess
77 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
78
79 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
80 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
81
82 //XIndexAccess
83 virtual sal_Int32 SAL_CALL getCount() override;
84 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
85
86 //XElementAccess
87 virtual css::uno::Type SAL_CALL getElementType( ) override;
88 virtual sal_Bool SAL_CALL hasElements( ) override;
89
90 //XShapes
91 virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > & xShape) override;
92 virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > & xShape) override;
93
94 //XShapeGrouper
95 virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > & xShapes) override;
96 virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > & aGroup) override;
97
98 //XServiceInfo
99 virtual OUString SAL_CALL getImplementationName() override;
100 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
101 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
102
103 // renamed and outlined to detect where it's called
104 void InvalidateSwDoc(); // {pDoc = 0;}
105};
106
108typedef
110<
111 css::beans::XPropertySet,
112 css::beans::XPropertyState,
113 css::text::XTextContent,
114 css::lang::XServiceInfo,
115 css::lang::XUnoTunnel,
116 css::drawing::XShape
117>
120{
121 friend class SwXGroupShape;
122 friend class SwFmDrawPage;
125
126 css::uno::Reference< css::uno::XAggregation > m_xShapeAgg;
127 // reference to <XShape>, determined in the
128 // constructor by <queryAggregation> at <xShapeAgg>.
129 css::uno::Reference< css::drawing::XShape > mxShape;
130
133 css::uno::Reference< css::beans::XPropertySetInfo > mxPropertySetInfo;
134
135 std::unique_ptr<SwShapeDescriptor_Impl> m_pImpl;
136
138
140
142 SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr );
143
145 css::awt::Point GetAttrPosition();
146
149 css::awt::Point ConvertPositionToHoriL2R(
150 const css::awt::Point& rObjPos,
151 const css::awt::Size& rObjSize );
152
156 css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(
157 const css::drawing::HomogenMatrix3& rMatrixInHoriL2R );
158
166 void AdjustPositionProperties(const css::awt::Point& rPosition);
167
171 css::awt::Point ConvertStartOrEndPosToLayoutDir(
172 const css::awt::Point& aStartOrEndPos );
173
177 css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(
178 const css::drawing::PolyPolygonBezierCoords& aPath );
179
186 css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName );
188 {
190 StartListening(pFormat->GetNotifier());
191 m_pFormat = pFormat;
192 }
193
194protected:
195 virtual ~SwXShape() override;
196public:
197 SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const*const pDoc);
198
199 virtual void Notify(const SfxHint&) override;
200 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
201 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
202 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
203 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
204
205 //XUnoTunnel
206 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
207
208 //XPropertySet
209 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
210 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
211 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
212 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
213 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
214 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
215 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
216
217 //XPropertyState
218 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
219 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
220 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
221 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
222
223 //XTextContent
224 virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
225 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
226
227 //XComponent
228 virtual void SAL_CALL dispose() override;
229 virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
230 virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
231
232 //XServiceInfo
233 virtual OUString SAL_CALL getImplementationName() override;
234 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
235 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
236
237 virtual css::awt::Point SAL_CALL getPosition( ) override;
238 virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
239 virtual css::awt::Size SAL_CALL getSize( ) override;
240 virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
241 virtual OUString SAL_CALL getShapeType( ) override;
242
245 const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() const {return m_xShapeAgg;}
246
247 // helper
248 static void AddExistingShapeToFormat( SdrObject const & _rObj );
249};
250
251class SwXGroupShape final :
252 public SwXShape,
253 public css::drawing::XShapes
254{
255 virtual ~SwXGroupShape() override;
256public:
257 SwXGroupShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
258
259 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
260 virtual void SAL_CALL acquire( ) noexcept override;
261 virtual void SAL_CALL release( ) noexcept override;
262
263 //XShapes
264 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
265 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
266
267 //XIndexAccess
268 virtual sal_Int32 SAL_CALL getCount() override;
269 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
270
271 //XElementAccess
272 virtual css::uno::Type SAL_CALL getElementType( ) override;
273 virtual sal_Bool SAL_CALL hasElements( ) override;
274};
275#endif
276
277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void EndListeningAll()
bool StartListening(SvtBroadcaster &rBroadcaster)
Definition: doc.hxx:194
SdrPageView * m_pPageView
Definition: unodraw.hxx:50
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:516
std::vector< rtl::Reference< SwXShape > > m_vShapes
Definition: unodraw.hxx:51
void InvalidateSwDoc()
Renamed and outlined to detect where it's called.
Definition: unodraw.cxx:775
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unodraw.cxx:451
SwDoc * m_pDoc
Definition: unodraw.hxx:49
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:463
static css::uno::Reference< css::drawing::XShapeGroup > GetShapeGroup(SdrObject *pObj)
Definition: unodraw.cxx:313
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:468
static css::uno::Reference< css::drawing::XShape > GetShape(SdrObject *pObj)
Definition: unodraw.cxx:293
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:511
virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > &xShapes) override
Definition: unodraw.cxx:715
virtual ~SwFmDrawPage() noexcept override
Definition: unodraw.cxx:260
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:458
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:473
virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:697
virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > &aGroup) override
Definition: unodraw.cxx:754
SwFmDrawPage(SwDoc *pDoc, SdrPage *pPage)
Definition: unodraw.cxx:255
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: unodraw.cxx:318
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:526
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:481
void RemoveShape(const SwXShape *pShape)
Definition: unodraw.hxx:69
void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup > &rShapeGroup)
Definition: unodraw.cxx:274
SdrView * GetDrawView()
Definition: unodraw.hxx:59
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:500
void RemovePageView()
Definition: unodraw.cxx:286
const SdrMarkList & PreGroup(const css::uno::Reference< css::drawing::XShapes > &rShapes)
Definition: unodraw.cxx:267
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:489
SdrPageView * GetPageView()
Definition: unodraw.cxx:279
Style of a layout element.
Definition: frmfmt.hxx:62
virtual void SAL_CALL acquire() noexcept override
Definition: unodraw.cxx:2684
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:2780
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:2674
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:2810
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2694
virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2750
virtual void SAL_CALL release() noexcept override
Definition: unodraw.cxx:2689
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:2765
virtual ~SwXGroupShape() override
Definition: unodraw.cxx:2670
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:2795
css::uno::Reference< css::uno::XAggregation > m_xShapeAgg
Definition: unodraw.hxx:126
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unodraw.cxx:1916
css::uno::Any _getPropAtAggrObj(const OUString &_rPropertyName)
method to get property from aggregation object
Definition: unodraw.cxx:1714
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:905
css::awt::Point GetAttrPosition()
method to determine position according to the positioning attributes
Definition: unodraw.cxx:2348
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1975
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unodraw.cxx:1731
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1982
std::unique_ptr< SwShapeDescriptor_Impl > m_pImpl
Definition: unodraw.hxx:135
virtual css::awt::Point SAL_CALL getPosition() override
Definition: unodraw.cxx:2171
o3tl::span< const SfxItemPropertyMapEntry > m_pPropertyMapEntries
Definition: unodraw.hxx:132
void SetFrameFormat(SwFrameFormat *pFormat)
Definition: unodraw.hxx:187
SwFrameFormat * m_pFormat
Definition: unodraw.hxx:124
SwShapeDescriptor_Impl * GetDescImpl()
Definition: unodraw.hxx:243
static void AddExistingShapeToFormat(SdrObject const &_rObj)
Definition: unodraw.cxx:860
virtual OUString SAL_CALL getShapeType() override
Definition: unodraw.cxx:2313
bool m_bDescriptor
Definition: unodraw.hxx:137
virtual void Notify(const SfxHint &) override
Definition: unodraw.cxx:1989
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unodraw.cxx:1998
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:2143
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unodraw.cxx:1962
SdrObject * GetTopGroupObj(SvxShape *_pSvxShape=nullptr)
method to determine top group object
Definition: unodraw.cxx:2324
friend class SwXGroupShape
Definition: unodraw.hxx:121
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2127
SwXShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *const pDoc)
Definition: unodraw.cxx:815
SvxShape * GetSvxShape()
Definition: unodraw.cxx:2162
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unodraw.cxx:786
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unodraw.cxx:955
css::uno::Reference< css::drawing::XShape > mxShape
Definition: unodraw.hxx:129
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unodraw.cxx:780
const SwFmDrawPage * m_pPage
Definition: unodraw.hxx:123
css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(const css::drawing::HomogenMatrix3 &rMatrixInHoriL2R)
method to convert the transformation of the drawing object to the layout direction,...
Definition: unodraw.cxx:2433
virtual css::awt::Size SAL_CALL getSize() override
Definition: unodraw.cxx:2291
const SfxItemPropertySet * m_pPropSet
Definition: unodraw.hxx:131
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unodraw.cxx:1739
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unodraw.cxx:1855
css::uno::Reference< css::beans::XPropertySetInfo > mxPropertySetInfo
Definition: unodraw.hxx:133
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unodraw.cxx:979
virtual void SAL_CALL dispose() override
Definition: unodraw.cxx:2073
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:244
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unodraw.cxx:1412
virtual void SAL_CALL setSize(const css::awt::Size &aSize) override
Definition: unodraw.cxx:2301
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unodraw.cxx:950
css::awt::Point ConvertStartOrEndPosToLayoutDir(const css::awt::Point &aStartOrEndPos)
method to convert start or end position of the drawing object to the Writer specific position,...
Definition: unodraw.cxx:2573
css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(const css::drawing::PolyPolygonBezierCoords &aPath)
method to convert PolyPolygonBezier of the drawing object to the Writer specific position,...
Definition: unodraw.cxx:2611
css::awt::Point ConvertPositionToHoriL2R(const css::awt::Point &rObjPos, const css::awt::Size &rObjSize)
method to convert the position (translation) of the drawing object to the layout direction horizontal...
Definition: unodraw.cxx:2392
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unodraw.cxx:1949
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2135
void AdjustPositionProperties(const css::awt::Point &rPosition)
method to adjust the positioning properties
Definition: unodraw.cxx:2497
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:2148
virtual ~SwXShape() override
Definition: unodraw.cxx:890
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unodraw.cxx:2044
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:2153
virtual void SAL_CALL setPosition(const css::awt::Point &aPosition) override
Definition: unodraw.cxx:2209
const css::uno::Reference< css::uno::XAggregation > & GetAggregationInterface() const
Definition: unodraw.hxx:245
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:934
sal_Int32 nIndex
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
UnoViewSharedPtr mpView
unsigned char sal_Bool
cppu::WeakAggImplHelper6< css::beans::XPropertySet, css::beans::XPropertyState, css::text::XTextContent, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::drawing::XShape > SwXShapeBaseClass
Definition: unodraw.hxx:107
cppu::ImplInheritanceHelper< SvxFmDrawPage, css::container::XEnumerationAccess > SwFmDrawPage_Base
Definition: unodraw.hxx:40