summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/tools
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/inc/basegfx/tools')
-rw-r--r--basegfx/inc/basegfx/tools/b2dclipstate.hxx119
-rwxr-xr-xbasegfx/inc/basegfx/tools/canvastools.hxx221
-rw-r--r--basegfx/inc/basegfx/tools/debugplotter.hxx107
-rw-r--r--basegfx/inc/basegfx/tools/gradienttools.hxx410
-rw-r--r--basegfx/inc/basegfx/tools/keystoplerp.hxx100
-rw-r--r--basegfx/inc/basegfx/tools/lerp.hxx60
-rw-r--r--basegfx/inc/basegfx/tools/rectcliptools.hxx88
-rw-r--r--basegfx/inc/basegfx/tools/tools.hxx131
-rwxr-xr-xbasegfx/inc/basegfx/tools/unopolypolygon.hxx112
9 files changed, 1348 insertions, 0 deletions
diff --git a/basegfx/inc/basegfx/tools/b2dclipstate.hxx b/basegfx/inc/basegfx/tools/b2dclipstate.hxx
new file mode 100644
index 000000000000..7d336d8cb48e
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/b2dclipstate.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: rectcliptools.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_CLIPSTATE_HXX
+#define _BGFX_TOOLS_CLIPSTATE_HXX
+
+#include <sal/types.h>
+#include <o3tl/cow_wrapper.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ class B2DRange;
+ class B2DPolyRange;
+ class B2DPolygon;
+ class B2DPolyPolygon;
+
+ namespace tools
+ {
+ class ImplB2DClipState;
+
+ /** This class provides an optimized, symbolic clip state for graphical output
+
+ Having a current 'clip' state is a common attribute of
+ almost all graphic output APIs, most of which internally
+ represent it via a list of rectangular bands. In contrast,
+ this implementation purely uses symbolic clips, but in a
+ quite efficient manner, deferring actual evaluation until
+ a clip representation is requested, and using faster code
+ paths for common special cases (like all-rectangle clips)
+ */
+ class B2DClipState
+ {
+ public:
+ typedef o3tl::cow_wrapper< ImplB2DClipState > ImplType;
+
+ private:
+ ImplType mpImpl;
+
+ public:
+ /// Init clip, in 'cleared' state - everything is visible
+ B2DClipState();
+ ~B2DClipState();
+ B2DClipState( const B2DClipState& );
+ explicit B2DClipState( const B2DRange& );
+ explicit B2DClipState( const B2DPolygon& );
+ explicit B2DClipState( const B2DPolyPolygon& );
+ B2DClipState& operator=( const B2DClipState& );
+
+ /// unshare this poly-range with all internally shared instances
+ void makeUnique();
+
+ /// Set clip to 'null' - nothing is visible
+ void makeNull();
+ /// returns true when clip is 'null' - nothing is visible
+ bool isNull() const;
+
+ /// Set clip 'cleared' - everything is visible
+ void makeClear();
+ /// returns true when clip is 'cleared' - everything is visible
+ bool isCleared() const;
+
+ bool operator==(const B2DClipState&) const;
+ bool operator!=(const B2DClipState&) const;
+
+ void unionRange(const B2DRange& );
+ void unionPolygon(const B2DPolygon& );
+ void unionPolyPolygon(const B2DPolyPolygon& );
+ void unionClipState(const B2DClipState& );
+
+ void intersectRange(const B2DRange& );
+ void intersectPolygon(const B2DPolygon& );
+ void intersectPolyPolygon(const B2DPolyPolygon& );
+ void intersectClipState(const B2DClipState& );
+
+ void subtractRange(const B2DRange& );
+ void subtractPolygon(const B2DPolygon& );
+ void subtractPolyPolygon(const B2DPolyPolygon& );
+ void subtractClipState(const B2DClipState& );
+
+ void xorRange(const B2DRange& );
+ void xorPolygon(const B2DPolygon& );
+ void xorPolyPolygon(const B2DPolyPolygon& );
+ void xorClipState(const B2DClipState& );
+
+ B2DPolyPolygon getClipPoly() const;
+ };
+ }
+}
+
+#endif // _BGFX_TOOLS_CLIPSTATE_HXX
diff --git a/basegfx/inc/basegfx/tools/canvastools.hxx b/basegfx/inc/basegfx/tools/canvastools.hxx
new file mode 100755
index 000000000000..1903518d991b
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/canvastools.hxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#define _BGFX_TOOLS_CANVASTOOLS_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+
+namespace com { namespace sun { namespace star { namespace geometry
+{
+ struct AffineMatrix2D;
+ struct AffineMatrix3D;
+ struct Matrix2D;
+ struct RealPoint2D;
+ struct RealSize2D;
+ struct RealRectangle2D;
+ struct RealRectangle3D;
+ struct IntegerPoint2D;
+ struct IntegerSize2D;
+ struct IntegerRectangle2D;
+ struct RealBezierSegment2D;
+} } } }
+
+namespace com { namespace sun { namespace star { namespace rendering
+{
+ class XGraphicDevice;
+ class XPolyPolygon2D;
+} } } }
+
+namespace com { namespace sun { namespace star { namespace awt
+{
+ struct Point;
+ struct Size;
+ struct Rectangle;
+} } } }
+
+namespace basegfx
+{
+ class B2DHomMatrix;
+ class B3DHomMatrix;
+ class B2DVector;
+ class B2DPoint;
+ class B2DRange;
+ class B3DRange;
+ class B2IVector;
+ class B2IPoint;
+ class B2IRange;
+ class B2DPolygon;
+ class B2DPolyPolygon;
+
+ namespace unotools
+ {
+ // Polygon conversions
+ // ===================================================================
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
+ xPolyPolygonFromB2DPolygon( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice,
+ const ::basegfx::B2DPolygon& rPoly );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
+ xPolyPolygonFromB2DPolyPolygon( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice,
+ const ::basegfx::B2DPolyPolygon& rPolyPoly );
+
+
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::geometry::RealBezierSegment2D > >
+ bezierSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly );
+
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::geometry::RealPoint2D > >
+ pointSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly );
+
+ ::basegfx::B2DPolygon polygonFromPoint2DSequence(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::geometry::RealPoint2D >& rPoints );
+
+ ::basegfx::B2DPolyPolygon polyPolygonFromPoint2DSequenceSequence(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& rPoints );
+
+ ::basegfx::B2DPolygon polygonFromBezier2DSequence(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::geometry::RealBezierSegment2D >& rPoints );
+
+ ::basegfx::B2DPolyPolygon polyPolygonFromBezier2DSequenceSequence(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& rPoints );
+
+ ::basegfx::B2DPolyPolygon b2DPolyPolygonFromXPolyPolygon2D(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XPolyPolygon2D >& rPoly );
+
+ // Matrix conversions
+ // ===================================================================
+
+ ::com::sun::star::geometry::AffineMatrix2D&
+ affineMatrixFromHomMatrix( ::com::sun::star::geometry::AffineMatrix2D& matrix,
+ const ::basegfx::B2DHomMatrix& transform);
+
+ ::com::sun::star::geometry::AffineMatrix3D& affineMatrixFromHomMatrix3D(
+ ::com::sun::star::geometry::AffineMatrix3D& matrix,
+ const ::basegfx::B3DHomMatrix& transform);
+
+ ::basegfx::B2DHomMatrix&
+ homMatrixFromAffineMatrix( ::basegfx::B2DHomMatrix& transform,
+ const ::com::sun::star::geometry::AffineMatrix2D& matrix );
+
+ ::basegfx::B2DHomMatrix homMatrixFromAffineMatrix( const ::com::sun::star::geometry::AffineMatrix2D& matrix );
+ ::basegfx::B3DHomMatrix homMatrixFromAffineMatrix3D( const ::com::sun::star::geometry::AffineMatrix3D& matrix );
+
+ ::com::sun::star::geometry::Matrix2D&
+ matrixFromHomMatrix( ::com::sun::star::geometry::Matrix2D& matrix,
+ const ::basegfx::B2DHomMatrix& transform);
+
+ ::basegfx::B2DHomMatrix&
+ homMatrixFromMatrix( ::basegfx::B2DHomMatrix& transform,
+ const ::com::sun::star::geometry::Matrix2D& matrix );
+
+ // Geometry conversions
+ // ===================================================================
+
+ ::com::sun::star::geometry::RealSize2D size2DFromB2DSize( const ::basegfx::B2DVector& );
+ ::com::sun::star::geometry::RealPoint2D point2DFromB2DPoint( const ::basegfx::B2DPoint& );
+ ::com::sun::star::geometry::RealRectangle2D rectangle2DFromB2DRectangle( const ::basegfx::B2DRange& );
+ ::com::sun::star::geometry::RealRectangle3D rectangle3DFromB3DRectangle( const ::basegfx::B3DRange& );
+
+ ::basegfx::B2DVector b2DSizeFromRealSize2D( const ::com::sun::star::geometry::RealSize2D& );
+ ::basegfx::B2DPoint b2DPointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& );
+ ::basegfx::B2DRange b2DRectangleFromRealRectangle2D( const ::com::sun::star::geometry::RealRectangle2D& );
+ ::basegfx::B3DRange b3DRectangleFromRealRectangle3D( const ::com::sun::star::geometry::RealRectangle3D& );
+
+ ::com::sun::star::geometry::IntegerSize2D integerSize2DFromB2ISize( const ::basegfx::B2IVector& );
+ ::com::sun::star::geometry::IntegerPoint2D integerPoint2DFromB2IPoint( const ::basegfx::B2IPoint& );
+ ::com::sun::star::geometry::IntegerRectangle2D integerRectangle2DFromB2IRectangle( const ::basegfx::B2IRange& );
+
+ ::basegfx::B2IVector b2ISizeFromIntegerSize2D( const ::com::sun::star::geometry::IntegerSize2D& );
+ ::basegfx::B2IPoint b2IPointFromIntegerPoint2D( const ::com::sun::star::geometry::IntegerPoint2D& );
+ ::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D( const ::com::sun::star::geometry::IntegerRectangle2D& );
+
+ ::com::sun::star::awt::Size awtSizeFromB2ISize( const ::basegfx::B2IVector& );
+ ::com::sun::star::awt::Point awtPointFromB2IPoint( const ::basegfx::B2IPoint& );
+ ::com::sun::star::awt::Rectangle awtRectangleFromB2IRectangle( const ::basegfx::B2IRange& );
+
+ ::basegfx::B2IVector b2ISizeFromAwtSize( const ::com::sun::star::awt::Size& );
+ ::basegfx::B2IPoint b2IPointFromAwtPoint( const ::com::sun::star::awt::Point& );
+ ::basegfx::B2IRange b2IRectangleFromAwtRectangle( const ::com::sun::star::awt::Rectangle& );
+
+ // Geometry comparisons
+ // ===================================================================
+
+ bool RealSize2DAreEqual( const ::com::sun::star::geometry::RealSize2D& rA, const ::com::sun::star::geometry::RealSize2D& rB );
+ bool RealPoint2DAreEqual( const ::com::sun::star::geometry::RealPoint2D& rA, const ::com::sun::star::geometry::RealPoint2D& rB );
+ bool RealRectangle2DAreEqual( const ::com::sun::star::geometry::RealRectangle2D& rA, const ::com::sun::star::geometry::RealRectangle2D& rB );
+ bool RealRectangle3DAreEqual( const ::com::sun::star::geometry::RealRectangle3D& rA, const ::com::sun::star::geometry::RealRectangle3D& rB );
+ bool AffineMatrix2DAreEqual( const ::com::sun::star::geometry::AffineMatrix2D& rA, const ::com::sun::star::geometry::AffineMatrix2D& rB );
+
+ bool IntegerSize2DAreEqual( const ::com::sun::star::geometry::IntegerSize2D& rA, const ::com::sun::star::geometry::IntegerSize2D& rB );
+ bool IntegerPoint2DAreEqual( const ::com::sun::star::geometry::IntegerPoint2D& rA, const ::com::sun::star::geometry::IntegerPoint2D& rB );
+ bool IntegerRectangle2DAreEqual( const ::com::sun::star::geometry::IntegerRectangle2D& rA, const ::com::sun::star::geometry::IntegerRectangle2D& rB );
+
+ bool awtSizeAreEqual( const ::com::sun::star::awt::Size& rA, const ::com::sun::star::awt::Size& rB );
+ bool awtPointAreEqual( const ::com::sun::star::awt::Point& rA, const ::com::sun::star::awt::Point& rB );
+ bool awtRectangleAreEqual( const ::com::sun::star::awt::Rectangle& rA, const ::com::sun::star::awt::Rectangle& rB );
+
+ /** Return smalltest integer range, which completely contains
+ given floating point range.
+
+ @param rRange
+ Input range. Values must be within the representable
+ bounds of sal_Int32
+
+ @return the closest integer range, which completely
+ contains rRange.
+ */
+ ::basegfx::B2IRange b2ISurroundingRangeFromB2DRange( const ::basegfx::B2DRange& rRange );
+
+ /** Return smalltest B2DRange with integer values, which
+ completely contains given floating point range.
+
+ @param rRange
+ Input range.
+
+ @return the closest B2DRange with integer coordinates,
+ which completely contains rRange.
+ */
+ ::basegfx::B2DRange b2DSurroundingIntegerRangeFromB2DRange( const ::basegfx::B2DRange& rRange );
+
+ }
+}
+
+#endif /* _BGFX_TOOLS_CANVASTOOLS_HXX */
diff --git a/basegfx/inc/basegfx/tools/debugplotter.hxx b/basegfx/inc/basegfx/tools/debugplotter.hxx
new file mode 100644
index 000000000000..ece104af3553
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/debugplotter.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_DEBUGPLOTTER_HXX
+#define _BGFX_TOOLS_DEBUGPLOTTER_HXX
+
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <rtl/string.hxx>
+#include <boost/utility.hpp> // for noncopyable
+#include <vector>
+#include <utility>
+#include <iostream>
+
+
+namespace basegfx
+{
+ class B2DCubicBezier;
+
+ /** Generates debug output for various basegfx data types.
+
+ Use this class to produce debug (trace) output for various
+ basegfx geometry data types. By default, this class outputs
+ via OSL_TRACE (i.e. to stderr), and uses the gnuplot output
+ format.
+
+ To be able to generate one coherent block of output, this
+ class delays actual writing to its destructor
+ */
+ class DebugPlotter : private ::boost::noncopyable
+ {
+ public:
+ /** Create new debug output object
+
+ @param pTitle
+ Title of the debug output, will appear in trace output
+ */
+ explicit DebugPlotter( const sal_Char* pTitle );
+
+ /** Create new debug output object
+
+ @param pTitle
+ Title of the debug output, will appear in trace output
+
+ @param rOutputStream
+ Stream to write output to. Must stay valid over the
+ lifetime of this object!
+ */
+ DebugPlotter( const sal_Char* pTitle,
+ ::std::ostream& rOutputStream );
+
+ ~DebugPlotter();
+
+ void plot( const B2DPoint& rPoint,
+ const sal_Char* pTitle );
+ void plot( const B2DVector& rVec,
+ const sal_Char* pTitle );
+ void plot( const B2DCubicBezier& rBezier,
+ const sal_Char* pTitle );
+ void plot( const B2DRange& rRange,
+ const sal_Char* pTitle );
+ void plot( const B2DPolygon& rPoly,
+ const sal_Char* pTitle );
+ void plot( const B2DPolyPolygon& rPoly,
+ const sal_Char* pTitle );
+
+ private:
+ void print( const sal_Char* );
+
+ ::rtl::OString maTitle;
+ ::std::vector< ::std::pair< B2DPoint, ::rtl::OString > > maPoints;
+ ::std::vector< ::std::pair< B2DVector, ::rtl::OString > > maVectors;
+ ::std::vector< ::std::pair< B2DRange, ::rtl::OString > > maRanges;
+ ::std::vector< ::std::pair< B2DPolygon, ::rtl::OString > > maPolygons;
+
+ ::std::ostream* mpOutputStream;
+ };
+}
+
+#endif /* _BGFX_TOOLS_DEBUGPLOTTER_HXX */
diff --git a/basegfx/inc/basegfx/tools/gradienttools.hxx b/basegfx/inc/basegfx/tools/gradienttools.hxx
new file mode 100644
index 000000000000..2f436fa1d717
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/gradienttools.hxx
@@ -0,0 +1,410 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_GRADIENTTOOLS_HXX
+#define _BGFX_TOOLS_GRADIENTTOOLS_HXX
+
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <vector>
+#include <algorithm>
+
+namespace basegfx
+{
+ /** Gradient definition as used in ODF 1.2
+
+ This struct collects all data necessary for rendering ODF
+ 1.2-compatible gradients. Use the createXXXODFGradientInfo()
+ methods below for initializing from ODF attributes.
+ */
+ struct ODFGradientInfo
+ {
+ /** transformation mapping from [0,1]^2 texture coordinate
+ space to [0,1]^2 shape coordinate space
+ */
+ B2DHomMatrix maTextureTransform;
+
+ /** transformation mapping from [0,1]^2 shape coordinate space
+ to [0,1]^2 texture coordinate space. This is the
+ transformation commonly used to create gradients from a
+ scanline rasterizer (put shape u/v coordinates into it, get
+ texture s/t coordinates out of it)
+ */
+ B2DHomMatrix maBackTextureTransform;
+
+ /** Aspect ratio of the gradient. Only used in drawinglayer
+ for generating nested gradient polygons currently. Already
+ catered for in the transformations above.
+ */
+ double mfAspectRatio;
+
+ /** Requested gradient steps to render. See the
+ implementations of the getXXXGradientAlpha() methods below,
+ the semantic differs slightly for the different gradient
+ types.
+ */
+ sal_uInt32 mnSteps;
+ };
+
+ namespace tools
+ {
+ /** Create matrix for ODF's linear gradient definition
+
+ Note that odf linear gradients are varying in y direction.
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createLinearODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ sal_uInt32 nSteps,
+ double fBorder,
+ double fAngle);
+
+ /** Calculate linear gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped. Assumes gradient color varies along the y axis.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getLinearGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV);
+ const double t(clamp(aCoor.getY(), 0.0, 1.0));
+ const sal_uInt32 nSteps(rGradInfo.mnSteps);
+
+ if(nSteps > 2L && nSteps < 128L)
+ return floor(t * nSteps) / double(nSteps + 1L);
+
+ return t;
+ }
+
+ /** Create matrix for ODF's axial gradient definition
+
+ Note that odf axial gradients are varying in y
+ direction. Note further that you can map the axial
+ gradient to a linear gradient (in case you want or need to
+ avoid an extra gradient renderer), by using
+ createLinearODFGradientInfo() instead, shifting the
+ resulting texture transformation by 0.5 to the top and
+ appending the same stop colors again, but mirrored.
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createAxialODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ sal_uInt32 nSteps,
+ double fBorder,
+ double fAngle);
+
+ /** Calculate axial gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped. Assumes gradient color varies along the y axis.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getAxialGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV);
+ const double t(clamp(fabs(aCoor.getY()), 0.0, 1.0));
+ const sal_uInt32 nSteps(rGradInfo.mnSteps);
+ const double fInternalSteps((nSteps * 2L) - 1L);
+
+ if(nSteps > 2L && nSteps < 128L)
+ return floor(((t * fInternalSteps) + 1.0) / 2.0) / double(nSteps - 1L);
+
+ return t;
+ }
+
+ /** Create matrix for ODF's radial gradient definition
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param rOffset
+ Gradient offset value (from ODF)
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createRadialODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ const B2DVector& rOffset,
+ sal_uInt32 nSteps,
+ double fBorder);
+
+ /** Calculate radial gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getRadialGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV);
+ const double fDist(
+ clamp(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY(),
+ 0.0,
+ 1.0));
+
+ const double t(1.0 - sqrt(fDist));
+ const sal_uInt32 nSteps(rGradInfo.mnSteps);
+
+ if(nSteps > 2L && nSteps < 128L)
+ return floor(t * nSteps) / double(nSteps - 1L);
+
+ return t;
+ }
+
+ /** Create matrix for ODF's elliptical gradient definition
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param rOffset
+ Gradient offset value (from ODF)
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createEllipticalODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ const B2DVector& rOffset,
+ sal_uInt32 nSteps,
+ double fBorder,
+ double fAngle);
+
+ /** Calculate elliptical gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getEllipticalGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ return getRadialGradientAlpha(rUV,rGradInfo); // only matrix setup differs
+ }
+
+ /** Create matrix for ODF's square gradient definition
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param rOffset
+ Gradient offset value (from ODF)
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createSquareODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ const B2DVector& rOffset,
+ sal_uInt32 nSteps,
+ double fBorder,
+ double fAngle);
+
+ /** Calculate square gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getSquareGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV);
+ const double fAbsX(fabs(aCoor.getX()));
+ const double fAbsY(fabs(aCoor.getY()));
+
+ if(fTools::moreOrEqual(fAbsX, 1.0) || fTools::moreOrEqual(fAbsY, 1.0))
+ return 0.0;
+
+ const double t(1.0 - (fAbsX > fAbsY ? fAbsX : fAbsY));
+ const sal_uInt32 nSteps(rGradInfo.mnSteps);
+
+ if(nSteps > 2L && nSteps < 128L)
+ return floor(t * nSteps) / double(nSteps - 1L);
+
+ return t;
+ }
+
+ /** Create matrix for ODF's rectangular gradient definition
+
+ @param o_rGradientInfo
+ Receives the calculated texture transformation matrix (for
+ use with standard [0,1]x[0,1] texture coordinates)
+
+ @param rTargetArea
+ Output area, needed for aspect ratio calculations and
+ texture transformation
+
+ @param rOffset
+ Gradient offset value (from ODF)
+
+ @param nSteps
+ Number of gradient steps (from ODF)
+
+ @param fBorder
+ Width of gradient border (from ODF)
+
+ @param fAngle
+ Gradient angle (from ODF)
+ */
+ ODFGradientInfo& createRectangularODFGradientInfo(ODFGradientInfo& o_rGradientInfo,
+ const B2DRange& rTargetArea,
+ const B2DVector& rOffset,
+ sal_uInt32 nSteps,
+ double fBorder,
+ double fAngle);
+
+ /** Calculate rectangular gradient blend value
+
+ This method generates you the lerp alpha value for
+ blending linearly between gradient start and end color,
+ according to the formula (startCol*(1.0-alpha) + endCol*alpha)
+
+ @param rUV
+ Current uv coordinate. Values outside [0,1] will be
+ clamped.
+
+ @param rGradInfo
+ Gradient info, for transformation and number of steps
+ */
+ inline double getRectangularGradientAlpha(const B2DPoint& rUV,
+ const ODFGradientInfo& rGradInfo )
+ {
+ return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs
+ }
+ }
+}
+
+#endif
diff --git a/basegfx/inc/basegfx/tools/keystoplerp.hxx b/basegfx/inc/basegfx/tools/keystoplerp.hxx
new file mode 100644
index 000000000000..a54b3485b1a1
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/keystoplerp.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: canvastools.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_KEYSTOPLERP_HXX
+#define _BGFX_TOOLS_KEYSTOPLERP_HXX
+
+#include <basegfx/numeric/ftools.hxx>
+#include <vector>
+
+namespace com{ namespace sun{ namespace star{ namespace uno {
+ template<typename T> class Sequence;
+}}}}
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Lerp in a vector of key stops
+
+ This class holds a key stop vector and provides the
+ functionality to lerp inside it. Useful e.g. for
+ multi-stop gradients, or the SMIL key time activity.
+
+ For those, given a global [0,1] lerp alpha, one need to
+ find the suitable bucket index from key stop vector, and
+ then calculate the relative alpha between the two buckets
+ found.
+ */
+ class KeyStopLerp
+ {
+ public:
+ typedef std::pair<std::ptrdiff_t,double> ResultType;
+
+ /** Create lerper with given vector of stops
+
+ @param rKeyStops
+
+ Vector of stops, must contain at least two elements
+ (though preferrably more, otherwise you probably don't
+ need key stop lerping in the first place). All
+ elements must be of monotonically increasing value.
+ */
+ explicit KeyStopLerp( const std::vector<double>& rKeyStops );
+
+ /** Create lerper with given sequence of stops
+
+ @param rKeyStops
+
+ Sequence of stops, must contain at least two elements
+ (though preferrably more, otherwise you probably don't
+ need key stop lerping in the first place). All
+ elements must be of monotonically increasing value.
+ */
+ explicit KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops );
+
+ /** Find two nearest bucket index & interpolate
+
+ @param fAlpha
+ Find bucket index i, with keyStops[i] < fAlpha <=
+ keyStops[i+1]. Return new alpha value in [0,1),
+ proportional to fAlpha's position between keyStops[i]
+ and keyStops[i+1]
+ */
+ ResultType lerp(double fAlpha) const;
+
+ private:
+ std::vector<double> maKeyStops;
+ mutable std::ptrdiff_t mnLastIndex;
+ };
+ }
+}
+
+#endif
diff --git a/basegfx/inc/basegfx/tools/lerp.hxx b/basegfx/inc/basegfx/tools/lerp.hxx
new file mode 100644
index 000000000000..590ef34c2009
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/lerp.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: lerp.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_LERP_HXX
+#define _BGFX_TOOLS_LERP_HXX
+
+#include <sal/types.h>
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Generic linear interpolator
+
+ @tpl ValueType
+ Must have operator+ and operator* defined, and should
+ have value semantics.
+
+ @param t
+ As usual, t must be in the [0,1] range
+ */
+ template< typename ValueType > ValueType lerp( const ValueType& rFrom,
+ const ValueType& rTo,
+ double t )
+ {
+ // This is only to suppress a double->int warning. All other
+ // types should be okay here.
+ return static_cast<ValueType>( (1.0-t)*rFrom + t*rTo );
+ }
+ }
+}
+
+#endif /* _BGFX_TOOLS_LERP_HXX */
diff --git a/basegfx/inc/basegfx/tools/rectcliptools.hxx b/basegfx/inc/basegfx/tools/rectcliptools.hxx
new file mode 100644
index 000000000000..ae7c057666d9
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/rectcliptools.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_RECTCLIPTOOLS_HXX
+#define _BGFX_TOOLS_RECTCLIPTOOLS_HXX
+
+#include <sal/types.h>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ namespace tools
+ {
+ namespace RectClipFlags
+ {
+ static const sal_uInt32 LEFT = (sal_Int32)0x01;
+ static const sal_uInt32 RIGHT = (sal_Int32)0x02;
+ static const sal_uInt32 TOP = (sal_Int32)0x04;
+ static const sal_uInt32 BOTTOM = (sal_Int32)0x08;
+ }
+
+ /** Calc clip mask for Cohen-Sutherland rectangle clip
+
+ This function returns a clip mask used for the
+ Cohen-Sutherland rectangle clip method, where one or more
+ of the lower four bits are set, if the given point is
+ outside one or more of the four half planes defining the
+ rectangle (see RectClipFlags for possible values)
+ */
+ template< class Point, class Rect > inline
+ sal_uInt32 getCohenSutherlandClipFlags( const Point& rP,
+ const Rect& rR )
+ {
+ // maxY | minY | maxX | minX
+ sal_uInt32 clip = (rP.getX() < rR.getMinX()) << 0;
+ clip |= (rP.getX() > rR.getMaxX()) << 1;
+ clip |= (rP.getY() < rR.getMinY()) << 2;
+ clip |= (rP.getY() > rR.getMaxY()) << 3;
+ return clip;
+ }
+
+ /** Determine number of clip planes hit by given clip mask
+
+ This method returns the number of one bits in the four
+ least significant bits of the argument, which amounts to
+ the number of clip planes hit within the
+ getCohenSutherlandClipFlags() method.
+ */
+ inline sal_uInt32 getNumberOfClipPlanes( sal_uInt32 nFlags )
+ {
+ // classic bit count algo, see e.g. Reingold, Nievergelt,
+ // Deo: Combinatorial Algorithms, Theory and Practice,
+ // Prentice-Hall 1977
+ nFlags = (nFlags & 0x05) + ((nFlags >> 1) & 0x05);
+ nFlags = (nFlags & 0x03) + (nFlags >> 2); // no need for &
+ // 0x03, can't
+ // overflow
+ return nFlags;
+ }
+ }
+}
+
+#endif // _BGFX_TOOLS_RECTCLIPTOOLS_HXX
diff --git a/basegfx/inc/basegfx/tools/tools.hxx b/basegfx/inc/basegfx/tools/tools.hxx
new file mode 100644
index 000000000000..896fd22c162d
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/tools.hxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_TOOLS_HXX
+#define _BGFX_TOOLS_TOOLS_HXX
+
+#include <sal/types.h>
+
+namespace basegfx
+{
+ class B2DPoint;
+ class B2DRange;
+
+ namespace tools
+ {
+ /** Liang-Barsky 2D line clipping algorithm
+
+ This function clips a line given by two points against the
+ given rectangle. The resulting line is returned in the
+ given points.
+
+ @param io_rStart
+ Start point of the line. On return, contains the clipped
+ start point.
+
+ @param io_rEnd
+ End point of the line. On return, contains the clipped
+ end point.
+
+ @param rClipRect
+ The rectangle to clip against
+
+ @return true, when at least part of the line is visible
+ after the clip, false otherwise
+ */
+ bool liangBarskyClip2D( ::basegfx::B2DPoint& io_rStart,
+ ::basegfx::B2DPoint& io_rEnd,
+ const ::basegfx::B2DRange& rClipRect );
+
+ /** Expand given parallelogram, such that it extends beyond
+ bound rect in a given direction.
+
+ This method is useful when e.g. generating one-dimensional
+ gradients, such as linear or axial gradients: those
+ gradients vary only in one direction, the other has
+ constant color. Most of the time, those gradients extends
+ infinitely in the direction with the constant color, but
+ practically, one always has a limiting bound rect into
+ which the gradient is painted. The method at hand now
+ extends a given parallelogram (e.g. the transformed
+ bounding box of a gradient) virtually into infinity to the
+ top and to the bottom (i.e. normal to the line io_rLeftTop
+ io_rRightTop), such that the given rectangle is guaranteed
+ to be covered in that direction.
+
+ @attention There might be some peculiarities with this
+ method, that might limit its usage to the described
+ gradients. One of them is the fact that when determining
+ how far the parallelogram has to be extended to the top or
+ the bottom, the upper and lower border are assumed to be
+ infinite lines.
+
+ @param io_rLeftTop
+ Left, top edge of the parallelogramm. Note that this need
+ not be the left, top edge geometrically, it's just used
+ when determining the extension direction. Thus, it's
+ perfectly legal to affine-transform a rectangle, and given
+ the transformed point here. On method return, this
+ parameter will contain the adapted output.
+
+ @param io_rLeftBottom
+ Left, bottom edge of the parallelogramm. Note that this need
+ not be the left, bottom edge geometrically, it's just used
+ when determining the extension direction. Thus, it's
+ perfectly legal to affine-transform a rectangle, and given
+ the transformed point here. On method return, this
+ parameter will contain the adapted output.
+
+ @param io_rRightTop
+ Right, top edge of the parallelogramm. Note that this need
+ not be the right, top edge geometrically, it's just used
+ when determining the extension direction. Thus, it's
+ perfectly legal to affine-transform a rectangle, and given
+ the transformed point here. On method return, this
+ parameter will contain the adapted output.
+
+ @param io_rRightBottom
+ Right, bottom edge of the parallelogramm. Note that this need
+ not be the right, bottom edge geometrically, it's just used
+ when determining the extension direction. Thus, it's
+ perfectly legal to affine-transform a rectangle, and given
+ the transformed point here. On method return, this
+ parameter will contain the adapted output.
+
+ @param rFitTarget
+ The rectangle to fit the parallelogram into.
+ */
+ void infiniteLineFromParallelogram( ::basegfx::B2DPoint& io_rLeftTop,
+ ::basegfx::B2DPoint& io_rLeftBottom,
+ ::basegfx::B2DPoint& io_rRightTop,
+ ::basegfx::B2DPoint& io_rRightBottom,
+ const ::basegfx::B2DRange& rFitTarget );
+
+ }
+}
+
+#endif /* _BGFX_TOOLS_TOOLS_HXX */
diff --git a/basegfx/inc/basegfx/tools/unopolypolygon.hxx b/basegfx/inc/basegfx/tools/unopolypolygon.hxx
new file mode 100755
index 000000000000..8a4044e1ca4b
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/unopolypolygon.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_BASEGFX_UNOPOLYPOLYGON_HXX
+#define INCLUDED_BASEGFX_UNOPOLYPOLYGON_HXX
+
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/rendering/FillRule.hpp>
+#include <com/sun/star/rendering/XLinePolyPolygon2D.hpp>
+#include <com/sun/star/rendering/XBezierPolyPolygon2D.hpp>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+
+namespace basegfx
+{
+namespace unotools
+{
+ typedef ::cppu::WeakComponentImplHelper3<
+ ::com::sun::star::rendering::XLinePolyPolygon2D,
+ ::com::sun::star::rendering::XBezierPolyPolygon2D,
+ ::com::sun::star::lang::XServiceInfo > UnoPolyPolygonBase;
+
+ class UnoPolyPolygon : private cppu::BaseMutex,
+ public UnoPolyPolygonBase
+ {
+ public:
+ explicit UnoPolyPolygon( const B2DPolyPolygon& );
+
+ // XPolyPolygon2D
+ virtual void SAL_CALL addPolyPolygon( const ::com::sun::star::geometry::RealPoint2D& position, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& polyPolygon ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getNumberOfPolygons( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getNumberOfPolygonPoints( ::sal_Int32 polygon ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::rendering::FillRule SAL_CALL getFillRule( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFillRule( ::com::sun::star::rendering::FillRule fillRule ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isClosed( ::sal_Int32 index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClosed( ::sal_Int32 index, ::sal_Bool closedState ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // XLinePolyPolygon2D
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > > SAL_CALL getPoints( ::sal_Int32 nPolygonIndex, ::sal_Int32 nNumberOfPolygons, ::sal_Int32 nPointIndex, ::sal_Int32 nNumberOfPoints ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPoints( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points, ::sal_Int32 nPolygonIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::geometry::RealPoint2D SAL_CALL getPoint( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPoint( const ::com::sun::star::geometry::RealPoint2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // XBezierPolyPolygon2D
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > > SAL_CALL getBezierSegments( ::sal_Int32 nPolygonIndex, ::sal_Int32 nNumberOfPolygons, ::sal_Int32 nPointIndex, ::sal_Int32 nNumberOfPoints ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBezierSegments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points, ::sal_Int32 nPolygonIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::geometry::RealBezierSegment2D SAL_CALL getBezierSegment( ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBezierSegment( const ::com::sun::star::geometry::RealBezierSegment2D& point, ::sal_Int32 nPolygonIndex, ::sal_Int32 nPointIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ B2DPolyPolygon getPolyPolygon() const;
+
+ protected:
+ /// Check whether index is a valid polygon index
+ void checkIndex( sal_Int32 nIndex ) const // throw (::com::sun::star::lang::IndexOutOfBoundsException);
+ {
+ if( nIndex < 0 || nIndex >= static_cast<sal_Int32>(maPolyPoly.count()) )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ }
+
+ B2DPolyPolygon getSubsetPolyPolygon( sal_Int32 nPolygonIndex,
+ sal_Int32 nNumberOfPolygons,
+ sal_Int32 nPointIndex,
+ sal_Int32 nNumberOfPoints ) const;
+
+ /// Get cow copy of internal polygon. not thread-safe outside this object.
+ B2DPolyPolygon getPolyPolygonUnsafe() const;
+
+ /// Called whenever internal polypolygon gets modified
+ virtual void modifying() const {}
+
+ private:
+ UnoPolyPolygon( const UnoPolyPolygon& );
+ UnoPolyPolygon& operator=( const UnoPolyPolygon& );
+
+ B2DPolyPolygon maPolyPoly;
+ ::com::sun::star::rendering::FillRule meFillRule;
+ };
+}
+}
+
+#endif /* INCLUDED_BASEGFX_UNOPOLYPOLYGON_HXX */