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 INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
22 #include <com/sun/star/awt/Point.hpp>
23 #include <com/sun/star/awt/Size.hpp>
24 #include <com/sun/star/drawing/Direction3D.hpp>
25 #include <com/sun/star/drawing/HomogenMatrix.hpp>
26 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
27 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
28 #include <com/sun/star/drawing/Position3D.hpp>
29 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <basegfx/point/b3dpoint.hxx>
32 #include <basegfx/vector/b3dvector.hxx>
33 #include "charttoolsdllapi.hxx"
35 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ struct Rectangle
; } } } }
36 namespace com
{ namespace sun
{ namespace star
{ namespace chart2
{ namespace data
{ class XDataSequence
; } } } } }
37 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ struct PolyPolygonBezierCoords
; } } } }
43 diverse methods for class conversions; e.g. ::basegfx::B3DHomMatrix to HomogenMatrix
44 and operations e.g drawing::Position3D + drawing::Direction3D
47 /** ::basegfx::B3DHomMatrix -> HomogenMatrix
49 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::HomogenMatrix
50 B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix
& rM
);
52 /** HomogenMatrix -> ::basegfx::B3DHomMatrix
54 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix
HomogenMatrixToB3DHomMatrix( const css::drawing::HomogenMatrix
& rHM
);
56 /** ::basegfx::B3DHomMatrix -> B2DHomMatrix
58 OOO_DLLPUBLIC_CHARTTOOLS
59 ::basegfx::B2DHomMatrix
IgnoreZ( const ::basegfx::B3DHomMatrix
& rM
);
61 /** B2DHomMatrix <-> HomogenMatrix3
63 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::HomogenMatrix3
64 B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix
& rM
);
66 /** Position3D -> B3DPoint
68 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DPoint
Position3DToB3DPoint( const css::drawing::Position3D
& rPosition
);
70 /** B3DVector -> Direction3D
72 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Direction3D
B3DVectorToDirection3D( const ::basegfx::B3DVector
& rVector
);
74 /** B3DPoint -> Position3D
76 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Position3D
B3DPointToPosition3D( const ::basegfx::B3DPoint
& rPoint
);
78 /** Direction3D -> B3DVector
80 OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DVector
Direction3DToB3DVector( const css::drawing::Direction3D
& rDirection
);
82 /** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D
84 OOO_DLLPUBLIC_CHARTTOOLS
85 void AddPointToPoly( css::drawing::PolyPolygonShape3D
& rPoly
86 , const css::drawing::Position3D
& rPos
87 , sal_Int32 nSequenceIndex
=0 );
89 /** get a single Point from a Polygon
91 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Position3D
getPointFromPoly(
92 const css::drawing::PolyPolygonShape3D
& rPolygon
93 , sal_Int32 nPointIndex
, sal_Int32 nPolyIndex
);
95 OOO_DLLPUBLIC_CHARTTOOLS
96 void addPolygon( css::drawing::PolyPolygonShape3D
& rRet
97 , const css::drawing::PolyPolygonShape3D
& rAdd
);
98 /** PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D
100 OOO_DLLPUBLIC_CHARTTOOLS
101 void appendPoly( css::drawing::PolyPolygonShape3D
& rRet
102 , const css::drawing::PolyPolygonShape3D
& rAdd
);
104 /** PolyPolygonBezierCoords -> PolyPolygonShape3D
106 OOO_DLLPUBLIC_CHARTTOOLS
107 css::drawing::PolyPolygonShape3D
BezierToPoly(
108 const css::drawing::PolyPolygonBezierCoords
& rBezier
);
110 /** PolyPolygonShape3D -> drawing::PointSequenceSequence (2D)
112 OOO_DLLPUBLIC_CHARTTOOLS
113 css::drawing::PointSequenceSequence
PolyToPointSequence(
114 const css::drawing::PolyPolygonShape3D
& rPolyPolygon
);
116 /** drawing::PointSequenceSequence + drawing::PointSequenceSequence
118 OOO_DLLPUBLIC_CHARTTOOLS
119 void appendPointSequence( css::drawing::PointSequenceSequence
& rTarget
120 , css::drawing::PointSequenceSequence
& rAdd
);
122 /** Position3D + Direction3D == Position3D
124 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Position3D
125 operator+( const css::drawing::Position3D
& rPos
126 , const css::drawing::Direction3D
& rDirection
);
128 /** Position3D - Position3D == Direction3D
130 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Direction3D
131 operator-( const css::drawing::Position3D
& rPos1
132 , const css::drawing::Position3D
& rPos2
);
134 /** awt::Rect --> awt::Point (2D)
136 OOO_DLLPUBLIC_CHARTTOOLS
css::awt::Point
ToPoint( const css::awt::Rectangle
& rRectangle
);
138 /** awt::Rect --> awt::Size (2D)
140 OOO_DLLPUBLIC_CHARTTOOLS
css::awt::Size
ToSize( const css::awt::Rectangle
& rRectangle
);
142 /** Position3D --> awt::Point (2D)
144 OOO_DLLPUBLIC_CHARTTOOLS
css::awt::Point
Position3DToAWTPoint( const css::drawing::Position3D
& rPos
);
146 /** Direction3D --> awt::Size (2D)
148 OOO_DLLPUBLIC_CHARTTOOLS
css::awt::Size
Direction3DToAWTSize( const css::drawing::Direction3D
& rDirection
);
150 /** B3DPoint -> Sequence<double>
152 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Sequence
< double > B3DPointToSequence( const ::basegfx::B3DPoint
& rPoint
);
154 /** Sequence<double> -> drawing::Position3D
156 OOO_DLLPUBLIC_CHARTTOOLS
css::drawing::Position3D
157 SequenceToPosition3D( const css::uno::Sequence
< double >& rSeq
);
159 /** drawing::Position3D -> Sequence<double>
162 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Sequence
< double >
163 Position3DToSequence( const css::drawing::Position3D
& rPosition
);
165 /** chart2::XDataSequence -> uno::Sequence< double >
168 OOO_DLLPUBLIC_CHARTTOOLS
169 css::uno::Sequence
< double > DataSequenceToDoubleSequence(
170 const css::uno::Reference
< css::chart2::data::XDataSequence
> & xDataSequence
);
172 OOO_DLLPUBLIC_CHARTTOOLS
173 css::uno::Sequence
< OUString
> DataSequenceToStringSequence(
174 const css::uno::Reference
< css::chart2::data::XDataSequence
> & xDataSequence
);
176 /** uno::Sequence< uno::Sequence< T > > -> uno::Sequence< T >
178 template< typename T
>
179 css::uno::Sequence
< T
>
180 FlattenSequence( const css::uno::Sequence
< css::uno::Sequence
< T
> > & aSeqSeq
)
182 sal_Int32 nOuter
, nInner
, nCount
= 0,
184 const sal_Int32 nOuterSize
= aSeqSeq
.getLength();
185 for( nOuter
=0; nOuter
<nOuterSize
; ++nOuter
)
186 nResultSize
+= aSeqSeq
[nOuter
].getLength();
187 css::uno::Sequence
< T
> aResult( nResultSize
);
189 for( nOuter
=0; nOuter
<nOuterSize
; ++nOuter
)
191 const sal_Int32 nInnerSize
= aSeqSeq
[nOuter
].getLength();
192 for( nInner
=0; nInner
<nInnerSize
; ++nInner
, ++nCount
)
193 aResult
[nCount
] = aSeqSeq
[nOuter
][nInner
];
198 OOO_DLLPUBLIC_CHARTTOOLS
199 bool hasDoubleValue( const css::uno::Any
& rAny
);
201 OOO_DLLPUBLIC_CHARTTOOLS
202 bool hasLongOrShortValue( const css::uno::Any
& rAny
);
203 OOO_DLLPUBLIC_CHARTTOOLS
204 sal_Int16
getShortForLongAlso( const css::uno::Any
& rAny
);
206 OOO_DLLPUBLIC_CHARTTOOLS
207 bool replaceParamterInString( OUString
& rInOutResourceString
,
208 const OUString
& rParamToReplace
,
209 const OUString
& rReplaceWith
);
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */