1*de7b3f82SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*de7b3f82SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*de7b3f82SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*de7b3f82SAndrew Rist  * distributed with this work for additional information
6*de7b3f82SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*de7b3f82SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*de7b3f82SAndrew Rist  * "License"); you may not use this file except in compliance
9*de7b3f82SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*de7b3f82SAndrew Rist  *
11*de7b3f82SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*de7b3f82SAndrew Rist  *
13*de7b3f82SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*de7b3f82SAndrew Rist  * software distributed under the License is distributed on an
15*de7b3f82SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*de7b3f82SAndrew Rist  * KIND, either express or implied.  See the License for the
17*de7b3f82SAndrew Rist  * specific language governing permissions and limitations
18*de7b3f82SAndrew Rist  * under the License.
19*de7b3f82SAndrew Rist  *
20*de7b3f82SAndrew Rist  *************************************************************/
21*de7b3f82SAndrew Rist 
22*de7b3f82SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CHART2_VIEW_SHAPEFACTORY_HXX
24cdf0e10cSrcweir #define _CHART2_VIEW_SHAPEFACTORY_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "PropertyMapper.hxx"
27cdf0e10cSrcweir #include "VLineProperties.hxx"
28cdf0e10cSrcweir #include "BaseGFXHelper.hxx"
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir namespace chart
42cdf0e10cSrcweir {
43cdf0e10cSrcweir //.............................................................................
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class Stripe;
46cdf0e10cSrcweir class ShapeFactory
47cdf0e10cSrcweir {
48cdf0e10cSrcweir public:
ShapeFactory(::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> xFactory)49cdf0e10cSrcweir     ShapeFactory(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory)
50cdf0e10cSrcweir         {m_xShapeFactory = xFactory;}
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
53cdf0e10cSrcweir         createGroup2D(
54cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
55cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
56cdf0e10cSrcweir                 , ::rtl::OUString aName = ::rtl::OUString() );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
60cdf0e10cSrcweir         createGroup3D(
61cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
62cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
63cdf0e10cSrcweir                 , ::rtl::OUString aName = ::rtl::OUString() );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     //------
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
68cdf0e10cSrcweir             createCube(   const ::com::sun::star::uno::Reference<
69cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
70cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
71cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
72cdf0e10cSrcweir                         , sal_Int32 nRotateZAngleHundredthDegree
73cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
74cdf0e10cSrcweir                         , const tPropertyNameMap& rPropertyNameMap
75cdf0e10cSrcweir                         , bool bRounded = false);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
78cdf0e10cSrcweir         createCylinder(   const ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
80cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
81cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
82cdf0e10cSrcweir                         , sal_Int32 nRotateZAngleHundredthDegree );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
85cdf0e10cSrcweir         createPyramid(    const ::com::sun::star::uno::Reference<
86cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
87cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
88cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
89cdf0e10cSrcweir                         , double fTopHeight
90cdf0e10cSrcweir                         , bool bRotateZ
91cdf0e10cSrcweir                         , const ::com::sun::star::uno::Reference<
92cdf0e10cSrcweir                             ::com::sun::star::beans::XPropertySet >& xSourceProp
93cdf0e10cSrcweir                         , const tPropertyNameMap& rPropertyNameMap);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
96cdf0e10cSrcweir         createCone(       const ::com::sun::star::uno::Reference<
97cdf0e10cSrcweir                                 ::com::sun::star::drawing::XShapes >& xTarget
98cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Position3D& rPosition
99cdf0e10cSrcweir                         , const ::com::sun::star::drawing::Direction3D& rSize
100cdf0e10cSrcweir                         , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
103cdf0e10cSrcweir         createPieSegment2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
104cdf0e10cSrcweir                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
105cdf0e10cSrcweir                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
106cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rOffset
107cdf0e10cSrcweir                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
110cdf0e10cSrcweir         createPieSegment( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
111cdf0e10cSrcweir                     , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree
112cdf0e10cSrcweir                     , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius
113cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rOffset
114cdf0e10cSrcweir                     , const ::com::sun::star::drawing::HomogenMatrix& rUnitCircleToScene
115cdf0e10cSrcweir                     , double fDepth );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
118cdf0e10cSrcweir         createStripe( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
119cdf0e10cSrcweir                     , const Stripe& rStripe
120cdf0e10cSrcweir                     , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSourceProp
121cdf0e10cSrcweir                     , const tPropertyNameMap& rPropertyNameMap
122cdf0e10cSrcweir                     , sal_Bool bDoubleSided = true
123cdf0e10cSrcweir                     , short nRotatedTexture = 0 //0 to 7 are the different possibilities
124cdf0e10cSrcweir                     , bool bFlatNormals=true );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
127cdf0e10cSrcweir         createArea3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
128cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon
129cdf0e10cSrcweir                     , double fDepth);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
132cdf0e10cSrcweir         createArea2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
133cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     static sal_Int32 getSymbolCount();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
138cdf0e10cSrcweir         createSymbol2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
139cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
140cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
141cdf0e10cSrcweir                     , sal_Int32 nStandardSymbol
142cdf0e10cSrcweir                     , sal_Int32 nBorderColor=0
143cdf0e10cSrcweir                     , sal_Int32 nFillColor=0 );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
146cdf0e10cSrcweir         createGraphic2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
147cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
148cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
149cdf0e10cSrcweir                     , const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
152cdf0e10cSrcweir         createLine2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
153cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
154cdf0e10cSrcweir                     , const VLineProperties* pLineProperties = NULL );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
157cdf0e10cSrcweir         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
158cdf0e10cSrcweir                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
159cdf0e10cSrcweir                     , const VLineProperties& rLineProperties );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
162cdf0e10cSrcweir         createCircle2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
163cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPos
164cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     //------------------- create 2D elements:
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
169cdf0e10cSrcweir         createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D
170cdf0e10cSrcweir                     , const ::rtl::OUString& rText
171cdf0e10cSrcweir                     , const tNameSequence& rPropNames
172cdf0e10cSrcweir                     , const tAnySequence& rPropValues
173cdf0e10cSrcweir                     , const ::com::sun::star::uno::Any& rATransformation
174cdf0e10cSrcweir                      );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
177cdf0e10cSrcweir         createInvisibleRectangle(
178cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
179cdf0e10cSrcweir                 ::com::sun::star::drawing::XShapes >& xTarget
180cdf0e10cSrcweir                 , const ::com::sun::star::awt::Size& rSize );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
183cdf0e10cSrcweir          getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
184cdf0e10cSrcweir             ::com::sun::star::drawing::XDrawPage>& xPage );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
187cdf0e10cSrcweir          getChartRootShape( const ::com::sun::star::uno::Reference<
188cdf0e10cSrcweir             ::com::sun::star::drawing::XDrawPage>& xPage );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     //------
191cdf0e10cSrcweir     static void makeShapeInvisible( const ::com::sun::star::uno::Reference<
192cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir      static void setShapeName( const ::com::sun::star::uno::Reference<
195cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape
196cdf0e10cSrcweir                              , const rtl::OUString& rName );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir      static rtl::OUString getShapeName( const ::com::sun::star::uno::Reference<
199cdf0e10cSrcweir                                      ::com::sun::star::drawing::XShape >& xShape );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir      static ::com::sun::star::uno::Any makeTransformation( const ::com::sun::star::awt::Point& rScreenPosition2D, double fRotationAnglePi=0.0 );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir      static rtl::OUString getStackedString( const rtl::OUString& rString, bool bStacked=true );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir      static bool hasPolygonAnyLines( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
206cdf0e10cSrcweir      static bool isPolygonEmptyOrSinglePoint( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
207cdf0e10cSrcweir      static void closePolygon( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir      static ::com::sun::star::awt::Size calculateNewSizeRespectingAspectRatio(
210cdf0e10cSrcweir            const ::com::sun::star::awt::Size& rTargetSize
211cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rSourceSizeWithCorrectAspectRatio );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir      static ::com::sun::star::awt::Point calculateTopLeftPositionToCenterObject(
214cdf0e10cSrcweir            const ::com::sun::star::awt::Point& rTargetAreaPosition
215cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rTargetAreaSize
216cdf0e10cSrcweir          , const ::com::sun::star::awt::Size& rObjectSize );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir      static ::basegfx::B2IRectangle getRectangleOfShape(
219cdf0e10cSrcweir          const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir      static ::com::sun::star::awt::Size getSizeAfterRotation(
222cdf0e10cSrcweir          const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, double fRotationAngleDegree );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir      static void removeSubShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir private:
227cdf0e10cSrcweir     ShapeFactory();
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
230cdf0e10cSrcweir         impl_createCube( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
231cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPosition
232cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize, sal_Int32 nRotateZAngleHundredthDegree
233cdf0e10cSrcweir                     , bool bRounded );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
236cdf0e10cSrcweir         impl_createConeOrCylinder( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
237cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Position3D& rPosition
238cdf0e10cSrcweir                     , const ::com::sun::star::drawing::Direction3D& rSize
239cdf0e10cSrcweir                     , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
240cdf0e10cSrcweir                     , bool bCylinder = false);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     //member:
243cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
244cdf0e10cSrcweir         m_xShapeFactory;
245cdf0e10cSrcweir };
246cdf0e10cSrcweir 
247cdf0e10cSrcweir //.............................................................................
248cdf0e10cSrcweir } //namespace chart
249cdf0e10cSrcweir //.............................................................................
250cdf0e10cSrcweir #endif
251