fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / view / main / DummyXShape.hxx
blobfd97dff16031d625809a8b9093e013f5a29a6fb7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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"
57 #include "Stripe.hxx"
59 #include <rtl/ustring.hxx>
61 #include <map>
62 #include <unordered_map>
63 #include <vector>
65 namespace chart {
67 namespace dummy {
69 class DummyChart;
71 class TextCache
73 public:
74 struct TextCacheKey
76 OUString maText;
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);
97 private:
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 >
110 public:
111 DummyXShape();
113 // XNamed
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;
117 // XShape
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;
123 // XShapeDescriptor
124 virtual OUString SAL_CALL getShapeType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 // XPropertySet
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;
135 // XMultiPropertySet
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;
153 // XChild
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;
157 // XServiceInfo
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
172 protected:
174 std::map<OUString, css::uno::Any> maProperties;
175 com::sun::star::awt::Point maPosition;
176 com::sun::star::awt::Size maSize;
178 private:
179 OUString maName;
181 com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent;
185 class DummyCube : public DummyXShape
187 public:
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
195 public:
196 DummyCylinder(const css::drawing::Position3D&, const css::drawing::Direction3D& rSize );
199 class DummyPyramid : public DummyXShape
201 public:
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
209 public:
210 DummyCone(const css::drawing::Position3D& rPosition, const css::drawing::Direction3D& rSize);
213 class DummyPieSegment2D : public DummyXShape
215 public:
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;
220 private:
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
232 public:
233 DummyPieSegment(
234 const css::drawing::Direction3D& rOffset, const css::drawing::HomogenMatrix& rUnitCircleToScene);
236 private:
237 css::drawing::Direction3D maOffset;
238 css::drawing::HomogenMatrix maUnitCircleToScene;
241 class DummyStripe : public DummyXShape
243 public:
244 DummyStripe(const Stripe& rStripe, const css::uno::Reference< css::beans::XPropertySet > & xPropSet,
245 const tPropertyNameMap& rPropertyNameMap );
247 private:
248 Stripe maStripe;
251 class DummyArea3D : public DummyXShape
253 public:
254 DummyArea3D(const css::drawing::PolyPolygonShape3D& rShape);
256 private:
257 css::drawing::PolyPolygonShape3D maShapes;
260 class DummyArea2D : public DummyXShape
262 public:
263 DummyArea2D(const css::drawing::PointSequenceSequence& rShape);
265 virtual void render() SAL_OVERRIDE;
267 private:
268 css::drawing::PointSequenceSequence maShapes;
271 class DummySymbol2D : public DummyXShape
273 public:
274 DummySymbol2D(const css::drawing::Position3D& rPosition, const css::drawing::Direction3D& rSize,
275 sal_Int32 nStandardSymbol, sal_Int32 nFillColor);
276 void render() SAL_OVERRIDE;
277 private:
278 css::drawing::Position3D mrPosition;
279 css::drawing::Direction3D mrSize;
280 sal_Int32 mnStandardSymbol;
281 sal_Int32 mnFillColor;
284 class DummyGraphic2D : public DummyXShape
286 public:
287 DummyGraphic2D(const css::drawing::Position3D& rPosition, const css::drawing::Direction3D& rSize,
288 const css::uno::Reference< css::graphic::XGraphic >& rGraphic );
290 private:
291 css::uno::Reference< css::graphic::XGraphic > mxGraphic;
294 class DummyCircle : public DummyXShape
296 public:
297 DummyCircle(const css::awt::Point& rPosition, const css::awt::Size& rSize);
299 virtual void render() SAL_OVERRIDE;
302 class DummyLine3D : public DummyXShape
304 public:
305 DummyLine3D(const css::drawing::PolyPolygonShape3D& rPoints, const VLineProperties& rProperties);
307 private:
308 css::drawing::PolyPolygonShape3D maPoints;
311 class DummyLine2D : public DummyXShape
313 public:
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;
319 private:
320 css::drawing::PointSequenceSequence maPoints;
323 class DummyRectangle : public DummyXShape
325 public:
326 DummyRectangle();
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
336 public:
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;
347 private:
348 void setTransformatAsProperty(const com::sun::star::drawing::HomogenMatrix3& rMatrix);
350 OUString maText;
351 css::uno::Any maTrans;
352 BitmapEx maBitmap;
353 double mnRotation;
356 class DummyXShapes : public DummyXShape, public com::sun::star::drawing::XShapes
358 public:
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;
365 // XShapes
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;
369 // XElementAccess
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;
373 // XIndexAccess
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;
377 // normal methods
378 virtual void render() SAL_OVERRIDE;
380 protected:
381 std::vector<com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > maUNOShapes;
382 std::vector<DummyXShape*> maShapes;
385 class DummyChart : public DummyXShapes
387 public:
388 DummyChart();
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;
397 void clear();
398 void invalidateInit() { mbNotInit = true; }
399 TextCache& getTextCache() { return maTextCache;}
401 OpenGLRender& getRenderer() { return m_GLRender; }
403 private:
405 TextCache maTextCache;
406 bool mbNotInit;
408 public:
409 OpenGLRender m_GLRender;
413 class DummyGroup2D : public DummyXShapes
415 public:
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
426 public:
427 DummyGroup3D(const OUString& rName);
434 #endif
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */