LCOV - code coverage report
Current view: top level - chart2/source/view/inc - AbstractShapeFactory.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 5 40.0 %
Date: 2015-06-13 12:38:46 Functions: 2 5 40.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             : 
      10             : #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_ABSTRACTSHAPEFACTORY_HXX
      11             : #define INCLUDED_CHART2_SOURCE_VIEW_INC_ABSTRACTSHAPEFACTORY_HXX
      12             : 
      13             : #include "PropertyMapper.hxx"
      14             : #include "VLineProperties.hxx"
      15             : #include "BaseGFXHelper.hxx"
      16             : #include <com/sun/star/awt/Size.hpp>
      17             : #include <com/sun/star/awt/Point.hpp>
      18             : #include <com/sun/star/beans/XPropertySet.hpp>
      19             : #include <com/sun/star/chart2/XFormattedString.hpp>
      20             : #include <com/sun/star/drawing/Direction3D.hpp>
      21             : #include <com/sun/star/drawing/HomogenMatrix.hpp>
      22             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      23             : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
      24             : #include <com/sun/star/drawing/Position3D.hpp>
      25             : #include <com/sun/star/drawing/XDrawPage.hpp>
      26             : #include <com/sun/star/drawing/XShapes2.hpp>
      27             : #include <com/sun/star/graphic/XGraphic.hpp>
      28             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29             : 
      30             : #include <rtl/ustring.hxx>
      31             : 
      32             : class OpenGLWindow;
      33             : 
      34             : namespace chart {
      35             : 
      36             : // Be careful here not to clash with the SYMBOL_FOO #defines in
      37             : // <rsc/rsc-vcl-shared-types.hxx>
      38             : enum SymbolEnum { Symbol_Square=0
      39             :                  , Symbol_Diamond
      40             :                  , Symbol_DownArrow
      41             :                  , Symbol_UpArrow
      42             :                  , Symbol_RightArrow
      43             :                  , Symbol_LeftArrow
      44             :                  , Symbol_Bowtie
      45             :                  , Symbol_Sandglass
      46             :                  , Symbol_Circle
      47             :                  , Symbol_Star
      48             :                  , Symbol_X
      49             :                  , Symbol_Plus
      50             :                  , Symbol_Asterisk
      51             :                  , Symbol_HorizontalBar
      52             :                  , Symbol_VerticalBar
      53             :                  , Symbol_COUNT
      54             : };
      55             : 
      56             : class Stripe;
      57             : 
      58          16 : class AbstractShapeFactory
      59             : {
      60             : protected:
      61             : 
      62             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
      63             :         m_xShapeFactory;
      64             : public:
      65             : 
      66             :     enum StackPosition { Top, Bottom };
      67           0 :     void setShapeFactory(com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory)
      68           0 :         { m_xShapeFactory = xFactory; }
      69             : 
      70             :     static AbstractShapeFactory* getOrCreateShapeFactory(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory);
      71             : 
      72           0 :     virtual ~AbstractShapeFactory() {};
      73             : 
      74             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
      75             :         createGroup2D(
      76             :             const ::com::sun::star::uno::Reference<
      77             :                 ::com::sun::star::drawing::XShapes >& xTarget
      78             :                 , const OUString& aName = OUString() ) = 0;
      79             : 
      80             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
      81             :         createGroup3D(
      82             :             const ::com::sun::star::uno::Reference<
      83             :                 ::com::sun::star::drawing::XShapes >& xTarget
      84             :                 , const OUString& aName = OUString() ) = 0;
      85             : 
      86             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
      87             :             createCube(   const ::com::sun::star::uno::Reference<
      88             :                                 ::com::sun::star::drawing::XShapes >& xTarget
      89             :                         , const ::com::sun::star::drawing::Position3D& rPosition
      90             :                         , const ::com::sun::star::drawing::Direction3D& rSize
      91             :                         , sal_Int32 nRotateZAngleHundredthDegree
      92             :                         , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
      93             :                         , const tPropertyNameMap& rPropertyNameMap
      94             :                         , bool bRounded = false) = 0;
      95             : 
      96             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
      97             :         createCylinder(   const ::com::sun::star::uno::Reference<
      98             :                                 ::com::sun::star::drawing::XShapes >& xTarget
      99             :                         , const ::com::sun::star::drawing::Position3D& rPosition
     100             :                         , const ::com::sun::star::drawing::Direction3D& rSize
     101             :                         , sal_Int32 nRotateZAngleHundredthDegree ) = 0;
     102             : 
     103             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     104             :         createPyramid(    const ::com::sun::star::uno::Reference<
     105             :                                 ::com::sun::star::drawing::XShapes >& xTarget
     106             :                         , const ::com::sun::star::drawing::Position3D& rPosition
     107             :                         , const ::com::sun::star::drawing::Direction3D& rSize
     108             :                         , double fTopHeight
     109             :                         , bool bRotateZ
     110             :                         , const ::com::sun::star::uno::Reference<
     111             :                             ::com::sun::star::beans::XPropertySet >& xSourceProp
     112             :                         , const tPropertyNameMap& rPropertyNameMap) = 0;
     113             : 
     114             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     115             :         createCone(       const ::com::sun::star::uno::Reference<
     116             :                                 ::com::sun::star::drawing::XShapes >& xTarget
     117             :                         , const ::com::sun::star::drawing::Position3D& rPosition
     118             :                         , const ::com::sun::star::drawing::Direction3D& rSize
     119             :                         , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) = 0;
     120             : 
     121             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     122             :         createPieSegment2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     123             :                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
     124             :                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
     125             :                     , const ::com::sun::star::drawing::Direction3D& rOffset
     126             :                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene ) = 0;
     127             : 
     128             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     129             :         createPieSegment( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     130             :                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
     131             :                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
     132             :                     , const ::com::sun::star::drawing::Direction3D& rOffset
     133             :                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene
     134             :                     , double fDepth ) = 0;
     135             : 
     136             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     137             :         createStripe( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     138             :                     , const Stripe& rStripe
     139             :                     , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
     140             :                     , const tPropertyNameMap& rPropertyNameMap
     141             :                     , bool bDoubleSided = true
     142             :                     , short nRotatedTexture = 0 //0 to 7 are the different possibilities
     143             :                     , bool bFlatNormals=true ) = 0;
     144             : 
     145             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     146             :         createArea3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     147             :                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon
     148             :                     , double fDepth) = 0;
     149             : 
     150             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     151             :         createArea2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     152             :                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon) = 0;
     153             : 
     154         502 :     static sal_Int32 getSymbolCount() { return Symbol_COUNT; }
     155             : 
     156             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     157             :         createSymbol2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     158             :                     , const ::com::sun::star::drawing::Position3D& rPos
     159             :                     , const ::com::sun::star::drawing::Direction3D& rSize
     160             :                     , sal_Int32 nStandardSymbol
     161             :                     , sal_Int32 nBorderColor=0
     162             :                     , sal_Int32 nFillColor=0 ) = 0;
     163             : 
     164             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     165             :         createGraphic2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     166             :                     , const ::com::sun::star::drawing::Position3D& rPos
     167             :                     , const ::com::sun::star::drawing::Direction3D& rSize
     168             :                     , const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic ) = 0;
     169             : 
     170             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     171             :         createLine2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     172             :                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
     173             :                     , const VLineProperties* pLineProperties = NULL ) = 0;
     174             : 
     175             :     virtual com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
     176             :         createLine ( const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& xTarget,
     177             :                 const com::sun::star::awt::Size& rSize, const com::sun::star::awt::Point& rPosition ) = 0;
     178             : 
     179             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     180             :         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     181             :                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
     182             :                     , const VLineProperties& rLineProperties ) = 0;
     183             : 
     184             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     185             :         createCircle2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     186             :                     , const ::com::sun::star::drawing::Position3D& rPos
     187             :                     , const ::com::sun::star::drawing::Direction3D& rSize ) = 0;
     188             : 
     189             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     190             :         createCircle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
     191             :                     , const ::com::sun::star::awt::Size& rSize
     192             :                     , const ::com::sun::star::awt::Point& rPosition ) = 0;
     193             : 
     194             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     195             :         createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D
     196             :                     , const OUString& rText
     197             :                     , const tNameSequence& rPropNames
     198             :                     , const tAnySequence& rPropValues
     199             :                     , const ::com::sun::star::uno::Any& rATransformation
     200             :                      ) = 0;
     201             : 
     202             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     203             :         createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D,
     204             :                 const com::sun::star::awt::Size& rSize,
     205             :                 const com::sun::star::awt::Point& rPosition,
     206             :                 com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::chart2::XFormattedString > >& xFormattedString,
     207             :                 const com::sun::star::uno::Reference<
     208             :                 com::sun::star::beans::XPropertySet > & xTextProperties,
     209             :                 double nRotation, const OUString& aName ) = 0;
     210             : 
     211             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     212             :         createInvisibleRectangle(
     213             :             const ::com::sun::star::uno::Reference<
     214             :                 ::com::sun::star::drawing::XShapes >& xTarget
     215             :                 , const ::com::sun::star::awt::Size& rSize ) = 0;
     216             : 
     217             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     218             :         createRectangle(
     219             :             const com::sun::star::uno::Reference<
     220             :                 com::sun::star::drawing::XShapes >& xTarget,
     221             :             const com::sun::star::awt::Size& rSize,
     222             :             const com::sun::star::awt::Point& rPosition,
     223             :             const tNameSequence& rPropNames,
     224             :             const tAnySequence& rPropValues,
     225             :             StackPosition ePos = Top ) = 0;
     226             : 
     227             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     228             :         createRectangle(
     229             :             const ::com::sun::star::uno::Reference<
     230             :                 ::com::sun::star::drawing::XShapes >& xTarget ) = 0;
     231             : 
     232             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
     233             :          getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
     234             :             ::com::sun::star::drawing::XDrawPage>& xPage ) = 0;
     235             : 
     236             :     virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize ) = 0;
     237             : 
     238             :     /**
     239             :      * Only necessary for stateless implementations
     240             :      */
     241             :     virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, bool bInitOpenGL = true) = 0;
     242             : 
     243             :     virtual bool preRender(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, OpenGLWindow* pWindow) = 0;
     244             :     virtual void postRender(OpenGLWindow* pWindow) = 0;
     245             : 
     246             :     virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape) = 0;
     247             : 
     248             :     static ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
     249             :          getChartRootShape( const ::com::sun::star::uno::Reference<
     250             :             ::com::sun::star::drawing::XDrawPage>& xPage );
     251             : 
     252             :     static void makeShapeInvisible( const ::com::sun::star::uno::Reference<
     253             :             ::com::sun::star::drawing::XShape >& xShape );
     254             : 
     255             :     static void setShapeName( const ::com::sun::star::uno::Reference<
     256             :             ::com::sun::star::drawing::XShape >& xShape
     257             :             , const OUString& rName );
     258             : 
     259             :     static OUString getShapeName( const ::com::sun::star::uno::Reference<
     260             :             ::com::sun::star::drawing::XShape >& xShape );
     261             : 
     262             :     static ::com::sun::star::uno::Any makeTransformation( const ::com::sun::star::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 );
     263             : 
     264             :     static OUString getStackedString( const OUString& rString, bool bStacked=true );
     265             : 
     266             :     static bool hasPolygonAnyLines( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
     267             :     static bool isPolygonEmptyOrSinglePoint( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
     268             :     static void closePolygon( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
     269             : 
     270             :     static ::com::sun::star::awt::Size calculateNewSizeRespectingAspectRatio(
     271             :             const ::com::sun::star::awt::Size& rTargetSize
     272             :             , const ::com::sun::star::awt::Size& rSourceSizeWithCorrectAspectRatio );
     273             : 
     274             :     static ::com::sun::star::awt::Point calculateTopLeftPositionToCenterObject(
     275             :             const ::com::sun::star::awt::Point& rTargetAreaPosition
     276             :             , const ::com::sun::star::awt::Size& rTargetAreaSize
     277             :             , const ::com::sun::star::awt::Size& rObjectSize );
     278             : 
     279             :     static ::basegfx::B2IRectangle getRectangleOfShape(
     280             :             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
     281             : 
     282             :     static ::com::sun::star::awt::Size getSizeAfterRotation(
     283             :             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, double fRotationAngleDegree );
     284             : 
     285             :     static void removeSubShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes );
     286             : 
     287             : };
     288             : 
     289             : }
     290             : 
     291             : #endif
     292             : 
     293             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11