Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #ifndef INCLUDED_CHART2_SOURCE_VIEW_MAIN_DUMMYXSHAPE_HXX
11 : #define INCLUDED_CHART2_SOURCE_VIEW_MAIN_DUMMYXSHAPE_HXX
12 :
13 : #include <cppuhelper/implbase6.hxx>
14 :
15 : #include <vcl/opengl/OpenGLContext.hxx>
16 : #include "OpenGLRender.hxx"
17 :
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>
54 :
55 : #include "PropertyMapper.hxx"
56 : #include "VLineProperties.hxx"
57 : #include "Stripe.hxx"
58 :
59 : #include <rtl/ustring.hxx>
60 :
61 : #include <map>
62 : #include <unordered_map>
63 : #include <vector>
64 :
65 : namespace chart {
66 :
67 : namespace dummy {
68 :
69 : class DummyChart;
70 :
71 0 : class TextCache
72 : {
73 : public:
74 0 : struct TextCacheKey
75 : {
76 : OUString maText;
77 : std::map<OUString, com::sun::star::uno::Any> maProperties;
78 :
79 0 : bool operator==(const TextCacheKey& rKey) const
80 : {
81 0 : return maText == rKey.maText && maProperties == rKey.maProperties;
82 : }
83 : };
84 :
85 : struct TextCacheKeyHash
86 : {
87 0 : size_t operator()(const TextCacheKey& rKey) const
88 : {
89 0 : return rKey.maText.hashCode();
90 : }
91 : };
92 :
93 : bool hasEntry(const TextCacheKey& rKey);
94 : BitmapEx& getBitmap(const TextCacheKey& rKey);
95 : void insertBitmap(const TextCacheKey& rKey, const BitmapEx& rBitmap);
96 :
97 : private:
98 :
99 : std::unordered_map<TextCacheKey, BitmapEx, TextCacheKeyHash> maCache;
100 : };
101 :
102 0 : 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 >
109 : {
110 : public:
111 : DummyXShape();
112 :
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;
116 :
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;
122 :
123 : // XShapeDescriptor
124 : virtual OUString SAL_CALL getShapeType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 :
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;
134 :
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;
140 :
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;
144 :
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;
146 :
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;
148 :
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;
152 :
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;
156 :
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;
161 :
162 : // normal non UNO methods
163 :
164 : virtual DummyChart* getRootShape();
165 : /**
166 : * Implement this method for all subclasses that should be rendered
167 : */
168 : virtual void render();
169 :
170 0 : const com::sun::star::awt::Point& getPos() { return maPosition;} // internal API
171 :
172 : protected:
173 :
174 : std::map<OUString, css::uno::Any> maProperties;
175 : com::sun::star::awt::Point maPosition;
176 : com::sun::star::awt::Size maSize;
177 :
178 : private:
179 : OUString maName;
180 :
181 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent;
182 :
183 : };
184 :
185 0 : class DummyCube : public DummyXShape
186 : {
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 );
191 : };
192 :
193 0 : class DummyCylinder : public DummyXShape
194 : {
195 : public:
196 : DummyCylinder(const css::drawing::Position3D&, const css::drawing::Direction3D& rSize );
197 : };
198 :
199 0 : class DummyPyramid : public DummyXShape
200 : {
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 );
205 : };
206 :
207 0 : class DummyCone : public DummyXShape
208 : {
209 : public:
210 : DummyCone(const css::drawing::Position3D& rPosition, const css::drawing::Direction3D& rSize);
211 : };
212 :
213 0 : class DummyPieSegment2D : public DummyXShape
214 : {
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;
225 :
226 : css::drawing::Direction3D maOffset;
227 : css::drawing::HomogenMatrix maUnitCircleToScene;
228 : };
229 :
230 0 : class DummyPieSegment : public DummyXShape
231 : {
232 : public:
233 : DummyPieSegment(
234 : const css::drawing::Direction3D& rOffset, const css::drawing::HomogenMatrix& rUnitCircleToScene);
235 :
236 : private:
237 : css::drawing::Direction3D maOffset;
238 : css::drawing::HomogenMatrix maUnitCircleToScene;
239 : };
240 :
241 0 : class DummyStripe : public DummyXShape
242 : {
243 : public:
244 : DummyStripe(const Stripe& rStripe, const css::uno::Reference< css::beans::XPropertySet > & xPropSet,
245 : const tPropertyNameMap& rPropertyNameMap );
246 :
247 : private:
248 : Stripe maStripe;
249 : };
250 :
251 0 : class DummyArea3D : public DummyXShape
252 : {
253 : public:
254 : explicit DummyArea3D(const css::drawing::PolyPolygonShape3D& rShape);
255 :
256 : private:
257 : css::drawing::PolyPolygonShape3D maShapes;
258 : };
259 :
260 0 : class DummyArea2D : public DummyXShape
261 : {
262 : public:
263 : explicit DummyArea2D(const css::drawing::PointSequenceSequence& rShape);
264 :
265 : virtual void render() SAL_OVERRIDE;
266 :
267 : private:
268 : css::drawing::PointSequenceSequence maShapes;
269 : };
270 :
271 0 : class DummySymbol2D : public DummyXShape
272 : {
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;
282 : };
283 :
284 0 : class DummyGraphic2D : public DummyXShape
285 : {
286 : public:
287 : DummyGraphic2D(const css::drawing::Position3D& rPosition, const css::drawing::Direction3D& rSize,
288 : const css::uno::Reference< css::graphic::XGraphic >& rGraphic );
289 :
290 : private:
291 : css::uno::Reference< css::graphic::XGraphic > mxGraphic;
292 : };
293 :
294 0 : class DummyCircle : public DummyXShape
295 : {
296 : public:
297 : DummyCircle(const css::awt::Point& rPosition, const css::awt::Size& rSize);
298 :
299 : virtual void render() SAL_OVERRIDE;
300 : };
301 :
302 0 : class DummyLine3D : public DummyXShape
303 : {
304 : public:
305 : DummyLine3D(const css::drawing::PolyPolygonShape3D& rPoints, const VLineProperties& rProperties);
306 :
307 : private:
308 : css::drawing::PolyPolygonShape3D maPoints;
309 : };
310 :
311 0 : class DummyLine2D : public DummyXShape
312 : {
313 : public:
314 : DummyLine2D(const css::drawing::PointSequenceSequence& rPoints, const VLineProperties* pProperties);
315 : DummyLine2D(const css::awt::Size& rSize, const css::awt::Point& rPosition);
316 :
317 : virtual void render() SAL_OVERRIDE;
318 :
319 : private:
320 : css::drawing::PointSequenceSequence maPoints;
321 : };
322 :
323 0 : class DummyRectangle : public DummyXShape
324 : {
325 : public:
326 : DummyRectangle();
327 : explicit 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 );
330 :
331 : virtual void render() SAL_OVERRIDE;
332 : };
333 :
334 0 : class DummyText : public DummyXShape
335 : {
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);
340 :
341 : virtual void render() SAL_OVERRIDE;
342 :
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;
344 :
345 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
346 :
347 : private:
348 : void setTransformatAsProperty(const com::sun::star::drawing::HomogenMatrix3& rMatrix);
349 :
350 : OUString maText;
351 : css::uno::Any maTrans;
352 : BitmapEx maBitmap;
353 : double mnRotation;
354 : };
355 :
356 0 : class DummyXShapes : public DummyXShape, public com::sun::star::drawing::XShapes
357 : {
358 : public:
359 :
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;
364 :
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;
368 :
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;
372 :
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;
376 :
377 : // normal methods
378 : virtual void render() SAL_OVERRIDE;
379 :
380 : protected:
381 : std::vector<com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > maUNOShapes;
382 : std::vector<DummyXShape*> maShapes;
383 : };
384 :
385 : class DummyChart : public DummyXShapes
386 : {
387 : public:
388 : DummyChart();
389 : virtual ~DummyChart();
390 : virtual DummyChart* getRootShape() SAL_OVERRIDE;
391 :
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;
394 :
395 : virtual void render() SAL_OVERRIDE;
396 :
397 : void clear();
398 0 : void invalidateInit() { mbNotInit = true; }
399 0 : TextCache& getTextCache() { return maTextCache;}
400 :
401 0 : OpenGLRender& getRenderer() { return m_GLRender; }
402 :
403 : private:
404 :
405 : TextCache maTextCache;
406 : bool mbNotInit;
407 :
408 : public:
409 : OpenGLRender m_GLRender;
410 :
411 : };
412 :
413 0 : class DummyGroup2D : public DummyXShapes
414 : {
415 : public:
416 : explicit DummyGroup2D(const OUString& rName);
417 :
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;
422 : };
423 :
424 0 : class DummyGroup3D : public DummyXShapes
425 : {
426 : public:
427 : explicit DummyGroup3D(const OUString& rName);
428 : };
429 :
430 : }
431 :
432 : }
433 :
434 : #endif
435 :
436 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|