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