LCOV - code coverage report
Current view: top level - chart2/source/view/main - DummyXShape.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 569 0.0 %
Date: 2014-04-14 Functions: 0 102 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10