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 : #include "DummyXShape.hxx"
10 :
11 : #include <stdio.h>
12 : #include <string>
13 : #include <vector>
14 : #include <iostream>
15 : #include <fstream>
16 : #include <algorithm>
17 : #include <stdlib.h>
18 : #include <string.h>
19 :
20 : #include "CommonConverters.hxx"
21 :
22 : #include <rtl/ustring.hxx>
23 :
24 : #include <vcl/window.hxx>
25 : #include <vcl/virdev.hxx>
26 : #include <vcl/svapp.hxx>
27 : #include <tools/gen.hxx>
28 : #include <cppuhelper/supportsservice.hxx>
29 : #include <cppuhelper/implbase1.hxx>
30 : #include <editeng/unoprnms.hxx>
31 : #include <toolkit/helper/vclunohelper.hxx>
32 :
33 : #include <basegfx/point/b2dpoint.hxx>
34 : #include <basegfx/matrix/b3dhommatrix.hxx>
35 :
36 : #include <com/sun/star/beans/Property.hpp>
37 :
38 : #include <com/sun/star/awt/XBitmap.hpp>
39 :
40 : #define ENABLE_DEBUG_PROPERTIES 0
41 :
42 : using namespace com::sun::star;
43 :
44 : using namespace std;
45 :
46 : namespace chart {
47 :
48 : namespace dummy {
49 :
50 : #if 0
51 :
52 : std::ostream& operator<<(std::ostream& rStrm, const awt::Point& rPoint)
53 : {
54 : rStrm << rPoint.X << "," << rPoint.Y;
55 : return rStrm;
56 : }
57 :
58 : std::ostream& operator<<(std::ostream& rStrm, const awt::Size& rSize)
59 : {
60 : rStrm << rSize.Width << "," << rSize.Height;
61 : return rStrm;
62 : }
63 :
64 : #endif
65 :
66 0 : bool TextCache::hasEntry(const TextCacheKey& rKey)
67 : {
68 0 : return maCache.find(rKey) != maCache.end();
69 : }
70 :
71 0 : BitmapEx& TextCache::getBitmap(const TextCacheKey& rKey)
72 : {
73 0 : return maCache.find(rKey)->second;
74 : }
75 :
76 0 : void TextCache::insertBitmap(const TextCacheKey& rKey, const BitmapEx& rBitmap)
77 : {
78 0 : maCache.insert(std::pair<TextCacheKey, BitmapEx>(rKey, rBitmap));
79 0 : }
80 :
81 0 : class DummyPropertySetInfo : public cppu::WeakImplHelper1<
82 : com::sun::star::beans::XPropertySetInfo >
83 : {
84 : public:
85 0 : DummyPropertySetInfo(const std::map<OUString, uno::Any>& rProps ):
86 0 : mrProperties(rProps) {}
87 :
88 : virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& rName )
89 : throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 :
91 : virtual beans::Property SAL_CALL getPropertyByName( const OUString& rName )
92 : throw(uno::RuntimeException, beans::UnknownPropertyException, std::exception) SAL_OVERRIDE;
93 :
94 : virtual uno::Sequence< beans::Property > SAL_CALL getProperties()
95 : throw(uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 :
97 : private:
98 : const std::map<OUString, uno::Any>& mrProperties;
99 : };
100 :
101 0 : sal_Bool SAL_CALL DummyPropertySetInfo::hasPropertyByName( const OUString& rName )
102 : throw(uno::RuntimeException, std::exception)
103 : {
104 0 : return mrProperties.find(rName) != mrProperties.end();
105 : }
106 :
107 0 : beans::Property SAL_CALL DummyPropertySetInfo::getPropertyByName( const OUString& rName )
108 : throw(uno::RuntimeException, beans::UnknownPropertyException, std::exception)
109 : {
110 0 : beans::Property aRet;
111 0 : if(mrProperties.find(rName) == mrProperties.end())
112 0 : throw beans::UnknownPropertyException();
113 :
114 0 : std::map<OUString, uno::Any>::const_iterator itr = mrProperties.find(rName);
115 0 : aRet.Name = rName;
116 0 : aRet.Type = itr->second.getValueType();
117 :
118 0 : return aRet;
119 : }
120 :
121 0 : uno::Sequence< beans::Property > SAL_CALL DummyPropertySetInfo::getProperties()
122 : throw(uno::RuntimeException, std::exception)
123 : {
124 0 : uno::Sequence< beans::Property > aRet(mrProperties.size());
125 :
126 0 : size_t i = 0;
127 0 : for(std::map<OUString, uno::Any>::const_iterator itr = mrProperties.begin(),
128 0 : itrEnd = mrProperties.end(); itr != itrEnd; ++itr, ++i)
129 : {
130 0 : beans::Property aProp;
131 :
132 0 : aProp.Name = itr->first;
133 0 : aProp.Type = itr->second.getValueType();
134 0 : aRet[i] = aProp;
135 0 : }
136 0 : return aRet;
137 : }
138 :
139 : namespace {
140 :
141 : struct PrintProperties
142 : {
143 : #if ENABLE_DEBUG_PROPERTIES
144 : void operator()(const std::pair<OUString, uno::Any>& rProp)
145 : {
146 : SAL_INFO("chart2.opengl.properties", "Property: " << rProp.first);
147 : }
148 : #else
149 0 : void operator()(const std::pair<OUString, uno::Any>&)
150 : {
151 0 : }
152 : #endif
153 : };
154 :
155 0 : void debugProperties(std::map<OUString, uno::Any>& rProperties)
156 : {
157 0 : for_each(rProperties.begin(), rProperties.end(), PrintProperties());
158 0 : }
159 :
160 : }
161 :
162 0 : DummyXShape::DummyXShape()
163 : {
164 0 : }
165 :
166 0 : OUString SAL_CALL DummyXShape::getName()
167 : throw(uno::RuntimeException, std::exception)
168 : {
169 0 : return maName;
170 : }
171 :
172 0 : void SAL_CALL DummyXShape::setName( const OUString& rName )
173 : throw(uno::RuntimeException, std::exception)
174 : {
175 0 : maName = rName;
176 0 : }
177 :
178 0 : awt::Point SAL_CALL DummyXShape::getPosition()
179 : throw(uno::RuntimeException, std::exception)
180 : {
181 0 : return maPosition;
182 : }
183 :
184 0 : void SAL_CALL DummyXShape::setPosition( const awt::Point& rPoint )
185 : throw(uno::RuntimeException, std::exception)
186 : {
187 0 : maPosition = rPoint;
188 0 : }
189 :
190 0 : awt::Size SAL_CALL DummyXShape::getSize()
191 : throw(uno::RuntimeException, std::exception)
192 : {
193 0 : return maSize;
194 : }
195 :
196 0 : void SAL_CALL DummyXShape::setSize( const awt::Size& rSize )
197 : throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
198 : {
199 0 : maSize = rSize;
200 0 : }
201 :
202 0 : OUString SAL_CALL DummyXShape::getShapeType()
203 : throw(uno::RuntimeException, std::exception)
204 : {
205 0 : return OUString("dummy shape");
206 : }
207 :
208 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL DummyXShape::getPropertySetInfo()
209 : throw(uno::RuntimeException, std::exception)
210 : {
211 0 : return new DummyPropertySetInfo(maProperties);
212 : }
213 :
214 0 : void SAL_CALL DummyXShape::setPropertyValue( const OUString& rName, const uno::Any& rValue)
215 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
216 : lang::IllegalArgumentException, lang::WrappedTargetException,
217 : uno::RuntimeException, std::exception)
218 : {
219 : SAL_INFO("chart2", "DummyXShape::setProperty: " << rName << " Any");
220 0 : maProperties[rName] = rValue;
221 0 : if(rName == "Transformation")
222 : {
223 : SAL_INFO("chart2.opengl", "Transformation");
224 : }
225 0 : }
226 :
227 0 : uno::Any SAL_CALL DummyXShape::getPropertyValue( const OUString& rName )
228 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
229 : {
230 : SAL_INFO("chart2.opengl", "DummyXShape::getPropertyValue: " << rName);
231 0 : std::map<OUString, uno::Any>::iterator itr = maProperties.find(rName);
232 0 : if(itr != maProperties.end())
233 0 : return itr->second;
234 :
235 0 : return uno::Any();
236 : }
237 :
238 0 : void SAL_CALL DummyXShape::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
239 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
240 : {
241 0 : }
242 :
243 0 : void SAL_CALL DummyXShape::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
244 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
245 : {
246 0 : }
247 :
248 0 : void SAL_CALL DummyXShape::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
249 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
250 : {
251 0 : }
252 :
253 0 : void SAL_CALL DummyXShape::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
254 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
255 : {
256 0 : }
257 :
258 0 : void SAL_CALL DummyXShape::setPropertyValues( const uno::Sequence< OUString >& rNames,
259 : const uno::Sequence< uno::Any >& rValues)
260 : throw (beans::PropertyVetoException, lang::IllegalArgumentException,
261 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
262 : {
263 0 : size_t n = std::min<size_t>(rNames.getLength(), rValues.getLength());
264 0 : for(size_t i = 0; i < n; ++i)
265 : {
266 0 : maProperties[rNames[i]] = rValues[i];
267 : }
268 0 : }
269 :
270 0 : uno::Sequence< uno::Any > SAL_CALL DummyXShape::getPropertyValues(
271 : const uno::Sequence< OUString >& rNames)
272 : throw (uno::RuntimeException, std::exception)
273 : {
274 0 : uno::Sequence< uno::Any > aValues(rNames.getLength());
275 0 : for(sal_Int32 i = 0; i < rNames.getLength(); ++i)
276 : {
277 0 : OUString aName = rNames[i];
278 :
279 0 : std::map<OUString, uno::Any>::iterator itr = maProperties.find(aName);
280 0 : if(itr != maProperties.end())
281 0 : aValues[i] = itr->second;
282 0 : }
283 0 : return aValues;
284 : }
285 :
286 0 : void SAL_CALL DummyXShape::addPropertiesChangeListener( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException, std::exception)
287 : {
288 0 : }
289 :
290 0 : void SAL_CALL DummyXShape::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException, std::exception)
291 : {
292 0 : }
293 :
294 0 : void SAL_CALL DummyXShape::firePropertiesChangeEvent( const uno::Sequence< OUString >& ,
295 : const uno::Reference< beans::XPropertiesChangeListener >& )
296 : throw (uno::RuntimeException, std::exception)
297 : {
298 0 : }
299 :
300 0 : OUString SAL_CALL DummyXShape::getImplementationName()
301 : throw(uno::RuntimeException, std::exception)
302 : {
303 0 : return OUString("DummyXShape");
304 : }
305 :
306 : namespace {
307 :
308 0 : uno::Sequence< OUString > listSupportedServices()
309 : {
310 0 : static uno::Sequence< OUString > aSupportedServices;
311 0 : if(aSupportedServices.getLength() == 0)
312 : {
313 0 : aSupportedServices.realloc(3);
314 0 : aSupportedServices[0] = "com.sun.star.drawing.Shape";
315 0 : aSupportedServices[1] = "com.sun.star.container.Named";
316 0 : aSupportedServices[2] = "com.sun.star.beans.PropertySet";
317 : }
318 :
319 0 : return aSupportedServices;
320 : }
321 :
322 : }
323 :
324 0 : uno::Sequence< OUString > SAL_CALL DummyXShape::getSupportedServiceNames()
325 : throw(uno::RuntimeException, std::exception)
326 : {
327 0 : return listSupportedServices();
328 : }
329 :
330 0 : sal_Bool SAL_CALL DummyXShape::supportsService( const OUString& rServiceName )
331 : throw(uno::RuntimeException, std::exception)
332 : {
333 0 : return cppu::supportsService(this, rServiceName);
334 : }
335 :
336 0 : uno::Reference< uno::XInterface > SAL_CALL DummyXShape::getParent()
337 : throw(uno::RuntimeException, std::exception)
338 : {
339 0 : return mxParent;
340 : }
341 :
342 0 : void SAL_CALL DummyXShape::setParent( const uno::Reference< uno::XInterface >& xParent )
343 : throw(lang::NoSupportException, uno::RuntimeException, std::exception)
344 : {
345 0 : mxParent = xParent;
346 0 : }
347 :
348 0 : void DummyXShape::render()
349 : {
350 : SAL_WARN("chart2.opengl", "maybe a missing implementation in a subclass?");
351 0 : }
352 :
353 : namespace {
354 :
355 0 : void setProperties( const uno::Reference< beans::XPropertySet > & xPropSet, const tPropertyNameMap& rPropertyNameMap,
356 : std::map<OUString, uno::Any>& rTargetMap)
357 : {
358 0 : tNameSequence aNames;
359 0 : tAnySequence aValues;
360 : PropertyMapper::getMultiPropertyLists( aNames, aValues,
361 0 : xPropSet, rPropertyNameMap );
362 :
363 0 : sal_Int32 nSize = std::min(aNames.getLength(), aValues.getLength());
364 0 : for(sal_Int32 i = 0; i < nSize; ++i)
365 : {
366 0 : rTargetMap[aNames[i]] = aValues[i];
367 0 : }
368 0 : }
369 :
370 0 : void setProperties( const tNameSequence& rNames, const tAnySequence& rValues,
371 : std::map<OUString, uno::Any>& rTargetMap)
372 : {
373 0 : sal_Int32 nSize = std::min(rNames.getLength(), rValues.getLength());
374 0 : for(sal_Int32 i = 0; i < nSize; ++i)
375 : {
376 0 : rTargetMap[rNames[i]] = rValues[i];
377 : }
378 0 : }
379 :
380 : }
381 :
382 0 : DummyCube::DummyCube(const drawing::Position3D &rPos, const drawing::Direction3D& rSize,
383 : const uno::Reference< beans::XPropertySet > & xPropSet,
384 0 : const tPropertyNameMap& rPropertyNameMap )
385 : {
386 0 : setPosition(Position3DToAWTPoint(rPos));
387 0 : setSize(Direction3DToAWTSize(rSize));
388 0 : setProperties(xPropSet, rPropertyNameMap, maProperties);
389 0 : }
390 :
391 0 : DummyCylinder::DummyCylinder(const drawing::Position3D& rPos, const drawing::Direction3D& rSize )
392 : {
393 0 : setPosition(Position3DToAWTPoint(rPos));
394 0 : setSize(Direction3DToAWTSize(rSize));
395 0 : }
396 :
397 0 : DummyPyramid::DummyPyramid(const drawing::Position3D& rPos, const drawing::Direction3D& rSize,
398 : const uno::Reference< beans::XPropertySet > & xPropSet,
399 0 : const tPropertyNameMap& rPropertyNameMap)
400 : {
401 0 : setPosition(Position3DToAWTPoint(rPos));
402 0 : setSize(Direction3DToAWTSize(rSize));
403 0 : setProperties(xPropSet, rPropertyNameMap, maProperties);
404 0 : }
405 :
406 0 : DummyCone::DummyCone(const drawing::Position3D& rPos, const drawing::Direction3D& rSize)
407 : {
408 0 : setPosition(Position3DToAWTPoint(rPos));
409 0 : setSize(Direction3DToAWTSize(rSize));
410 0 : }
411 :
412 0 : DummyPieSegment2D::DummyPieSegment2D(double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree,
413 : double fUnitCircleInnerRadius, double fUnitCircleOuterRadius,
414 : const drawing::Direction3D& rOffset, const drawing::HomogenMatrix& rUnitCircleToScene):
415 : mfUnitCircleStartAngleDegree(fUnitCircleStartAngleDegree),
416 : mfUnitCircleWidthAngleDegree(fUnitCircleWidthAngleDegree),
417 : mfUnitCircleInnerRadius(fUnitCircleInnerRadius),
418 : mfUnitCircleOuterRadius(fUnitCircleOuterRadius),
419 : maOffset(rOffset),
420 0 : maUnitCircleToScene(rUnitCircleToScene)
421 : {
422 0 : }
423 :
424 0 : void DummyPieSegment2D::render()
425 : {
426 : SAL_INFO("chart2.opengl", "render DummyPieSegment2D");
427 0 : DummyChart* pChart = getRootShape();
428 :
429 0 : while(mfUnitCircleWidthAngleDegree>360)
430 0 : mfUnitCircleWidthAngleDegree -= 360.0;
431 0 : while(mfUnitCircleWidthAngleDegree<0)
432 0 : mfUnitCircleWidthAngleDegree += 360.0;
433 :
434 : pChart->m_GLRender.GeneratePieSegment2D(mfUnitCircleInnerRadius, mfUnitCircleOuterRadius,
435 0 : mfUnitCircleStartAngleDegree, mfUnitCircleWidthAngleDegree);
436 :
437 0 : sal_uInt8 nAlpha = 255;
438 0 : std::map<OUString, uno::Any>::const_iterator itr = maProperties.find(UNO_NAME_FILL_TRANSPARENCE);
439 0 : if(itr != maProperties.end())
440 : {
441 0 : nAlpha = 255 - itr->second.get<sal_Int32>();
442 : }
443 :
444 0 : itr = maProperties.find(UNO_NAME_FILLCOLOR);
445 0 : if(itr != maProperties.end())
446 : {
447 0 : sal_Int32 nColor = itr->second.get<sal_Int32>();
448 0 : pChart->m_GLRender.SetColor(nColor, nAlpha);
449 : }
450 :
451 0 : float nSize = std::max<float>(maUnitCircleToScene.Line1.Column1, maUnitCircleToScene.Line2.Column2);
452 0 : pChart->m_GLRender.RenderPieSegment2DShape(nSize, maUnitCircleToScene.Line1.Column4 + maOffset.DirectionX,
453 0 : maUnitCircleToScene.Line2.Column4 + maOffset.DirectionY);
454 :
455 0 : }
456 :
457 0 : DummyPieSegment::DummyPieSegment(
458 : const drawing::Direction3D& rOffset, const drawing::HomogenMatrix& rUnitCircleToScene ):
459 : maOffset(rOffset),
460 0 : maUnitCircleToScene(rUnitCircleToScene)
461 : {
462 0 : }
463 :
464 0 : DummyStripe::DummyStripe(const Stripe& rStripe, const uno::Reference< beans::XPropertySet > & xPropSet,
465 : const tPropertyNameMap& rPropertyNameMap ):
466 0 : maStripe(rStripe)
467 : {
468 0 : setProperties(xPropSet, rPropertyNameMap, maProperties);
469 0 : }
470 :
471 0 : DummyArea3D::DummyArea3D(const drawing::PolyPolygonShape3D& rShape):
472 0 : maShapes(rShape)
473 : {
474 0 : }
475 :
476 0 : DummyArea2D::DummyArea2D(const drawing::PointSequenceSequence& rShape):
477 0 : maShapes(rShape)
478 : {
479 0 : }
480 :
481 0 : void DummyArea2D::render()
482 : {
483 : SAL_INFO("chart2.opengl", "render DummyArea2D");
484 0 : DummyChart* pChart = getRootShape();
485 0 : sal_Int32 nPointssCount = maShapes.getLength();
486 0 : for(sal_Int32 i = 0; i < nPointssCount; i++)
487 : {
488 0 : const com::sun::star::uno::Sequence<com::sun::star::awt::Point>& points = maShapes[i];
489 0 : sal_Int32 nPointsCount = points.getLength();
490 0 : for(sal_Int32 j = 0; j < nPointsCount; j++)
491 : {
492 0 : const com::sun::star::awt::Point& p = points[j];
493 0 : pChart->m_GLRender.SetArea2DShapePoint((float)p.X, (float)p.Y, nPointsCount);
494 : }
495 : }
496 :
497 0 : std::map<OUString, uno::Any>::const_iterator itr = maProperties.find(UNO_NAME_FILLCOLOR);
498 0 : if(itr != maProperties.end())
499 : {
500 0 : sal_Int32 nColor = itr->second.get<sal_Int32>();
501 0 : pChart->m_GLRender.SetColor(nColor, 255);
502 : }
503 :
504 0 : pChart->m_GLRender.RenderArea2DShape();
505 0 : }
506 :
507 0 : DummySymbol2D::DummySymbol2D(const drawing::Position3D& rPos, const drawing::Direction3D& rSize,
508 : sal_Int32 nStandardSymbol, sal_Int32 nFillColor):
509 : mrPosition(rPos),
510 : mrSize(rSize),
511 : mnStandardSymbol(nStandardSymbol),
512 0 : mnFillColor(nFillColor)
513 : {
514 0 : setPosition(Position3DToAWTPoint(rPos));
515 0 : setSize(Direction3DToAWTSize(rSize));
516 0 : }
517 :
518 0 : void DummySymbol2D::render()
519 : {
520 0 : DummyChart* pChart = getRootShape();
521 :
522 0 : pChart->m_GLRender.SetColor(mnFillColor, 255);
523 :
524 0 : pChart->m_GLRender.RenderSymbol2DShape(maPosition.X, maPosition.Y, maSize.Width, maSize.Height, mnStandardSymbol);
525 0 : }
526 :
527 0 : DummyCircle::DummyCircle(const awt::Point& rPos, const awt::Size& rSize)
528 : {
529 0 : setPosition(rPos);
530 0 : setSize(rSize);
531 0 : }
532 :
533 0 : void DummyCircle::render()
534 : {
535 : SAL_INFO("chart2.opengl", "render DummyCircle");
536 0 : debugProperties(maProperties);
537 0 : DummyChart* pChart = getRootShape();
538 :
539 0 : sal_uInt8 nAlpha = 255;
540 0 : std::map<OUString, uno::Any>::const_iterator itr = maProperties.find("FillTransparence");
541 0 : if(itr != maProperties.end())
542 : {
543 0 : sal_Int32 nTrans = itr->second.get<sal_Int32>()/100.0*255;
544 0 : nAlpha = 255 - static_cast<sal_uInt8>(nTrans & 0xFF);
545 :
546 0 : if(nAlpha == 0)
547 0 : return;
548 : }
549 :
550 0 : itr = maProperties.find("FillColor");
551 0 : if(itr != maProperties.end())
552 : {
553 0 : sal_Int32 nColor = itr->second.get<sal_Int32>();
554 0 : pChart->m_GLRender.SetColor(nColor, nAlpha);
555 : }
556 : else
557 : SAL_WARN("chart2.opengl", "missing color");
558 :
559 : pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y,
560 0 : maSize.Width, maSize.Height);
561 0 : pChart->m_GLRender.RenderBubble2FBO(GL_TRUE);
562 : }
563 :
564 : namespace {
565 :
566 0 : void setProperties( const VLineProperties& rLineProperties, std::map<OUString, uno::Any>& rTargetProps )
567 : {
568 : //Transparency
569 0 : if(rLineProperties.Transparence.hasValue())
570 : rTargetProps.insert(std::pair<OUString, uno::Any>(
571 0 : UNO_NAME_LINETRANSPARENCE, rLineProperties.Transparence));
572 :
573 : //LineStyle
574 0 : if(rLineProperties.LineStyle.hasValue())
575 : rTargetProps.insert(std::pair<OUString, uno::Any>(
576 0 : UNO_NAME_LINESTYLE, rLineProperties.LineStyle));
577 :
578 : //LineWidth
579 0 : if(rLineProperties.Width.hasValue())
580 : rTargetProps.insert(std::pair<OUString, uno::Any>(
581 0 : UNO_NAME_LINEWIDTH, rLineProperties.Width));
582 :
583 : //LineColor
584 0 : if(rLineProperties.Color.hasValue())
585 : rTargetProps.insert(std::pair<OUString, uno::Any>(
586 0 : UNO_NAME_LINECOLOR, rLineProperties.Color));
587 :
588 : //LineDashName
589 0 : if(rLineProperties.DashName.hasValue())
590 : rTargetProps.insert(std::pair<OUString, uno::Any>(
591 0 : "LineDashName", rLineProperties.DashName));
592 0 : }
593 :
594 : }
595 :
596 0 : DummyLine3D::DummyLine3D(const drawing::PolyPolygonShape3D& rPoints, const VLineProperties& rLineProperties):
597 0 : maPoints(rPoints)
598 : {
599 0 : setProperties(rLineProperties, maProperties);
600 0 : }
601 :
602 0 : DummyLine2D::DummyLine2D(const drawing::PointSequenceSequence& rPoints, const VLineProperties* pLineProperties):
603 0 : maPoints(rPoints)
604 : {
605 0 : if(pLineProperties)
606 0 : setProperties(*pLineProperties, maProperties);
607 0 : }
608 :
609 0 : DummyLine2D::DummyLine2D(const awt::Size& rSize, const awt::Point& rPosition)
610 : {
611 0 : setPosition(rPosition);
612 0 : setSize(rSize);
613 0 : }
614 :
615 0 : void DummyLine2D::render()
616 : {
617 : SAL_INFO("chart2.opengl", "rendering line 2D");
618 0 : debugProperties(maProperties);
619 0 : DummyChart* pChart = getRootShape();
620 :
621 : //add style and transparency
622 0 : std::map< OUString, uno::Any >::const_iterator itr = maProperties.find(UNO_NAME_LINESTYLE);
623 0 : if (itr != maProperties.end())
624 : {
625 0 : uno::Any cow = itr->second;
626 0 : drawing::LineStyle nStyle = cow.get<drawing::LineStyle>();
627 0 : if (drawing::LineStyle_NONE == nStyle)
628 : {
629 : // nothing to render
630 0 : return;
631 0 : }
632 : }
633 :
634 0 : sal_uInt8 nAlpha = 255;
635 0 : itr = maProperties.find("LineTransparence");
636 0 : if(itr != maProperties.end())
637 : {
638 0 : uno::Any al = itr->second;
639 0 : nAlpha = 255 - al.get<sal_Int32>();
640 : }
641 :
642 0 : itr = maProperties.find(UNO_NAME_LINECOLOR);
643 0 : if(itr != maProperties.end())
644 : {
645 : //set line color
646 0 : uno::Any co = itr->second;
647 0 : sal_Int32 nColorValue = co.get<sal_Int32>();
648 : SAL_INFO("chart2.opengl", "line colorvalue = " << nColorValue);
649 0 : sal_uInt8 R = (nColorValue & 0x00FF0000) >> 16;
650 0 : sal_uInt8 G = (nColorValue & 0x0000FF00) >> 8;
651 0 : sal_uInt8 B = (nColorValue & 0x000000FF);
652 0 : pChart->m_GLRender.SetLine2DColor(R, G, B, nAlpha);
653 :
654 0 : SAL_INFO("chart2.opengl", "line colorvalue = " << nColorValue << ", R = " << (int)R << ", G = " << (int)G << ", B = " << (int)B);
655 : }
656 : else
657 : SAL_WARN("chart2.opengl", "no line color set");
658 :
659 : //set line width
660 0 : itr = maProperties.find(UNO_NAME_LINEWIDTH);
661 0 : if(itr != maProperties.end())
662 : {
663 0 : uno::Any cow = itr->second;
664 0 : sal_Int32 nWidth = cow.get<sal_Int32>();
665 0 : pChart->m_GLRender.SetLine2DWidth(nWidth);
666 :
667 0 : SAL_INFO("chart2.opengl", "width = " << nWidth);
668 : }
669 : else
670 : SAL_WARN("chart2.opengl", "no line width set");
671 :
672 0 : sal_Int32 pointsscount = maPoints.getLength();
673 0 : for(sal_Int32 i = 0; i < pointsscount; i++)
674 : {
675 0 : com::sun::star::uno::Sequence<com::sun::star::awt::Point>& points = maPoints[i];
676 0 : sal_Int32 pointscount = points.getLength();
677 0 : for(sal_Int32 j = 0; j < pointscount; j++)
678 : {
679 0 : com::sun::star::awt::Point& p = points[j];
680 0 : pChart->m_GLRender.SetLine2DShapePoint((float)p.X, (float)p.Y, pointscount);
681 : }
682 :
683 : }
684 0 : pChart->m_GLRender.RenderLine2FBO(GL_TRUE);
685 :
686 : }
687 :
688 0 : DummyRectangle::DummyRectangle()
689 : {
690 0 : }
691 :
692 0 : DummyRectangle::DummyRectangle(const awt::Size& rSize)
693 : {
694 0 : setSize(rSize);
695 0 : }
696 :
697 0 : DummyRectangle::DummyRectangle(const awt::Size& rSize, const awt::Point& rPoint, const tNameSequence& rNames,
698 0 : const tAnySequence& rValues)
699 : {
700 0 : setSize(rSize);
701 0 : setPosition(rPoint);
702 0 : setProperties(rNames, rValues, maProperties);
703 0 : }
704 :
705 0 : void DummyRectangle::render()
706 : {
707 : SAL_INFO("chart2.opengl", "render DummyRectangle");
708 0 : debugProperties(maProperties);
709 0 : DummyChart* pChart = getRootShape();
710 0 : std::map< OUString, uno::Any >::const_iterator itr = maProperties.find("Invisible");
711 0 : if(itr != maProperties.end())
712 : {
713 0 : return;
714 : }
715 :
716 0 : bool bFill = true;
717 0 : drawing::FillStyle eStyle = drawing::FillStyle_NONE;
718 0 : itr = maProperties.find("FillStyle");
719 0 : if(itr != maProperties.end())
720 : {
721 0 : eStyle = itr->second.get<drawing::FillStyle>();
722 0 : if(eStyle == drawing::FillStyle_NONE)
723 : {
724 0 : bFill = false;
725 : }
726 : }
727 :
728 0 : itr = maProperties.find("FillColor");
729 0 : if(itr != maProperties.end())
730 : {
731 0 : uno::Any co = itr->second;
732 0 : sal_Int32 nColorValue = co.get<sal_Int32>();
733 : //here FillStyle works for background color and gradients
734 0 : pChart->m_GLRender.SetBackGroundColor(nColorValue, nColorValue, eStyle);
735 : }
736 :
737 0 : bool bBorder = true;
738 0 : itr = maProperties.find(UNO_NAME_LINESTYLE);
739 0 : if (itr != maProperties.end())
740 : {
741 0 : uno::Any cow = itr->second;
742 0 : drawing::LineStyle nStyle = cow.get<drawing::LineStyle>();
743 0 : if (drawing::LineStyle_NONE == nStyle)
744 : {
745 0 : bBorder = false;
746 0 : }
747 : }
748 :
749 : //TODO: moggi: correct handling of gradients
750 0 : itr = maProperties.find("FillTransparenceGradientName");
751 0 : if (itr != maProperties.end())
752 : {
753 0 : uno::Any co = itr->second;
754 0 : rtl::OUString aGradientValue = co.get<rtl::OUString>();
755 0 : if (aGradientValue.endsWithAsciiL("1", 1))
756 : {
757 0 : pChart->m_GLRender.SetChartTransparencyGradient(1);
758 0 : }
759 : }
760 0 : pChart->m_GLRender.RectangleShapePoint(maPosition.X, maPosition.Y, maSize.Width, maSize.Height);
761 0 : pChart->m_GLRender.RenderRectangleShape(bBorder, bFill);
762 : }
763 :
764 : namespace {
765 :
766 : struct FontAttribSetter
767 : {
768 0 : FontAttribSetter(vcl::Font& rFont):
769 0 : mrFont(rFont) {}
770 :
771 0 : void operator()(const std::pair<OUString, uno::Any>& rProp)
772 : {
773 0 : const OUString& rPropName = rProp.first;
774 0 : if(rPropName == "CharFontName")
775 : {
776 0 : OUString aName = rProp.second.get<OUString>();
777 0 : mrFont.SetName(aName);
778 : }
779 0 : else if(rPropName == "CharColor")
780 : {
781 0 : sal_Int32 nColor = rProp.second.get<sal_Int32>();
782 0 : mrFont.SetFillColor(nColor);
783 : }
784 0 : else if(rPropName == "CharHeight")
785 : {
786 0 : float fHeight = rProp.second.get<float>();
787 0 : mrFont.SetSize(Size(0,(fHeight*127+36)/72)); //taken from the MCW implementation
788 : }
789 0 : else if(rPropName == "CharUnderline")
790 : {
791 0 : FontUnderline eUnderline = static_cast<FontUnderline>(rProp.second.get<sal_Int16>());
792 0 : mrFont.SetUnderline(eUnderline);
793 : }
794 0 : else if(rPropName == "CharWeight")
795 : {
796 0 : float fWeight = rProp.second.get<float>();
797 0 : FontWeight eFontWeight = VCLUnoHelper::ConvertFontWeight(fWeight);
798 0 : mrFont.SetWeight(eFontWeight);
799 : }
800 0 : else if(rPropName == "ChartWidth")
801 : {
802 0 : float fWidth = rProp.second.get<float>();
803 0 : FontWidth eFontWidth = VCLUnoHelper::ConvertFontWidth(fWidth);
804 0 : mrFont.SetWidth(eFontWidth);
805 : }
806 0 : }
807 : private:
808 : vcl::Font& mrFont;
809 : };
810 :
811 : }
812 :
813 0 : DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
814 : const tAnySequence& rValues, const uno::Any& rTrans, uno::Reference< drawing::XShapes > xTarget, double nRotation ):
815 : maText(rText),
816 : maTrans(rTrans),
817 0 : mnRotation(nRotation)
818 : {
819 0 : setProperties(rNames, rValues, maProperties);
820 :
821 0 : xTarget->add(this);
822 0 : DummyChart* pChart = getRootShape();
823 0 : TextCache& rCache = pChart->getTextCache();
824 0 : TextCache::TextCacheKey aKey;
825 0 : aKey.maText = maText;
826 0 : aKey.maProperties = maProperties;
827 : int bmpWidth;
828 : int bmpHeight;
829 0 : if(rCache.hasEntry(aKey))
830 : {
831 0 : maBitmap = rCache.getBitmap(aKey);
832 0 : bmpWidth = maBitmap.GetSizePixel().Width();
833 0 : bmpHeight = maBitmap.GetSizePixel().Height();
834 : }
835 : else
836 : {
837 0 : vcl::Font aFont;
838 0 : std::for_each(maProperties.begin(), maProperties.end(), FontAttribSetter(aFont));
839 0 : VirtualDevice aDevice(*Application::GetDefaultDevice(), 0, 0);
840 0 : aDevice.Erase();
841 0 : Rectangle aRect;
842 0 : aDevice.SetFont(aFont);
843 0 : aDevice.GetTextBoundRect(aRect, rText);
844 0 : int screenWidth = (aRect.BottomRight().X());
845 0 : int screenHeight = (aRect.BottomRight().Y());
846 0 : aDevice.SetOutputSizePixel(Size(screenWidth * 3, screenHeight));
847 0 : aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
848 0 : aDevice.DrawText(Point(0, 0), rText);
849 0 : bmpWidth = aRect.Right() - aRect.Left();
850 0 : bmpHeight = aRect.Bottom() - aRect.Top();
851 0 : maBitmap = BitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight)));
852 0 : rCache.insertBitmap(aKey, maBitmap);
853 : }
854 :
855 0 : if(rTrans.hasValue())
856 : {
857 0 : drawing::HomogenMatrix3 aTrans = rTrans.get<drawing::HomogenMatrix3>();
858 0 : setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
859 0 : setPosition(awt::Point(aTrans.Line1.Column3, aTrans.Line2.Column3));
860 0 : aTrans.Line1.Column1 = 20 * bmpWidth;
861 0 : aTrans.Line2.Column2 = 20 * bmpHeight;
862 0 : setTransformatAsProperty(aTrans);
863 : }
864 : else
865 : {
866 0 : setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
867 0 : uno::Reference< drawing::XShape > xTargetShape(xTarget, uno::UNO_QUERY);
868 0 : drawing::HomogenMatrix3 aTrans;
869 0 : aTrans.Line1.Column1 = 20 * bmpWidth;
870 0 : aTrans.Line2.Column2 = 20 * bmpHeight;
871 0 : aTrans.Line3.Column3 = 1;
872 0 : if(xTargetShape.is())
873 : {
874 0 : const awt::Point rPoint = xTargetShape->getPosition();
875 0 : setPosition(rPoint);
876 0 : aTrans.Line1.Column3 = rPoint.X;
877 0 : aTrans.Line2.Column3 = rPoint.Y;
878 : }
879 0 : setTransformatAsProperty(aTrans);
880 0 : }
881 0 : }
882 :
883 0 : void DummyText::render()
884 : {
885 : SAL_INFO("chart2.opengl", "render DummyText");
886 0 : debugProperties(maProperties);
887 :
888 0 : DummyChart* pChart = getRootShape();
889 :
890 0 : drawing::HomogenMatrix3 aTransformation;
891 : std::map<OUString, uno::Any>::const_iterator itr =
892 0 : maProperties.find("Transformation");
893 0 : if(itr != maProperties.end())
894 : {
895 : SAL_INFO("chart2.opengl", "found a transformation");
896 0 : if(itr->second.hasValue())
897 : {
898 0 : aTransformation = itr->second.get<drawing::HomogenMatrix3>();
899 : }
900 : }
901 0 : else if(maTrans.hasValue())
902 : {
903 0 : aTransformation = maTrans.get<drawing::HomogenMatrix3>();
904 : }
905 : pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize,
906 0 : mnRotation, aTransformation);
907 0 : pChart->m_GLRender.RenderTextShape();
908 0 : }
909 :
910 0 : void SAL_CALL DummyText::setPropertyValue( const OUString& rName, const uno::Any& rValue)
911 : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
912 : lang::IllegalArgumentException, lang::WrappedTargetException,
913 : uno::RuntimeException, std::exception)
914 : {
915 : SAL_INFO("chart2.opengl", "property value set after image has been created");
916 0 : DummyXShape::setPropertyValue(rName, rValue);
917 0 : }
918 :
919 0 : void SAL_CALL DummyText::setPosition(const awt::Point& rPosition )
920 : throw(uno::RuntimeException, std::exception)
921 : {
922 0 : DummyXShape::setPosition(rPosition);
923 0 : if(maTrans.hasValue())
924 0 : return;
925 :
926 : std::map<OUString, uno::Any>::const_iterator itr =
927 0 : maProperties.find("Transformation");
928 0 : if(itr != maProperties.end())
929 : {
930 0 : if(itr->second.hasValue())
931 : {
932 0 : drawing::HomogenMatrix3 aTrans = itr->second.get<drawing::HomogenMatrix3>();
933 0 : aTrans.Line1.Column3 = rPosition.X;
934 0 : aTrans.Line2.Column3 = rPosition.Y;
935 0 : setTransformatAsProperty(aTrans);
936 : }
937 : }
938 : }
939 :
940 0 : void DummyText::setTransformatAsProperty(const drawing::HomogenMatrix3& rMatrix)
941 : {
942 0 : uno::Any aNewTrans;
943 0 : aNewTrans <<= rMatrix;
944 0 : setPropertyValue("Transformation", aNewTrans);
945 0 : }
946 :
947 0 : DummyGroup3D::DummyGroup3D(const OUString& rName)
948 : {
949 0 : setName(rName);
950 0 : }
951 :
952 0 : DummyGroup2D::DummyGroup2D(const OUString& rName)
953 : {
954 0 : setName(rName);
955 0 : }
956 :
957 0 : awt::Point SAL_CALL DummyGroup2D::getPosition()
958 : throw(uno::RuntimeException, std::exception)
959 : {
960 0 : long nTop = std::numeric_limits<long>::max();
961 0 : long nLeft = std::numeric_limits<long>::max();
962 0 : for(std::vector<DummyXShape*>::iterator itr = maShapes.begin(),
963 0 : itrEnd = maShapes.end(); itr != itrEnd; ++itr)
964 : {
965 0 : awt::Point aPoint = (*itr)->getPosition();
966 0 : if(aPoint.X >= 0 && aPoint.Y >= 0)
967 : {
968 0 : nLeft = std::min<long>(nLeft, aPoint.X);
969 0 : nTop = std::min<long>(nTop, aPoint.Y);
970 : }
971 : }
972 :
973 0 : return awt::Point(nLeft, nTop);
974 : }
975 :
976 0 : awt::Size SAL_CALL DummyGroup2D::getSize()
977 : throw(uno::RuntimeException, std::exception)
978 : {
979 0 : long nTop = std::numeric_limits<long>::max();
980 0 : long nLeft = std::numeric_limits<long>::max();
981 0 : long nBottom = 0;
982 0 : long nRight = 0;
983 0 : for(std::vector<DummyXShape*>::iterator itr = maShapes.begin(),
984 0 : itrEnd = maShapes.end(); itr != itrEnd; ++itr)
985 : {
986 0 : awt::Point aPoint = (*itr)->getPosition();
987 0 : nLeft = std::min<long>(nLeft, aPoint.X);
988 0 : nTop = std::min<long>(nTop, aPoint.Y);
989 0 : awt::Size aSize = (*itr)->getSize();
990 0 : nRight = std::max<long>(nRight, aPoint.X + aSize.Width);
991 0 : nBottom = std::max<long>(nBottom, aPoint.Y + aSize.Height);
992 : }
993 :
994 0 : return awt::Size(nRight - nLeft, nBottom - nTop);
995 : }
996 :
997 0 : void SAL_CALL DummyGroup2D::setPosition( const awt::Point& rPos )
998 : throw(uno::RuntimeException, std::exception)
999 : {
1000 0 : for(std::vector<DummyXShape*>::const_iterator itr = maShapes.begin(),
1001 0 : itrEnd = maShapes.end(); itr != itrEnd; ++itr)
1002 : {
1003 0 : const awt::Point& rOldPos = (*itr)->getPos();
1004 0 : awt::Point aNewPos( rPos.X + rOldPos.X, rPos.Y + rOldPos.Y);
1005 0 : (*itr)->setPosition(aNewPos);
1006 : }
1007 0 : }
1008 :
1009 0 : void SAL_CALL DummyGroup2D::setSize( const awt::Size& )
1010 : throw( beans::PropertyVetoException, uno::RuntimeException, std::exception )
1011 : {
1012 : SAL_WARN("chart2.opengl", "set size on group shape");
1013 0 : }
1014 :
1015 0 : DummyGraphic2D::DummyGraphic2D(const drawing::Position3D& rPos, const drawing::Direction3D& rSize,
1016 : const uno::Reference< graphic::XGraphic > xGraphic ):
1017 0 : mxGraphic(xGraphic)
1018 : {
1019 0 : setPosition(Position3DToAWTPoint(rPos));
1020 0 : setSize(Direction3DToAWTSize(rSize));
1021 0 : }
1022 :
1023 0 : DummyChart* DummyXShape::getRootShape()
1024 : {
1025 : assert(mxParent.is());
1026 0 : DummyXShape& rParent = dynamic_cast<DummyXShape&>(*mxParent.get());
1027 0 : return rParent.getRootShape();
1028 : }
1029 :
1030 0 : DummyChart* DummyChart::getRootShape()
1031 : {
1032 0 : return this;
1033 : }
1034 :
1035 : #define QUERYINT( xint ) \
1036 : if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
1037 : aAny <<= uno::Reference< xint >(this)
1038 :
1039 : #define QUERY_INTERFACE( xint ) \
1040 : if( rType == ::getCppuType((const uno::Reference< xint >*)0 ) ) \
1041 : return uno::makeAny(uno::Reference<xint>(this));
1042 :
1043 0 : uno::Any SAL_CALL DummyXShapes::queryInterface( const uno::Type& rType )
1044 : throw(uno::RuntimeException, std::exception)
1045 : {
1046 0 : QUERY_INTERFACE( drawing::XShapes );
1047 0 : QUERY_INTERFACE( container::XIndexAccess );
1048 0 : return DummyXShape::queryInterface(rType);
1049 : }
1050 :
1051 0 : uno::Any SAL_CALL DummyXShapes::queryAggregation( const uno::Type & rType )
1052 : throw(uno::RuntimeException, std::exception)
1053 : {
1054 0 : uno::Any aAny;
1055 :
1056 : //QUERYINT( drawing::XShapeGroup );
1057 0 : QUERYINT( drawing::XShapes );
1058 : else
1059 0 : return DummyXShape::queryAggregation( rType );
1060 :
1061 0 : return aAny;
1062 : }
1063 :
1064 0 : void SAL_CALL DummyXShapes::acquire()
1065 : throw()
1066 : {
1067 0 : DummyXShape::acquire();
1068 0 : }
1069 :
1070 0 : void DummyXShapes::release()
1071 : throw()
1072 : {
1073 0 : DummyXShape::release();
1074 0 : }
1075 :
1076 0 : void SAL_CALL DummyXShapes::add( const uno::Reference< drawing::XShape>& xShape )
1077 : throw(uno::RuntimeException, std::exception)
1078 : {
1079 0 : DummyXShape& rChild = dynamic_cast<DummyXShape&>(*xShape.get());
1080 0 : maUNOShapes.push_back(xShape);
1081 0 : rChild.setParent(static_cast< ::cppu::OWeakObject* >( this ));
1082 0 : maShapes.push_back(&rChild);
1083 0 : }
1084 :
1085 0 : void SAL_CALL DummyXShapes::remove( const uno::Reference< drawing::XShape>& xShape )
1086 : throw(uno::RuntimeException, std::exception)
1087 : {
1088 0 : std::vector< uno::Reference<drawing::XShape> >::iterator itr = std::find(maUNOShapes.begin(), maUNOShapes.end(), xShape);
1089 0 : if(itr != maUNOShapes.end())
1090 : {
1091 0 : DummyXShape* pChild = dynamic_cast<DummyXShape*>((*itr).get());
1092 0 : std::vector< DummyXShape* >::iterator itrShape = std::find(maShapes.begin(), maShapes.end(), pChild);
1093 0 : if(itrShape != maShapes.end())
1094 0 : maShapes.erase(itrShape);
1095 :
1096 0 : maUNOShapes.erase(itr);
1097 : }
1098 0 : }
1099 :
1100 0 : uno::Type SAL_CALL DummyXShapes::getElementType()
1101 : throw(uno::RuntimeException, std::exception)
1102 : {
1103 0 : return cppu::UnoType<drawing::XShape>::get();
1104 : }
1105 :
1106 0 : sal_Bool SAL_CALL SAL_CALL DummyXShapes::hasElements()
1107 : throw(uno::RuntimeException, std::exception)
1108 : {
1109 0 : return !maUNOShapes.empty();
1110 : }
1111 :
1112 0 : sal_Int32 SAL_CALL DummyXShapes::getCount()
1113 : throw(uno::RuntimeException, std::exception)
1114 : {
1115 0 : return maUNOShapes.size();
1116 : }
1117 :
1118 0 : uno::Any SAL_CALL DummyXShapes::getByIndex(sal_Int32 nIndex)
1119 : throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException,
1120 : uno::RuntimeException, std::exception)
1121 : {
1122 0 : uno::Any aShape;
1123 0 : aShape <<= maUNOShapes[nIndex];
1124 0 : return aShape;
1125 : }
1126 :
1127 0 : void DummyXShapes::render()
1128 : {
1129 : SAL_INFO("chart2.opengl", "render DummyShapes");
1130 0 : for(std::vector<DummyXShape*>::iterator itr = maShapes.begin(),
1131 0 : itrEnd = maShapes.end(); itr != itrEnd; ++itr)
1132 : {
1133 0 : (*itr)->render();
1134 : }
1135 0 : }
1136 :
1137 0 : DummyChart::DummyChart():
1138 : mbNotInit(true),
1139 0 : m_GLRender()
1140 : {
1141 : SAL_INFO("chart2.opengl", "DummyXShape::DummyChart()-----test: ");
1142 0 : setName("com.sun.star.chart2.shapes");
1143 0 : }
1144 :
1145 0 : void SAL_CALL DummyChart::setPosition( const awt::Point& aPosition )
1146 : throw( uno::RuntimeException, std::exception )
1147 : {
1148 0 : DummyXShape::setPosition(aPosition);
1149 0 : }
1150 :
1151 0 : DummyChart::~DummyChart()
1152 : {
1153 0 : }
1154 :
1155 0 : void SAL_CALL DummyChart::setSize( const awt::Size& aSize )
1156 : throw( beans::PropertyVetoException, uno::RuntimeException, std::exception )
1157 : {
1158 : SAL_INFO("chart2.opengl", "DummyChart::setSize()---aSize.Width = " << aSize.Width << ", aSize.Height = " << aSize.Height);
1159 0 : int width = aSize.Width;
1160 0 : int height = aSize.Height;
1161 0 : DummyXShape::setSize(awt::Size(0,0));
1162 0 : m_GLRender.SetSize(width, height);
1163 : SAL_INFO("chart2.opengl", "DummyChart::GLRender.Width = " << width << ", GLRender.Height = " << height);
1164 0 : }
1165 :
1166 0 : void DummyChart::render()
1167 : {
1168 0 : if(mbNotInit)
1169 : {
1170 0 : m_GLRender.InitOpenGL();
1171 0 : mbNotInit = false;
1172 : }
1173 :
1174 : SAL_INFO("chart2.opengl", "render chart");
1175 0 : m_GLRender.prepareToRender();
1176 : #if 0
1177 : m_GLRender.renderDebug();
1178 : #else
1179 0 : DummyXShapes::render();
1180 : #endif
1181 0 : }
1182 :
1183 0 : void DummyChart::clear()
1184 : {
1185 0 : maUNOShapes.clear();
1186 0 : maShapes.clear();
1187 0 : }
1188 :
1189 : }
1190 :
1191 0 : }
1192 :
1193 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|