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/implbase3.hxx>
32 #include <cppuhelper/implbase4.hxx>
33 #include <cppuhelper/implbase6.hxx>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
36 #include <svl/itemprop.hxx>
43 class SwFmDrawPage
: public SvxFmDrawPage
45 SdrPageView
* pPageView
;
48 // Create a SdrObject according to a description. Can be used by derived classes to
49 // support own ::com::sun::star::drawing::Shapes (e.g. controls).
50 virtual SdrObject
*_CreateSdrObject( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
)
51 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
54 SwFmDrawPage( SdrPage
* pPage
);
55 virtual ~SwFmDrawPage() throw ();
57 const SdrMarkList
& PreGroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& rShapes
);
58 void PreUnGroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapeGroup
>& rShapeGroup
);
60 SdrView
* GetDrawView() {return mpView
;}
61 SdrPageView
* GetPageView();
62 void RemovePageView();
63 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> GetInterface( SdrObject
* pObj
);
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 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> _CreateShape( SdrObject
*pObj
) const throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
71 typedef cppu::WeakAggImplHelper4
73 ::com::sun::star::container::XEnumerationAccess
,
74 ::com::sun::star::drawing::XDrawPage
,
75 ::com::sun::star::lang::XServiceInfo
,
76 ::com::sun::star::drawing::XShapeGrouper
79 class SwXDrawPage
: public SwXDrawPageBaseClass
82 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> xPageAgg
;
83 SwFmDrawPage
* pDrawPage
;
85 SwXDrawPage(SwDoc
* pDoc
);
86 virtual ~SwXDrawPage();
89 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
92 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual sal_Int32 SAL_CALL
getCount() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
96 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
100 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
103 virtual void SAL_CALL
add(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 virtual void SAL_CALL
remove(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapeGroup
> SAL_CALL
group(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
> & xShapes
)
108 throw (::com::sun::star::uno::RuntimeException
,
109 std::exception
) SAL_OVERRIDE
;
110 virtual void SAL_CALL
ungroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapeGroup
> & aGroup
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 virtual OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
117 SwFmDrawPage
* GetSvxPage();
118 // renamed and outlined to detect where it's called
119 void InvalidateSwDoc(); // {pDoc = 0;}
121 /// Same as getByIndex(nIndex), except that it also takes a set of formats to ignore, so the method itself doesn't have to generate such a list.
122 css::uno::Any
getByIndex(sal_Int32 nIndex
, std::set
<const SwFrameFormat
*>* pTextBoxes
) throw(css::lang::IndexOutOfBoundsException
, css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
);
125 class SwShapeDescriptor_Impl
;
128 cppu::WeakAggImplHelper6
130 ::com::sun::star::beans::XPropertySet
,
131 ::com::sun::star::beans::XPropertyState
,
132 ::com::sun::star::text::XTextContent
,
133 ::com::sun::star::lang::XServiceInfo
,
134 ::com::sun::star::lang::XUnoTunnel
,
135 ::com::sun::star::drawing::XShape
138 class SwXShape
: public SwXShapeBaseClass
,
141 friend class SwXGroupShape
;
142 friend class SwXDrawPage
;
144 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> xShapeAgg
;
145 // reference to <XShape>, determined in the
146 // constructor by <queryAggregation> at <xShapeAgg>.
147 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> mxShape
;
149 const SfxItemPropertySet
* m_pPropSet
;
150 const SfxItemPropertyMapEntry
* m_pPropertyMapEntries
;
152 SwShapeDescriptor_Impl
* pImpl
;
156 SvxShape
* GetSvxShape();
158 /** method to determine top group object
162 SdrObject
* _GetTopGroupObj( SvxShape
* _pSvxShape
= 0L );
164 /** method to determine position according to the positioning attributes
168 com::sun::star::awt::Point
_GetAttrPosition();
170 /** method to convert the position (translation) of the drawing object to
171 the layout direction horizontal left-to-right.
175 ::com::sun::star::awt::Point
_ConvertPositionToHoriL2R(
176 const css::awt::Point
& rObjPos
,
177 const css::awt::Size
& rObjSize
);
179 /** method to convert the transformation of the drawing object to the layout
180 direction, the drawing object is in
184 css::drawing::HomogenMatrix3
_ConvertTransformationToLayoutDir(
185 const css::drawing::HomogenMatrix3
& rMatrixInHoriL2R
);
187 /** method to adjust the positioning properties
192 input parameter - point representing the new shape position. The position
193 has to be given in the layout direction the shape is in and relative to
194 its position alignment areas.
196 void _AdjustPositionProperties(const css::awt::Point
& rPosition
);
198 /** method to convert start or end position of the drawing object to the
199 Writer specific position, which is the attribute position in layout direction
203 ::com::sun::star::awt::Point
_ConvertStartOrEndPosToLayoutDir(
204 const ::com::sun::star::awt::Point
& aStartOrEndPos
);
206 /** method to convert PolyPolygonBezier of the drawing object to the
207 Writer specific position, which is the attribute position in layout direction
211 ::com::sun::star::drawing::PolyPolygonBezierCoords
_ConvertPolyPolygonBezierToLayoutDir(
212 const ::com::sun::star::drawing::PolyPolygonBezierCoords
& aPath
);
214 /** method to get property from aggregation object
218 ::com::sun::star::uno::Any
_getPropAtAggrObj( const OUString
& _rPropertyName
)
219 throw( ::com::sun::star::beans::UnknownPropertyException
,
220 ::com::sun::star::lang::WrappedTargetException
,
221 ::com::sun::star::uno::RuntimeException
);
226 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
) SAL_OVERRIDE
;
229 SwXShape(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> & xShape
);
232 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
233 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
234 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
235 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
238 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
241 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
242 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
243 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
244 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
245 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
246 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
247 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
250 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
251 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
getPropertyStates( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
252 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
253 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
256 virtual void SAL_CALL
attach(const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> & xTextRange
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
257 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getAnchor() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
260 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
261 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
262 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
265 virtual OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
266 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
267 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
269 virtual ::com::sun::star::awt::Point SAL_CALL
getPosition( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
270 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
271 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
272 virtual void SAL_CALL
setSize( const ::com::sun::star::awt::Size
& aSize
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
273 virtual OUString SAL_CALL
getShapeType( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
275 SwShapeDescriptor_Impl
* GetDescImpl() {return pImpl
;}
276 SwFrameFormat
* GetFrameFormat() const { return const_cast<SwFrameFormat
*>(static_cast<const SwFrameFormat
*>(GetRegisteredIn())); }
277 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> GetAggregationInterface() {return xShapeAgg
;}
280 static void AddExistingShapeToFormat( SdrObject
& _rObj
);
283 class SwXGroupShape
:
285 public ::com::sun::star::drawing::XShapes
288 virtual ~SwXGroupShape();
290 SwXGroupShape(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> & xShape
);
292 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
293 virtual void SAL_CALL
acquire( ) throw() SAL_OVERRIDE
;
294 virtual void SAL_CALL
release( ) throw() SAL_OVERRIDE
;
297 virtual void SAL_CALL
add( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
298 virtual void SAL_CALL
remove( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
301 virtual sal_Int32 SAL_CALL
getCount() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
302 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex(sal_Int32 nIndex
) throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
305 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
306 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */