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 <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/implbase4.hxx>
32 #include <cppuhelper/implbase6.hxx>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
35 
36 class SdrMarkList;
37 class SdrView;
38 class SwDoc;
39 
41 {
43 public:
44  SwFmDrawPage( SdrPage* pPage );
45  virtual ~SwFmDrawPage() throw () override;
46 
47  const SdrMarkList& PreGroup(const css::uno::Reference< css::drawing::XShapes >& rShapes);
48  void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup >& rShapeGroup);
49 
50  SdrView* GetDrawView() {return mpView.get();}
52  void RemovePageView();
53  static css::uno::Reference< css::uno::XInterface > GetInterface( SdrObject* pObj );
54 
55  // The following method is called when a SvxShape-object is to be created.
56  // Derived classes may obtain at this point a derivation or an object
57  // that is aggregating a SvxShape.
58  virtual css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override;
59 };
60 
62 <
63  css::container::XEnumerationAccess,
64  css::drawing::XDrawPage,
65  css::lang::XServiceInfo,
66  css::drawing::XShapeGrouper
67 >
70 {
72  css::uno::Reference< css::uno::XAggregation > xPageAgg;
74 public:
75  SwXDrawPage(SwDoc* pDoc);
76  virtual ~SwXDrawPage() override;
77 
78  //XEnumerationAccess
79  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
80 
81  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
82  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) 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 
106  // renamed and outlined to detect where it's called
107  void InvalidateSwDoc(); // {pDoc = 0;}
108 };
109 
111 typedef
113 <
114  css::beans::XPropertySet,
115  css::beans::XPropertyState,
116  css::text::XTextContent,
117  css::lang::XServiceInfo,
118  css::lang::XUnoTunnel,
119  css::drawing::XShape
120 >
123  public SwClient
124 {
125  friend class SwXGroupShape;
126  friend class SwXDrawPage;
127  friend class SwFmDrawPage;
128 
129  css::uno::Reference< css::uno::XAggregation > xShapeAgg;
130  // reference to <XShape>, determined in the
131  // constructor by <queryAggregation> at <xShapeAgg>.
132  css::uno::Reference< css::drawing::XShape > mxShape;
133 
136 
137  std::unique_ptr<SwShapeDescriptor_Impl> pImpl;
138 
140 
142 
144  SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr );
145 
147  css::awt::Point GetAttrPosition();
148 
151  css::awt::Point ConvertPositionToHoriL2R(
152  const css::awt::Point& rObjPos,
153  const css::awt::Size& rObjSize );
154 
158  css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(
159  const css::drawing::HomogenMatrix3& rMatrixInHoriL2R );
160 
168  void AdjustPositionProperties(const css::awt::Point& rPosition);
169 
173  css::awt::Point ConvertStartOrEndPosToLayoutDir(
174  const css::awt::Point& aStartOrEndPos );
175 
179  css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(
180  const css::drawing::PolyPolygonBezierCoords& aPath );
181 
188  css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName );
189 
190 protected:
191  virtual ~SwXShape() override;
192  //SwClient
193  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
194 
195 public:
196  SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
197 
198  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
199  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
200  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
201  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
202 
203  //XUnoTunnel
204  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
205 
206  //XPropertySet
207  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
208  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
209  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
210  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
211  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
212  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
213  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
214 
215  //XPropertyState
216  virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
217  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
218  virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
219  virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
220 
221  //XTextContent
222  virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override;
223  virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override;
224 
225  //XComponent
226  virtual void SAL_CALL dispose() override;
227  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
228  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
229 
230  //XServiceInfo
231  virtual OUString SAL_CALL getImplementationName() override;
232  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
233  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
234 
235  virtual css::awt::Point SAL_CALL getPosition( ) override;
236  virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
237  virtual css::awt::Size SAL_CALL getSize( ) override;
238  virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
239  virtual OUString SAL_CALL getShapeType( ) override;
240 
241  SwShapeDescriptor_Impl* GetDescImpl() {return pImpl.get();}
242  SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
243  const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() {return xShapeAgg;}
244 
245  // helper
246  static void AddExistingShapeToFormat( SdrObject const & _rObj );
247 };
248 
250  public SwXShape,
251  public css::drawing::XShapes
252 {
253 protected:
254  virtual ~SwXGroupShape() override;
255 public:
256  SwXGroupShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
257 
258  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
259  virtual void SAL_CALL acquire( ) throw() override;
260  virtual void SAL_CALL release( ) throw() override;
261 
262  //XShapes
263  virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
264  virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
265 
266  //XIndexAccess
267  virtual sal_Int32 SAL_CALL getCount() override;
268  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
269 
270  //XElementAccess
271  virtual css::uno::Type SAL_CALL getElementType( ) override;
272  virtual sal_Bool SAL_CALL hasElements( ) override;
273 };
274 #endif
275 
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unodraw.cxx:1748
SwXGroupShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *pDoc)
Definition: unodraw.cxx:2686
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:2794
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unodraw.cxx:1956
std::unique_ptr< SwShapeDescriptor_Impl > pImpl
Definition: unodraw.hxx:137
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:536
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unodraw.cxx:1041
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:2824
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unodraw.cxx:1014
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:2153
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:474
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unodraw.cxx:1969
Definition: doc.hxx:185
SdrObject * GetTopGroupObj(SvxShape *_pSvxShape=nullptr)
method to determine top group object
Definition: unodraw.cxx:2344
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: unodraw.cxx:321
virtual void SAL_CALL dispose() override
Definition: unodraw.cxx:2084
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:998
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:2839
void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup > &rShapeGroup)
Definition: unodraw.cxx:268
virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > &xShapes) override
Definition: unodraw.cxx:738
SwShapeDescriptor_Impl * GetDescImpl()
Definition: unodraw.hxx:241
virtual void SAL_CALL acquire() override
Definition: unodraw.cxx:2710
SwXDrawPage(SwDoc *pDoc)
Definition: unodraw.cxx:480
virtual css::awt::Point SAL_CALL getPosition() override
Definition: unodraw.cxx:2183
virtual ~SwXGroupShape() override
Definition: unodraw.cxx:2696
void RemovePageView()
Definition: unodraw.cxx:281
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2132
SdrPageView * GetPageView()
Definition: unodraw.cxx:274
const SfxItemPropertyMapEntry * m_pPropertyMapEntries
Definition: unodraw.hxx:135
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:464
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1989
SdrPageView * pPageView
Definition: unodraw.hxx:42
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unodraw.cxx:1740
css::awt::Point GetAttrPosition()
method to determine position according to the positioning attributes
Definition: unodraw.cxx:2368
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:2158
css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(const css::drawing::HomogenMatrix3 &rMatrixInHoriL2R)
method to convert the transformation of the drawing object to the layout direction, the drawing object is in
Definition: unodraw.cxx:2453
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:553
Style of a layout element.
Definition: frmfmt.hxx:57
SwXShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *pDoc)
Definition: unodraw.cxx:883
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unodraw.cxx:1019
SvxShape * GetSvxShape()
Definition: unodraw.cxx:2168
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:2593
static css::uno::Reference< css::uno::XInterface > GetInterface(SdrObject *pObj)
Definition: unodraw.cxx:288
std::unique_ptr< SdrView > mpView
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unodraw.cxx:847
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:495
unsigned char sal_Bool
SwFmDrawPage * GetSvxPage()
Definition: unodraw.cxx:811
SdrView * GetDrawView()
Definition: unodraw.hxx:50
css::uno::Reference< css::drawing::XShape > mxShape
Definition: unodraw.hxx:132
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:522
const css::uno::Reference< css::uno::XAggregation > & GetAggregationInterface()
Definition: unodraw.hxx:243
cppu::WeakAggImplHelper4< css::container::XEnumerationAccess, css::drawing::XDrawPage, css::lang::XServiceInfo, css::drawing::XShapeGrouper > SwXDrawPageBaseClass
Definition: unodraw.hxx:68
cppu::WeakAggImplHelper6< css::beans::XPropertySet, css::beans::XPropertyState, css::text::XTextContent, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::drawing::XShape > SwXShapeBaseClass
Definition: unodraw.hxx:110
virtual ~SwXDrawPage() override
Definition: unodraw.cxx:486
static void AddExistingShapeToFormat(SdrObject const &_rObj)
Definition: unodraw.cxx:932
css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(const css::drawing::PolyPolygonBezierCoords &aPath)
method to convert PolyPolygonBezier of the drawing object to the Writer specific position, which is the attribute position in layout direction
Definition: unodraw.cxx:2631
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:564
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unodraw.cxx:457
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2720
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:2148
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unodraw.cxx:1438
SwFmDrawPage(SdrPage *pPage)
Definition: unodraw.cxx:251
virtual ~SwXShape() override
Definition: unodraw.cxx:966
css::uno::Reference< css::uno::XAggregation > xShapeAgg
Definition: unodraw.hxx:129
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:2700
css::uno::Reference< css::uno::XAggregation > xPageAgg
Definition: unodraw.hxx:72
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:514
virtual void SAL_CALL setPosition(const css::awt::Point &aPosition) override
Definition: unodraw.cxx:2223
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unodraw.cxx:852
SwDoc * pDoc
Definition: unodraw.hxx:71
void AdjustPositionProperties(const css::awt::Point &rPosition)
method to adjust the positioning properties
Definition: unodraw.cxx:2517
css::uno::Any _getPropAtAggrObj(const OUString &_rPropertyName)
method to get property from aggregation object
Definition: unodraw.cxx:1723
void InvalidateSwDoc()
Renamed and outlined to detect where it's called.
Definition: unodraw.cxx:837
virtual css::awt::Size SAL_CALL getSize() override
Definition: unodraw.cxx:2311
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:2412
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:978
virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > &aGroup) override
Definition: unodraw.cxx:787
const SfxItemPropertySet * m_pPropSet
Definition: unodraw.hxx:134
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:469
virtual void SAL_CALL release() override
Definition: unodraw.cxx:2715
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2140
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: unodraw.cxx:1996
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unodraw.cxx:1923
virtual ~SwFmDrawPage() override
Definition: unodraw.cxx:256
const SdrMarkList & PreGroup(const css::uno::Reference< css::drawing::XShapes > &rShapes)
Definition: unodraw.cxx:261
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:2809
bool m_bDescriptor
Definition: unodraw.hxx:139
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:242
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unodraw.cxx:1862
virtual OUString SAL_CALL getShapeType() override
Definition: unodraw.cxx:2333
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:548
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unodraw.cxx:2001
SwFmDrawPage * pDrawPage
Definition: unodraw.hxx:73
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unodraw.cxx:2062
virtual void SAL_CALL setSize(const css::awt::Size &aSize) override
Definition: unodraw.cxx:2321
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1982