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