diff options
author | Armin Le Grand <alg@apache.org> | 2013-10-29 14:11:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-31 15:56:14 +0000 |
commit | 223f6b631c1b087754c0f9051fb55f029f2503ce (patch) | |
tree | 14582be2894a88d16c6b0debbc8491350f9a5cce /include/basegfx/polygon | |
parent | 9069e26d1fe1fbbe7bceab0bae8a186d8cdb47cc (diff) |
Resolves: #i123433# Detect pseudo-vertices at svg import...
unify svg:d handling, correct svg:d import for relative sub-polygons in svg
import; changed default for moveto writes for svg:d in ODF to absolute
(cherry picked from commit f15874d8f976f3874bdbcb53429eeefa65c28841)
Conflicts:
basegfx/inc/basegfx/polygon/b2dpolygontools.hxx
basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx
basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx
basegfx/source/polygon/b2dpolypolygontools.cxx
basegfx/source/polygon/b2dsvgpolypolygon.cxx
basegfx/source/polygon/b3dpolypolygontools.cxx
basegfx/source/tools/makefile.mk
basegfx/test/boxclipper.cxx
basegfx/test/clipstate.cxx
basegfx/test/genericclipper.cxx
canvas/source/tools/surfaceproxy.cxx
sdext/source/pdfimport/tree/drawtreevisiting.cxx
sdext/source/pdfimport/tree/writertreevisiting.cxx
xmloff/inc/xexptran.hxx
xmloff/source/draw/XMLImageMapContext.cxx
xmloff/source/draw/XMLImageMapExport.cxx
xmloff/source/draw/shapeexport2.cxx
xmloff/source/draw/shapeexport3.cxx
xmloff/source/draw/xexptran.cxx
xmloff/source/draw/ximp3dobject.cxx
xmloff/source/draw/ximpshap.cxx
xmloff/source/style/MarkerStyle.cxx
xmloff/source/text/XMLTextFrameContext.cxx
xmloff/source/text/txtparae.cxx
Change-Id: I5171b4a3559ea116bea45152e1f2685666463635
Diffstat (limited to 'include/basegfx/polygon')
-rw-r--r-- | include/basegfx/polygon/b2dpolygontools.hxx | 54 | ||||
-rw-r--r-- | include/basegfx/polygon/b2dpolypolygontools.hxx | 103 | ||||
-rw-r--r-- | include/basegfx/polygon/b3dpolypolygontools.hxx | 11 |
3 files changed, 140 insertions, 28 deletions
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx index 6aa96927edd7..73137568c703 100644 --- a/include/basegfx/polygon/b2dpolygontools.hxx +++ b/include/basegfx/polygon/b2dpolygontools.hxx @@ -25,6 +25,8 @@ #include <basegfx/range/b2drectangle.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b3dpolygon.hxx> +#include <com/sun/star/drawing/PointSequence.hpp> +#include <com/sun/star/drawing/FlagSequence.hpp> #include <vector> #include <basegfx/basegfxdllapi.h> @@ -451,6 +453,58 @@ namespace basegfx /// polygon path data. Take into account all stuff like closed state, zero-length edges and others. BASEGFX_DLLPUBLIC B2DVector getTangentLeavingPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex); + /// converters for com::sun::star::drawing::PointSequence + BASEGFX_DLLPUBLIC B2DPolygon UnoPointSequenceToB2DPolygon( + const com::sun::star::drawing::PointSequence& rPointSequenceSource, + bool bCheckClosed = true); + BASEGFX_DLLPUBLIC void B2DPolygonToUnoPointSequence( + const B2DPolygon& rPolygon, + com::sun::star::drawing::PointSequence& rPointSequenceRetval); + + /* converters for com::sun::star::drawing::PointSequence and + com::sun::star::drawing::FlagSequence to B2DPolygon (curved polygons) + */ + B2DPolygon UnoPolygonBezierCoordsToB2DPolygon( + const com::sun::star::drawing::PointSequence& rPointSequenceSource, + const com::sun::star::drawing::FlagSequence& rFlagSequenceSource, + bool bCheckClosed = true); + void B2DPolygonToUnoPolygonBezierCoords( + const B2DPolygon& rPolyPolygon, + com::sun::star::drawing::PointSequence& rPointSequenceRetval, + com::sun::star::drawing::FlagSequence& rFlagSequenceRetval); + + /** Read poly-polygon from SVG. + + This function imports a poly-polygon from an SVG points + attribute (a plain list of coordinate pairs). + + @param o_rPoly + The output polygon. Note that svg:points can only define a + single polygon + + @param rSvgPointsAttribute + A valid SVG points attribute string + + @return true, if the string was successfully parsed + */ + BASEGFX_DLLPUBLIC bool importFromSvgPoints( B2DPolygon& o_rPoly, + const OUString& rSvgPointsAttribute ); + + /** Write poly-polygon to SVG. + + This function imports a non-bezier polygon to SVG points + (a plain list of coordinate pairs). + + @param rPoly + The polygon to export + + @param rSvgPointsAttribute + A valid SVG points attribute string + + @return true, if the string was successfully parsed + */ + BASEGFX_DLLPUBLIC OUString exportToSvgPoints( const B2DPolygon& rPoly ); + } // end of namespace tools } // end of namespace basegfx diff --git a/include/basegfx/polygon/b2dpolypolygontools.hxx b/include/basegfx/polygon/b2dpolypolygontools.hxx index 521d07595f8a..182053bfbd90 100644 --- a/include/basegfx/polygon/b2dpolypolygontools.hxx +++ b/include/basegfx/polygon/b2dpolypolygontools.hxx @@ -24,7 +24,10 @@ #include <basegfx/vector/b2dvector.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b3dpolypolygon.hxx> +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <vector> +#include <set> #include <basegfx/basegfxdllapi.h> @@ -100,6 +103,32 @@ namespace basegfx // with distance fDistance and rounded edges (start and end point). BASEGFX_DLLPUBLIC bool isInEpsilonRange(const B2DPolyPolygon& rCandidate, const B2DPoint& rTestPosition, double fDistance); + /** Helper class to transport PointIndices to a PolyPolygon, + with an operator< for convenient sorting in a std::set usage + */ + class BASEGFX_DLLPUBLIC SAL_WARN_UNUSED PointIndex + { + private: + sal_uInt32 mnPolygonIndex; + sal_uInt32 mnPointIndex; + + public: + PointIndex(sal_uInt32 nPolygonIndex, sal_uInt32 nPointIndex) + : mnPolygonIndex(nPolygonIndex), + mnPointIndex(nPointIndex) + {} + + sal_uInt32 getPolygonIndex() const { return mnPolygonIndex; } + sal_uInt32 getPointIndex() const { return mnPointIndex; } + bool operator<(const PointIndex& rComp) const; + }; + + /** the PointIndexSet itself; it allows to define a 'selection'of + points in a PolyPolygon by giving the polygon and point index. + Adding points double makes no sense, hence the std::set + */ + typedef std::set< PointIndex > PointIndexSet; + /** Read poly-polygon from SVG. This function imports a poly-polygon from an SVG-D @@ -111,33 +140,29 @@ namespace basegfx @param rSvgDAttribute A valid SVG-D attribute string - @param rWrongPositionAfterZ - Indicates wheter the generator interprets wrongly - the position in the path after Z or z elements - https://bugs.freedesktop.org/show_bug.cgi?id=47406 - - @return true, if the string was successfully parsed - */ - BASEGFX_DLLPUBLIC bool importFromSvgD( B2DPolyPolygon& o_rPolyPoly, - const OUString& rSvgDAttribute, bool bWrongPositionAfterZ = false ); - - /** Read poly-polygon from SVG. - - This function imports a poly-polygon from an SVG points - attribute (a plain list of coordinate pairs). - - @param o_rPoly - The output polygon. Note that svg:points can only define a - single polygon - - @param rSvgPointsAttribute - A valid SVG points attribute string + @param bHandleRelativeNextPointCompatible + If set to true, the old error that after a relative 'z' command + the current point was not reset to the first point of the current + polygon is kept; this is needed to read odf files. + If false, pure svg is used; this is needed for svg import. + + @param pHelpPointIndexSet + If given, all points created in the target PolyPolygon + which are only helper points are added here using their + point indices; this are currently points created from + import of the 'a' and 'A' svg:d statements which create + bezier curve info as representation and maybe points + which are no 'real' svg:d points, but helper points. It + is necessary to identify these e.g. when markers need to + be created in the svg import @return true, if the string was successfully parsed */ - BASEGFX_DLLPUBLIC bool importFromSvgPoints( B2DPolygon& o_rPoly, - const OUString& rSvgPointsAttribute ); - + BASEGFX_DLLPUBLIC bool importFromSvgD( + B2DPolyPolygon& o_rPolyPoly, + const OUString& rSvgDAttribute, + bool bHandleRelativeNextPointCompatible, + PointIndexSet* pHelpPointIndexSet); // grow for polyPolygon. Move all geometry in each point in the direction of the normal in that point // with the given amount. Value may be negative. @@ -210,12 +235,20 @@ namespace basegfx quadratic bezier segments. Note that the generated string causes versions prior to OOo2.0 to crash. + @param bHandleRelativeNextPointCompatible + If set to true, the old error that after a relative 'z' command + the current point was not reset to the first point of the current + polygon is kept; this is needed to read odf files. + If false, pure svg is used; this is needed for svg import. + @return the generated SVG-D statement (the XML d attribute value alone, without any "<path ...>" or "d="...") */ - BASEGFX_DLLPUBLIC OUString exportToSvgD( const B2DPolyPolygon& rPolyPoly, - bool bUseRelativeCoordinates=true, - bool bDetectQuadraticBeziers=true ); + BASEGFX_DLLPUBLIC OUString exportToSvgD( + const B2DPolyPolygon& rPolyPoly, + bool bUseRelativeCoordinates, + bool bDetectQuadraticBeziers, + bool bHandleRelativeNextPointCompatible); // #i76891# Try to remove existing curve segments if they are simply edges BASEGFX_DLLPUBLIC B2DPolyPolygon simplifyCurveSegments(const B2DPolyPolygon& rCandidate); @@ -259,6 +292,22 @@ namespace basegfx */ BASEGFX_DLLPUBLIC bool containsOnlyHorizontalAndVerticalEdges(const B2DPolyPolygon& rCandidate); + /// converters for com::sun::star::drawing::PointSequence + BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon( + const com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceSource, + bool bCheckClosed = true); + BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPointSequenceSequence( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceRetval); + + /// converters for com::sun::star::drawing::PolyPolygonBezierCoords (curved polygons) + BASEGFX_DLLPUBLIC B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon( + const com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource, + bool bCheckClosed = true); + BASEGFX_DLLPUBLIC void B2DPolyPolygonToUnoPolyPolygonBezierCoords( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval); + } // end of namespace tools } // end of namespace basegfx diff --git a/include/basegfx/polygon/b3dpolypolygontools.hxx b/include/basegfx/polygon/b3dpolypolygontools.hxx index 3b5011ddeeb3..24fb902e79cc 100644 --- a/include/basegfx/polygon/b3dpolypolygontools.hxx +++ b/include/basegfx/polygon/b3dpolypolygontools.hxx @@ -22,9 +22,10 @@ #include <basegfx/point/b2dpoint.hxx> #include <basegfx/vector/b2dvector.hxx> -#include <vector> #include <basegfx/numeric/ftools.hxx> #include <basegfx/point/b3dpoint.hxx> +#include <com/sun/star/drawing/PolyPolygonShape3D.hpp> +#include <vector> #include <basegfx/basegfxdllapi.h> ////////////////////////////////////////////////////////////////////////////// @@ -125,6 +126,14 @@ namespace basegfx // in bWithBorder flag. It is assumed that the orientations of the given polygon are correct. BASEGFX_DLLPUBLIC bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint, bool bWithBorder = false); + /// converters for com::sun::star::drawing::PolyPolygonShape3D + BASEGFX_DLLPUBLIC B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon( + const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource, + bool bCheckClosed = true); + BASEGFX_DLLPUBLIC void B3DPolyPolygonToUnoPolyPolygonShape3D( + const B3DPolyPolygon& rPolyPolygonSource, + com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval); + } // end of namespace tools } // end of namespace basegfx |