Author: jani Date: Mon Nov 4 19:00:37 2013 New Revision: 1538719 URL: http://svn.apache.org/r1538719 Log: merge from main, and changes to make it build again.
Added: openoffice/branches/capstone2013/main/basegfx/source/inc/stringconversiontools.hxx - copied unchanged from r1538440, openoffice/trunk/main/basegfx/source/inc/stringconversiontools.hxx openoffice/branches/capstone2013/main/basegfx/source/tools/stringconversiontools.cxx - copied unchanged from r1538440, openoffice/trunk/main/basegfx/source/tools/stringconversiontools.cxx Modified: openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolygontools.cxx openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolypolygontools.cxx openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dsvgpolypolygon.cxx openoffice/branches/capstone2013/main/basegfx/source/polygon/b3dpolypolygontools.cxx openoffice/branches/capstone2013/main/basegfx/source/tools/makefile.mk openoffice/branches/capstone2013/main/basegfx/test/basegfx2d.cxx openoffice/branches/capstone2013/main/basegfx/test/boxclipper.cxx openoffice/branches/capstone2013/main/basegfx/test/clipstate.cxx openoffice/branches/capstone2013/main/basegfx/test/genericclipper.cxx openoffice/branches/capstone2013/main/canvas/source/tools/surfaceproxy.cxx openoffice/branches/capstone2013/main/cui/source/dialogs/colorpicker.cxx openoffice/branches/capstone2013/main/cui/source/dialogs/colorpicker.hrc openoffice/branches/capstone2013/main/cui/source/dialogs/colorpicker.src openoffice/branches/capstone2013/main/cui/source/tabpages/tpbitmap.cxx openoffice/branches/capstone2013/main/cui/source/tabpages/tpcolor.cxx openoffice/branches/capstone2013/main/cui/source/tabpages/tplneend.cxx openoffice/branches/capstone2013/main/desktop/os2/source/applauncher/launcher.cxx openoffice/branches/capstone2013/main/drawinglayer/source/processor2d/vclprocessor2d.cxx openoffice/branches/capstone2013/main/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx openoffice/branches/capstone2013/main/instsetoo_native/util/makefile.mk openoffice/branches/capstone2013/main/instsetoo_native/util/openoffice.lst openoffice/branches/capstone2013/main/odk/util/makefile.pmk openoffice/branches/capstone2013/main/oox/source/core/xmlfilterbase.cxx openoffice/branches/capstone2013/main/oox/source/token/namespaces.txt openoffice/branches/capstone2013/main/oox/source/token/tokens.txt openoffice/branches/capstone2013/main/sal/inc/sal/main.h openoffice/branches/capstone2013/main/sal/osl/os2/salinit.cxx openoffice/branches/capstone2013/main/sal/osl/os2/thread.c openoffice/branches/capstone2013/main/sd/source/core/CustomAnimationEffect.cxx openoffice/branches/capstone2013/main/sdext/source/pdfimport/test/tests.cxx openoffice/branches/capstone2013/main/sdext/source/pdfimport/tree/drawtreevisiting.cxx openoffice/branches/capstone2013/main/sdext/source/pdfimport/tree/writertreevisiting.cxx openoffice/branches/capstone2013/main/set_soenv.in openoffice/branches/capstone2013/main/slideshow/source/engine/animationfactory.cxx openoffice/branches/capstone2013/main/solenv/bin/make_installer.pl openoffice/branches/capstone2013/main/solenv/bin/modules/installer/archivefiles.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/configuration.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/control.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/download.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/downloadsigner.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/environment.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/epmfile.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/exiter.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/files.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/followme.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/globals.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/javainstaller.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/languagepack.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/logger.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/packagelist.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/packagepool.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/parameter.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/profiles.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/scppatchsoname.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/scpzipfiles.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/scriptitems.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/setupscript.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/simplepackage.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/strip.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/substfilenamefiles.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/systemactions.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/upx.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/admin.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/assembly.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/binary.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/component.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/createfolder.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/directory.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/feature.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/featurecomponent.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/file.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/font.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/icon.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/idtglobal.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/inifile.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/java.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/media.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/mergemodule.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/msiglobal.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/msp.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/patch.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/property.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/registry.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/removefile.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/selfreg.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/shortcut.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/sign.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/strip.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/update.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/windows/upgrade.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/worker.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/xpdinstaller.pm openoffice/branches/capstone2013/main/solenv/bin/modules/installer/ziplist.pm openoffice/branches/capstone2013/main/solenv/gbuild/platform/os2.mk openoffice/branches/capstone2013/main/solenv/inc/os2gcci.mk openoffice/branches/capstone2013/main/svgio/inc/svgio/svgreader/svgpathnode.hxx openoffice/branches/capstone2013/main/svgio/inc/svgio/svgreader/svgstyleattributes.hxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgcirclenode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgellipsenode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svglinenode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgnode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgpathnode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgpolynode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgrectnode.cxx openoffice/branches/capstone2013/main/svgio/source/svgreader/svgstyleattributes.cxx openoffice/branches/capstone2013/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx openoffice/branches/capstone2013/main/svx/source/sdr/properties/customshapeproperties.cxx openoffice/branches/capstone2013/main/svx/source/xoutdev/xattrbmp.cxx openoffice/branches/capstone2013/main/sw/inc/ndgrf.hxx openoffice/branches/capstone2013/main/sw/source/core/doc/notxtfrm.cxx openoffice/branches/capstone2013/main/sw/source/filter/rtf/swparrtf.cxx openoffice/branches/capstone2013/main/tools/source/generic/toolsin.cxx openoffice/branches/capstone2013/main/vcl/os2/source/gdi/salgdi3.cxx openoffice/branches/capstone2013/main/xmloff/inc/xexptran.hxx openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapContext.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/XMLImageMapExport.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport2.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/shapeexport3.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/xexptran.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/ximp3dobject.cxx openoffice/branches/capstone2013/main/xmloff/source/draw/ximpshap.cxx openoffice/branches/capstone2013/main/xmloff/source/style/MarkerStyle.cxx openoffice/branches/capstone2013/main/xmloff/source/text/XMLTextFrameContext.cxx openoffice/branches/capstone2013/main/xmloff/source/text/txtparae.cxx Modified: openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx (original) +++ openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx Mon Nov 4 19:00:37 2013 @@ -29,6 +29,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> ////////////////////////////////////////////////////////////////////////////// @@ -540,6 +542,58 @@ namespace basegfx /// polygon path data. Take into account all stuff like closed state, zero-length edges and others. B2DVector getTangentLeavingPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex); + /// converters for com::sun::star::drawing::PointSequence + B2DPolygon UnoPointSequenceToB2DPolygon( + const com::sun::star::drawing::PointSequence& rPointSequenceSource, + bool bCheckClosed = true); + 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 + */ + bool importFromSvgPoints( B2DPolygon& o_rPoly, + const ::rtl::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 + */ + ::rtl::OUString exportToSvgPoints( const B2DPolygon& rPoly ); + } // end of namespace tools } // end of namespace basegfx Modified: openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx (original) +++ openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx Mon Nov 4 19:00:37 2013 @@ -19,8 +19,6 @@ * *************************************************************/ - - #ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX #define _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX @@ -28,7 +26,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> namespace rtl { @@ -120,11 +121,37 @@ namespace basegfx // with distance fDistance and rounded edges (start and end point). 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 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 - attribute. Currently, elliptical arc elements are not yet - supported (and ignored during parsing). + This function imports a poly-polygon from an SVG-D + attribute. Currently, elliptical arc elements are not yet + supported (and ignored during parsing). @param o_rPolyPoly The output poly-polygon @@ -132,28 +159,30 @@ namespace basegfx @param rSvgDAttribute A valid SVG-D attribute string - @return true, if the string was successfully parsed - */ - bool importFromSvgD( B2DPolyPolygon& o_rPolyPoly, - const ::rtl::OUString& rSvgDAttribute ); - - /** 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 */ - bool importFromSvgPoints( B2DPolygon& o_rPoly, - const ::rtl::OUString& rSvgPointsAttribute ); + bool importFromSvgD( + B2DPolyPolygon& o_rPolyPoly, + const ::rtl::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. @@ -232,12 +261,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="...") */ - ::rtl::OUString exportToSvgD( const B2DPolyPolygon& rPolyPoly, - bool bUseRelativeCoordinates=true, - bool bDetectQuadraticBeziers=true ); + ::rtl::OUString exportToSvgD( + const B2DPolyPolygon& rPolyPoly, + bool bUseRelativeCoordinates, + bool bDetectQuadraticBeziers, + bool bHandleRelativeNextPointCompatible); // #i76891# Try to remove existing curve segments if they are simply edges B2DPolyPolygon simplifyCurveSegments(const B2DPolyPolygon& rCandidate); @@ -280,6 +317,22 @@ namespace basegfx */ bool containsOnlyHorizontalAndVerticalEdges(const B2DPolyPolygon& rCandidate); + /// converters for com::sun::star::drawing::PointSequence + B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon( + const com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceSource, + bool bCheckClosed = true); + void B2DPolyPolygonToUnoPointSequenceSequence( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceRetval); + + /// converters for com::sun::star::drawing::PolyPolygonBezierCoords (curved polygons) + B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon( + const com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource, + bool bCheckClosed = true); + void B2DPolyPolygonToUnoPolyPolygonBezierCoords( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval); + } // end of namespace tools } // end of namespace basegfx Modified: openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx (original) +++ openoffice/branches/capstone2013/main/basegfx/inc/basegfx/polygon/b3dpolypolygontools.hxx Mon Nov 4 19:00:37 2013 @@ -26,9 +26,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> ////////////////////////////////////////////////////////////////////////////// @@ -144,7 +145,15 @@ namespace basegfx bool equal(const B3DPolyPolygon& rCandidateA, const B3DPolyPolygon& rCandidateB, const double& rfSmallValue); bool equal(const B3DPolyPolygon& rCandidateA, const B3DPolyPolygon& rCandidateB); - } // end of namespace tools + /// converters for com::sun::star::drawing::PolyPolygonShape3D + B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon( + const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource, + bool bCheckClosed = true); + void B3DPolyPolygonToUnoPolyPolygonShape3D( + const B3DPolyPolygon& rPolyPolygonSource, + com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval); + + } // end of namespace tools } // end of namespace basegfx #endif /* _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX */ Modified: openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolygontools.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolygontools.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolygontools.cxx (original) +++ openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolygontools.cxx Mon Nov 4 19:00:37 2013 @@ -3742,6 +3742,349 @@ namespace basegfx return aRetval; } + ////////////////////////////////////////////////////////////////////////////// + // converters for com::sun::star::drawing::PointSequence + + B2DPolygon UnoPointSequenceToB2DPolygon( + const com::sun::star::drawing::PointSequence& rPointSequenceSource, + bool bCheckClosed) + { + B2DPolygon aRetval; + const sal_uInt32 nLength(rPointSequenceSource.getLength()); + + if(nLength) + { + aRetval.reserve(nLength); + const com::sun::star::awt::Point* pArray = rPointSequenceSource.getConstArray(); + const com::sun::star::awt::Point* pArrayEnd = pArray + rPointSequenceSource.getLength(); + + for(;pArray != pArrayEnd; pArray++) + { + aRetval.append(B2DPoint(pArray->X, pArray->Y)); + } + + if(bCheckClosed) + { + // check for closed state flag + tools::checkClosed(aRetval); + } + } + + return aRetval; + } + + void B2DPolygonToUnoPointSequence( + const B2DPolygon& rPolygon, + com::sun::star::drawing::PointSequence& rPointSequenceRetval) + { + B2DPolygon aPolygon(rPolygon); + + if(aPolygon.areControlPointsUsed()) + { + OSL_ENSURE(false, "B2DPolygonToUnoPointSequence: Source contains bezier segments, wrong UNO API data type may be used (!)"); + aPolygon = aPolygon.getDefaultAdaptiveSubdivision(); + } + + const sal_uInt32 nPointCount(aPolygon.count()); + + if(nPointCount) + { + // Take closed state into account, the API polygon still uses the old closed definition + // with last/first point are identical (cannot hold information about open polygons with identical + // first and last point, though) + const bool bIsClosed(aPolygon.isClosed()); + + rPointSequenceRetval.realloc(bIsClosed ? nPointCount + 1 : nPointCount); + com::sun::star::awt::Point* pSequence = rPointSequenceRetval.getArray(); + + for(sal_uInt32 b(0); b < nPointCount; b++) + { + const B2DPoint aPoint(aPolygon.getB2DPoint(b)); + const com::sun::star::awt::Point aAPIPoint(fround(aPoint.getX()), fround(aPoint.getY())); + + *pSequence = aAPIPoint; + pSequence++; + } + + // copy first point if closed + if(bIsClosed) + { + *pSequence = *rPointSequenceRetval.getArray(); + } + } + else + { + rPointSequenceRetval.realloc(0); + } + } + + ////////////////////////////////////////////////////////////////////////////// + // 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) + { + const sal_uInt32 nCount((sal_uInt32)rPointSequenceSource.getLength()); + OSL_ENSURE(nCount == (sal_uInt32)rFlagSequenceSource.getLength(), + "UnoPolygonBezierCoordsToB2DPolygon: Unequal count of Points and Flags (!)"); + + // prepare new polygon + B2DPolygon aRetval; + const com::sun::star::awt::Point* pPointSequence = rPointSequenceSource.getConstArray(); + const com::sun::star::drawing::PolygonFlags* pFlagSequence = rFlagSequenceSource.getConstArray(); + + // get first point and flag + B2DPoint aNewCoordinatePair(pPointSequence->X, pPointSequence->Y); pPointSequence++; + com::sun::star::drawing::PolygonFlags ePolygonFlag(*pFlagSequence); pFlagSequence++; + B2DPoint aControlA; + B2DPoint aControlB; + + // first point is not allowed to be a control point + OSL_ENSURE(com::sun::star::drawing::PolygonFlags_CONTROL != ePolygonFlag, + "UnoPolygonBezierCoordsToB2DPolygon: Start point is a control point, illegal input polygon (!)"); + + // add first point as start point + aRetval.append(aNewCoordinatePair); + + for(sal_uInt32 b(1); b < nCount;) + { + // prepare loop + bool bControlA(false); + bool bControlB(false); + + // get next point and flag + aNewCoordinatePair = B2DPoint(pPointSequence->X, pPointSequence->Y); + ePolygonFlag = *pFlagSequence; + pPointSequence++; pFlagSequence++; b++; + + if(b < nCount && com::sun::star::drawing::PolygonFlags_CONTROL == ePolygonFlag) + { + aControlA = aNewCoordinatePair; + bControlA = true; + + // get next point and flag + aNewCoordinatePair = B2DPoint(pPointSequence->X, pPointSequence->Y); + ePolygonFlag = *pFlagSequence; + pPointSequence++; pFlagSequence++; b++; + } + + if(b < nCount && com::sun::star::drawing::PolygonFlags_CONTROL == ePolygonFlag) + { + aControlB = aNewCoordinatePair; + bControlB = true; + + // get next point and flag + aNewCoordinatePair = B2DPoint(pPointSequence->X, pPointSequence->Y); + ePolygonFlag = *pFlagSequence; + pPointSequence++; pFlagSequence++; b++; + } + + // two or no control points are consumed, another one would be an error. + // It's also an error if only one control point was read + OSL_ENSURE(com::sun::star::drawing::PolygonFlags_CONTROL != ePolygonFlag && bControlA == bControlB, + "UnoPolygonBezierCoordsToB2DPolygon: Illegal source polygon (!)"); + + // the previous writes used the B2DPolyPoygon -> PolyPolygon converter + // which did not create minimal PolyPolygons, but created all control points + // as null vectors (identical points). Because of the former P(CA)(CB)-norm of + // B2DPolygon and it's unused sign of being the zero-vector and CA and CB being + // relative to P, an empty edge was exported as P == CA == CB. Luckily, the new + // export format can be read without errors by the old OOo-versions, so we need only + // to correct here at read and do not need to export a wrong but compatible version + // for the future. + if(bControlA + && aControlA.equal(aControlB) + && aControlA.equal(aRetval.getB2DPoint(aRetval.count() - 1))) + { + bControlA = bControlB = false; + } + + if(bControlA) + { + // add bezier edge + aRetval.appendBezierSegment(aControlA, aControlB, aNewCoordinatePair); + } + else + { + // add edge + aRetval.append(aNewCoordinatePair); + } + } + + // #i72807# API import uses old line start/end-equal definition for closed, + // so we need to correct this to closed state here + if(bCheckClosed) + { + checkClosed(aRetval); + } + + return aRetval; + } + + void B2DPolygonToUnoPolygonBezierCoords( + const B2DPolygon& rPolygon, + com::sun::star::drawing::PointSequence& rPointSequenceRetval, + com::sun::star::drawing::FlagSequence& rFlagSequenceRetval) + { + const sal_uInt32 nPointCount(rPolygon.count()); + + if(nPointCount) + { + const bool bCurve(rPolygon.areControlPointsUsed()); + const bool bClosed(rPolygon.isClosed()); + + if(nPointCount) + { + if(bCurve) + { + // calculate target point count + const sal_uInt32 nLoopCount(bClosed ? nPointCount : (nPointCount ? nPointCount - 1 : 0)); + + if(nLoopCount) + { + // prepare target data. The real needed number of target points (and flags) + // could only be calculated by using two loops, so use dynamic memory + std::vector< com::sun::star::awt::Point > aCollectPoints; + std::vector< com::sun::star::drawing::PolygonFlags > aCollectFlags; + + // reserve maximum creatable points + const sal_uInt32 nMaxTargetCount((nLoopCount * 3) + 1); + aCollectPoints.reserve(nMaxTargetCount); + aCollectFlags.reserve(nMaxTargetCount); + + // prepare current bezier segment by setting start point + B2DCubicBezier aBezierSegment; + aBezierSegment.setStartPoint(rPolygon.getB2DPoint(0)); + + for(sal_uInt32 a(0); a < nLoopCount; a++) + { + // add current point (always) and remember StartPointIndex for evtl. later corrections + const sal_uInt32 nStartPointIndex(aCollectPoints.size()); + aCollectPoints.push_back( + com::sun::star::awt::Point( + fround(aBezierSegment.getStartPoint().getX()), + fround(aBezierSegment.getStartPoint().getY()))); + aCollectFlags.push_back(com::sun::star::drawing::PolygonFlags_NORMAL); + + // prepare next segment + const sal_uInt32 nNextIndex((a + 1) % nPointCount); + aBezierSegment.setEndPoint(rPolygon.getB2DPoint(nNextIndex)); + aBezierSegment.setControlPointA(rPolygon.getNextControlPoint(a)); + aBezierSegment.setControlPointB(rPolygon.getPrevControlPoint(nNextIndex)); + + if(aBezierSegment.isBezier()) + { + // if bezier is used, add always two control points due to the old schema + aCollectPoints.push_back( + com::sun::star::awt::Point( + fround(aBezierSegment.getControlPointA().getX()), + fround(aBezierSegment.getControlPointA().getY()))); + aCollectFlags.push_back(com::sun::star::drawing::PolygonFlags_CONTROL); + + aCollectPoints.push_back( + com::sun::star::awt::Point( + fround(aBezierSegment.getControlPointB().getX()), + fround(aBezierSegment.getControlPointB().getY()))); + aCollectFlags.push_back(com::sun::star::drawing::PolygonFlags_CONTROL); + } + + // test continuity with previous control point to set flag value + if(aBezierSegment.getControlPointA() != aBezierSegment.getStartPoint() && (bClosed || a)) + { + const B2VectorContinuity eCont(rPolygon.getContinuityInPoint(a)); + + if(CONTINUITY_C1 == eCont) + { + aCollectFlags[nStartPointIndex] = com::sun::star::drawing::PolygonFlags_SMOOTH; + } + else if(CONTINUITY_C2 == eCont) + { + aCollectFlags[nStartPointIndex] = com::sun::star::drawing::PolygonFlags_SYMMETRIC; + } + } + + // prepare next loop + aBezierSegment.setStartPoint(aBezierSegment.getEndPoint()); + } + + if(bClosed) + { + // add first point again as closing point due to old definition + aCollectPoints.push_back(aCollectPoints[0]); + aCollectFlags.push_back(com::sun::star::drawing::PolygonFlags_NORMAL); + } + else + { + // add last point as closing point + const B2DPoint aClosingPoint(rPolygon.getB2DPoint(nPointCount - 1L)); + aCollectPoints.push_back( + com::sun::star::awt::Point( + fround(aClosingPoint.getX()), + fround(aClosingPoint.getY()))); + aCollectFlags.push_back(com::sun::star::drawing::PolygonFlags_NORMAL); + } + + // copy collected data to target arrays + const sal_uInt32 nTargetCount(aCollectPoints.size()); + OSL_ENSURE(nTargetCount == aCollectFlags.size(), "Unequal Point and Flag count (!)"); + + rPointSequenceRetval.realloc((sal_Int32)nTargetCount); + rFlagSequenceRetval.realloc((sal_Int32)nTargetCount); + com::sun::star::awt::Point* pPointSequence = rPointSequenceRetval.getArray(); + com::sun::star::drawing::PolygonFlags* pFlagSequence = rFlagSequenceRetval.getArray(); + + for(sal_uInt32 a(0); a < nTargetCount; a++) + { + *pPointSequence = aCollectPoints[a]; + *pFlagSequence = aCollectFlags[a]; + pPointSequence++; + pFlagSequence++; + } + } + } + else + { + // straightforward point list creation + const sal_uInt32 nTargetCount(nPointCount + (bClosed ? 1 : 0)); + + rPointSequenceRetval.realloc((sal_Int32)nTargetCount); + rFlagSequenceRetval.realloc((sal_Int32)nTargetCount); + + com::sun::star::awt::Point* pPointSequence = rPointSequenceRetval.getArray(); + com::sun::star::drawing::PolygonFlags* pFlagSequence = rFlagSequenceRetval.getArray(); + + for(sal_uInt32 a(0); a < nPointCount; a++) + { + const B2DPoint aB2DPoint(rPolygon.getB2DPoint(a)); + const com::sun::star::awt::Point aAPIPoint( + fround(aB2DPoint.getX()), + fround(aB2DPoint.getY())); + + *pPointSequence = aAPIPoint; + *pFlagSequence = com::sun::star::drawing::PolygonFlags_NORMAL; + pPointSequence++; + pFlagSequence++; + } + + if(bClosed) + { + // add first point as closing point + *pPointSequence = *rPointSequenceRetval.getConstArray(); + *pFlagSequence = com::sun::star::drawing::PolygonFlags_NORMAL; + } + } + } + } + else + { + rPointSequenceRetval.realloc(0); + rFlagSequenceRetval.realloc(0); + } + } + } // end of namespace tools } // end of namespace basegfx Modified: openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolypolygontools.cxx URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolypolygontools.cxx?rev=1538719&r1=1538718&r2=1538719&view=diff ============================================================================== --- openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolypolygontools.cxx (original) +++ openoffice/branches/capstone2013/main/basegfx/source/polygon/b2dpolypolygontools.cxx Mon Nov 4 19:00:37 2013 @@ -19,10 +19,9 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basegfx.hxx" + #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <osl/diagnose.h> #include <basegfx/polygon/b2dpolypolygon.hxx> @@ -30,7 +29,6 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> - #include <numeric> ////////////////////////////////////////////////////////////////////////////// @@ -611,6 +609,120 @@ namespace basegfx return true; } + + ////////////////////////////////////////////////////////////////////////////// + // converters for com::sun::star::drawing::PointSequence + + B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon( + const com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceSource, + bool bCheckClosed) + { + B2DPolyPolygon aRetval; + const com::sun::star::drawing::PointSequence* pPointSequence = rPointSequenceSequenceSource.getConstArray(); + const com::sun::star::drawing::PointSequence* pPointSeqEnd = pPointSequence + rPointSequenceSequenceSource.getLength(); + + for(;pPointSequence != pPointSeqEnd; pPointSequence++) + { + const B2DPolygon aNewPolygon = UnoPointSequenceToB2DPolygon(*pPointSequence, bCheckClosed); + aRetval.append(aNewPolygon); + } + + return aRetval; + } + + void B2DPolyPolygonToUnoPointSequenceSequence( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PointSequenceSequence& rPointSequenceSequenceRetval) + { + const sal_uInt32 nCount(rPolyPolygon.count()); + + if(nCount) + { + rPointSequenceSequenceRetval.realloc(nCount); + com::sun::star::drawing::PointSequence* pPointSequence = rPointSequenceSequenceRetval.getArray(); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(a)); + + B2DPolygonToUnoPointSequence(aPolygon, *pPointSequence); + pPointSequence++; + } + } + else + { + rPointSequenceSequenceRetval.realloc(0); + } + } + + ////////////////////////////////////////////////////////////////////////////// + // converters for com::sun::star::drawing::PolyPolygonBezierCoords (curved polygons) + + B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon( + const com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource, + bool bCheckClosed) + { + B2DPolyPolygon aRetval; + const sal_uInt32 nSequenceCount((sal_uInt32)rPolyPolygonBezierCoordsSource.Coordinates.getLength()); + + if(nSequenceCount) + { + OSL_ENSURE(nSequenceCount == (sal_uInt32)rPolyPolygonBezierCoordsSource.Flags.getLength(), + "UnoPolyPolygonBezierCoordsToB2DPolyPolygon: unequal number of Points and Flags (!)"); + const com::sun::star::drawing::PointSequence* pPointSequence = rPolyPolygonBezierCoordsSource.Coordinates.getConstArray(); + const com::sun::star::drawing::FlagSequence* pFlagSequence = rPolyPolygonBezierCoordsSource.Flags.getConstArray(); + + for(sal_uInt32 a(0); a < nSequenceCount; a++) + { + const B2DPolygon aNewPolygon(UnoPolygonBezierCoordsToB2DPolygon( + *pPointSequence, + *pFlagSequence, + bCheckClosed)); + + pPointSequence++; + pFlagSequence++; + aRetval.append(aNewPolygon); + } + } + + return aRetval; + } + + void B2DPolyPolygonToUnoPolyPolygonBezierCoords( + const B2DPolyPolygon& rPolyPolygon, + com::sun::star::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval) + { + const sal_uInt32 nCount(rPolyPolygon.count()); + + if(nCount) + { + // prepare return value memory + rPolyPolygonBezierCoordsRetval.Coordinates.realloc((sal_Int32)nCount); + rPolyPolygonBezierCoordsRetval.Flags.realloc((sal_Int32)nCount); + + // get pointers to arrays + com::sun::star::drawing::PointSequence* pPointSequence = rPolyPolygonBezierCoordsRetval.Coordinates.getArray(); + com::sun::star::drawing::FlagSequence* pFlagSequence = rPolyPolygonBezierCoordsRetval.Flags.getArray(); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const B2DPolygon aSource(rPolyPolygon.getB2DPolygon(a)); + + B2DPolygonToUnoPolygonBezierCoords( + aSource, + *pPointSequence, + *pFlagSequence); + pPointSequence++; + pFlagSequence++; + } + } + else + { + rPolyPolygonBezierCoordsRetval.Coordinates.realloc(0); + rPolyPolygonBezierCoordsRetval.Flags.realloc(0); + } + } + } // end of namespace tools } // end of namespace basegfx