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 <svx/fmdpage.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 #include <svl/itemprop.hxx>
42 class SwFmDrawPage
: public SvxFmDrawPage
44 SdrPageView
* pPageView
;
46 SwFmDrawPage( SdrPage
* pPage
);
47 virtual ~SwFmDrawPage() throw () override
;
49 const SdrMarkList
& PreGroup(const css::uno::Reference
< css::drawing::XShapes
>& rShapes
);
50 void PreUnGroup(const css::uno::Reference
< css::drawing::XShapeGroup
>& rShapeGroup
);
52 SdrView
* GetDrawView() {return mpView
;}
53 SdrPageView
* GetPageView();
54 void RemovePageView();
55 static css::uno::Reference
< css::uno::XInterface
> GetInterface( SdrObject
* pObj
);
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
;
63 typedef cppu::WeakAggImplHelper4
65 css::container::XEnumerationAccess
,
66 css::drawing::XDrawPage
,
67 css::lang::XServiceInfo
,
68 css::drawing::XShapeGrouper
71 class SwXDrawPage
: public SwXDrawPageBaseClass
74 css::uno::Reference
< css::uno::XAggregation
> xPageAgg
;
75 SwFmDrawPage
* pDrawPage
;
77 SwXDrawPage(SwDoc
* pDoc
);
78 virtual ~SwXDrawPage() override
;
81 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() override
;
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
;
87 virtual sal_Int32 SAL_CALL
getCount() override
;
88 virtual css::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) override
;
91 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
92 virtual sal_Bool SAL_CALL
hasElements( ) override
;
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
;
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
;
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
;
107 SwFmDrawPage
* GetSvxPage();
108 // renamed and outlined to detect where it's called
109 void InvalidateSwDoc(); // {pDoc = 0;}
112 class SwShapeDescriptor_Impl
;
115 cppu::WeakAggImplHelper6
117 css::beans::XPropertySet
,
118 css::beans::XPropertyState
,
119 css::text::XTextContent
,
120 css::lang::XServiceInfo
,
121 css::lang::XUnoTunnel
,
125 class SwXShape
: public SwXShapeBaseClass
,
128 friend class SwXGroupShape
;
129 friend class SwXDrawPage
;
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
;
136 const SfxItemPropertySet
* m_pPropSet
;
137 const SfxItemPropertyMapEntry
* m_pPropertyMapEntries
;
139 SwShapeDescriptor_Impl
* pImpl
;
143 SvxShape
* GetSvxShape();
145 /** method to determine top group object
149 SdrObject
* GetTopGroupObj( SvxShape
* _pSvxShape
= nullptr );
151 /** 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.
162 css::awt::Point
ConvertPositionToHoriL2R(
163 const css::awt::Point
& rObjPos
,
164 const css::awt::Size
& rObjSize
);
166 /** method to convert the transformation of the drawing object to the layout
167 direction, the drawing object is in
171 css::drawing::HomogenMatrix3
ConvertTransformationToLayoutDir(
172 const css::drawing::HomogenMatrix3
& rMatrixInHoriL2R
);
174 /** method to adjust the positioning properties
179 input parameter - point representing the new shape position. The position
180 has to be given in the layout direction the shape is in and relative to
181 its position alignment areas.
183 void AdjustPositionProperties(const css::awt::Point
& rPosition
);
185 /** method to convert start or end position of the drawing object to the
186 Writer specific position, which is the attribute position in layout direction
190 css::awt::Point
ConvertStartOrEndPosToLayoutDir(
191 const css::awt::Point
& aStartOrEndPos
);
193 /** method to convert PolyPolygonBezier of the drawing object to the
194 Writer specific position, which is the attribute position in layout direction
198 css::drawing::PolyPolygonBezierCoords
ConvertPolyPolygonBezierToLayoutDir(
199 const css::drawing::PolyPolygonBezierCoords
& aPath
);
201 /** method to get property from aggregation object
205 @throws css::beans::UnknownPropertyException
206 @throws css::lang::WrappedTargetException
207 @throws css::uno::RuntimeException
209 css::uno::Any
_getPropAtAggrObj( const OUString
& _rPropertyName
);
212 virtual ~SwXShape() override
;
214 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) override
;
217 SwXShape(css::uno::Reference
< css::uno::XInterface
> & xShape
);
219 static const css::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
220 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
221 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
222 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
225 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
228 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
229 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
230 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
231 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
232 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
233 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
234 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
237 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
238 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
239 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
240 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
243 virtual void SAL_CALL
attach(const css::uno::Reference
< css::text::XTextRange
> & xTextRange
) override
;
244 virtual css::uno::Reference
< css::text::XTextRange
> SAL_CALL
getAnchor() override
;
247 virtual void SAL_CALL
dispose() override
;
248 virtual void SAL_CALL
addEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
;
249 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
< css::lang::XEventListener
> & aListener
) override
;
252 virtual OUString SAL_CALL
getImplementationName() override
;
253 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
254 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
256 virtual css::awt::Point SAL_CALL
getPosition( ) override
;
257 virtual void SAL_CALL
setPosition( const css::awt::Point
& aPosition
) override
;
258 virtual css::awt::Size SAL_CALL
getSize( ) override
;
259 virtual void SAL_CALL
setSize( const css::awt::Size
& aSize
) override
;
260 virtual OUString SAL_CALL
getShapeType( ) override
;
262 SwShapeDescriptor_Impl
* GetDescImpl() {return pImpl
;}
263 SwFrameFormat
* GetFrameFormat() const { return const_cast<SwFrameFormat
*>(static_cast<const SwFrameFormat
*>(GetRegisteredIn())); }
264 const css::uno::Reference
< css::uno::XAggregation
>& GetAggregationInterface() {return xShapeAgg
;}
267 static void AddExistingShapeToFormat( SdrObject
& _rObj
);
270 class SwXGroupShape
:
272 public css::drawing::XShapes
275 virtual ~SwXGroupShape() override
;
277 SwXGroupShape(css::uno::Reference
< css::uno::XInterface
> & xShape
);
279 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
280 virtual void SAL_CALL
acquire( ) throw() override
;
281 virtual void SAL_CALL
release( ) throw() override
;
284 virtual void SAL_CALL
add( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
285 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
288 virtual sal_Int32 SAL_CALL
getCount() override
;
289 virtual css::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) override
;
292 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
293 virtual sal_Bool SAL_CALL
hasElements( ) override
;
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */