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