summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/tools/CommonConverters.cxx377
1 files changed, 295 insertions, 82 deletions
diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx
index 32a048210e69..2d899b25cc78 100644
--- a/chart2/source/tools/CommonConverters.cxx
+++ b/chart2/source/tools/CommonConverters.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: CommonConverters.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: ihi $ $Date: 2006-11-14 15:32:42 $
+ * last change: $Author: vg $ $Date: 2007-05-22 18:56:47 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -46,8 +46,11 @@
#include <com/sun/star/text/WritingMode2.hpp>
#endif
-#ifndef _COM_SUN_STAR_CHART2_XNUMERICALDATASEQUENCE_HPP_
-#include <com/sun/star/chart2/XNumericalDataSequence.hpp>
+#ifndef _COM_SUN_STAR_CHART2_DATA_XNUMERICALDATASEQUENCE_HPP_
+#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART2_DATA_XTEXTUALDATASEQUENCE_HPP_
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#endif
#ifndef INCLUDED_RTL_MATH_HXX
@@ -74,94 +77,94 @@ using namespace ::com::sun::star;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-drawing::HomogenMatrix Matrix4DToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM4 )
+drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix( const ::basegfx::B3DHomMatrix& rM )
{
drawing::HomogenMatrix aHM;
- aHM.Line1.Column1 = rM4.get(0, 0);
- aHM.Line1.Column2 = rM4.get(0, 1);
- aHM.Line1.Column3 = rM4.get(0, 2);
- aHM.Line1.Column4 = rM4.get(0, 3);
- aHM.Line2.Column1 = rM4.get(1, 0);
- aHM.Line2.Column2 = rM4.get(1, 1);
- aHM.Line2.Column3 = rM4.get(1, 2);
- aHM.Line2.Column4 = rM4.get(1, 3);
- aHM.Line3.Column1 = rM4.get(2, 0);
- aHM.Line3.Column2 = rM4.get(2, 1);
- aHM.Line3.Column3 = rM4.get(2, 2);
- aHM.Line3.Column4 = rM4.get(2, 3);
- aHM.Line4.Column1 = rM4.get(3, 0);
- aHM.Line4.Column2 = rM4.get(3, 1);
- aHM.Line4.Column3 = rM4.get(3, 2);
- aHM.Line4.Column4 = rM4.get(3, 3);
+ aHM.Line1.Column1 = rM.get(0, 0);
+ aHM.Line1.Column2 = rM.get(0, 1);
+ aHM.Line1.Column3 = rM.get(0, 2);
+ aHM.Line1.Column4 = rM.get(0, 3);
+ aHM.Line2.Column1 = rM.get(1, 0);
+ aHM.Line2.Column2 = rM.get(1, 1);
+ aHM.Line2.Column3 = rM.get(1, 2);
+ aHM.Line2.Column4 = rM.get(1, 3);
+ aHM.Line3.Column1 = rM.get(2, 0);
+ aHM.Line3.Column2 = rM.get(2, 1);
+ aHM.Line3.Column3 = rM.get(2, 2);
+ aHM.Line3.Column4 = rM.get(2, 3);
+ aHM.Line4.Column1 = rM.get(3, 0);
+ aHM.Line4.Column2 = rM.get(3, 1);
+ aHM.Line4.Column3 = rM.get(3, 2);
+ aHM.Line4.Column4 = rM.get(3, 3);
return aHM;
}
-::basegfx::B3DHomMatrix HomogenMatrixToMatrix4D( const drawing::HomogenMatrix& rHM )
-{
- ::basegfx::B3DHomMatrix aM4;
- aM4.set(0, 0, rHM.Line1.Column1);
- aM4.set(0, 1, rHM.Line1.Column2);
- aM4.set(0, 2, rHM.Line1.Column3);
- aM4.set(0, 3, rHM.Line1.Column4);
- aM4.set(1, 0, rHM.Line2.Column1);
- aM4.set(1, 1, rHM.Line2.Column2);
- aM4.set(1, 2, rHM.Line2.Column3);
- aM4.set(1, 3, rHM.Line2.Column4);
- aM4.set(2, 0, rHM.Line3.Column1);
- aM4.set(2, 1, rHM.Line3.Column2);
- aM4.set(2, 2, rHM.Line3.Column3);
- aM4.set(2, 3, rHM.Line3.Column4);
- aM4.set(3, 0, rHM.Line4.Column1);
- aM4.set(3, 1, rHM.Line4.Column2);
- aM4.set(3, 2, rHM.Line4.Column3);
- aM4.set(3, 3, rHM.Line4.Column4);
- return aM4;
+::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix( const drawing::HomogenMatrix& rHM )
+{
+ ::basegfx::B3DHomMatrix aM;
+ aM.set(0, 0, rHM.Line1.Column1);
+ aM.set(0, 1, rHM.Line1.Column2);
+ aM.set(0, 2, rHM.Line1.Column3);
+ aM.set(0, 3, rHM.Line1.Column4);
+ aM.set(1, 0, rHM.Line2.Column1);
+ aM.set(1, 1, rHM.Line2.Column2);
+ aM.set(1, 2, rHM.Line2.Column3);
+ aM.set(1, 3, rHM.Line2.Column4);
+ aM.set(2, 0, rHM.Line3.Column1);
+ aM.set(2, 1, rHM.Line3.Column2);
+ aM.set(2, 2, rHM.Line3.Column3);
+ aM.set(2, 3, rHM.Line3.Column4);
+ aM.set(3, 0, rHM.Line4.Column1);
+ aM.set(3, 1, rHM.Line4.Column2);
+ aM.set(3, 2, rHM.Line4.Column3);
+ aM.set(3, 3, rHM.Line4.Column4);
+ return aM;
}
-::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM4 )
-{
- ::basegfx::B2DHomMatrix aM3;
- aM3.set(0, 0, rM4.get(0, 0));
- aM3.set(0, 1, rM4.get(0, 1));
- aM3.set(0, 2, rM4.get(0, 3));
- aM3.set(1, 0, rM4.get(1, 0));
- aM3.set(1, 1, rM4.get(1, 1));
- aM3.set(1, 2, rM4.get(1, 3));
- aM3.set(2, 0, rM4.get(3, 0));
- aM3.set(2, 1, rM4.get(3, 1));
- aM3.set(2, 2, rM4.get(3, 3));
- return aM3;
+::basegfx::B2DHomMatrix IgnoreZ( const ::basegfx::B3DHomMatrix& rM )
+{
+ ::basegfx::B2DHomMatrix aM;
+ aM.set(0, 0, rM.get(0, 0));
+ aM.set(0, 1, rM.get(0, 1));
+ aM.set(0, 2, rM.get(0, 3));
+ aM.set(1, 0, rM.get(1, 0));
+ aM.set(1, 1, rM.get(1, 1));
+ aM.set(1, 2, rM.get(1, 3));
+ aM.set(2, 0, rM.get(3, 0));
+ aM.set(2, 1, rM.get(3, 1));
+ aM.set(2, 2, rM.get(3, 3));
+ return aM;
}
-drawing::HomogenMatrix3 B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM3 )
+drawing::HomogenMatrix3 B2DHomMatrixToHomogenMatrix3( const ::basegfx::B2DHomMatrix& rM )
{
drawing::HomogenMatrix3 aHM;
- aHM.Line1.Column1 = rM3.get(0, 0);
- aHM.Line1.Column2 = rM3.get(0, 1);
- aHM.Line1.Column3 = rM3.get(0, 2);
- aHM.Line2.Column1 = rM3.get(1, 0);
- aHM.Line2.Column2 = rM3.get(1, 1);
- aHM.Line2.Column3 = rM3.get(1, 2);
- aHM.Line3.Column1 = rM3.get(2, 0);
- aHM.Line3.Column2 = rM3.get(2, 1);
- aHM.Line3.Column3 = rM3.get(2, 2);
+ aHM.Line1.Column1 = rM.get(0, 0);
+ aHM.Line1.Column2 = rM.get(0, 1);
+ aHM.Line1.Column3 = rM.get(0, 2);
+ aHM.Line2.Column1 = rM.get(1, 0);
+ aHM.Line2.Column2 = rM.get(1, 1);
+ aHM.Line2.Column3 = rM.get(1, 2);
+ aHM.Line3.Column1 = rM.get(2, 0);
+ aHM.Line3.Column2 = rM.get(2, 1);
+ aHM.Line3.Column3 = rM.get(2, 2);
return aHM;
}
::basegfx::B2DHomMatrix HomogenMatrix3ToB2DHomMatrix( const drawing::HomogenMatrix3& rHM )
{
- ::basegfx::B2DHomMatrix aM3;
- aM3.set(0, 0, rHM.Line1.Column1);
- aM3.set(0, 1, rHM.Line1.Column2);
- aM3.set(0, 2, rHM.Line1.Column3);
- aM3.set(1, 0, rHM.Line2.Column1);
- aM3.set(1, 1, rHM.Line2.Column2);
- aM3.set(1, 2, rHM.Line2.Column3);
- aM3.set(2, 0, rHM.Line3.Column1);
- aM3.set(2, 1, rHM.Line3.Column2);
- aM3.set(2, 2, rHM.Line3.Column3);
- return aM3;
+ ::basegfx::B2DHomMatrix aM;
+ aM.set(0, 0, rHM.Line1.Column1);
+ aM.set(0, 1, rHM.Line1.Column2);
+ aM.set(0, 2, rHM.Line1.Column3);
+ aM.set(1, 0, rHM.Line2.Column1);
+ aM.set(1, 1, rHM.Line2.Column2);
+ aM.set(1, 2, rHM.Line2.Column3);
+ aM.set(2, 0, rHM.Line3.Column1);
+ aM.set(2, 1, rHM.Line3.Column2);
+ aM.set(2, 2, rHM.Line3.Column3);
+ return aM;
}
::basegfx::B3DPoint Position3DToB3DPoint( const drawing::Position3D& rPosition )
@@ -181,6 +184,33 @@ drawing::Direction3D B3DVectorToDirection3D( const ::basegfx::B3DVector& rVector
);
}
+drawing::Position3D B3DVectorToPosition3D( const ::basegfx::B3DVector& rVector)
+{
+ return drawing::Position3D(
+ rVector.getX()
+ , rVector.getY()
+ , rVector.getZ()
+ );
+}
+
+drawing::Position3D B3DPointToPosition3D( const ::basegfx::B3DPoint& rPoint)
+{
+ return drawing::Position3D(
+ rPoint.getX()
+ , rPoint.getY()
+ , rPoint.getZ()
+ );
+}
+
+::basegfx::B3DPoint Direction3DToB3DPoint( const drawing::Direction3D& rDirection)
+{
+ return ::basegfx::B3DPoint(
+ rDirection.DirectionX
+ , rDirection.DirectionY
+ , rDirection.DirectionZ
+ );
+}
+
drawing::PolyPolygonShape3D MakeLine3D(
const drawing::Position3D & rStart,
const drawing::Position3D & rEnd )
@@ -410,6 +440,81 @@ drawing::PolyPolygonShape3D operator+(
}
*/
+drawing::PolyPolygonShape3D BezierToPoly(
+ const drawing::PolyPolygonBezierCoords& rBezier )
+{
+ const drawing::PointSequenceSequence& rPointSequence = rBezier.Coordinates;
+ const drawing::FlagSequenceSequence& rFlags = rBezier.Flags;
+
+ drawing::PolyPolygonShape3D aRet;
+ aRet.SequenceX.realloc( rPointSequence.getLength() );
+ aRet.SequenceY.realloc( rPointSequence.getLength() );
+ aRet.SequenceZ.realloc( rPointSequence.getLength() );
+
+ sal_Int32 nRealOuter = 0;
+ for(sal_Int32 nN = 0; nN < rPointSequence.getLength(); nN++)
+ {
+ sal_Int32 nInnerLength = rPointSequence[nN].getLength();
+ aRet.SequenceX[nN].realloc( nInnerLength );
+ aRet.SequenceY[nN].realloc( nInnerLength );
+ aRet.SequenceZ[nN].realloc( nInnerLength );
+
+ bool bHasOuterFlags = nN < rBezier.Flags.getLength();
+
+ sal_Int32 nRealInner = 0;
+ for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
+ {
+ bool bHasInnerFlags = bHasOuterFlags && (nM < rBezier.Flags[nN].getLength());
+
+ if( !bHasInnerFlags || (rBezier.Flags[nN][nM] == drawing::PolygonFlags_NORMAL) )
+ {
+ aRet.SequenceX[nRealOuter][nRealInner] = rPointSequence[nN][nM].X;
+ aRet.SequenceY[nRealOuter][nRealInner] = rPointSequence[nN][nM].Y;
+ aRet.SequenceZ[nRealOuter][nRealInner] = 0.0;
+ nRealInner++;
+ }
+ }
+
+ aRet.SequenceX[nRealOuter].realloc( nRealInner );
+ aRet.SequenceY[nRealOuter].realloc( nRealInner );
+ aRet.SequenceZ[nRealOuter].realloc( nRealInner );
+
+ if( nRealInner>0 )
+ nRealOuter++;
+ }
+
+ aRet.SequenceX.realloc( nRealOuter );
+ aRet.SequenceY.realloc( nRealOuter );
+ aRet.SequenceZ.realloc( nRealOuter );
+
+ return aRet;
+}
+
+drawing::PolyPolygonShape3D PointSequenceToPoly(
+ const drawing::PointSequenceSequence& rPointSequence )
+{
+ drawing::PolyPolygonShape3D aRet;
+ aRet.SequenceX.realloc( rPointSequence.getLength() );
+ aRet.SequenceY.realloc( rPointSequence.getLength() );
+ aRet.SequenceZ.realloc( rPointSequence.getLength() );
+
+ for(sal_Int32 nN = 0; nN < rPointSequence.getLength(); nN++)
+ {
+ sal_Int32 nInnerLength = rPointSequence[nN].getLength();
+ aRet.SequenceX[nN].realloc( nInnerLength );
+ aRet.SequenceY[nN].realloc( nInnerLength );
+ aRet.SequenceZ[nN].realloc( nInnerLength );
+
+ for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
+ {
+ aRet.SequenceX[nN][nM] = rPointSequence[nN][nM].X;
+ aRet.SequenceY[nN][nM] = rPointSequence[nN][nM].Y;
+ aRet.SequenceZ[nN][nM] = 0.0;
+ }
+ }
+ return aRet;
+}
+
drawing::PointSequenceSequence PolyToPointSequence(
const drawing::PolyPolygonShape3D& rPolyPolygon )
{
@@ -429,8 +534,8 @@ drawing::PointSequenceSequence PolyToPointSequence(
return aRet;
}
-void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget
- , com::sun::star::drawing::PointSequenceSequence& rAdd )
+void appendPointSequence( drawing::PointSequenceSequence& rTarget
+ , drawing::PointSequenceSequence& rAdd )
{
sal_Int32 nAddCount = rAdd.getLength();
if(!nAddCount)
@@ -512,6 +617,16 @@ drawing::Position3D operator+( const drawing::Position3D& rPos
);
}
+drawing::Direction3D operator+( const drawing::Direction3D& rDirection
+ , const drawing::Direction3D& rDirectionAdd)
+{
+ return drawing::Direction3D(
+ rDirection.DirectionX + rDirectionAdd.DirectionX
+ , rDirection.DirectionY + rDirectionAdd.DirectionY
+ , rDirection.DirectionZ + rDirectionAdd.DirectionZ
+ );
+}
+
drawing::Position3D operator-( const drawing::Position3D& rPos
, const drawing::Direction3D& rDirection)
{
@@ -550,6 +665,32 @@ bool operator==( const drawing::Position3D& rPos1
&& rPos1.PositionZ == rPos2.PositionZ;
}
+awt::Point Position3DToAWTPoint( const drawing::Position3D& rPos )
+{
+ awt::Point aRet;
+ aRet.X = static_cast<sal_Int32>(rPos.PositionX);
+ aRet.Y = static_cast<sal_Int32>(rPos.PositionY);
+ return aRet;
+}
+
+awt::Point ToPoint( const awt::Rectangle& rRectangle )
+{
+ return awt::Point( rRectangle.X, rRectangle.Y );
+}
+
+awt::Size ToSize( const awt::Rectangle& rRectangle )
+{
+ return awt::Size( rRectangle.Width, rRectangle.Height );
+}
+
+awt::Size Direction3DToAWTSize( const drawing::Direction3D& rDirection )
+{
+ awt::Size aRet;
+ aRet.Width = static_cast<sal_Int32>(rDirection.DirectionX);
+ aRet.Height = static_cast<sal_Int32>(rDirection.DirectionY);
+ return aRet;
+}
+
::basegfx::B3DPoint SequenceToB3DPoint( const uno::Sequence< double >& rSeq )
{
OSL_ENSURE(rSeq.getLength()==3,"The sequence needs to have length 3 for conversion into vector");
@@ -637,14 +778,14 @@ text::WritingMode WritingMode2ToWritingMode1( sal_Int16 nWritingMode2 )
using namespace ::com::sun::star::chart2;
uno::Sequence< double > DataSequenceToDoubleSequence(
- const uno::Reference< XDataSequence > & xDataSequence )
+ const uno::Reference< data::XDataSequence >& xDataSequence )
{
uno::Sequence< double > aResult;
OSL_ASSERT( xDataSequence.is());
if(!xDataSequence.is())
return aResult;
- uno::Reference< XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY );
+ uno::Reference< data::XNumericalDataSequence > xNumericalDataSequence( xDataSequence, uno::UNO_QUERY );
if( xNumericalDataSequence.is() )
{
aResult = xNumericalDataSequence->getNumericalData();
@@ -656,15 +797,87 @@ uno::Sequence< double > DataSequenceToDoubleSequence(
for(sal_Int32 nN=aValues.getLength();nN--;)
{
if( !(aValues[nN] >>= aResult[nN]) )
- {
- ::rtl::math::setNan( & aResult[nN] );
- }
+ ::rtl::math::setNan( &aResult[nN] );
}
}
return aResult;
}
+uno::Sequence< rtl::OUString > DataSequenceToStringSequence(
+ const uno::Reference< data::XDataSequence >& xDataSequence )
+{
+ uno::Sequence< rtl::OUString > aResult;
+ OSL_ASSERT( xDataSequence.is());
+ if(!xDataSequence.is())
+ return aResult;
+
+ uno::Reference< data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
+ if( xTextualDataSequence.is() )
+ {
+ aResult = xTextualDataSequence->getTextualData();
+ }
+ else
+ {
+ uno::Sequence< uno::Any > aValues = xDataSequence->getData();
+ aResult.realloc(aValues.getLength());
+
+ for(sal_Int32 nN=aValues.getLength();nN--;)
+ aValues[nN] >>= aResult[nN];
+ }
+
+ return aResult;
+}
+
+sal_Bool hasDoubleValue( const uno::Any& rAny )
+{
+ sal_Bool bRet = sal_False;
+ double fValue = 0.0;
+ if( rAny >>= fValue )
+ bRet = sal_True;
+ return bRet;
+}
+
+sal_Bool hasLongOrShortValue( const uno::Any& rAny )
+{
+ sal_Bool bRet = sal_False;
+ sal_Int32 n32 = 0;
+ if( rAny >>= n32 )
+ bRet = sal_True;
+ else
+ {
+ sal_Int16 n16 = 0;
+ if( rAny >>= n16 )
+ bRet = sal_True;
+ }
+ return bRet;
+}
+sal_Int16 getShortForLongAlso( const uno::Any& rAny )
+{
+ sal_Int16 nRet = 0;
+
+ if( !(rAny >>= nRet) )
+ {
+ sal_Int32 n32 = 0;
+ if( rAny >>= n32 )
+ nRet = static_cast<sal_Int16>(n32);
+ }
+ return nRet;
+}
+
+bool replaceParamterInString( rtl::OUString & rInOutResourceString,
+ const rtl::OUString & rParamToReplace,
+ const rtl::OUString & rReplaceWith )
+{
+ sal_Int32 nPos = rInOutResourceString.indexOf( rParamToReplace );
+ if( nPos == -1 )
+ return false;
+
+ rInOutResourceString = rInOutResourceString.replaceAt( nPos
+ , rParamToReplace.getLength(), rReplaceWith );
+ return true;
+}
+
//.............................................................................
} //namespace chart
//.............................................................................