diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-03-01 15:54:32 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-06 15:45:41 +0200 |
commit | f91d22bfefd1a5f1b8e31f25004e6ef9b34b5db0 (patch) | |
tree | b5fae37992d9da474663d2fc22cc4386e3e37546 | |
parent | 12bb11c6466fb93fe3f0ec1a8302db32a2ce4839 (diff) |
SOSAW080: Added first bunch of basic changes to helpers
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
-rw-r--r-- | basegfx/Library_basegfx.mk | 1 | ||||
-rw-r--r-- | basegfx/source/matrix/b2dhommatrix.cxx | 15 | ||||
-rw-r--r-- | basegfx/source/matrix/b3dhommatrix.cxx | 15 | ||||
-rwxr-xr-x | basegfx/source/matrix/b3dhommatrixtools.cxx | 76 | ||||
-rw-r--r-- | basegfx/source/numeric/ftools.cxx | 53 | ||||
-rw-r--r-- | basegfx/source/range/b2drange.cxx | 20 | ||||
-rw-r--r-- | basegfx/source/range/b3drange.cxx | 19 | ||||
-rw-r--r-- | include/basegfx/matrix/b2dhommatrix.hxx | 2 | ||||
-rw-r--r-- | include/basegfx/matrix/b3dhommatrix.hxx | 3 | ||||
-rwxr-xr-x | include/basegfx/matrix/b3dhommatrixtools.hxx | 46 | ||||
-rw-r--r-- | include/basegfx/numeric/ftools.hxx | 19 | ||||
-rw-r--r-- | include/basegfx/range/b1drange.hxx | 5 | ||||
-rw-r--r-- | include/basegfx/range/b2drange.hxx | 25 | ||||
-rw-r--r-- | include/basegfx/range/b2irange.hxx | 7 | ||||
-rw-r--r-- | include/basegfx/range/b3drange.hxx | 25 | ||||
-rw-r--r-- | include/basegfx/range/basicrange.hxx | 22 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap3.cxx | 81 | ||||
-rw-r--r-- | xmloff/source/draw/xexptran.cxx | 39 |
18 files changed, 363 insertions, 110 deletions
diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk index 087e4a081419..de744b5a15ce 100644 --- a/basegfx/Library_basegfx.mk +++ b/basegfx/Library_basegfx.mk @@ -38,6 +38,7 @@ $(eval $(call gb_Library_add_exception_objects,basegfx,\ basegfx/source/matrix/b2dhommatrix \ basegfx/source/matrix/b2dhommatrixtools \ basegfx/source/matrix/b3dhommatrix \ + basegfx/source/matrix/b3dhommatrixtools \ basegfx/source/numeric/ftools \ basegfx/source/pixel/bpixel \ basegfx/source/point/b2dpoint \ diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 9f7d5bff0156..466e9037d149 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -115,6 +115,11 @@ namespace basegfx bool B2DHomMatrix::invert() { + if(isIdentity()) + { + return true; + } + Impl2DHomMatrix aWork(*mpImpl); std::unique_ptr<sal_uInt16[]> pIndex( new sal_uInt16[Impl2DHomMatrix_Base::getEdgeLength()] ); sal_Int16 nParity; @@ -213,6 +218,11 @@ namespace basegfx } } + void B2DHomMatrix::translate(const B2DTuple& rTuple) + { + translate(rTuple.getX(), rTuple.getY()); + } + void B2DHomMatrix::scale(double fX, double fY) { const double fOne(1.0); @@ -228,6 +238,11 @@ namespace basegfx } } + void B2DHomMatrix::scale(const B2DTuple& rTuple) + { + scale(rTuple.getX(), rTuple.getY()); + } + void B2DHomMatrix::shearX(double fSx) { // #i76239# do not test against 1.0, but against 0.0. We are talking about a value not on the diagonal (!) diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx index 6cfd054992ec..b55dd079b514 100644 --- a/basegfx/source/matrix/b3dhommatrix.cxx +++ b/basegfx/source/matrix/b3dhommatrix.cxx @@ -203,6 +203,11 @@ namespace basegfx } } + void B3DHomMatrix::rotate(const B3DTuple& rRotation) + { + rotate(rRotation.getX(), rRotation.getY(), rRotation.getZ()); + } + void B3DHomMatrix::translate(double fX, double fY, double fZ) { if(!fTools::equalZero(fX) || !fTools::equalZero(fY) || !fTools::equalZero(fZ)) @@ -217,6 +222,11 @@ namespace basegfx } } + void B3DHomMatrix::translate(const B3DTuple& rRotation) + { + translate(rRotation.getX(), rRotation.getY(), rRotation.getZ()); + } + void B3DHomMatrix::scale(double fX, double fY, double fZ) { const double fOne(1.0); @@ -233,6 +243,11 @@ namespace basegfx } } + void B3DHomMatrix::scale(const B3DTuple& rRotation) + { + scale(rRotation.getX(), rRotation.getY(), rRotation.getZ()); + } + void B3DHomMatrix::shearXY(double fSx, double fSy) { // #i76239# do not test against 1.0, but against 0.0. We are talking about a value not on the diagonal (!) diff --git a/basegfx/source/matrix/b3dhommatrixtools.cxx b/basegfx/source/matrix/b3dhommatrixtools.cxx new file mode 100755 index 000000000000..e1349df7d97a --- /dev/null +++ b/basegfx/source/matrix/b3dhommatrixtools.cxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <basegfx/matrix/b3dhommatrixtools.hxx> + +namespace basegfx +{ + namespace utils + { + B3DHomMatrix UnoHomogenMatrixToB3DHomMatrix( + const com::sun::star::drawing::HomogenMatrix rMatrixIn) + { + B3DHomMatrix aRetval; + + aRetval.set(0, 0, rMatrixIn.Line1.Column1); + aRetval.set(0, 1, rMatrixIn.Line1.Column2); + aRetval.set(0, 2, rMatrixIn.Line1.Column3); + aRetval.set(0, 3, rMatrixIn.Line1.Column4); + aRetval.set(1, 0, rMatrixIn.Line2.Column1); + aRetval.set(1, 1, rMatrixIn.Line2.Column2); + aRetval.set(1, 2, rMatrixIn.Line2.Column3); + aRetval.set(1, 3, rMatrixIn.Line2.Column4); + aRetval.set(2, 0, rMatrixIn.Line3.Column1); + aRetval.set(2, 1, rMatrixIn.Line3.Column2); + aRetval.set(2, 2, rMatrixIn.Line3.Column3); + aRetval.set(2, 3, rMatrixIn.Line3.Column4); + aRetval.set(3, 0, rMatrixIn.Line4.Column1); + aRetval.set(3, 1, rMatrixIn.Line4.Column2); + aRetval.set(3, 2, rMatrixIn.Line4.Column3); + aRetval.set(3, 3, rMatrixIn.Line4.Column4); + + return aRetval; + } + + void B3DHomMatrixToUnoHomogenMatrix( + const B3DHomMatrix& rMatrixIn, + com::sun::star::drawing::HomogenMatrix& rMatrixOut) + { + rMatrixOut.Line1.Column1 = rMatrixIn.get(0, 0); + rMatrixOut.Line1.Column2 = rMatrixIn.get(0, 1); + rMatrixOut.Line1.Column3 = rMatrixIn.get(0, 2); + rMatrixOut.Line1.Column4 = rMatrixIn.get(0, 3); + rMatrixOut.Line2.Column1 = rMatrixIn.get(1, 0); + rMatrixOut.Line2.Column2 = rMatrixIn.get(1, 1); + rMatrixOut.Line2.Column3 = rMatrixIn.get(1, 2); + rMatrixOut.Line2.Column4 = rMatrixIn.get(1, 3); + rMatrixOut.Line3.Column1 = rMatrixIn.get(2, 0); + rMatrixOut.Line3.Column2 = rMatrixIn.get(2, 1); + rMatrixOut.Line3.Column3 = rMatrixIn.get(2, 2); + rMatrixOut.Line3.Column4 = rMatrixIn.get(2, 3); + rMatrixOut.Line4.Column1 = rMatrixIn.get(3, 0); + rMatrixOut.Line4.Column2 = rMatrixIn.get(3, 1); + rMatrixOut.Line4.Column3 = rMatrixIn.get(3, 2); + rMatrixOut.Line4.Column4 = rMatrixIn.get(3, 3); + } + + } // end of namespace tools +} // end of namespace basegfx + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basegfx/source/numeric/ftools.cxx b/basegfx/source/numeric/ftools.cxx index 994bd29e30eb..d1eca66ca2fc 100644 --- a/basegfx/source/numeric/ftools.cxx +++ b/basegfx/source/numeric/ftools.cxx @@ -45,6 +45,59 @@ namespace basegfx } } + double snapToZeroRange(double v, double fWidth) + { + if(fTools::equalZero(fWidth)) + { + // with no range all snaps to range bound + return 0.0; + } + else + { + if(v < 0.0 || v > fWidth) + { + double fRetval(fmod(v, fWidth)); + + if(fRetval < 0.0) + { + fRetval += fWidth; + } + + return fRetval; + } + else + { + return v; + } + } + } + + double snapToRange(double v, double fLow, double fHigh) + { + if(fTools::equal(fLow, fHigh)) + { + // with no range all snaps to range bound + return 0.0; + } + else + { + if(fLow > fHigh) + { + // correct range order. Evtl. assert this (?) + std::swap(fLow, fHigh); + } + + if(v < fLow || v > fHigh) + { + return snapToZeroRange(v - fLow, fHigh - fLow) + fLow; + } + else + { + return v; + } + } + } + double normalizeToRange(double v, const double fRange) { if(fTools::lessOrEqual(fRange, 0.0)) diff --git a/basegfx/source/range/b2drange.cxx b/basegfx/source/range/b2drange.cxx index 2f4a3e08e69e..331c5431bcf3 100644 --- a/basegfx/source/range/b2drange.cxx +++ b/basegfx/source/range/b2drange.cxx @@ -51,6 +51,19 @@ namespace basegfx } } + B2DRange& B2DRange::operator*=( const ::basegfx::B2DHomMatrix& rMat ) + { + transform(rMat); + return *this; + } + + const B2DRange& B2DRange::getUnitB2DRange() + { + static const B2DRange aUnitB2DRange(0.0, 0.0, 1.0, 1.0); + + return aUnitB2DRange; + } + B2IRange fround(const B2DRange& rRange) { return rRange.isEmpty() ? @@ -58,6 +71,13 @@ namespace basegfx B2IRange(fround(rRange.getMinimum()), fround(rRange.getMaximum())); } + + B2DRange operator*( const ::basegfx::B2DHomMatrix& rMat, const B2DRange& rB2DRange ) + { + B2DRange aRes( rB2DRange ); + return aRes *= rMat; + } + } // end of namespace basegfx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basegfx/source/range/b3drange.cxx b/basegfx/source/range/b3drange.cxx index f779f1855d79..879dbb0f9974 100644 --- a/basegfx/source/range/b3drange.cxx +++ b/basegfx/source/range/b3drange.cxx @@ -40,6 +40,25 @@ namespace basegfx } } + B3DRange& B3DRange::operator*=( const ::basegfx::B3DHomMatrix& rMat ) + { + transform(rMat); + return *this; + } + + const B3DRange& B3DRange::getUnitB3DRange() + { + static const B3DRange aUnitB3DRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); + + return aUnitB3DRange; + } + + B3DRange operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DRange& rB3DRange ) + { + B3DRange aRes( rB3DRange ); + return aRes *= rMat; + } + } // end of namespace basegfx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basegfx/matrix/b2dhommatrix.hxx b/include/basegfx/matrix/b2dhommatrix.hxx index a7ab0c3f5917..9f2c8a338412 100644 --- a/include/basegfx/matrix/b2dhommatrix.hxx +++ b/include/basegfx/matrix/b2dhommatrix.hxx @@ -74,8 +74,10 @@ namespace basegfx void rotate(double fRadiant); void translate(double fX, double fY); + void translate(const B2DTuple& rTuple); void scale(double fX, double fY); + void scale(const B2DTuple& rTuple); // Shearing-Matrices void shearX(double fSx); diff --git a/include/basegfx/matrix/b3dhommatrix.hxx b/include/basegfx/matrix/b3dhommatrix.hxx index 09d700547363..6d5d5c486b9b 100644 --- a/include/basegfx/matrix/b3dhommatrix.hxx +++ b/include/basegfx/matrix/b3dhommatrix.hxx @@ -64,12 +64,15 @@ namespace basegfx /// Rotation void rotate(double fAngleX,double fAngleY,double fAngleZ); + void rotate(const B3DTuple& rRotation); /// Translation void translate(double fX, double fY, double fZ); + void translate(const B3DTuple& rTranslation); /// Scaling void scale(double fX, double fY, double fZ); + void scale(const B3DTuple& rScale); // Shearing-Matrices void shearXY(double fSx, double fSy); diff --git a/include/basegfx/matrix/b3dhommatrixtools.hxx b/include/basegfx/matrix/b3dhommatrixtools.hxx new file mode 100755 index 000000000000..1d4247579690 --- /dev/null +++ b/include/basegfx/matrix/b3dhommatrixtools.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX +#define INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX + +#include <sal/types.h> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <com/sun/star/drawing/HomogenMatrix.hpp> + +namespace basegfx +{ + namespace utils + { + /* tooling methods for converting API matrices (drawing::HomogenMatrix) to + B3DHomMatrix. drawing::HomogenMatrix4 is not used by OOo + */ + BASEGFX_DLLPUBLIC B3DHomMatrix UnoHomogenMatrixToB3DHomMatrix( + const com::sun::star::drawing::HomogenMatrix rMatrixIn); + + BASEGFX_DLLPUBLIC void B3DHomMatrixToUnoHomogenMatrix( + const B3DHomMatrix& rMatrixIn, + com::sun::star::drawing::HomogenMatrix& rMatrixOut); + + } // end of namespace tools +} // end of namespace basegfx + +#endif // INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx index 52909c9cd75b..1ade3bb3a3d6 100644 --- a/include/basegfx/numeric/ftools.hxx +++ b/include/basegfx/numeric/ftools.hxx @@ -153,6 +153,25 @@ namespace basegfx */ BASEGFX_DLLPUBLIC double snapToNearestMultiple(double v, const double fStep); + /** Snap v to the range [0.0 .. fWidth] using modulo + */ + double snapToZeroRange(double v, double fWidth); + + /** Snap v to the range [fLow .. fHigh] using modulo + */ + double snapToRange(double v, double fLow, double fHigh); + + /** return fValue with the sign of fSignCarrier, thus evtl. changed + */ + inline double copySign(double fValue, double fSignCarrier) + { +#ifdef WNT + return _copysign(fValue, fSignCarrier); +#else + return copysign(fValue, fSignCarrier); +#endif + } + /** RotateFlyFrame3: Normalize to range defined by [0.0 ... fRange[, independent if v is positive or negative. diff --git a/include/basegfx/range/b1drange.hxx b/include/basegfx/range/b1drange.hxx index c1e35b13605c..7b0d22869559 100644 --- a/include/basegfx/range/b1drange.hxx +++ b/include/basegfx/range/b1drange.hxx @@ -141,6 +141,11 @@ namespace basegfx maRange.intersect(rRange.maRange); } + /// clamp value on range + double clamp(double fValue) const + { + return maRange.clamp(fValue); + } }; } // end of namespace basegfx diff --git a/include/basegfx/range/b2drange.hxx b/include/basegfx/range/b2drange.hxx index 0de9dba0e783..00eab63d1472 100644 --- a/include/basegfx/range/b2drange.hxx +++ b/include/basegfx/range/b2drange.hxx @@ -274,8 +274,29 @@ namespace basegfx maRangeY.grow(fValue); } + /// clamp value on range + B2DTuple clamp(const B2DTuple& rTuple) const + { + return B2DTuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY())); + } + + /** Transform Range by given transformation matrix. */ BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix& rMatrix); + /** Transform Range by given transformation matrix. + + This operation transforms the Range by transforming all four possible + extrema points (corners) of the given range and building a new one. + This means that the range will grow evtl. when a shear and/or rotation + is part of the transformation. + */ + B2DRange& operator*=( const ::basegfx::B2DHomMatrix& rMat ); + + /** Get a range filled with (0.0, 0.0, 1.0, 1.0) */ + static const B2DRange& getUnitB2DRange(); + private: typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange; @@ -283,6 +304,10 @@ namespace basegfx MyBasicRange maRangeY; }; + /** Transform B2DRange by given transformation matrix (see operator*=()) + */ + B2DRange operator*( const B2DHomMatrix& rMat, const B2DRange& rB2DRange ); + /** Round double to nearest integer for 2D range @return the nearest integer for this range diff --git a/include/basegfx/range/b2irange.hxx b/include/basegfx/range/b2irange.hxx index 3d7d0edba6c9..a8a95d69ceed 100644 --- a/include/basegfx/range/b2irange.hxx +++ b/include/basegfx/range/b2irange.hxx @@ -208,6 +208,13 @@ namespace basegfx maRangeY.intersect(rRange.maRangeY); } + B2ITuple clamp(const B2ITuple& rTuple) const + { + return B2ITuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY())); + } + private: typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange; diff --git a/include/basegfx/range/b3drange.hxx b/include/basegfx/range/b3drange.hxx index 881dce612297..e1c44393813a 100644 --- a/include/basegfx/range/b3drange.hxx +++ b/include/basegfx/range/b3drange.hxx @@ -195,9 +195,34 @@ namespace basegfx maRangeZ.grow(fValue); } + /// clamp value on range + B3DTuple clamp(const B3DTuple& rTuple) const + { + return B3DTuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY()), + maRangeZ.clamp(rTuple.getZ())); + } + BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix); + + /** Transform Range by given transformation matrix. + + This operation transforms the Range by transforming all eight possible + extrema points (corners) of the given range and building a new one. + This means that the range will grow evtl. when a shear and/or rotation + is part of the transformation. + */ + B3DRange& operator*=( const ::basegfx::B3DHomMatrix& rMat ); + + /** Get a range filled with (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) */ + static const B3DRange& getUnitB3DRange(); }; + /** Transform B3DRange by given transformation matrix (see operator*=()) + */ + B3DRange operator*( const B3DHomMatrix& rMat, const B3DRange& rB2DRange ); + } // end of namespace basegfx diff --git a/include/basegfx/range/basicrange.hxx b/include/basegfx/range/basicrange.hxx index bea40dd3ded2..17f31ea42f19 100644 --- a/include/basegfx/range/basicrange.hxx +++ b/include/basegfx/range/basicrange.hxx @@ -248,6 +248,28 @@ namespace basegfx } } + T clamp(T nValue) const + { + if(isEmpty()) + { + return nValue; + } + else + { + if(nValue < mnMinimum) + { + return mnMinimum; + } + + if(nValue > mnMaximum) + { + return mnMaximum; + } + + return nValue; + } + } + typename Traits::DifferenceType getRange() const { if(isEmpty()) diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx index 66ac52b876db..c7bbc8bc1c65 100644 --- a/svx/source/unodraw/unoshap3.cxx +++ b/svx/source/unodraw/unoshap3.cxx @@ -45,6 +45,7 @@ #include <basegfx/polygon/b3dpolygontools.hxx> #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/matrix/b3dhommatrixtools.hxx> #include "shapeimpl.hxx" using namespace ::cppu; @@ -227,27 +228,10 @@ sal_Bool SAL_CALL Svx3DSceneObject::hasElements() static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue ) { - drawing::HomogenMatrix m; - if( rValue >>= m ) + drawing::HomogenMatrix aMat; + if( rValue >>= aMat ) { - basegfx::B3DHomMatrix aMat; - aMat.set(0, 0, m.Line1.Column1); - aMat.set(0, 1, m.Line1.Column2); - aMat.set(0, 2, m.Line1.Column3); - aMat.set(0, 3, m.Line1.Column4); - aMat.set(1, 0, m.Line2.Column1); - aMat.set(1, 1, m.Line2.Column2); - aMat.set(1, 2, m.Line2.Column3); - aMat.set(1, 3, m.Line2.Column4); - aMat.set(2, 0, m.Line3.Column1); - aMat.set(2, 1, m.Line3.Column2); - aMat.set(2, 2, m.Line3.Column3); - aMat.set(2, 3, m.Line3.Column4); - aMat.set(3, 0, m.Line4.Column1); - aMat.set(3, 1, m.Line4.Column2); - aMat.set(3, 2, m.Line4.Column3); - aMat.set(3, 3, m.Line4.Column4); - pObject->SetTransform(aMat); + pObject->SetTransform(basegfx::utils::UnoHomogenMatrixToB3DHomMatrix(aMat)); return true; } return false; @@ -257,22 +241,7 @@ static void ConvertObjectToHomogenMatric( E3dObject const * pObject, Any& rValue { drawing::HomogenMatrix aHomMat; const basegfx::B3DHomMatrix& rMat = pObject->GetTransform(); - aHomMat.Line1.Column1 = rMat.get(0, 0); - aHomMat.Line1.Column2 = rMat.get(0, 1); - aHomMat.Line1.Column3 = rMat.get(0, 2); - aHomMat.Line1.Column4 = rMat.get(0, 3); - aHomMat.Line2.Column1 = rMat.get(1, 0); - aHomMat.Line2.Column2 = rMat.get(1, 1); - aHomMat.Line2.Column3 = rMat.get(1, 2); - aHomMat.Line2.Column4 = rMat.get(1, 3); - aHomMat.Line3.Column1 = rMat.get(2, 0); - aHomMat.Line3.Column2 = rMat.get(2, 1); - aHomMat.Line3.Column3 = rMat.get(2, 2); - aHomMat.Line3.Column4 = rMat.get(2, 3); - aHomMat.Line4.Column1 = rMat.get(3, 0); - aHomMat.Line4.Column2 = rMat.get(3, 1); - aHomMat.Line4.Column3 = rMat.get(3, 2); - aHomMat.Line4.Column4 = rMat.get(3, 3); + basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(rMat, aHomMat); rValue <<= aHomMat; } @@ -824,25 +793,7 @@ bool Svx3DLatheObject::getPropertyValueImpl( const OUString& rName, const SfxIte // pack transformation to a homogeneous matrix drawing::HomogenMatrix aHomMat; basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform(); - - // pack evtl. transformed matrix to output - aHomMat.Line1.Column1 = aMat.get(0, 0); - aHomMat.Line1.Column2 = aMat.get(0, 1); - aHomMat.Line1.Column3 = aMat.get(0, 2); - aHomMat.Line1.Column4 = aMat.get(0, 3); - aHomMat.Line2.Column1 = aMat.get(1, 0); - aHomMat.Line2.Column2 = aMat.get(1, 1); - aHomMat.Line2.Column3 = aMat.get(1, 2); - aHomMat.Line2.Column4 = aMat.get(1, 3); - aHomMat.Line3.Column1 = aMat.get(2, 0); - aHomMat.Line3.Column2 = aMat.get(2, 1); - aHomMat.Line3.Column3 = aMat.get(2, 2); - aHomMat.Line3.Column4 = aMat.get(2, 3); - aHomMat.Line4.Column1 = aMat.get(3, 0); - aHomMat.Line4.Column2 = aMat.get(3, 1); - aHomMat.Line4.Column3 = aMat.get(3, 2); - aHomMat.Line4.Column4 = aMat.get(3, 3); - + basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat); rValue <<= aHomMat; break; } @@ -923,25 +874,7 @@ bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxI // pack transformation to a homogeneous matrix drawing::HomogenMatrix aHomMat; basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform(); - - // pack evtl. transformed matrix to output - aHomMat.Line1.Column1 = aMat.get(0, 0); - aHomMat.Line1.Column2 = aMat.get(0, 1); - aHomMat.Line1.Column3 = aMat.get(0, 2); - aHomMat.Line1.Column4 = aMat.get(0, 3); - aHomMat.Line2.Column1 = aMat.get(1, 0); - aHomMat.Line2.Column2 = aMat.get(1, 1); - aHomMat.Line2.Column3 = aMat.get(1, 2); - aHomMat.Line2.Column4 = aMat.get(1, 3); - aHomMat.Line3.Column1 = aMat.get(2, 0); - aHomMat.Line3.Column2 = aMat.get(2, 1); - aHomMat.Line3.Column3 = aMat.get(2, 2); - aHomMat.Line3.Column4 = aMat.get(2, 3); - aHomMat.Line4.Column1 = aMat.get(3, 0); - aHomMat.Line4.Column2 = aMat.get(3, 1); - aHomMat.Line4.Column3 = aMat.get(3, 2); - aHomMat.Line4.Column4 = aMat.get(3, 3); - + basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat); rValue <<= aHomMat; break; } diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index 4601f35b485d..54f7f70631a1 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -33,6 +33,7 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/utils/unotools.hxx> +#include <basegfx/matrix/b3dhommatrixtools.hxx> using namespace ::com::sun::star; @@ -600,22 +601,7 @@ void SdXMLImExTransform3D::AddMatrix(const ::basegfx::B3DHomMatrix& rNew) void SdXMLImExTransform3D::AddHomogenMatrix(const drawing::HomogenMatrix& xHomMat) { - ::basegfx::B3DHomMatrix aExportMatrix; - - aExportMatrix.set(0, 0, xHomMat.Line1.Column1); - aExportMatrix.set(0, 1, xHomMat.Line1.Column2); - aExportMatrix.set(0, 2, xHomMat.Line1.Column3); - aExportMatrix.set(0, 3, xHomMat.Line1.Column4); - aExportMatrix.set(1, 0, xHomMat.Line2.Column1); - aExportMatrix.set(1, 1, xHomMat.Line2.Column2); - aExportMatrix.set(1, 2, xHomMat.Line2.Column3); - aExportMatrix.set(1, 3, xHomMat.Line2.Column4); - aExportMatrix.set(2, 0, xHomMat.Line3.Column1); - aExportMatrix.set(2, 1, xHomMat.Line3.Column2); - aExportMatrix.set(2, 2, xHomMat.Line3.Column3); - aExportMatrix.set(2, 3, xHomMat.Line3.Column4); - - AddMatrix(aExportMatrix); + AddMatrix(basegfx::utils::UnoHomogenMatrixToB3DHomMatrix(xHomMat)); } // gen string for export @@ -928,26 +914,7 @@ bool SdXMLImExTransform3D::GetFullHomogenTransform(css::drawing::HomogenMatrix& if(!aFullTransform.isIdentity()) { - xHomMat.Line1.Column1 = aFullTransform.get(0, 0); - xHomMat.Line1.Column2 = aFullTransform.get(0, 1); - xHomMat.Line1.Column3 = aFullTransform.get(0, 2); - xHomMat.Line1.Column4 = aFullTransform.get(0, 3); - - xHomMat.Line2.Column1 = aFullTransform.get(1, 0); - xHomMat.Line2.Column2 = aFullTransform.get(1, 1); - xHomMat.Line2.Column3 = aFullTransform.get(1, 2); - xHomMat.Line2.Column4 = aFullTransform.get(1, 3); - - xHomMat.Line3.Column1 = aFullTransform.get(2, 0); - xHomMat.Line3.Column2 = aFullTransform.get(2, 1); - xHomMat.Line3.Column3 = aFullTransform.get(2, 2); - xHomMat.Line3.Column4 = aFullTransform.get(2, 3); - - xHomMat.Line4.Column1 = aFullTransform.get(3, 0); - xHomMat.Line4.Column2 = aFullTransform.get(3, 1); - xHomMat.Line4.Column3 = aFullTransform.get(3, 2); - xHomMat.Line4.Column4 = aFullTransform.get(3, 3); - + basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aFullTransform, xHomMat); return true; } |