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 <svx/fmdpage.hxx>
24 #include "calbck.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 <cppuhelper/implbase4.hxx>
34 #include <cppuhelper/implbase6.hxx>
35 #include <com/sun/star/container/XEnumerationAccess.hpp>
36 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
37 
38 class SdrMarkList;
39 class SdrView;
40 class SwDoc;
41 
43 {
45 public:
46  SwFmDrawPage( SdrPage* pPage );
47  virtual ~SwFmDrawPage() throw () override;
48 
49  const SdrMarkList& PreGroup(const css::uno::Reference< css::drawing::XShapes >& rShapes);
50  void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup >& rShapeGroup);
51 
52  SdrView* GetDrawView() {return mpView.get();}
54  void RemovePageView();
55  static css::uno::Reference< css::uno::XInterface > GetInterface( SdrObject* pObj );
56 
57  // The following method is called when a SvxShape-object is to be created.
58  // Derived classes may obtain at this point a derivation or an object
59  // that is aggregating a SvxShape.
60  virtual css::uno::Reference< css::drawing::XShape > CreateShape( SdrObject *pObj ) const override;
61 };
62 
64 <
65  css::container::XEnumerationAccess,
66  css::drawing::XDrawPage,
67  css::lang::XServiceInfo,
68  css::drawing::XShapeGrouper
69 >
72 {
74  css::uno::Reference< css::uno::XAggregation > xPageAgg;
76 public:
77  SwXDrawPage(SwDoc* pDoc);
78  virtual ~SwXDrawPage() override;
79 
80  //XEnumerationAccess
81  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
82 
83  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
84  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
85 
86  //XIndexAccess
87  virtual sal_Int32 SAL_CALL getCount() override;
88  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
89 
90  //XElementAccess
91  virtual css::uno::Type SAL_CALL getElementType( ) override;
92  virtual sal_Bool SAL_CALL hasElements( ) override;
93 
94  //XShapes
95  virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > & xShape) override;
96  virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > & xShape) override;
97 
98  //XShapeGrouper
99  virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > & xShapes) override;
100  virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > & aGroup) override;
101 
102  //XServiceInfo
103  virtual OUString SAL_CALL getImplementationName() override;
104  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
105  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
106 
108  // renamed and outlined to detect where it's called
109  void InvalidateSwDoc(); // {pDoc = 0;}
110 };
111 
113 typedef
115 <
116  css::beans::XPropertySet,
117  css::beans::XPropertyState,
118  css::text::XTextContent,
119  css::lang::XServiceInfo,
120  css::lang::XUnoTunnel,
121  css::drawing::XShape
122 >
125  public SwClient
126 {
127  friend class SwXGroupShape;
128  friend class SwXDrawPage;
129  friend class SwFmDrawPage;
130 
131  css::uno::Reference< css::uno::XAggregation > xShapeAgg;
132  // reference to <XShape>, determined in the
133  // constructor by <queryAggregation> at <xShapeAgg>.
134  css::uno::Reference< css::drawing::XShape > mxShape;
135 
138 
139  std::unique_ptr<SwShapeDescriptor_Impl> pImpl;
140 
142 
144 
146  SdrObject* GetTopGroupObj( SvxShape* _pSvxShape = nullptr );
147 
149  css::awt::Point GetAttrPosition();
150 
153  css::awt::Point ConvertPositionToHoriL2R(
154  const css::awt::Point& rObjPos,
155  const css::awt::Size& rObjSize );
156 
160  css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(
161  const css::drawing::HomogenMatrix3& rMatrixInHoriL2R );
162 
170  void AdjustPositionProperties(const css::awt::Point& rPosition);
171 
175  css::awt::Point ConvertStartOrEndPosToLayoutDir(
176  const css::awt::Point& aStartOrEndPos );
177 
181  css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(
182  const css::drawing::PolyPolygonBezierCoords& aPath );
183 
190  css::uno::Any _getPropAtAggrObj( const OUString& _rPropertyName );
191 
192 protected:
193  virtual ~SwXShape() override;
194  //SwClient
195  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
196 
197 public:
198  SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
199 
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 
243  SwShapeDescriptor_Impl* GetDescImpl() {return pImpl.get();}
244  SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
245  const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() {return xShapeAgg;}
246 
247  // helper
248  static void AddExistingShapeToFormat( SdrObject const & _rObj );
249 };
250 
252  public SwXShape,
253  public css::drawing::XShapes
254 {
255 protected:
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( ) throw() override;
262  virtual void SAL_CALL release( ) throw() 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: */
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unodraw.cxx:1747
SwXGroupShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *pDoc)
Definition: unodraw.cxx:2675
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:2783
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unodraw.cxx:1955
std::unique_ptr< SwShapeDescriptor_Impl > pImpl
Definition: unodraw.hxx:139
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:535
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unodraw.cxx:1040
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:2813
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unodraw.cxx:1013
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:2152
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:473
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unodraw.cxx:1968
Definition: doc.hxx:185
SdrObject * GetTopGroupObj(SvxShape *_pSvxShape=nullptr)
method to determine top group object
Definition: unodraw.cxx:2339
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: unodraw.cxx:320
virtual void SAL_CALL dispose() override
Definition: unodraw.cxx:2083
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:997
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:2828
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:737
SwShapeDescriptor_Impl * GetDescImpl()
Definition: unodraw.hxx:243
virtual void SAL_CALL acquire() override
Definition: unodraw.cxx:2699
SwXDrawPage(SwDoc *pDoc)
Definition: unodraw.cxx:479
virtual css::awt::Point SAL_CALL getPosition() override
Definition: unodraw.cxx:2182
virtual ~SwXGroupShape() override
Definition: unodraw.cxx:2685
void RemovePageView()
Definition: unodraw.cxx:280
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2131
SdrPageView * GetPageView()
Definition: unodraw.cxx:273
const SfxItemPropertyMapEntry * m_pPropertyMapEntries
Definition: unodraw.hxx:137
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:463
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1988
SdrPageView * pPageView
Definition: unodraw.hxx:44
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unodraw.cxx:1739
css::awt::Point GetAttrPosition()
method to determine position according to the positioning attributes
Definition: unodraw.cxx:2363
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:2157
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:2448
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:552
Style of a layout element.
Definition: frmfmt.hxx:57
SwXShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *pDoc)
Definition: unodraw.cxx:882
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unodraw.cxx:1018
SvxShape * GetSvxShape()
Definition: unodraw.cxx:2167
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:2588
static css::uno::Reference< css::uno::XInterface > GetInterface(SdrObject *pObj)
Definition: unodraw.cxx:287
std::unique_ptr< SdrView > mpView
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unodraw.cxx:846
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:494
unsigned char sal_Bool
SwFmDrawPage * GetSvxPage()
Definition: unodraw.cxx:810
SdrView * GetDrawView()
Definition: unodraw.hxx:52
css::uno::Reference< css::drawing::XShape > mxShape
Definition: unodraw.hxx:134
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:521
const css::uno::Reference< css::uno::XAggregation > & GetAggregationInterface()
Definition: unodraw.hxx:245
cppu::WeakAggImplHelper4< css::container::XEnumerationAccess, css::drawing::XDrawPage, css::lang::XServiceInfo, css::drawing::XShapeGrouper > SwXDrawPageBaseClass
Definition: unodraw.hxx:70
cppu::WeakAggImplHelper6< css::beans::XPropertySet, css::beans::XPropertyState, css::text::XTextContent, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::drawing::XShape > SwXShapeBaseClass
Definition: unodraw.hxx:112
virtual ~SwXDrawPage() override
Definition: unodraw.cxx:485
static void AddExistingShapeToFormat(SdrObject const &_rObj)
Definition: unodraw.cxx:931
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:2626
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:563
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unodraw.cxx:456
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2709
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:2147
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unodraw.cxx:1437
SwFmDrawPage(SdrPage *pPage)
Definition: unodraw.cxx:251
virtual ~SwXShape() override
Definition: unodraw.cxx:965
css::uno::Reference< css::uno::XAggregation > xShapeAgg
Definition: unodraw.hxx:131
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:2689
css::uno::Reference< css::uno::XAggregation > xPageAgg
Definition: unodraw.hxx:74
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:513
virtual void SAL_CALL setPosition(const css::awt::Point &aPosition) override
Definition: unodraw.cxx:2220
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:851
SwDoc * pDoc
Definition: unodraw.hxx:73
void AdjustPositionProperties(const css::awt::Point &rPosition)
method to adjust the positioning properties
Definition: unodraw.cxx:2512
css::uno::Any _getPropAtAggrObj(const OUString &_rPropertyName)
method to get property from aggregation object
Definition: unodraw.cxx:1722
void InvalidateSwDoc()
Renamed and outlined to detect where it's called.
Definition: unodraw.cxx:836
virtual css::awt::Size SAL_CALL getSize() override
Definition: unodraw.cxx:2306
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:2407
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:977
virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > &aGroup) override
Definition: unodraw.cxx:786
const SfxItemPropertySet * m_pPropSet
Definition: unodraw.hxx:136
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:468
virtual void SAL_CALL release() override
Definition: unodraw.cxx:2704
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2139
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: unodraw.cxx:1995
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unodraw.cxx:1922
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:2798
bool m_bDescriptor
Definition: unodraw.hxx:141
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:244
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unodraw.cxx:1861
virtual OUString SAL_CALL getShapeType() override
Definition: unodraw.cxx:2328
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:547
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unodraw.cxx:2000
SwFmDrawPage * pDrawPage
Definition: unodraw.hxx:75
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unodraw.cxx:2061
virtual void SAL_CALL setSize(const css::awt::Size &aSize) override
Definition: unodraw.cxx:2316
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1981