21#include <com/sun/star/awt/Rectangle.hpp>
22#include <com/sun/star/drawing/DoubleSequence.hpp>
23#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
24#include <com/sun/star/chart2/data/XDataSequence.hpp>
25#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
26#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
28#include <osl/diagnose.h>
44 drawing::HomogenMatrix aHM;
45 aHM.Line1.Column1 = rM.get(0, 0);
46 aHM.Line1.Column2 = rM.get(0, 1);
47 aHM.Line1.Column3 = rM.get(0, 2);
48 aHM.Line1.Column4 = rM.get(0, 3);
49 aHM.Line2.Column1 = rM.get(1, 0);
50 aHM.Line2.Column2 = rM.get(1, 1);
51 aHM.Line2.Column3 = rM.get(1, 2);
52 aHM.Line2.Column4 = rM.get(1, 3);
53 aHM.Line3.Column1 = rM.get(2, 0);
54 aHM.Line3.Column2 = rM.get(2, 1);
55 aHM.Line3.Column3 = rM.get(2, 2);
56 aHM.Line3.Column4 = rM.get(2, 3);
57 aHM.Line4.Column1 = rM.get(3, 0);
58 aHM.Line4.Column2 = rM.get(3, 1);
59 aHM.Line4.Column3 = rM.get(3, 2);
60 aHM.Line4.Column4 = rM.get(3, 3);
67 aM.
set(0, 0, rHM.Line1.Column1);
68 aM.
set(0, 1, rHM.Line1.Column2);
69 aM.
set(0, 2, rHM.Line1.Column3);
70 aM.
set(0, 3, rHM.Line1.Column4);
71 aM.
set(1, 0, rHM.Line2.Column1);
72 aM.
set(1, 1, rHM.Line2.Column2);
73 aM.
set(1, 2, rHM.Line2.Column3);
74 aM.
set(1, 3, rHM.Line2.Column4);
75 aM.
set(2, 0, rHM.Line3.Column1);
76 aM.
set(2, 1, rHM.Line3.Column2);
77 aM.
set(2, 2, rHM.Line3.Column3);
78 aM.
set(2, 3, rHM.Line3.Column4);
79 aM.
set(3, 0, rHM.Line4.Column1);
80 aM.
set(3, 1, rHM.Line4.Column2);
81 aM.
set(3, 2, rHM.Line4.Column3);
82 aM.
set(3, 3, rHM.Line4.Column4);
89 aM.
set(0, 0, rM.get(0, 0));
90 aM.
set(0, 1, rM.get(0, 1));
91 aM.
set(0, 2, rM.get(0, 3));
92 aM.
set(1, 0, rM.get(1, 0));
93 aM.
set(1, 1, rM.get(1, 1));
94 aM.
set(1, 2, rM.get(1, 3));
96 assert( rM.get(3, 0) == 0 );
97 assert( rM.get(3, 1) == 0 );
98 assert( rM.get(3, 3) == 1 );
104 drawing::HomogenMatrix3 aHM;
105 aHM.Line1.Column1 = rM.get(0, 0);
106 aHM.Line1.Column2 = rM.get(0, 1);
107 aHM.Line1.Column3 = rM.get(0, 2);
108 aHM.Line2.Column1 = rM.get(1, 0);
109 aHM.Line2.Column2 = rM.get(1, 1);
110 aHM.Line2.Column3 = rM.get(1, 2);
111 aHM.Line3.Column1 = 0;
112 aHM.Line3.Column2 = 0;
113 aHM.Line3.Column3 = 1;
119 return ::basegfx::B3DPoint(
120 rPosition.PositionX ,
121 rPosition.PositionY ,
122 rPosition.PositionZ );
127 return drawing::Direction3D(
136 return drawing::Position3D(
145 return ::basegfx::B3DVector(
146 rDirection.DirectionX
147 , rDirection.DirectionY
148 , rDirection.DirectionZ
152void AddPointToPoly( drawing::PolyPolygonShape3D& rPoly,
const drawing::Position3D& rPos, sal_Int32 nPolygonIndex )
156 OSL_FAIL(
"The polygon index needs to be > 0");
161 if(nPolygonIndex >= rPoly.SequenceX.getLength() )
163 rPoly.SequenceX.realloc(nPolygonIndex+1);
164 rPoly.SequenceY.realloc(nPolygonIndex+1);
165 rPoly.SequenceZ.realloc(nPolygonIndex+1);
168 drawing::DoubleSequence* pOuterSequenceX = &rPoly.SequenceX.getArray()[nPolygonIndex];
169 drawing::DoubleSequence* pOuterSequenceY = &rPoly.SequenceY.getArray()[nPolygonIndex];
170 drawing::DoubleSequence* pOuterSequenceZ = &rPoly.SequenceZ.getArray()[nPolygonIndex];
172 sal_Int32 nOldPointCount = pOuterSequenceX->getLength();
174 pOuterSequenceX->realloc(nOldPointCount+1);
175 pOuterSequenceY->realloc(nOldPointCount+1);
176 pOuterSequenceZ->realloc(nOldPointCount+1);
178 double* pInnerSequenceX = pOuterSequenceX->getArray();
179 double* pInnerSequenceY = pOuterSequenceY->getArray();
180 double* pInnerSequenceZ = pOuterSequenceZ->getArray();
182 pInnerSequenceX[nOldPointCount] = rPos.PositionX;
183 pInnerSequenceY[nOldPointCount] = rPos.PositionY;
184 pInnerSequenceZ[nOldPointCount] = rPos.PositionZ;
187void AddPointToPoly( std::vector<std::vector<css::drawing::Position3D>>& rPoly,
const drawing::Position3D& rPos, sal_Int32 nPolygonIndex )
191 OSL_FAIL(
"The polygon index needs to be > 0");
198 rPoly.resize(nPolygonIndex+1);
201 std::vector<css::drawing::Position3D>* pOuterSequence = &rPoly[nPolygonIndex];
202 pOuterSequence->push_back(rPos);
205drawing::Position3D
getPointFromPoly(
const drawing::PolyPolygonShape3D& rPolygon, sal_Int32 nPointIndex, sal_Int32 nPolyIndex )
207 drawing::Position3D aRet(0.0,0.0,0.0);
209 if( nPolyIndex>=0 && nPolyIndex<rPolygon.SequenceX.getLength())
211 if(nPointIndex<rPolygon.SequenceX[nPolyIndex].getLength())
213 aRet.PositionX = rPolygon.SequenceX[nPolyIndex][nPointIndex];
214 aRet.PositionY = rPolygon.SequenceY[nPolyIndex][nPointIndex];
215 aRet.PositionZ = rPolygon.SequenceZ[nPolyIndex][nPointIndex];
219 OSL_FAIL(
"polygon was accessed with a wrong index");
224 OSL_FAIL(
"polygon was accessed with a wrong index");
229drawing::Position3D
getPointFromPoly(
const std::vector<std::vector<css::drawing::Position3D>>& rPolygon, sal_Int32 nPointIndex, sal_Int32 nPolyIndex )
231 drawing::Position3D aRet(0.0,0.0,0.0);
235 if(nPointIndex<
static_cast<sal_Int32
>(rPolygon[nPolyIndex].
size()))
237 aRet = rPolygon[nPolyIndex][nPointIndex];
241 OSL_FAIL(
"polygon was accessed with a wrong index");
246 OSL_FAIL(
"polygon was accessed with a wrong index");
251void addPolygon( std::vector<std::vector<css::drawing::Position3D>>& rRet,
const std::vector<std::vector<css::drawing::Position3D>>& rAdd )
253 sal_Int32 nAddOuterCount = rAdd.size();
254 sal_Int32 nOuterCount = rRet.size() + nAddOuterCount;
255 rRet.resize( nOuterCount );
256 auto pSequence = rRet.data();
259 sal_Int32 nOuter = nOuterCount - nAddOuterCount;
260 for( ; nOuter < nOuterCount; nOuter++ )
262 if(
nIndex >= nAddOuterCount )
265 pSequence[nOuter] = rAdd[
nIndex];
271void appendPoly( std::vector<std::vector<css::drawing::Position3D>>& rRet,
const std::vector<std::vector<css::drawing::Position3D>>& rAdd )
273 std::size_t nOuterCount = std::max( rRet.size(), rAdd.size() );
274 rRet.resize(nOuterCount);
275 auto pSequence = rRet.data();
277 for( std::size_t nOuter=0;nOuter<nOuterCount;nOuter++ )
279 sal_Int32 nOldPointCount = rRet[nOuter].size();
280 sal_Int32 nAddPointCount = 0;
281 if(nOuter<rAdd.size())
282 nAddPointCount = rAdd[nOuter].size();
286 sal_Int32 nNewPointCount = nOldPointCount + nAddPointCount;
288 pSequence[nOuter].resize(nNewPointCount);
289 auto pSequence_nOuter = pSequence[nOuter].data();
291 sal_Int32 nPointTarget=nOldPointCount;
292 sal_Int32 nPointSource=nAddPointCount;
293 for( ; nPointSource-- ; nPointTarget++ )
295 pSequence_nOuter[nPointTarget] = rAdd[nOuter][nPointSource];
301 const drawing::PolyPolygonBezierCoords& rBezier )
303 const drawing::PointSequenceSequence& rPointSequence = rBezier.Coordinates;
305 drawing::PolyPolygonShape3D aRet;
306 aRet.SequenceX.realloc( rPointSequence.getLength() );
307 auto pSequenceX = aRet.SequenceX.getArray();
308 aRet.SequenceY.realloc( rPointSequence.getLength() );
309 auto pSequenceY = aRet.SequenceY.getArray();
310 aRet.SequenceZ.realloc( rPointSequence.getLength() );
311 auto pSequenceZ = aRet.SequenceZ.getArray();
313 sal_Int32 nRealOuter = 0;
314 for(sal_Int32 nN = 0; nN < rPointSequence.getLength(); nN++)
316 sal_Int32 nInnerLength = rPointSequence[nN].getLength();
317 pSequenceX[nRealOuter].realloc( nInnerLength );
318 auto pSequenceX_nRealOuter = pSequenceX[nRealOuter].getArray();
319 pSequenceY[nRealOuter].realloc( nInnerLength );
320 auto pSequenceY_nRealOuter = pSequenceY[nRealOuter].getArray();
321 pSequenceZ[nRealOuter].realloc( nInnerLength );
322 auto pSequenceZ_nRealOuter = pSequenceZ[nRealOuter].getArray();
324 bool bHasOuterFlags = nN < rBezier.Flags.getLength();
326 sal_Int32 nRealInner = 0;
327 for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
329 bool bHasInnerFlags = bHasOuterFlags && (nM < rBezier.Flags[nN].getLength());
331 if( !bHasInnerFlags || (rBezier.Flags[nN][nM] == drawing::PolygonFlags_NORMAL) )
333 pSequenceX_nRealOuter[nRealInner] = rPointSequence[nN][nM].X;
334 pSequenceY_nRealOuter[nRealInner] = rPointSequence[nN][nM].Y;
335 pSequenceZ_nRealOuter[nRealInner] = 0.0;
340 pSequenceX[nRealOuter].realloc( nRealInner );
341 pSequenceY[nRealOuter].realloc( nRealInner );
342 pSequenceZ[nRealOuter].realloc( nRealInner );
348 aRet.SequenceX.realloc( nRealOuter );
349 aRet.SequenceY.realloc( nRealOuter );
350 aRet.SequenceZ.realloc( nRealOuter );
356 const drawing::PolyPolygonShape3D& rPolyPolygon )
358 drawing::PointSequenceSequence aRet;
359 aRet.realloc( rPolyPolygon.SequenceX.getLength() );
360 auto pRet = aRet.getArray();
362 for(sal_Int32 nN = 0; nN < rPolyPolygon.SequenceX.getLength(); nN++)
364 sal_Int32 nInnerLength = rPolyPolygon.SequenceX[nN].getLength();
365 pRet[nN].realloc( nInnerLength );
366 auto pRet_nN = pRet[nN].getArray();
367 for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
369 pRet_nN[nM].X =
static_cast<sal_Int32
>(rPolyPolygon.SequenceX[nN][nM]);
370 pRet_nN[nM].Y =
static_cast<sal_Int32
>(rPolyPolygon.SequenceY[nN][nM]);
377 const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
379 drawing::PointSequenceSequence aRet;
380 aRet.realloc( rPolyPolygon.size() );
381 auto pRet = aRet.getArray();
383 for(std::size_t nN = 0; nN < rPolyPolygon.size(); nN++)
385 sal_Int32 nInnerLength = rPolyPolygon[nN].size();
386 pRet[nN].realloc( nInnerLength );
387 auto pRet_nN = pRet[nN].getArray();
388 for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
390 pRet_nN[nM].X =
static_cast<sal_Int32
>(rPolyPolygon[nN][nM].PositionX);
391 pRet_nN[nM].Y =
static_cast<sal_Int32
>(rPolyPolygon[nN][nM].PositionY);
398 const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
402 for(
auto const & nN: rPolyPolygon)
405 sal_Int32 nInnerLength = nN.size();
408 aNewPolygon.
reserve(nInnerLength);
409 for( sal_Int32 nM = 0; nM < nInnerLength; nM++)
411 auto X =
static_cast<sal_Int32
>(nN[nM].PositionX);
412 auto Y =
static_cast<sal_Int32
>(nN[nM].PositionY);
418 aRetval.
append(std::move(aNewPolygon));
425 ,
const drawing::PointSequenceSequence& rAdd )
427 sal_Int32 nAddCount = rAdd.getLength();
430 sal_Int32 nOldCount =
rTarget.getLength();
432 rTarget.realloc(nOldCount+nAddCount);
433 auto pTarget =
rTarget.getArray();
434 for(sal_Int32 nS=0; nS<nAddCount; nS++ )
435 pTarget[nOldCount+nS]=rAdd[nS];
438drawing::Position3D
operator+(
const drawing::Position3D& rPos
439 ,
const drawing::Direction3D& rDirection)
441 return drawing::Position3D(
442 rPos.PositionX + rDirection.DirectionX
443 , rPos.PositionY + rDirection.DirectionY
444 , rPos.PositionZ + rDirection.DirectionZ
448drawing::Direction3D
operator-(
const drawing::Position3D& rPos1
449 ,
const drawing::Position3D& rPos2)
451 return drawing::Direction3D(
452 rPos1.PositionX - rPos2.PositionX
453 , rPos1.PositionY - rPos2.PositionY
454 , rPos1.PositionZ - rPos2.PositionZ
461 aRet.X =
static_cast<sal_Int32
>(rPos.PositionX);
462 aRet.Y =
static_cast<sal_Int32
>(rPos.PositionY);
466awt::Point
ToPoint(
const awt::Rectangle& rRectangle )
468 return awt::Point( rRectangle.X, rRectangle.Y );
471awt::Size
ToSize(
const awt::Rectangle& rRectangle )
473 return awt::Size( rRectangle.Width, rRectangle.Height );
479 aRet.Width =
static_cast<sal_Int32
>(rDirection.DirectionX);
480 aRet.Height =
static_cast<sal_Int32
>(rDirection.DirectionY);
486 OSL_ENSURE(rSeq.getLength()==3,
"The sequence needs to have length 3 for conversion into vector");
488 drawing::Position3D aRet;
489 aRet.PositionX = rSeq.getLength()>0?rSeq[0]:0.0;
490 aRet.PositionY = rSeq.getLength()>1?rSeq[1]:0.0;
491 aRet.PositionZ = rSeq.getLength()>2?rSeq[2]:0.0;
501 OSL_ASSERT( xDataSequence.is());
502 if(!xDataSequence.is())
506 if( xNumericalDataSequence.is() )
508 aResult = xNumericalDataSequence->getNumericalData();
513 aResult.realloc(aValues.getLength());
514 auto pResult = aResult.getArray();
515 for(sal_Int32 nN=aValues.getLength();nN--;)
517 if( !(aValues[nN] >>= pResult[nN]) )
518 pResult[nN] = std::numeric_limits<double>::quiet_NaN();
529 if(!xDataSequence.is())
533 if( xTextualDataSequence.is() )
535 aResult = xTextualDataSequence->getTextualData();
540 aResult.realloc(aValues.getLength());
541 auto pResult = aResult.getArray();
543 for(sal_Int32 nN=aValues.getLength();nN--;)
544 aValues[nN] >>= pResult[nN];
554 if( rAny >>= fValue )
577 if( !(rAny >>= nRet) )
581 nRet =
static_cast<sal_Int16
>(n32);
587 std::u16string_view rParamToReplace,
588 std::u16string_view rReplaceWith )
590 sal_Int32
nPos = rInOutResourceString.indexOf( rParamToReplace );
594 rInOutResourceString = rInOutResourceString.replaceAt(
nPos
595 , rParamToReplace.size(), rReplaceWith );
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void reserve(sal_uInt32 nCount)
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void checkClosed(B2DPolygon &rCandidate)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DVector Direction3DToB3DVector(const css::drawing::Direction3D &rDirection)
Direction3D -> B3DVector.
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D getPointFromPoly(const std::vector< std::vector< css::drawing::Position3D > > &rPolygon, sal_Int32 nPointIndex, sal_Int32 nPolyIndex)
get a single Point from a Polygon
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D B3DPointToPosition3D(const ::basegfx::B3DPoint &rPoint)
B3DPoint -> Position3D.
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point Position3DToAWTPoint(const css::drawing::Position3D &rPos)
Position3D --> awt::Point (2D)
OOO_DLLPUBLIC_CHARTTOOLS bool hasLongOrShortValue(const css::uno::Any &rAny)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix3 B2DHomMatrixToHomogenMatrix3(const ::basegfx::B2DHomMatrix &rM)
B2DHomMatrix <-> HomogenMatrix3.
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Direction3D operator-(const css::drawing::Position3D &rPos1, const css::drawing::Position3D &rPos2)
Position3D - Position3D == Direction3D.
OOO_DLLPUBLIC_CHARTTOOLS bool replaceParamterInString(OUString &rInOutResourceString, std::u16string_view rParamToReplace, std::u16string_view rReplaceWith)
OOO_DLLPUBLIC_CHARTTOOLS void AddPointToPoly(css::drawing::PolyPolygonShape3D &rPoly, const css::drawing::Position3D &rPos, sal_Int32 nSequenceIndex=0)
PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D.
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size ToSize(const css::awt::Rectangle &rRectangle)
awt::Rect --> awt::Size (2D)
OOO_DLLPUBLIC_CHARTTOOLS basegfx::B2DPolyPolygon PolyToB2DPolyPolygon(const std::vector< std::vector< css::drawing::Position3D > > &rPolyPolygon)
PolyPolygonShape3D -> basegfx::B2DPolyPolygon (2D)
OOO_DLLPUBLIC_CHARTTOOLS void addPolygon(std::vector< std::vector< css::drawing::Position3D > > &rRet, const std::vector< std::vector< css::drawing::Position3D > > &rAdd)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::PolyPolygonShape3D BezierToPoly(const css::drawing::PolyPolygonBezierCoords &rBezier)
PolyPolygonBezierCoords -> PolyPolygonShape3D.
OOO_DLLPUBLIC_CHARTTOOLS void appendPointSequence(css::drawing::PointSequenceSequence &rTarget, const css::drawing::PointSequenceSequence &rAdd)
drawing::PointSequenceSequence + drawing::PointSequenceSequence
OOO_DLLPUBLIC_CHARTTOOLS void appendPoly(std::vector< std::vector< css::drawing::Position3D > > &rRet, const std::vector< std::vector< css::drawing::Position3D > > &rAdd)
PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D.
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DPoint Position3DToB3DPoint(const css::drawing::Position3D &rPosition)
Position3D -> B3DPoint.
OOO_DLLPUBLIC_CHARTTOOLS sal_Int16 getShortForLongAlso(const css::uno::Any &rAny)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Direction3D B3DVectorToDirection3D(const ::basegfx::B3DVector &rVector)
B3DVector -> Direction3D.
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point ToPoint(const css::awt::Rectangle &rRectangle)
awt::Rect --> awt::Point (2D)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::HomogenMatrix B3DHomMatrixToHomogenMatrix(const ::basegfx::B3DHomMatrix &rM)
diverse methods for class conversions; e.g.
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Sequence< double > DataSequenceToDoubleSequence(const css::uno::Reference< css::chart2::data::XDataSequence > &xDataSequence)
chart2::XDataSequence -> uno::Sequence< double >
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size Direction3DToAWTSize(const css::drawing::Direction3D &rDirection)
Direction3D --> awt::Size (2D)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B2DHomMatrix IgnoreZ(const ::basegfx::B3DHomMatrix &rM)
basegfx::B3DHomMatrix -> B2DHomMatrix
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::PointSequenceSequence PolyToPointSequence(const css::drawing::PolyPolygonShape3D &rPolyPolygon)
PolyPolygonShape3D -> drawing::PointSequenceSequence (2D)
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Sequence< OUString > DataSequenceToStringSequence(const css::uno::Reference< css::chart2::data::XDataSequence > &xDataSequence)
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D operator+(const css::drawing::Position3D &rPos, const css::drawing::Direction3D &rDirection)
Position3D + Direction3D == Position3D.
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Position3D SequenceToPosition3D(const css::uno::Sequence< double > &rSeq)
Sequence<double> -> drawing::Position3D.
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix(const css::drawing::HomogenMatrix &rHM)
HomogenMatrix -> basegfx::B3DHomMatrix.
OOO_DLLPUBLIC_CHARTTOOLS bool hasDoubleValue(const css::uno::Any &rAny)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)