Branch data 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 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef __CHART_COMMON_CONVERTERS_HXX
20 : : #define __CHART_COMMON_CONVERTERS_HXX
21 : :
22 : : #include <tools/poly.hxx>
23 : : #include <com/sun/star/awt/Point.hpp>
24 : : #include <com/sun/star/awt/Rectangle.hpp>
25 : : #include <com/sun/star/awt/Size.hpp>
26 : : #include <com/sun/star/drawing/Direction3D.hpp>
27 : : #include <com/sun/star/drawing/HomogenMatrix.hpp>
28 : : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
29 : : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
30 : : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
31 : : #include <com/sun/star/drawing/Position3D.hpp>
32 : : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
33 : : #include <com/sun/star/text/WritingMode.hpp>
34 : : #include <com/sun/star/chart2/data/XDataSequence.hpp>
35 : : #include <basegfx/matrix/b2dhommatrix.hxx>
36 : : #include <basegfx/point/b3dpoint.hxx>
37 : : #include <basegfx/vector/b3dvector.hxx>
38 : : #include "charttoolsdllapi.hxx"
39 : :
40 : : #include <vector>
41 : : #include <algorithm>
42 : :
43 : : //.............................................................................
44 : : namespace chart
45 : : {
46 : : //.............................................................................
47 : :
48 : : //-----------------------------------------------------------------------------
49 : : /**
50 : : diverse methods for class conversions; e.g. ::basegfx::B3DHomMatrix to HomogenMatrix
51 : : and operations e.g drawing::Position3D + drawing::Direction3D
52 : : */
53 : :
54 : : //-----------------------------------------------------------------------------
55 : : /** ::basegfx::B3DHomMatrix -> HomogenMatrix
56 : : */
57 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix
58 : : B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM );
59 : :
60 : : //-----------------------------------------------------------------------------
61 : : /** HomogenMatrix -> ::basegfx::B3DHomMatrix
62 : : */
63 : : OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( const com::sun::star::drawing::HomogenMatrix& rHM );
64 : :
65 : : //-----------------------------------------------------------------------------
66 : : /** ::basegfx::B3DHomMatrix -> B2DHomMatrix
67 : : */
68 : : OOO_DLLPUBLIC_CHARTTOOLS
69 : : ::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM );
70 : :
71 : : //-----------------------------------------------------------------------------
72 : : /** B2DHomMatrix <-> HomogenMatrix3
73 : : */
74 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix3
75 : : B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM );
76 : :
77 : : //-----------------------------------------------------------------------------
78 : : /** Position3D -> B3DPoint
79 : : */
80 : : OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DPoint Position3DToB3DPoint( const com::sun::star::drawing::Position3D& rPosition );
81 : :
82 : : //-----------------------------------------------------------------------------
83 : : /** B3DVector -> Direction3D
84 : : */
85 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D B3DVectorToDirection3D( const ::basegfx::B3DVector& rVector);
86 : :
87 : : //-----------------------------------------------------------------------------
88 : : /** B3DPoint -> Position3D
89 : : */
90 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D B3DPointToPosition3D( const ::basegfx::B3DPoint& rPoint);
91 : :
92 : : //-----------------------------------------------------------------------------
93 : : /** Direction3D -> B3DVector
94 : : */
95 : : OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DVector Direction3DToB3DVector( const com::sun::star::drawing::Direction3D& rDirection);
96 : :
97 : : //-----------------------------------------------------------------------------
98 : : /** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D
99 : : */
100 : : OOO_DLLPUBLIC_CHARTTOOLS
101 : : void AddPointToPoly( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly
102 : : , const com::sun::star::drawing::Position3D& rPos
103 : : , sal_Int32 nSequenceIndex=0 );
104 : :
105 : : //-----------------------------------------------------------------------------
106 : : /** get a single Point from a Polygon
107 : : */
108 : : OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::drawing::Position3D getPointFromPoly(
109 : : const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon
110 : : , sal_Int32 nPointIndex, sal_Int32 nPolyIndex=0 );
111 : :
112 : : //-----------------------------------------------------------------------------
113 : : OOO_DLLPUBLIC_CHARTTOOLS
114 : : void addPolygon( com::sun::star::drawing::PolyPolygonShape3D& rRet
115 : : , const com::sun::star::drawing::PolyPolygonShape3D& rAdd );
116 : : //-----------------------------------------------------------------------------
117 : : /** PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D
118 : : */
119 : : OOO_DLLPUBLIC_CHARTTOOLS
120 : : void appendPoly( com::sun::star::drawing::PolyPolygonShape3D& rRet
121 : : , const com::sun::star::drawing::PolyPolygonShape3D& rAdd );
122 : :
123 : : //-----------------------------------------------------------------------------
124 : : /** PolyPolygonBezierCoords -> PolyPolygonShape3D
125 : : */
126 : : OOO_DLLPUBLIC_CHARTTOOLS
127 : : com::sun::star::drawing::PolyPolygonShape3D BezierToPoly(
128 : : const com::sun::star::drawing::PolyPolygonBezierCoords& rBezier );
129 : :
130 : : //-----------------------------------------------------------------------------
131 : : /** PolyPolygonShape3D -> drawing::PointSequenceSequence (2D)
132 : : */
133 : : OOO_DLLPUBLIC_CHARTTOOLS
134 : : com::sun::star::drawing::PointSequenceSequence PolyToPointSequence(
135 : : const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon );
136 : :
137 : : //-----------------------------------------------------------------------------
138 : : /** drawing::PointSequenceSequence + drawing::PointSequenceSequence
139 : : */
140 : : OOO_DLLPUBLIC_CHARTTOOLS
141 : : void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget
142 : : , com::sun::star::drawing::PointSequenceSequence& rAdd );
143 : :
144 : : //-----------------------------------------------------------------------------
145 : : /** Position3D + Direction3D == Position3D
146 : : */
147 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D
148 : : operator+( const com::sun::star::drawing::Position3D& rPos
149 : : , const com::sun::star::drawing::Direction3D& rDirection);
150 : :
151 : : //-----------------------------------------------------------------------------
152 : : /** Position3D - Position3D == Direction3D
153 : : */
154 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D
155 : : operator-( const com::sun::star::drawing::Position3D& rPos1
156 : : , const com::sun::star::drawing::Position3D& rPos2);
157 : :
158 : : //-----------------------------------------------------------------------------
159 : : /** Position3D == Position3D ?
160 : : */
161 : : OOO_DLLPUBLIC_CHARTTOOLS
162 : : bool operator==( const com::sun::star::drawing::Position3D& rPos1
163 : : , const com::sun::star::drawing::Position3D& rPos2);
164 : :
165 : : //-----------------------------------------------------------------------------
166 : : /** awt::Rect --> awt::Point (2D)
167 : : */
168 : : OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point ToPoint( const com::sun::star::awt::Rectangle& rRectangle );
169 : :
170 : : //-----------------------------------------------------------------------------
171 : : /** awt::Rect --> awt::Size (2D)
172 : : */
173 : : OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size ToSize( const com::sun::star::awt::Rectangle& rRectangle );
174 : :
175 : : //-----------------------------------------------------------------------------
176 : : /** Position3D --> awt::Point (2D)
177 : : */
178 : : OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point Position3DToAWTPoint( const com::sun::star::drawing::Position3D& rPos );
179 : :
180 : : //-----------------------------------------------------------------------------
181 : : /** Direction3D --> awt::Size (2D)
182 : : */
183 : : OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size Direction3DToAWTSize( const com::sun::star::drawing::Direction3D& rDirection );
184 : :
185 : : //-----------------------------------------------------------------------------
186 : : /** B3DPoint -> Sequence<double>
187 : : */
188 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double > B3DPointToSequence( const ::basegfx::B3DPoint& rPoint );
189 : :
190 : : //-----------------------------------------------------------------------------
191 : : /** Sequence<double> -> drawing::Position3D
192 : : */
193 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D
194 : : SequenceToPosition3D( const com::sun::star::uno::Sequence< double >& rSeq );
195 : :
196 : : //-----------------------------------------------------------------------------
197 : : /** drawing::Position3D -> Sequence<double>
198 : : */
199 : :
200 : : OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double >
201 : : Position3DToSequence( const com::sun::star::drawing::Position3D& rPosition );
202 : :
203 : : //-----------------------------------------------------------------------------
204 : : /** chart2::XDataSequence -> uno::Sequence< double >
205 : : */
206 : :
207 : : OOO_DLLPUBLIC_CHARTTOOLS
208 : : ::com::sun::star::uno::Sequence< double > DataSequenceToDoubleSequence(
209 : : const ::com::sun::star::uno::Reference<
210 : : ::com::sun::star::chart2::data::XDataSequence > & xDataSequence );
211 : :
212 : : OOO_DLLPUBLIC_CHARTTOOLS
213 : : ::com::sun::star::uno::Sequence< rtl::OUString > DataSequenceToStringSequence(
214 : : const ::com::sun::star::uno::Reference<
215 : : ::com::sun::star::chart2::data::XDataSequence > & xDataSequence );
216 : :
217 : : //-----------------------------------------------------------------------------
218 : : /** uno::Sequence< uno::Sequence< T > > -> uno::Sequence< T >
219 : : */
220 : : template< typename T >
221 : : ::com::sun::star::uno::Sequence< T >
222 : 78 : FlattenSequence( const ::com::sun::star::uno::Sequence<
223 : : ::com::sun::star::uno::Sequence< T > > & aSeqSeq )
224 : : {
225 : 78 : sal_Int32 nOuter, nInner, nCount = 0,
226 : 78 : nResultSize = 0;
227 : 78 : const sal_Int32 nOuterSize = aSeqSeq.getLength();
228 [ + + ]: 156 : for( nOuter=0; nOuter<nOuterSize; ++nOuter )
229 : 78 : nResultSize += aSeqSeq[nOuter].getLength();
230 : 78 : ::com::sun::star::uno::Sequence< T > aResult( nResultSize );
231 : :
232 [ + + ]: 156 : for( nOuter=0; nOuter<nOuterSize; ++nOuter )
233 : : {
234 : 78 : const sal_Int32 nInnerSize = aSeqSeq[nOuter].getLength();
235 [ + + ]: 656 : for( nInner=0; nInner<nInnerSize; ++nInner, ++nCount )
236 [ + - ][ + - ]: 578 : aResult[nCount] = aSeqSeq[nOuter][nInner];
237 : : }
238 : 78 : return aResult;
239 : : }
240 : :
241 : : template< typename T >
242 : : ::std::vector< T >
243 : 981 : FlattenVector( const ::std::vector< ::std::vector< T > > & rVecVec )
244 : : {
245 : : typedef ::std::vector< T > tFlatVec;
246 : : typedef ::std::vector< tFlatVec > tVecVec;
247 : :
248 [ + - ]: 981 : tFlatVec aResult;
249 : 981 : typename tVecVec::const_iterator aOuterEnd( rVecVec.end());
250 [ + - ][ + + ]: 1980 : for( typename tVecVec::const_iterator aOuterIt( rVecVec.begin()); aOuterIt != aOuterEnd; ++aOuterIt )
251 [ + - ][ + - ]: 999 : ::std::copy( aOuterIt->begin(), aOuterIt->end(), back_inserter( aResult ));
252 : 981 : return aResult;
253 : : }
254 : :
255 : : OOO_DLLPUBLIC_CHARTTOOLS
256 : : sal_Bool hasDoubleValue( const ::com::sun::star::uno::Any& rAny );
257 : :
258 : : OOO_DLLPUBLIC_CHARTTOOLS
259 : : sal_Bool hasLongOrShortValue( const ::com::sun::star::uno::Any& rAny );
260 : : OOO_DLLPUBLIC_CHARTTOOLS
261 : : sal_Int16 getShortForLongAlso( const ::com::sun::star::uno::Any& rAny );
262 : :
263 : : OOO_DLLPUBLIC_CHARTTOOLS
264 : : bool replaceParamterInString( rtl::OUString & rInOutResourceString,
265 : : const rtl::OUString & rParamToReplace,
266 : : const rtl::OUString & rReplaceWith );
267 : :
268 : : //.............................................................................
269 : : } //namespace chart
270 : : //.............................................................................
271 : : #endif
272 : :
273 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|