1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _CHART2_VIEW_SHAPEFACTORY_HXX
20 #define _CHART2_VIEW_SHAPEFACTORY_HXX
22 #include "PropertyMapper.hxx"
23 #include "VLineProperties.hxx"
24 #include "BaseGFXHelper.hxx"
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/drawing/Direction3D.hpp>
27 #include <com/sun/star/drawing/HomogenMatrix.hpp>
28 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
29 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
30 #include <com/sun/star/drawing/Position3D.hpp>
31 #include <com/sun/star/drawing/XDrawPage.hpp>
32 #include <com/sun/star/drawing/XShapes.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/graphic/XGraphic.hpp>
36 //.............................................................................
39 //.............................................................................
45 ShapeFactory(::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xFactory
)
46 {m_xShapeFactory
= xFactory
;}
48 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>
50 const ::com::sun::star::uno::Reference
<
51 ::com::sun::star::drawing::XShapes
>& xTarget
52 , OUString aName
= OUString() );
55 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>
57 const ::com::sun::star::uno::Reference
<
58 ::com::sun::star::drawing::XShapes
>& xTarget
59 , OUString aName
= OUString() );
63 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
64 createCube( const ::com::sun::star::uno::Reference
<
65 ::com::sun::star::drawing::XShapes
>& xTarget
66 , const ::com::sun::star::drawing::Position3D
& rPosition
67 , const ::com::sun::star::drawing::Direction3D
& rSize
68 , sal_Int32 nRotateZAngleHundredthDegree
69 , const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xSourceProp
70 , const tPropertyNameMap
& rPropertyNameMap
71 , bool bRounded
= false);
73 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
74 createCylinder( const ::com::sun::star::uno::Reference
<
75 ::com::sun::star::drawing::XShapes
>& xTarget
76 , const ::com::sun::star::drawing::Position3D
& rPosition
77 , const ::com::sun::star::drawing::Direction3D
& rSize
78 , sal_Int32 nRotateZAngleHundredthDegree
);
80 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
81 createPyramid( const ::com::sun::star::uno::Reference
<
82 ::com::sun::star::drawing::XShapes
>& xTarget
83 , const ::com::sun::star::drawing::Position3D
& rPosition
84 , const ::com::sun::star::drawing::Direction3D
& rSize
87 , const ::com::sun::star::uno::Reference
<
88 ::com::sun::star::beans::XPropertySet
>& xSourceProp
89 , const tPropertyNameMap
& rPropertyNameMap
);
91 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
92 createCone( 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 createPieSegment2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
100 , double fUnitCircleStartAngleDegree
, double fUnitCircleWidthAngleDegree
101 , double fUnitCircleInnerRadius
, double fUnitCircleOuterRadius
102 , const ::com::sun::star::drawing::Direction3D
& rOffset
103 , const ::com::sun::star::drawing::HomogenMatrix
& rUnitCircleToScene
);
105 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
106 createPieSegment( 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
113 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
114 createStripe( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
115 , const Stripe
& rStripe
116 , const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xSourceProp
117 , const tPropertyNameMap
& rPropertyNameMap
118 , sal_Bool bDoubleSided
= true
119 , short nRotatedTexture
= 0 //0 to 7 are the different possibilities
120 , bool bFlatNormals
=true );
122 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
123 createArea3D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
124 , const ::com::sun::star::drawing::PolyPolygonShape3D
& rPolyPolygon
127 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
128 createArea2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
129 , const ::com::sun::star::drawing::PolyPolygonShape3D
& rPolyPolygon
);
131 static sal_Int32
getSymbolCount();
133 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
134 createSymbol2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
135 , const ::com::sun::star::drawing::Position3D
& rPos
136 , const ::com::sun::star::drawing::Direction3D
& rSize
137 , sal_Int32 nStandardSymbol
138 , sal_Int32 nBorderColor
=0
139 , sal_Int32 nFillColor
=0 );
141 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
142 createGraphic2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
143 , const ::com::sun::star::drawing::Position3D
& rPos
144 , const ::com::sun::star::drawing::Direction3D
& rSize
145 , const ::com::sun::star::uno::Reference
< ::com::sun::star::graphic::XGraphic
>& xGraphic
);
147 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
148 createLine2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
149 , const ::com::sun::star::drawing::PointSequenceSequence
& rPoints
150 , const VLineProperties
* pLineProperties
= NULL
);
152 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
153 createLine3D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
154 , const ::com::sun::star::drawing::PolyPolygonShape3D
& rPoints
155 , const VLineProperties
& rLineProperties
);
157 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
158 createCircle2D( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
159 , const ::com::sun::star::drawing::Position3D
& rPos
160 , const ::com::sun::star::drawing::Direction3D
& rSize
);
162 //------------------- create 2D elements:
164 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
165 createText( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget2D
166 , const OUString
& rText
167 , const tNameSequence
& rPropNames
168 , const tAnySequence
& rPropValues
169 , const ::com::sun::star::uno::Any
& rATransformation
172 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
173 createInvisibleRectangle(
174 const ::com::sun::star::uno::Reference
<
175 ::com::sun::star::drawing::XShapes
>& xTarget
176 , const ::com::sun::star::awt::Size
& rSize
);
178 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>
179 getOrCreateChartRootShape( const ::com::sun::star::uno::Reference
<
180 ::com::sun::star::drawing::XDrawPage
>& xPage
);
182 static ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>
183 getChartRootShape( const ::com::sun::star::uno::Reference
<
184 ::com::sun::star::drawing::XDrawPage
>& xPage
);
187 static void makeShapeInvisible( const ::com::sun::star::uno::Reference
<
188 ::com::sun::star::drawing::XShape
>& xShape
);
190 static void setShapeName( const ::com::sun::star::uno::Reference
<
191 ::com::sun::star::drawing::XShape
>& xShape
192 , const OUString
& rName
);
194 static OUString
getShapeName( const ::com::sun::star::uno::Reference
<
195 ::com::sun::star::drawing::XShape
>& xShape
);
197 static ::com::sun::star::uno::Any
makeTransformation( const ::com::sun::star::awt::Point
& rScreenPosition2D
, double fRotationAnglePi
=0.0 );
199 static OUString
getStackedString( const OUString
& rString
, bool bStacked
=true );
201 static bool hasPolygonAnyLines( ::com::sun::star::drawing::PolyPolygonShape3D
& rPoly
);
202 static bool isPolygonEmptyOrSinglePoint( ::com::sun::star::drawing::PolyPolygonShape3D
& rPoly
);
203 static void closePolygon( ::com::sun::star::drawing::PolyPolygonShape3D
& rPoly
);
205 static ::com::sun::star::awt::Size
calculateNewSizeRespectingAspectRatio(
206 const ::com::sun::star::awt::Size
& rTargetSize
207 , const ::com::sun::star::awt::Size
& rSourceSizeWithCorrectAspectRatio
);
209 static ::com::sun::star::awt::Point
calculateTopLeftPositionToCenterObject(
210 const ::com::sun::star::awt::Point
& rTargetAreaPosition
211 , const ::com::sun::star::awt::Size
& rTargetAreaSize
212 , const ::com::sun::star::awt::Size
& rObjectSize
);
214 static ::basegfx::B2IRectangle
getRectangleOfShape(
215 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
);
217 static ::com::sun::star::awt::Size
getSizeAfterRotation(
218 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
, double fRotationAngleDegree
);
220 static void removeSubShapes( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xShapes
);
225 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
226 impl_createCube( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
227 , const ::com::sun::star::drawing::Position3D
& rPosition
228 , const ::com::sun::star::drawing::Direction3D
& rSize
, sal_Int32 nRotateZAngleHundredthDegree
231 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
232 impl_createConeOrCylinder( const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>& xTarget
233 , const ::com::sun::star::drawing::Position3D
& rPosition
234 , const ::com::sun::star::drawing::Direction3D
& rSize
235 , double fTopHeight
, sal_Int32 nRotateZAngleHundredthDegree
236 , bool bCylinder
= false);
239 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>
243 //.............................................................................
245 //.............................................................................
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */