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 .
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> // helper for implementations
32 #include <cppuhelper/implbase4.hxx> // helper for implementations
33 #include <cppuhelper/implbase6.hxx> // helper for implementations
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
36 #include <svl/itemprop.hxx>
42 class SwFmDrawPage
: public SvxFmDrawPage
44 SdrPageView
* pPageView
;
47 // Create a SdrObject according to a description. Can be used by derived classes to
48 // support own ::com::sun::star::drawing::Shapes (e.g. controls).
49 virtual SdrObject
*_CreateSdrObject( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
) throw ();
52 SwFmDrawPage( SdrPage
* pPage
);
53 virtual ~SwFmDrawPage() throw ();
55 const SdrMarkList
& PreGroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
> & xShapes
);
56 void PreUnGroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapeGroup
> xShapeGroup
);
58 SdrView
* GetDrawView() {return mpView
;}
59 SdrPageView
* GetPageView();
60 void RemovePageView();
61 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> GetInterface( SdrObject
* pObj
);
63 // The following method is called when a SvxShape-object is to be created.
64 // Derived classes may obtain at this point a derivation or an object
65 // that is aggregating a SvxShape.
66 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> _CreateShape( SdrObject
*pObj
) const throw ();
69 typedef cppu::WeakAggImplHelper4
71 ::com::sun::star::container::XEnumerationAccess
,
72 ::com::sun::star::drawing::XDrawPage
,
73 ::com::sun::star::lang::XServiceInfo
,
74 ::com::sun::star::drawing::XShapeGrouper
77 class SwXDrawPage
: public SwXDrawPageBaseClass
80 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> xPageAgg
;
81 SwFmDrawPage
* pDrawPage
;
83 SwXDrawPage(SwDoc
* pDoc
);
87 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException
);
89 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
);
90 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
93 virtual sal_Int32 SAL_CALL
getCount(void) throw( ::com::sun::star::uno::RuntimeException
);
94 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
);
97 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
98 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
101 virtual void SAL_CALL
add(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
) throw( ::com::sun::star::uno::RuntimeException
);
102 virtual void SAL_CALL
remove(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> & xShape
) throw( ::com::sun::star::uno::RuntimeException
);
105 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
) throw( ::com::sun::star::uno::RuntimeException
);
106 virtual void SAL_CALL
ungroup(const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapeGroup
> & aGroup
) throw( ::com::sun::star::uno::RuntimeException
);
109 virtual OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
110 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
111 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
113 SwFmDrawPage
* GetSvxPage();
114 // renamed and outlined to detect where it's called
115 void InvalidateSwDoc(); // {pDoc = 0;}
118 class SwShapeDescriptor_Impl
;
121 cppu::WeakAggImplHelper6
123 ::com::sun::star::beans::XPropertySet
,
124 ::com::sun::star::beans::XPropertyState
,
125 ::com::sun::star::text::XTextContent
,
126 ::com::sun::star::lang::XServiceInfo
,
127 ::com::sun::star::lang::XUnoTunnel
,
128 ::com::sun::star::drawing::XShape
131 class SwXShape
: public SwXShapeBaseClass
,
134 friend class SwXGroupShape
;
135 friend class SwXDrawPage
;
137 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> xShapeAgg
;
138 // reference to <XShape>, determined in the
139 // constructor by <queryAggregation> at <xShapeAgg>.
140 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> mxShape
;
142 const SfxItemPropertySet
* m_pPropSet
;
143 const SfxItemPropertyMapEntry
* m_pPropertyMapEntries
;
144 com::sun::star::uno::Sequence
< sal_Int8
>* pImplementationId
;
146 SwShapeDescriptor_Impl
* pImpl
;
148 sal_Bool m_bDescriptor
;
150 SvxShape
* GetSvxShape();
152 /** method to determine top group object
156 SdrObject
* _GetTopGroupObj( SvxShape
* _pSvxShape
= 0L );
158 /** method to determine position according to the positioning attributes
162 com::sun::star::awt::Point
_GetAttrPosition();
164 /** method to convert the position (translation) of the drawing object to
165 the layout direction horizontal left-to-right.
169 ::com::sun::star::awt::Point
_ConvertPositionToHoriL2R(
170 const ::com::sun::star::awt::Point _aObjPos
,
171 const ::com::sun::star::awt::Size _aObjSize
);
173 /** method to convert the transformation of the drawing object to the layout
174 direction, the drawing object is in
178 ::com::sun::star::drawing::HomogenMatrix3
_ConvertTransformationToLayoutDir(
179 ::com::sun::star::drawing::HomogenMatrix3 _aMatrixInHoriL2R
);
181 /** method to adjust the positioning properties
186 input parameter - point representing the new shape position. The position
187 has to be given in the layout direction the shape is in and relative to
188 its position alignment areas.
190 void _AdjustPositionProperties( const ::com::sun::star::awt::Point _aPosition
);
192 /** method to convert start or end position of the drawing object to the
193 Writer specific position, which is the attribute position in layout direction
197 ::com::sun::star::awt::Point
_ConvertStartOrEndPosToLayoutDir(
198 const ::com::sun::star::awt::Point
& aStartOrEndPos
);
200 /** method to convert PolyPolygonBezier of the drawing object to the
201 Writer specific position, which is the attribute position in layout direction
205 ::com::sun::star::drawing::PolyPolygonBezierCoords
_ConvertPolyPolygonBezierToLayoutDir(
206 const ::com::sun::star::drawing::PolyPolygonBezierCoords
& aPath
);
208 /** method to get property from aggregation object
212 ::com::sun::star::uno::Any
_getPropAtAggrObj( const OUString
& _rPropertyName
)
213 throw( ::com::sun::star::beans::UnknownPropertyException
,
214 ::com::sun::star::lang::WrappedTargetException
,
215 ::com::sun::star::uno::RuntimeException
);
220 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNew
);
223 SwXShape(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> & xShape
);
227 static const ::com::sun::star::uno::Sequence
< sal_Int8
> & getUnoTunnelId();
228 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
);
229 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
230 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) throw(::com::sun::star::uno::RuntimeException
);
233 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
);
237 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
238 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
);
239 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
);
240 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
);
241 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
);
242 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
);
243 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
);
246 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
247 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
);
248 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
249 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
);
252 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
);
253 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> SAL_CALL
getAnchor(void) throw( ::com::sun::star::uno::RuntimeException
);
256 virtual void SAL_CALL
dispose(void) throw( ::com::sun::star::uno::RuntimeException
);
257 virtual void SAL_CALL
addEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
258 virtual void SAL_CALL
removeEventListener(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> & aListener
) throw( ::com::sun::star::uno::RuntimeException
);
261 virtual OUString SAL_CALL
getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException
);
262 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
263 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException
);
265 virtual ::com::sun::star::awt::Point SAL_CALL
getPosition( ) throw (::com::sun::star::uno::RuntimeException
);
266 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw (::com::sun::star::uno::RuntimeException
);
267 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( ) throw (::com::sun::star::uno::RuntimeException
);
268 virtual void SAL_CALL
setSize( const ::com::sun::star::awt::Size
& aSize
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::uno::RuntimeException
);
269 virtual OUString SAL_CALL
getShapeType( ) throw (::com::sun::star::uno::RuntimeException
);
271 SwShapeDescriptor_Impl
* GetDescImpl() {return pImpl
;}
272 SwFrmFmt
* GetFrmFmt() const { return (SwFrmFmt
*)GetRegisteredIn(); }
273 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
> GetAggregationInterface() {return xShapeAgg
;}
276 static void AddExistingShapeToFmt( SdrObject
& _rObj
);
279 class SwXGroupShape
:
281 public ::com::sun::star::drawing::XShapes
284 virtual ~SwXGroupShape();
286 SwXGroupShape(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> & xShape
);
289 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
);
290 virtual void SAL_CALL
acquire( ) throw();
291 virtual void SAL_CALL
release( ) throw();
294 virtual void SAL_CALL
add( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
) throw (::com::sun::star::uno::RuntimeException
);
295 virtual void SAL_CALL
remove( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
) throw (::com::sun::star::uno::RuntimeException
);
298 virtual sal_Int32 SAL_CALL
getCount(void) throw( ::com::sun::star::uno::RuntimeException
);
299 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
);
302 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
303 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */