1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CHART2_VIEW_SHAPEFACTORY_HXX
28*cdf0e10cSrcweir #define _CHART2_VIEW_SHAPEFACTORY_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "PropertyMapper.hxx"
31*cdf0e10cSrcweir #include "VLineProperties.hxx"
32*cdf0e10cSrcweir #include "BaseGFXHelper.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //.............................................................................
45*cdf0e10cSrcweir namespace chart
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir //.............................................................................
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir class Stripe;
50*cdf0e10cSrcweir class ShapeFactory
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir public:
53*cdf0e10cSrcweir     ShapeFactory(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory)
54*cdf0e10cSrcweir         {m_xShapeFactory = xFactory;}
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
57*cdf0e10cSrcweir         createGroup2D(
58*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
59*cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
60*cdf0e10cSrcweir                 , ::rtl::OUString aName = ::rtl::OUString() );
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
64*cdf0e10cSrcweir         createGroup3D(
65*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
66*cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
67*cdf0e10cSrcweir                 , ::rtl::OUString aName = ::rtl::OUString() );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     //------
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
72*cdf0e10cSrcweir             createCube(   const ::com::sun::star::uno::Reference<
73*cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
74*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
75*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
76*cdf0e10cSrcweir                         , sal_Int32 nRotateZAngleHundredthDegree
77*cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
78*cdf0e10cSrcweir                         , const tPropertyNameMap& rPropertyNameMap
79*cdf0e10cSrcweir                         , bool bRounded = false);
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
82*cdf0e10cSrcweir         createCylinder(   const ::com::sun::star::uno::Reference<
83*cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
84*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
85*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
86*cdf0e10cSrcweir                         , sal_Int32 nRotateZAngleHundredthDegree );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
89*cdf0e10cSrcweir         createPyramid(    const ::com::sun::star::uno::Reference<
90*cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
91*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
92*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
93*cdf0e10cSrcweir                         , double fTopHeight
94*cdf0e10cSrcweir                         , bool bRotateZ
95*cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference<
96*cdf0e10cSrcweir                             ::com::sun::star::beans::XPropertySet >& xSourceProp
97*cdf0e10cSrcweir                         , const tPropertyNameMap& rPropertyNameMap);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
100*cdf0e10cSrcweir         createCone(       const ::com::sun::star::uno::Reference<
101*cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
102*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
103*cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
104*cdf0e10cSrcweir                         , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
107*cdf0e10cSrcweir         createPieSegment2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
108*cdf0e10cSrcweir                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
109*cdf0e10cSrcweir                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
110*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rOffset
111*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
114*cdf0e10cSrcweir         createPieSegment( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
115*cdf0e10cSrcweir                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
116*cdf0e10cSrcweir                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
117*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rOffset
118*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene
119*cdf0e10cSrcweir                     , double fDepth );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
122*cdf0e10cSrcweir         createStripe( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
123*cdf0e10cSrcweir                     , const Stripe& rStripe
124*cdf0e10cSrcweir                     , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
125*cdf0e10cSrcweir                     , const tPropertyNameMap& rPropertyNameMap
126*cdf0e10cSrcweir                     , sal_Bool bDoubleSided = true
127*cdf0e10cSrcweir                     , short nRotatedTexture = 0 //0 to 7 are the different possibilities
128*cdf0e10cSrcweir                     , bool bFlatNormals=true );
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
131*cdf0e10cSrcweir         createArea3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
132*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon
133*cdf0e10cSrcweir                     , double fDepth);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
136*cdf0e10cSrcweir         createArea2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
137*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     static sal_Int32 getSymbolCount();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
142*cdf0e10cSrcweir         createSymbol2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
143*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
144*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
145*cdf0e10cSrcweir                     , sal_Int32 nStandardSymbol
146*cdf0e10cSrcweir                     , sal_Int32 nBorderColor=0
147*cdf0e10cSrcweir                     , sal_Int32 nFillColor=0 );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
150*cdf0e10cSrcweir         createGraphic2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
151*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
152*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
153*cdf0e10cSrcweir                     , const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
156*cdf0e10cSrcweir         createLine2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
157*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
158*cdf0e10cSrcweir                     , const VLineProperties* pLineProperties = NULL );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
161*cdf0e10cSrcweir         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
162*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
163*cdf0e10cSrcweir                     , const VLineProperties& rLineProperties );
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
166*cdf0e10cSrcweir         createCircle2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
167*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
168*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     //------------------- create 2D elements:
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
173*cdf0e10cSrcweir         createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D
174*cdf0e10cSrcweir                     , const ::rtl::OUString& rText
175*cdf0e10cSrcweir                     , const tNameSequence& rPropNames
176*cdf0e10cSrcweir                     , const tAnySequence& rPropValues
177*cdf0e10cSrcweir                     , const ::com::sun::star::uno::Any& rATransformation
178*cdf0e10cSrcweir                      );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
181*cdf0e10cSrcweir         createInvisibleRectangle(
182*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
183*cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
184*cdf0e10cSrcweir                 , const ::com::sun::star::awt::Size& rSize );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
187*cdf0e10cSrcweir          getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
188*cdf0e10cSrcweir             ::com::sun::star::drawing::XDrawPage>& xPage );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
191*cdf0e10cSrcweir          getChartRootShape( const ::com::sun::star::uno::Reference<
192*cdf0e10cSrcweir             ::com::sun::star::drawing::XDrawPage>& xPage );
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     //------
195*cdf0e10cSrcweir     static void makeShapeInvisible( const ::com::sun::star::uno::Reference<
196*cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir      static void setShapeName( const ::com::sun::star::uno::Reference<
199*cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape
200*cdf0e10cSrcweir                              , const rtl::OUString& rName );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir      static rtl::OUString getShapeName( const ::com::sun::star::uno::Reference<
203*cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir      static ::com::sun::star::uno::Any makeTransformation( const ::com::sun::star::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 );
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir      static rtl::OUString getStackedString( const rtl::OUString& rString, bool bStacked=true );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir      static bool hasPolygonAnyLines( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
210*cdf0e10cSrcweir      static bool isPolygonEmptyOrSinglePoint( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
211*cdf0e10cSrcweir      static void closePolygon( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir      static ::com::sun::star::awt::Size calculateNewSizeRespectingAspectRatio(
214*cdf0e10cSrcweir            const ::com::sun::star::awt::Size& rTargetSize
215*cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rSourceSizeWithCorrectAspectRatio );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir      static ::com::sun::star::awt::Point calculateTopLeftPositionToCenterObject(
218*cdf0e10cSrcweir            const ::com::sun::star::awt::Point& rTargetAreaPosition
219*cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rTargetAreaSize
220*cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rObjectSize );
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir      static ::basegfx::B2IRectangle getRectangleOfShape(
223*cdf0e10cSrcweir          const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir      static ::com::sun::star::awt::Size getSizeAfterRotation(
226*cdf0e10cSrcweir          const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, double fRotationAngleDegree );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir      static void removeSubShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir private:
231*cdf0e10cSrcweir     ShapeFactory();
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
234*cdf0e10cSrcweir         impl_createCube( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
235*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPosition
236*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize, sal_Int32 nRotateZAngleHundredthDegree
237*cdf0e10cSrcweir                     , bool bRounded );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
240*cdf0e10cSrcweir         impl_createConeOrCylinder( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
241*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPosition
242*cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
243*cdf0e10cSrcweir                     , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
244*cdf0e10cSrcweir                     , bool bCylinder = false);
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     //member:
247*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
248*cdf0e10cSrcweir         m_xShapeFactory;
249*cdf0e10cSrcweir };
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir //.............................................................................
252*cdf0e10cSrcweir } //namespace chart
253*cdf0e10cSrcweir //.............................................................................
254*cdf0e10cSrcweir #endif
255