1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef __CHART_COMMON_CONVERTERS_HXX 28*cdf0e10cSrcweir #define __CHART_COMMON_CONVERTERS_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <tools/poly.hxx> 31*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix3.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/drawing/Position3D.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSequence.hpp> 43*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 44*cdf0e10cSrcweir #include <basegfx/point/b3dpoint.hxx> 45*cdf0e10cSrcweir #include <basegfx/vector/b3dvector.hxx> 46*cdf0e10cSrcweir #include "charttoolsdllapi.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <vector> 49*cdf0e10cSrcweir #include <algorithm> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //............................................................................. 52*cdf0e10cSrcweir namespace chart 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir //............................................................................. 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //----------------------------------------------------------------------------- 57*cdf0e10cSrcweir /** 58*cdf0e10cSrcweir diverse methods for class conversions; e.g. ::basegfx::B3DHomMatrix to HomogenMatrix 59*cdf0e10cSrcweir and operations e.g drawing::Position3D + drawing::Direction3D 60*cdf0e10cSrcweir */ 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //----------------------------------------------------------------------------- 63*cdf0e10cSrcweir /** ::basegfx::B3DHomMatrix -> HomogenMatrix 64*cdf0e10cSrcweir */ 65*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix 66*cdf0e10cSrcweir B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM ); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //----------------------------------------------------------------------------- 69*cdf0e10cSrcweir /** HomogenMatrix -> ::basegfx::B3DHomMatrix 70*cdf0e10cSrcweir */ 71*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( const com::sun::star::drawing::HomogenMatrix& rHM ); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir //----------------------------------------------------------------------------- 74*cdf0e10cSrcweir /** ::basegfx::B3DHomMatrix -> B2DHomMatrix 75*cdf0e10cSrcweir */ 76*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 77*cdf0e10cSrcweir ::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir //----------------------------------------------------------------------------- 80*cdf0e10cSrcweir /** B2DHomMatrix <-> HomogenMatrix3 81*cdf0e10cSrcweir */ 82*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::HomogenMatrix3 83*cdf0e10cSrcweir B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM ); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir //----------------------------------------------------------------------------- 86*cdf0e10cSrcweir /** Position3D -> B3DPoint 87*cdf0e10cSrcweir */ 88*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DPoint Position3DToB3DPoint( const com::sun::star::drawing::Position3D& rPosition ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //----------------------------------------------------------------------------- 91*cdf0e10cSrcweir /** B3DVector -> Direction3D 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D B3DVectorToDirection3D( const ::basegfx::B3DVector& rVector); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //----------------------------------------------------------------------------- 96*cdf0e10cSrcweir /** B3DPoint -> Position3D 97*cdf0e10cSrcweir */ 98*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D B3DPointToPosition3D( const ::basegfx::B3DPoint& rPoint); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir //----------------------------------------------------------------------------- 101*cdf0e10cSrcweir /** Direction3D -> B3DVector 102*cdf0e10cSrcweir */ 103*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::basegfx::B3DVector Direction3DToB3DVector( const com::sun::star::drawing::Direction3D& rDirection); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir //----------------------------------------------------------------------------- 106*cdf0e10cSrcweir /** PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D 107*cdf0e10cSrcweir */ 108*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 109*cdf0e10cSrcweir void AddPointToPoly( ::com::sun::star::drawing::PolyPolygonShape3D& rPoly 110*cdf0e10cSrcweir , const com::sun::star::drawing::Position3D& rPos 111*cdf0e10cSrcweir , sal_Int32 nSequenceIndex=0 ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir //----------------------------------------------------------------------------- 114*cdf0e10cSrcweir /** get a single Point from a Polygon 115*cdf0e10cSrcweir */ 116*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::drawing::Position3D getPointFromPoly( 117*cdf0e10cSrcweir const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon 118*cdf0e10cSrcweir , sal_Int32 nPointIndex, sal_Int32 nPolyIndex=0 ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir //----------------------------------------------------------------------------- 121*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 122*cdf0e10cSrcweir void addPolygon( com::sun::star::drawing::PolyPolygonShape3D& rRet 123*cdf0e10cSrcweir , const com::sun::star::drawing::PolyPolygonShape3D& rAdd ); 124*cdf0e10cSrcweir //----------------------------------------------------------------------------- 125*cdf0e10cSrcweir /** PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D 126*cdf0e10cSrcweir */ 127*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 128*cdf0e10cSrcweir void appendPoly( com::sun::star::drawing::PolyPolygonShape3D& rRet 129*cdf0e10cSrcweir , const com::sun::star::drawing::PolyPolygonShape3D& rAdd ); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //----------------------------------------------------------------------------- 132*cdf0e10cSrcweir /** PolyPolygonBezierCoords -> PolyPolygonShape3D 133*cdf0e10cSrcweir */ 134*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 135*cdf0e10cSrcweir com::sun::star::drawing::PolyPolygonShape3D BezierToPoly( 136*cdf0e10cSrcweir const com::sun::star::drawing::PolyPolygonBezierCoords& rBezier ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir //----------------------------------------------------------------------------- 139*cdf0e10cSrcweir /** PolyPolygonShape3D -> drawing::PointSequenceSequence (2D) 140*cdf0e10cSrcweir */ 141*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 142*cdf0e10cSrcweir com::sun::star::drawing::PointSequenceSequence PolyToPointSequence( 143*cdf0e10cSrcweir const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //----------------------------------------------------------------------------- 146*cdf0e10cSrcweir /** drawing::PointSequenceSequence + drawing::PointSequenceSequence 147*cdf0e10cSrcweir */ 148*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 149*cdf0e10cSrcweir void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget 150*cdf0e10cSrcweir , com::sun::star::drawing::PointSequenceSequence& rAdd ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //----------------------------------------------------------------------------- 153*cdf0e10cSrcweir /** Position3D + Direction3D == Position3D 154*cdf0e10cSrcweir */ 155*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D 156*cdf0e10cSrcweir operator+( const com::sun::star::drawing::Position3D& rPos 157*cdf0e10cSrcweir , const com::sun::star::drawing::Direction3D& rDirection); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir //----------------------------------------------------------------------------- 160*cdf0e10cSrcweir /** Position3D - Position3D == Direction3D 161*cdf0e10cSrcweir */ 162*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Direction3D 163*cdf0e10cSrcweir operator-( const com::sun::star::drawing::Position3D& rPos1 164*cdf0e10cSrcweir , const com::sun::star::drawing::Position3D& rPos2); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir //----------------------------------------------------------------------------- 167*cdf0e10cSrcweir /** Position3D == Position3D ? 168*cdf0e10cSrcweir */ 169*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 170*cdf0e10cSrcweir bool operator==( const com::sun::star::drawing::Position3D& rPos1 171*cdf0e10cSrcweir , const com::sun::star::drawing::Position3D& rPos2); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //----------------------------------------------------------------------------- 174*cdf0e10cSrcweir /** awt::Rect --> awt::Point (2D) 175*cdf0e10cSrcweir */ 176*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point ToPoint( const com::sun::star::awt::Rectangle& rRectangle ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir //----------------------------------------------------------------------------- 179*cdf0e10cSrcweir /** awt::Rect --> awt::Size (2D) 180*cdf0e10cSrcweir */ 181*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size ToSize( const com::sun::star::awt::Rectangle& rRectangle ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //----------------------------------------------------------------------------- 184*cdf0e10cSrcweir /** Position3D --> awt::Point (2D) 185*cdf0e10cSrcweir */ 186*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Point Position3DToAWTPoint( const com::sun::star::drawing::Position3D& rPos ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir //----------------------------------------------------------------------------- 189*cdf0e10cSrcweir /** Direction3D --> awt::Size (2D) 190*cdf0e10cSrcweir */ 191*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS ::com::sun::star::awt::Size Direction3DToAWTSize( const com::sun::star::drawing::Direction3D& rDirection ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir //----------------------------------------------------------------------------- 194*cdf0e10cSrcweir /** B3DPoint -> Sequence<double> 195*cdf0e10cSrcweir */ 196*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double > B3DPointToSequence( const ::basegfx::B3DPoint& rPoint ); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir //----------------------------------------------------------------------------- 199*cdf0e10cSrcweir /** Sequence<double> -> drawing::Position3D 200*cdf0e10cSrcweir */ 201*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::drawing::Position3D 202*cdf0e10cSrcweir SequenceToPosition3D( const com::sun::star::uno::Sequence< double >& rSeq ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir //----------------------------------------------------------------------------- 205*cdf0e10cSrcweir /** drawing::Position3D -> Sequence<double> 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS com::sun::star::uno::Sequence< double > 209*cdf0e10cSrcweir Position3DToSequence( const com::sun::star::drawing::Position3D& rPosition ); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir //----------------------------------------------------------------------------- 212*cdf0e10cSrcweir /** chart2::XDataSequence -> uno::Sequence< double > 213*cdf0e10cSrcweir */ 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 216*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > DataSequenceToDoubleSequence( 217*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 218*cdf0e10cSrcweir ::com::sun::star::chart2::data::XDataSequence > & xDataSequence ); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 221*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< rtl::OUString > DataSequenceToStringSequence( 222*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 223*cdf0e10cSrcweir ::com::sun::star::chart2::data::XDataSequence > & xDataSequence ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir //----------------------------------------------------------------------------- 226*cdf0e10cSrcweir /** uno::Sequence< uno::Sequence< T > > -> uno::Sequence< T > 227*cdf0e10cSrcweir */ 228*cdf0e10cSrcweir template< typename T > 229*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< T > 230*cdf0e10cSrcweir FlattenSequence( const ::com::sun::star::uno::Sequence< 231*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< T > > & aSeqSeq ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir sal_Int32 nOuter, nInner, nCount = 0, 234*cdf0e10cSrcweir nResultSize = 0; 235*cdf0e10cSrcweir const sal_Int32 nOuterSize = aSeqSeq.getLength(); 236*cdf0e10cSrcweir for( nOuter=0; nOuter<nOuterSize; ++nOuter ) 237*cdf0e10cSrcweir nResultSize += aSeqSeq[nOuter].getLength(); 238*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< T > aResult( nResultSize ); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir for( nOuter=0; nOuter<nOuterSize; ++nOuter ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir const sal_Int32 nInnerSize = aSeqSeq[nOuter].getLength(); 243*cdf0e10cSrcweir for( nInner=0; nInner<nInnerSize; ++nInner, ++nCount ) 244*cdf0e10cSrcweir aResult[nCount] = aSeqSeq[nOuter][nInner]; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir return aResult; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir template< typename T > 250*cdf0e10cSrcweir ::std::vector< T > 251*cdf0e10cSrcweir FlattenVector( const ::std::vector< ::std::vector< T > > & rVecVec ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir typedef ::std::vector< T > tFlatVec; 254*cdf0e10cSrcweir typedef ::std::vector< tFlatVec > tVecVec; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir tFlatVec aResult; 257*cdf0e10cSrcweir typename tVecVec::const_iterator aOuterEnd( rVecVec.end()); 258*cdf0e10cSrcweir for( typename tVecVec::const_iterator aOuterIt( rVecVec.begin()); aOuterIt != aOuterEnd; ++aOuterIt ) 259*cdf0e10cSrcweir ::std::copy( aOuterIt->begin(), aOuterIt->end(), back_inserter( aResult )); 260*cdf0e10cSrcweir return aResult; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 264*cdf0e10cSrcweir sal_Bool hasDoubleValue( const ::com::sun::star::uno::Any& rAny ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 267*cdf0e10cSrcweir sal_Bool hasLongOrShortValue( const ::com::sun::star::uno::Any& rAny ); 268*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 269*cdf0e10cSrcweir sal_Int16 getShortForLongAlso( const ::com::sun::star::uno::Any& rAny ); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir OOO_DLLPUBLIC_CHARTTOOLS 272*cdf0e10cSrcweir bool replaceParamterInString( rtl::OUString & rInOutResourceString, 273*cdf0e10cSrcweir const rtl::OUString & rParamToReplace, 274*cdf0e10cSrcweir const rtl::OUString & rReplaceWith ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir //............................................................................. 277*cdf0e10cSrcweir } //namespace chart 278*cdf0e10cSrcweir //............................................................................. 279*cdf0e10cSrcweir #endif 280