fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / inc / CommonConverters.hxx
blob7c779c94f654239e2379154bd0f3962aabb4f996
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
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"
40 #include <vector>
41 #include <algorithm>
43 namespace chart
46 /**
47 diverse methods for class conversions; e.g. ::basegfx::B3DHomMatrix to HomogenMatrix
48 and operations e.g drawing::Position3D + drawing::Direction3D
51 /** ::basegfx::B3DHomMatrix -> HomogenMatrix
53 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix
54 B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM );
56 /** HomogenMatrix -> ::basegfx::B3DHomMatrix
58 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( const com::sun::star::drawing::HomogenMatrix& rHM );
60 /** ::basegfx::B3DHomMatrix -> B2DHomMatrix
62 OOO_DLLPUBLIC_CHARTTOOLS
63 ::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM );
65 /** B2DHomMatrix <-> HomogenMatrix3
67 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix3
68 B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM );
70 /** Position3D -> B3DPoint
72 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DPoint Position3DToB3DPoint( const com::sun::star::drawing::Position3D& rPosition );
74 /** B3DVector -> Direction3D
76 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D B3DVectorToDirection3D( const ::basegfx::B3DVector& rVector);
78 /** B3DPoint -> Position3D
80 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D B3DPointToPosition3D( const ::basegfx::B3DPoint& rPoint);
82 /** Direction3D -> B3DVector
84 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DVector Direction3DToB3DVector( const com::sun::star::drawing::Direction3D& rDirection);
86 /** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D
88 OOO_DLLPUBLIC_CHARTTOOLS
89 void AddPointToPoly( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly
90 , const com::sun::star::drawing::Position3D& rPos
91 , sal_Int32 nSequenceIndex=0 );
93 /** get a single Point from a Polygon
95 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::drawing::Position3D getPointFromPoly(
96 const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon
97 , sal_Int32 nPointIndex, sal_Int32 nPolyIndex=0 );
99 OOO_DLLPUBLIC_CHARTTOOLS
100 void addPolygon( com::sun::star::drawing::PolyPolygonShape3D& rRet
101 , const com::sun::star::drawing::PolyPolygonShape3D& rAdd );
102 /** PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D
104 OOO_DLLPUBLIC_CHARTTOOLS
105 void appendPoly( com::sun::star::drawing::PolyPolygonShape3D& rRet
106 , const com::sun::star::drawing::PolyPolygonShape3D& rAdd );
108 /** PolyPolygonBezierCoords -> PolyPolygonShape3D
110 OOO_DLLPUBLIC_CHARTTOOLS
111 com::sun::star::drawing::PolyPolygonShape3D BezierToPoly(
112 const com::sun::star::drawing::PolyPolygonBezierCoords& rBezier );
114 /** PolyPolygonShape3D -> drawing::PointSequenceSequence (2D)
116 OOO_DLLPUBLIC_CHARTTOOLS
117 com::sun::star::drawing::PointSequenceSequence PolyToPointSequence(
118 const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon );
120 /** drawing::PointSequenceSequence + drawing::PointSequenceSequence
122 OOO_DLLPUBLIC_CHARTTOOLS
123 void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget
124 , com::sun::star::drawing::PointSequenceSequence& rAdd );
126 /** Position3D + Direction3D == Position3D
128 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D
129 operator+( const com::sun::star::drawing::Position3D& rPos
130 , const com::sun::star::drawing::Direction3D& rDirection);
132 /** Position3D - Position3D == Direction3D
134 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D
135 operator-( const com::sun::star::drawing::Position3D& rPos1
136 , const com::sun::star::drawing::Position3D& rPos2);
138 /** Position3D == Position3D ?
140 OOO_DLLPUBLIC_CHARTTOOLS
141 bool operator==( const com::sun::star::drawing::Position3D& rPos1
142 , const com::sun::star::drawing::Position3D& rPos2);
144 /** awt::Rect --> awt::Point (2D)
146 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point ToPoint( const com::sun::star::awt::Rectangle& rRectangle );
148 /** awt::Rect --> awt::Size (2D)
150 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size ToSize( const com::sun::star::awt::Rectangle& rRectangle );
152 /** Position3D --> awt::Point (2D)
154 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point Position3DToAWTPoint( const com::sun::star::drawing::Position3D& rPos );
156 /** Direction3D --> awt::Size (2D)
158 OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size Direction3DToAWTSize( const com::sun::star::drawing::Direction3D& rDirection );
160 /** B3DPoint -> Sequence<double>
162 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double > B3DPointToSequence( const ::basegfx::B3DPoint& rPoint );
164 /** Sequence<double> -> drawing::Position3D
166 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D
167 SequenceToPosition3D( const com::sun::star::uno::Sequence< double >& rSeq );
169 /** drawing::Position3D -> Sequence<double>
172 OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double >
173 Position3DToSequence( const com::sun::star::drawing::Position3D& rPosition );
175 /** chart2::XDataSequence -> uno::Sequence< double >
178 OOO_DLLPUBLIC_CHARTTOOLS
179 ::com::sun::star::uno::Sequence< double > DataSequenceToDoubleSequence(
180 const ::com::sun::star::uno::Reference<
181 ::com::sun::star::chart2::data::XDataSequence > & xDataSequence );
183 OOO_DLLPUBLIC_CHARTTOOLS
184 ::com::sun::star::uno::Sequence< OUString > DataSequenceToStringSequence(
185 const ::com::sun::star::uno::Reference<
186 ::com::sun::star::chart2::data::XDataSequence > & xDataSequence );
188 /** uno::Sequence< uno::Sequence< T > > -> uno::Sequence< T >
190 template< typename T >
191 ::com::sun::star::uno::Sequence< T >
192 FlattenSequence( const ::com::sun::star::uno::Sequence<
193 ::com::sun::star::uno::Sequence< T > > & aSeqSeq )
195 sal_Int32 nOuter, nInner, nCount = 0,
196 nResultSize = 0;
197 const sal_Int32 nOuterSize = aSeqSeq.getLength();
198 for( nOuter=0; nOuter<nOuterSize; ++nOuter )
199 nResultSize += aSeqSeq[nOuter].getLength();
200 ::com::sun::star::uno::Sequence< T > aResult( nResultSize );
202 for( nOuter=0; nOuter<nOuterSize; ++nOuter )
204 const sal_Int32 nInnerSize = aSeqSeq[nOuter].getLength();
205 for( nInner=0; nInner<nInnerSize; ++nInner, ++nCount )
206 aResult[nCount] = aSeqSeq[nOuter][nInner];
208 return aResult;
211 template< typename T >
212 ::std::vector< T >
213 FlattenVector( const ::std::vector< ::std::vector< T > > & rVecVec )
215 typedef ::std::vector< T > tFlatVec;
216 typedef ::std::vector< tFlatVec > tVecVec;
218 tFlatVec aResult;
219 typename tVecVec::const_iterator aOuterEnd( rVecVec.end());
220 for( typename tVecVec::const_iterator aOuterIt( rVecVec.begin()); aOuterIt != aOuterEnd; ++aOuterIt )
221 ::std::copy( aOuterIt->begin(), aOuterIt->end(), back_inserter( aResult ));
222 return aResult;
225 OOO_DLLPUBLIC_CHARTTOOLS
226 bool hasDoubleValue( const ::com::sun::star::uno::Any& rAny );
228 OOO_DLLPUBLIC_CHARTTOOLS
229 bool hasLongOrShortValue( const ::com::sun::star::uno::Any& rAny );
230 OOO_DLLPUBLIC_CHARTTOOLS
231 sal_Int16 getShortForLongAlso( const ::com::sun::star::uno::Any& rAny );
233 OOO_DLLPUBLIC_CHARTTOOLS
234 bool replaceParamterInString( OUString & rInOutResourceString,
235 const OUString & rParamToReplace,
236 const OUString & rReplaceWith );
238 } //namespace chart
239 #endif
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */