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/.
10 #ifndef INCLUDED_CHART2_SOURCE_VIEW_MAIN_DUMMYXSHAPE_HXX
11 #define INCLUDED_CHART2_SOURCE_VIEW_MAIN_DUMMYXSHAPE_HXX
13 #include <cppuhelper/implbase6.hxx>
15 #include <vcl/opengl/OpenGLContext.hxx>
16 #include "OpenGLRender.hxx"
18 #include <com/sun/star/drawing/XShape.hpp>
19 #include <com/sun/star/drawing/XShapes.hpp>
20 #include <com/sun/star/beans/XMultiPropertySet.hpp>
21 #include <com/sun/star/container/XNamed.hpp>
22 #include <com/sun/star/container/XChild.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/awt/Point.hpp>
25 #include <com/sun/star/awt/Size.hpp>
26 #include <com/sun/star/uno/Type.h>
27 #include <com/sun/star/uno/Any.h>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/drawing/CircleKind.hpp>
31 #include <com/sun/star/drawing/DoubleSequence.hpp>
32 #include <com/sun/star/drawing/FlagSequence.hpp>
33 #include <com/sun/star/drawing/FillStyle.hpp>
34 #include <com/sun/star/drawing/LineStyle.hpp>
35 #include <com/sun/star/drawing/NormalsKind.hpp>
36 #include <com/sun/star/drawing/PointSequence.hpp>
37 #include <com/sun/star/drawing/PolygonKind.hpp>
38 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
39 #include <com/sun/star/drawing/ProjectionMode.hpp>
40 #include <com/sun/star/drawing/ShadeMode.hpp>
41 #include <com/sun/star/drawing/TextFitToSizeType.hpp>
42 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
43 #include <com/sun/star/drawing/TextureProjectionMode.hpp>
44 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
45 #include <com/sun/star/text/XText.hpp>
46 #include <com/sun/star/uno/Any.hxx>
47 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
48 #include <com/sun/star/drawing/Direction3D.hpp>
49 #include <com/sun/star/drawing/Position3D.hpp>
50 #include <com/sun/star/graphic/XGraphic.hpp>
51 #include <com/sun/star/drawing/HomogenMatrix.hpp>
52 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
53 #include <com/sun/star/chart2/XFormattedString.hpp>
55 #include "PropertyMapper.hxx"
56 #include "VLineProperties.hxx"
59 #include <rtl/ustring.hxx>
62 #include <unordered_map>
77 std::map
<OUString
, com::sun::star::uno::Any
> maProperties
;
79 bool operator==(const TextCacheKey
& rKey
) const
81 return maText
== rKey
.maText
&& maProperties
== rKey
.maProperties
;
85 struct TextCacheKeyHash
87 size_t operator()(const TextCacheKey
& rKey
) const
89 return rKey
.maText
.hashCode();
93 bool hasEntry(const TextCacheKey
& rKey
);
94 BitmapEx
& getBitmap(const TextCacheKey
& rKey
);
95 void insertBitmap(const TextCacheKey
& rKey
, const BitmapEx
& rBitmap
);
99 std::unordered_map
<TextCacheKey
, BitmapEx
, TextCacheKeyHash
> maCache
;
102 class DummyXShape
: public cppu::WeakAggImplHelper6
<
103 ::com::sun::star::drawing::XShape
,
104 com::sun::star::beans::XPropertySet
,
105 com::sun::star::beans::XMultiPropertySet
,
106 com::sun::star::container::XNamed
,
107 com::sun::star::container::XChild
,
108 com::sun::star::lang::XServiceInfo
>
114 virtual OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 virtual void SAL_CALL
setName( const OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 virtual ::com::sun::star::awt::Point SAL_CALL
getPosition() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 virtual ::com::sun::star::awt::Size SAL_CALL
getSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
121 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
;
124 virtual OUString SAL_CALL
getShapeType() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
127 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 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
;
129 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
;
130 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
;
131 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
;
132 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
;
133 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
;
136 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
,
137 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aValues
)
138 throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
,
139 ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
141 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
getPropertyValues(
142 const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
)
143 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
145 virtual void SAL_CALL
addPropertiesChangeListener( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 virtual void SAL_CALL
removePropertiesChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 virtual void SAL_CALL
firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
,
150 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
151 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
154 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getParent( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 virtual void SAL_CALL
setParent( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Parent
) throw(::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
159 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
160 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
162 // normal non UNO methods
164 virtual DummyChart
* getRootShape();
166 * Implement this method for all subclasses that should be rendered
168 virtual void render();
170 const com::sun::star::awt::Point
& getPos() { return maPosition
;} // internal API
174 std::map
<OUString
, css::uno::Any
> maProperties
;
175 com::sun::star::awt::Point maPosition
;
176 com::sun::star::awt::Size maSize
;
181 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> mxParent
;
185 class DummyCube
: public DummyXShape
188 DummyCube(const css::drawing::Position3D
&rPos
, const css::drawing::Direction3D
& rSize
,
189 const css::uno::Reference
< css::beans::XPropertySet
> & xPropSet
,
190 const tPropertyNameMap
& rPropertyNameMap
);
193 class DummyCylinder
: public DummyXShape
196 DummyCylinder(const css::drawing::Position3D
&, const css::drawing::Direction3D
& rSize
);
199 class DummyPyramid
: public DummyXShape
202 DummyPyramid(const css::drawing::Position3D
& rPosition
, const css::drawing::Direction3D
& rSize
,
203 const css::uno::Reference
< css::beans::XPropertySet
> & xPropSet
,
204 const tPropertyNameMap
& rPropertyNameMap
);
207 class DummyCone
: public DummyXShape
210 DummyCone(const css::drawing::Position3D
& rPosition
, const css::drawing::Direction3D
& rSize
);
213 class DummyPieSegment2D
: public DummyXShape
216 DummyPieSegment2D(double fUnitCircleStartAngleDegree
, double fUnitCircleWidthAngleDegree
,
217 double fUnitCircleInnerRadius
, double fUnitCircleOuterRadius
,
218 const css::drawing::Direction3D
& rOffset
, const css::drawing::HomogenMatrix
& rUnitCircleToScene
);
219 void render() SAL_OVERRIDE
;
221 double mfUnitCircleStartAngleDegree
;
222 double mfUnitCircleWidthAngleDegree
;
223 double mfUnitCircleInnerRadius
;
224 double mfUnitCircleOuterRadius
;
226 css::drawing::Direction3D maOffset
;
227 css::drawing::HomogenMatrix maUnitCircleToScene
;
230 class DummyPieSegment
: public DummyXShape
234 const css::drawing::Direction3D
& rOffset
, const css::drawing::HomogenMatrix
& rUnitCircleToScene
);
237 css::drawing::Direction3D maOffset
;
238 css::drawing::HomogenMatrix maUnitCircleToScene
;
241 class DummyStripe
: public DummyXShape
244 DummyStripe(const Stripe
& rStripe
, const css::uno::Reference
< css::beans::XPropertySet
> & xPropSet
,
245 const tPropertyNameMap
& rPropertyNameMap
);
251 class DummyArea3D
: public DummyXShape
254 DummyArea3D(const css::drawing::PolyPolygonShape3D
& rShape
);
257 css::drawing::PolyPolygonShape3D maShapes
;
260 class DummyArea2D
: public DummyXShape
263 DummyArea2D(const css::drawing::PointSequenceSequence
& rShape
);
265 virtual void render() SAL_OVERRIDE
;
268 css::drawing::PointSequenceSequence maShapes
;
271 class DummySymbol2D
: public DummyXShape
274 DummySymbol2D(const css::drawing::Position3D
& rPosition
, const css::drawing::Direction3D
& rSize
,
275 sal_Int32 nStandardSymbol
, sal_Int32 nFillColor
);
276 void render() SAL_OVERRIDE
;
278 css::drawing::Position3D mrPosition
;
279 css::drawing::Direction3D mrSize
;
280 sal_Int32 mnStandardSymbol
;
281 sal_Int32 mnFillColor
;
284 class DummyGraphic2D
: public DummyXShape
287 DummyGraphic2D(const css::drawing::Position3D
& rPosition
, const css::drawing::Direction3D
& rSize
,
288 const css::uno::Reference
< css::graphic::XGraphic
>& rGraphic
);
291 css::uno::Reference
< css::graphic::XGraphic
> mxGraphic
;
294 class DummyCircle
: public DummyXShape
297 DummyCircle(const css::awt::Point
& rPosition
, const css::awt::Size
& rSize
);
299 virtual void render() SAL_OVERRIDE
;
302 class DummyLine3D
: public DummyXShape
305 DummyLine3D(const css::drawing::PolyPolygonShape3D
& rPoints
, const VLineProperties
& rProperties
);
308 css::drawing::PolyPolygonShape3D maPoints
;
311 class DummyLine2D
: public DummyXShape
314 DummyLine2D(const css::drawing::PointSequenceSequence
& rPoints
, const VLineProperties
* pProperties
);
315 DummyLine2D(const css::awt::Size
& rSize
, const css::awt::Point
& rPosition
);
317 virtual void render() SAL_OVERRIDE
;
320 css::drawing::PointSequenceSequence maPoints
;
323 class DummyRectangle
: public DummyXShape
327 DummyRectangle(const css::awt::Size
& rSize
);
328 DummyRectangle(const css::awt::Size
& rSize
, const css::awt::Point
& rPoint
, const tNameSequence
& rNames
,
329 const tAnySequence
& rValues
);
331 virtual void render() SAL_OVERRIDE
;
334 class DummyText
: public DummyXShape
337 DummyText(const OUString
& rText
, const tNameSequence
& rNames
,
338 const tAnySequence
& rValues
, const css::uno::Any
& rTrans
, com::sun::star::uno::Reference
<
339 com::sun::star::drawing::XShapes
> xTarget
, double nRotation
);
341 virtual void render() SAL_OVERRIDE
;
343 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
;
345 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
348 void setTransformatAsProperty(const com::sun::star::drawing::HomogenMatrix3
& rMatrix
);
351 css::uno::Any maTrans
;
356 class DummyXShapes
: public DummyXShape
, public com::sun::star::drawing::XShapes
360 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
361 virtual com::sun::star::uno::Any SAL_CALL
queryAggregation( const com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
362 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
363 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
366 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
;
367 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
;
370 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
371 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
374 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
375 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) throw(::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
378 virtual void render() SAL_OVERRIDE
;
381 std::vector
<com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
> > maUNOShapes
;
382 std::vector
<DummyXShape
*> maShapes
;
385 class DummyChart
: public DummyXShapes
389 virtual ~DummyChart();
390 virtual DummyChart
* getRootShape() SAL_OVERRIDE
;
392 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
393 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
;
395 virtual void render() SAL_OVERRIDE
;
398 void invalidateInit() { mbNotInit
= true; }
399 TextCache
& getTextCache() { return maTextCache
;}
401 OpenGLRender
& getRenderer() { return m_GLRender
; }
405 TextCache maTextCache
;
409 OpenGLRender m_GLRender
;
413 class DummyGroup2D
: public DummyXShapes
416 DummyGroup2D(const OUString
& rName
);
418 virtual ::com::sun::star::awt::Point SAL_CALL
getPosition() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
419 virtual ::com::sun::star::awt::Size SAL_CALL
getSize() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
420 virtual void SAL_CALL
setPosition( const ::com::sun::star::awt::Point
& aPosition
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
421 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
;
424 class DummyGroup3D
: public DummyXShapes
427 DummyGroup3D(const OUString
& rName
);
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */