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 CHART2_DUMMY_XSHAPE_HXX
11 : #define CHART2_DUMMY_XSHAPE_HXX
12 :
13 : #include <cppuhelper/implbase6.hxx>
14 :
15 : #include <vcl/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 <vector>
62 : #include <map>
63 : #include <boost/unordered_map.hpp>
64 :
65 : using namespace com::sun::star;
66 :
67 :
68 : namespace chart {
69 :
70 : namespace dummy {
71 :
72 : class DummyChart;
73 :
74 0 : class TextCache
75 : {
76 : public:
77 0 : struct TextCacheKey
78 : {
79 : OUString maText;
80 : std::map<OUString, com::sun::star::uno::Any> maProperties;
81 :
82 0 : bool operator==(const TextCacheKey& rKey) const
83 : {
84 0 : return maText == rKey.maText && maProperties == rKey.maProperties;
85 : }
86 : };
87 :
88 : struct TextCacheKeyHash
89 : {
90 0 : size_t operator()(const TextCacheKey& rKey) const
91 : {
92 0 : return rKey.maText.hashCode();
93 : }
94 : };
95 :
96 : bool hasEntry(const TextCacheKey& rKey);
97 : BitmapEx& getBitmap(const TextCacheKey& rKey);
98 : void insertBitmap(const TextCacheKey& rKey, const BitmapEx& rBitmap);
99 :
100 : private:
101 :
102 : boost::unordered_map<TextCacheKey, BitmapEx, TextCacheKeyHash> maCache;
103 : };
104 :
105 0 : class DummyXShape : public cppu::WeakAggImplHelper6<
106 : ::com::sun::star::drawing::XShape,
107 : com::sun::star::beans::XPropertySet,
108 : com::sun::star::beans::XMultiPropertySet,
109 : com::sun::star::container::XNamed,
110 : com::sun::star::container::XChild,
111 : com::sun::star::lang::XServiceInfo >
112 : {
113 : public:
114 : DummyXShape();
115 :
116 : // XNamed
117 : virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 : virtual void SAL_CALL setName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 : // XShape
121 : virtual ::com::sun::star::awt::Point SAL_CALL getPosition() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 : virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 : 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;
125 :
126 : // XShapeDescriptor
127 : virtual OUString SAL_CALL getShapeType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 :
129 : // XPropertySet
130 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : 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;
132 : 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;
133 : 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;
134 : 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;
135 : 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;
136 : 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;
137 :
138 : // XMultiPropertySet
139 : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
140 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
141 : throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException,
142 : ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 :
144 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(
145 : const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames )
146 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 :
148 : 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;
149 :
150 : 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;
151 :
152 : virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
153 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
154 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 :
157 : // XChild
158 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : 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;
160 :
161 : // XServiceInfo
162 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 :
166 : // normal non UNO methods
167 :
168 : virtual DummyChart* getRootShape();
169 : /**
170 : * Implement this method for all subclasses that should be rendered
171 : */
172 : virtual void render();
173 :
174 : const com::sun::star::awt::Point& getPos(); // internal API
175 :
176 : protected:
177 :
178 : std::map<OUString, uno::Any> maProperties;
179 : com::sun::star::awt::Point maPosition;
180 : com::sun::star::awt::Size maSize;
181 :
182 : private:
183 : OUString maName;
184 :
185 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > mxParent;
186 :
187 : };
188 :
189 0 : class DummyCube : public DummyXShape
190 : {
191 : public:
192 : DummyCube(const drawing::Position3D &rPos, const drawing::Direction3D& rSize,
193 : const uno::Reference< beans::XPropertySet > & xPropSet,
194 : const tPropertyNameMap& rPropertyNameMap );
195 : };
196 :
197 0 : class DummyCylinder : public DummyXShape
198 : {
199 : public:
200 : DummyCylinder(const drawing::Position3D&, const drawing::Direction3D& rSize );
201 : };
202 :
203 0 : class DummyPyramid : public DummyXShape
204 : {
205 : public:
206 : DummyPyramid(const drawing::Position3D& rPosition, const drawing::Direction3D& rSize,
207 : const uno::Reference< beans::XPropertySet > & xPropSet,
208 : const tPropertyNameMap& rPropertyNameMap );
209 : };
210 :
211 0 : class DummyCone : public DummyXShape
212 : {
213 : public:
214 : DummyCone(const drawing::Position3D& rPosition, const drawing::Direction3D& rSize);
215 : };
216 :
217 0 : class DummyPieSegment2D : public DummyXShape
218 : {
219 : public:
220 : DummyPieSegment2D(double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
221 : double fUnitCircleInnerRadius, double fUnitCircleOuterRadius,
222 : const drawing::Direction3D& rOffset, const drawing::HomogenMatrix& rUnitCircleToScene);
223 : void render() SAL_OVERRIDE;
224 : private:
225 : double mfUnitCircleStartAngleDegree;
226 : double mfUnitCircleWidthAngleDegree;
227 : double mfUnitCircleInnerRadius;
228 : double mfUnitCircleOuterRadius;
229 :
230 : drawing::Direction3D maOffset;
231 : drawing::HomogenMatrix maUnitCircleToScene;
232 : };
233 :
234 0 : class DummyPieSegment : public DummyXShape
235 : {
236 : public:
237 : DummyPieSegment(
238 : const drawing::Direction3D& rOffset, const drawing::HomogenMatrix& rUnitCircleToScene);
239 :
240 : private:
241 : drawing::Direction3D maOffset;
242 : drawing::HomogenMatrix maUnitCircleToScene;
243 : };
244 :
245 0 : class DummyStripe : public DummyXShape
246 : {
247 : public:
248 : DummyStripe(const Stripe& rStripe, const uno::Reference< beans::XPropertySet > & xPropSet,
249 : const tPropertyNameMap& rPropertyNameMap );
250 :
251 : private:
252 : Stripe maStripe;
253 : };
254 :
255 0 : class DummyArea3D : public DummyXShape
256 : {
257 : public:
258 : DummyArea3D(const drawing::PolyPolygonShape3D& rShape);
259 :
260 : private:
261 : drawing::PolyPolygonShape3D maShapes;
262 : };
263 :
264 0 : class DummyArea2D : public DummyXShape
265 : {
266 : public:
267 : DummyArea2D(const drawing::PointSequenceSequence& rShape);
268 :
269 : virtual void render() SAL_OVERRIDE;
270 :
271 : private:
272 : drawing::PointSequenceSequence maShapes;
273 : };
274 :
275 0 : class DummySymbol2D : public DummyXShape
276 : {
277 : public:
278 : DummySymbol2D(const drawing::Position3D& rPosition, const drawing::Direction3D& rSize,
279 : sal_Int32 nStandardSymbol, sal_Int32 nFillColor);
280 : void render() SAL_OVERRIDE;
281 : private:
282 : drawing::Position3D mrPosition;
283 : drawing::Direction3D mrSize;
284 : sal_Int32 mnStandardSymbol;
285 : sal_Int32 mnFillColor;
286 : };
287 :
288 0 : class DummyGraphic2D : public DummyXShape
289 : {
290 : public:
291 : DummyGraphic2D(const drawing::Position3D& rPosition, const drawing::Direction3D& rSize,
292 : const uno::Reference< graphic::XGraphic > xGraphic );
293 :
294 : private:
295 : uno::Reference< graphic::XGraphic > mxGraphic;
296 : };
297 :
298 0 : class DummyCircle : public DummyXShape
299 : {
300 : public:
301 : DummyCircle(const awt::Point& rPosition, const awt::Size& rSize);
302 :
303 : virtual void render() SAL_OVERRIDE;
304 : };
305 :
306 0 : class DummyLine3D : public DummyXShape
307 : {
308 : public:
309 : DummyLine3D(const drawing::PolyPolygonShape3D& rPoints, const VLineProperties& rProperties);
310 :
311 : private:
312 : drawing::PolyPolygonShape3D maPoints;
313 : };
314 :
315 0 : class DummyLine2D : public DummyXShape
316 : {
317 : public:
318 : DummyLine2D(const drawing::PointSequenceSequence& rPoints, const VLineProperties* pProperties);
319 : DummyLine2D(const awt::Size& rSize, const awt::Point& rPosition);
320 :
321 : virtual void render() SAL_OVERRIDE;
322 :
323 : private:
324 : drawing::PointSequenceSequence maPoints;
325 : };
326 :
327 0 : class DummyRectangle : public DummyXShape
328 : {
329 : public:
330 : DummyRectangle();
331 : DummyRectangle(const awt::Size& rSize);
332 : DummyRectangle(const awt::Size& rSize, const awt::Point& rPoint, const tNameSequence& rNames,
333 : const tAnySequence& rValues );
334 :
335 : virtual void render() SAL_OVERRIDE;
336 : };
337 :
338 0 : class DummyText : public DummyXShape
339 : {
340 : public:
341 : DummyText(const OUString& rText, const tNameSequence& rNames,
342 : const tAnySequence& rValues, const uno::Any& rTrans, com::sun::star::uno::Reference<
343 : com::sun::star::drawing::XShapes > xTarget, double nRotation);
344 :
345 : virtual void render() SAL_OVERRIDE;
346 :
347 : 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;
348 :
349 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
350 :
351 : private:
352 : void setTransformatAsProperty(const com::sun::star::drawing::HomogenMatrix3& rMatrix);
353 :
354 : OUString maText;
355 : uno::Any maTrans;
356 : BitmapEx maBitmap;
357 : double mnRotation;
358 : };
359 :
360 0 : class DummyXShapes : public DummyXShape, public com::sun::star::drawing::XShapes
361 : {
362 : public:
363 :
364 : 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;
365 : 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;
366 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
367 : virtual void SAL_CALL release() throw() SAL_OVERRIDE;
368 :
369 : // XShapes
370 : 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;
371 : 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;
372 :
373 : // XElementAccess
374 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
375 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
376 :
377 : // XIndexAccess
378 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
379 : 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;
380 :
381 : // normal methods
382 : virtual void render() SAL_OVERRIDE;
383 :
384 : protected:
385 : std::vector<com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > maUNOShapes;
386 : std::vector<DummyXShape*> maShapes;
387 : };
388 :
389 : class DummyChart : public DummyXShapes
390 : {
391 : public:
392 : DummyChart(com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xDrawPage);
393 : virtual ~DummyChart();
394 : virtual DummyChart* getRootShape() SAL_OVERRIDE;
395 :
396 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
397 : 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;
398 :
399 : virtual void render() SAL_OVERRIDE;
400 :
401 : void clear();
402 : TextCache& getTextCache();
403 :
404 : private:
405 :
406 : TextCache maTextCache;
407 :
408 : public:
409 : OpenGLRender m_GLRender;
410 : };
411 :
412 0 : class DummyGroup2D : public DummyXShapes
413 : {
414 : public:
415 : DummyGroup2D(const OUString& rName);
416 :
417 : virtual ::com::sun::star::awt::Point SAL_CALL getPosition() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
418 : virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
419 : virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
420 : 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;
421 : };
422 :
423 0 : class DummyGroup3D : public DummyXShapes
424 : {
425 : public:
426 : DummyGroup3D(const OUString& rName);
427 : };
428 :
429 : }
430 :
431 : }
432 :
433 : #endif
434 :
435 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|