1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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/implbase.hxx>
34 #include <cppuhelper/implbase2.hxx>
35 #include <com/sun/star/container/XEnumerationAccess.hpp>
36 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
43 typedef cppu::AggImplInheritanceHelper2
46 css::container::XEnumerationAccess
,
47 css::beans::XPropertySet
>
50 class SwFmDrawPage final
: public SwFmDrawPage_Base
53 SdrPageView
* m_pPageView
;
54 std::vector
<rtl::Reference
<SwXShape
>> m_vShapes
;
55 const SfxItemPropertySet
* m_pPropertySet
;
58 SwFmDrawPage( SwDoc
* pDoc
, SdrPage
* pPage
);
59 virtual ~SwFmDrawPage() noexcept override
;
61 const SdrMarkList
& PreGroup(const css::uno::Reference
< css::drawing::XShapes
>& rShapes
);
62 void PreUnGroup(const css::uno::Reference
< css::drawing::XShapeGroup
>& rShapeGroup
);
64 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
);
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
)
76 auto ppShape
= find(m_vShapes
.begin(), m_vShapes
.end(), pShape
);
77 if(ppShape
!= m_vShapes
.end())
78 m_vShapes
.erase(ppShape
);
82 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() override
;
85 virtual sal_Int32 SAL_CALL
getCount() override
;
86 virtual css::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) override
;
89 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
90 virtual sal_Bool SAL_CALL
hasElements( ) override
;
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
;
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
;
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
;
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
;
114 // renamed and outlined to detect where it's called
115 void InvalidateSwDoc(); // {pDoc = 0;}
118 class SwShapeDescriptor_Impl
;
122 css::beans::XPropertySet
,
123 css::beans::XPropertyState
,
124 css::text::XTextContent
,
125 css::lang::XServiceInfo
,
126 css::lang::XUnoTunnel
,
130 class SwXShape
: public SwXShapeBaseClass
132 friend class SwXGroupShape
;
133 friend class SwFmDrawPage
;
134 const SwFmDrawPage
* m_pPage
;
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
;
141 const SfxItemPropertySet
* m_pPropSet
;
142 o3tl::span
<const SfxItemPropertyMapEntry
> m_pPropertyMapEntries
;
143 css::uno::Reference
< css::beans::XPropertySetInfo
> mxPropertySetInfo
;
145 std::unique_ptr
<SwShapeDescriptor_Impl
> m_pImpl
;
149 SvxShape
* GetSvxShape();
151 /** method to determine top group object */
152 SdrObject
* GetTopGroupObj( SvxShape
* _pSvxShape
= nullptr );
154 /** method to determine position according to the positioning attributes */
155 css::awt::Point
GetAttrPosition();
157 /** method to convert the position (translation) of the drawing object to
158 the layout direction horizontal left-to-right. */
159 css::awt::Point
ConvertPositionToHoriL2R(
160 const css::awt::Point
& rObjPos
,
161 const css::awt::Size
& rObjSize
);
163 /** method to convert the transformation of the drawing object to the layout
164 direction, the drawing object is in
166 css::drawing::HomogenMatrix3
ConvertTransformationToLayoutDir(
167 const css::drawing::HomogenMatrix3
& rMatrixInHoriL2R
);
169 /** method to adjust the positioning properties
172 input parameter - point representing the new shape position. The position
173 has to be given in the layout direction the shape is in and relative to
174 its position alignment areas.
176 void AdjustPositionProperties(const css::awt::Point
& rPosition
);
178 /** method to convert start or end position of the drawing object to the
179 Writer specific position, which is the attribute position in layout direction
181 css::awt::Point
ConvertStartOrEndPosToLayoutDir(
182 const css::awt::Point
& aStartOrEndPos
);
184 /** method to convert PolyPolygonBezier of the drawing object to the
185 Writer specific position, which is the attribute position in layout direction
187 css::drawing::PolyPolygonBezierCoords
ConvertPolyPolygonBezierToLayoutDir(
188 const css::drawing::PolyPolygonBezierCoords
& aPath
);
190 /** method to get property from aggregation object
192 @throws css::beans::UnknownPropertyException
193 @throws css::lang::WrappedTargetException
194 @throws css::uno::RuntimeException
196 css::uno::Any
_getPropAtAggrObj( const OUString
& _rPropertyName
);
199 virtual ~SwXShape() override
;
201 SwXShape(css::uno::Reference
<css::uno::XInterface
> & xShape
, SwDoc
const*const pDoc
);
203 static const css::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
204 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
205 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
206 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
209 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
212 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
213 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
214 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
215 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
216 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
217 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
218 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
221 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
222 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
223 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
224 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
227 virtual void SAL_CALL
attach(const css::uno::Reference
< css::text::XTextRange
> & xTextRange
) override
;
228 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor() override
;
231 virtual void SAL_CALL
dispose() override
;
232 virtual void SAL_CALL
addEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
;
233 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
;
236 virtual OUString SAL_CALL
getImplementationName() override
;
237 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
238 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
240 virtual css::awt::Point SAL_CALL
getPosition( ) override
;
241 virtual void SAL_CALL
setPosition( const css::awt::Point
& aPosition
) override
;
242 virtual css::awt::Size SAL_CALL
getSize( ) override
;
243 virtual void SAL_CALL
setSize( const css::awt::Size
& aSize
) override
;
244 virtual OUString SAL_CALL
getShapeType( ) override
;
246 SwShapeDescriptor_Impl
* GetDescImpl() {return m_pImpl
.get();}
247 SwFrameFormat
* GetFrameFormat() const;
248 const css::uno::Reference
< css::uno::XAggregation
>& GetAggregationInterface() const {return m_xShapeAgg
;}
251 static void AddExistingShapeToFormat( SdrObject
const & _rObj
);
254 class SwXGroupShape final
:
256 public css::drawing::XShapes
258 virtual ~SwXGroupShape() override
;
260 SwXGroupShape(css::uno::Reference
<css::uno::XInterface
> & xShape
, SwDoc
const* pDoc
);
262 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
263 virtual void SAL_CALL
acquire( ) noexcept override
;
264 virtual void SAL_CALL
release( ) noexcept override
;
267 virtual void SAL_CALL
add( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
268 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
271 virtual sal_Int32 SAL_CALL
getCount() override
;
272 virtual css::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) override
;
275 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
276 virtual sal_Bool SAL_CALL
hasElements( ) override
;
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */