diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-05-11 13:45:11 +0200 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-05-11 13:45:11 +0200 |
commit | e924ca0d07165fa94c86e2c2b642458c9b2e08dd (patch) | |
tree | c2b111876c60865cf9165447c08d56b9e45e2073 | |
parent | ae9d7c2cef9ecd42687d64f985b9e2dcbc68a034 (diff) | |
parent | c5934ada09feec288519cbdfbe1c0c988a2fceec (diff) |
cws tl80: merge with DEV300 m77
353 files changed, 13395 insertions, 12573 deletions
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx index 4129cebdbd3d..6f96cf56f492 100644 --- a/basebmp/test/basictest.cxx +++ b/basebmp/test/basictest.cxx @@ -27,7 +27,10 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/point/b2ipoint.hxx> @@ -291,13 +294,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicTest, "BasicTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(BasicTest); } - -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -NOADDITIONAL; - +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx index e65c5e569d3c..9be504819fe8 100644 --- a/basebmp/test/bmpmasktest.cxx +++ b/basebmp/test/bmpmasktest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/range/b2irange.hxx> @@ -177,7 +179,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpMaskTest, "BmpMaskTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest); } diff --git a/basebmp/test/bmptest.cxx b/basebmp/test/bmptest.cxx index ce2e2440dcd1..9e33f0a8d713 100644 --- a/basebmp/test/bmptest.cxx +++ b/basebmp/test/bmptest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/range/b2irange.hxx> @@ -204,7 +206,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpTest, "BmpTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(BmpTest); } diff --git a/basebmp/test/cliptest.cxx b/basebmp/test/cliptest.cxx index 1c4a20bc0d86..875016d878cc 100644 --- a/basebmp/test/cliptest.cxx +++ b/basebmp/test/cliptest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/point/b2ipoint.hxx> @@ -271,7 +273,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ClipTest, "ClipTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(ClipTest); } diff --git a/basebmp/test/export.map b/basebmp/test/export.map index 709047ae63e5..3308588ef6f8 100644 --- a/basebmp/test/export.map +++ b/basebmp/test/export.map @@ -25,9 +25,9 @@ # #************************************************************************* -UDK_3.1 { +UDK_3_0_0 { global: - registerAllTestFunction; + cppunitTestPlugIn; local: *; diff --git a/basebmp/test/filltest.cxx b/basebmp/test/filltest.cxx index ea801de8111f..150fa11b3a72 100644 --- a/basebmp/test/filltest.cxx +++ b/basebmp/test/filltest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/range/b2drange.hxx> @@ -265,7 +267,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FillTest, "FillTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(FillTest); } diff --git a/basebmp/test/linetest.cxx b/basebmp/test/linetest.cxx index 3c30ed718b70..fcd383fccdb0 100644 --- a/basebmp/test/linetest.cxx +++ b/basebmp/test/linetest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/point/b2ipoint.hxx> @@ -213,7 +215,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(LineTest, "LineTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(LineTest); } diff --git a/basebmp/test/makefile.mk b/basebmp/test/makefile.mk index a11dacc1125d..ca77721716f7 100644 --- a/basebmp/test/makefile.mk +++ b/basebmp/test/makefile.mk @@ -60,6 +60,8 @@ CDEFS+=-xalias_level=compatible .ENDIF .ENDIF +CFLAGSCXX += $(CPPUNIT_CFLAGS) + # --- Common ---------------------------------------------------------- .IF "$(L10N_framework)"=="" @@ -74,17 +76,10 @@ SHL1OBJS= \ $(SLO)$/linetest.obj \ $(SLO)$/masktest.obj \ $(SLO)$/polytest.obj \ - $(SLO)$/tools.obj \ - $(SLO)$/bitmapdevice.obj \ - $(SLO)$/debug.obj \ - $(SLO)$/polypolygonrenderer.obj -# last three objs are a bit of a hack: cannot link against LIBBASEBMP -# here, because not yet delivered. Need the functionality to test, so -# we're linking it in statically. Need to keep this in sync with -# source/makefile.mk + $(SLO)$/tools.obj SHL1TARGET= tests -SHL1STDLIBS= $(SALLIB) \ - $(TESTSHL2LIB)\ +SHL1STDLIBS= $(BASEBMPLIB) \ + $(SALLIB) \ $(CPPUNITLIB) \ $(BASEGFXLIB) @@ -92,6 +87,8 @@ SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) SHL1VERSIONMAP = export.map +SHL1RPATH = NONE + .ENDIF # END ------------------------------------------------------------------ @@ -121,16 +118,8 @@ SLOFILES=$(SHL1OBJS) # --- Targets ------------------------------------------------------ .INCLUDE : target.mk -.INCLUDE : _cppunit.mk # --- Enable test execution in normal build ------------------------ .IF "$(L10N_framework)"=="" - -unittest : $(SHL1TARGETN) - @echo ---------------------------------------------------------- - @echo - start unit test on library $(SHL1TARGETN) - @echo ---------------------------------------------------------- - $(TESTSHL2) -sf $(mktmp ) $(SHL1TARGETN) - -ALLTAR : unittest +.INCLUDE : _cppunit.mk .ENDIF diff --git a/basebmp/test/masktest.cxx b/basebmp/test/masktest.cxx index e3843eba389a..77cd05588d5a 100644 --- a/basebmp/test/masktest.cxx +++ b/basebmp/test/masktest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/range/b2irange.hxx> @@ -165,7 +167,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MaskTest, "MaskTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(MaskTest); } diff --git a/basebmp/test/polytest.cxx b/basebmp/test/polytest.cxx index c8290668d1f8..f3b1f0018e17 100644 --- a/basebmp/test/polytest.cxx +++ b/basebmp/test/polytest.cxx @@ -27,7 +27,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/vector/b2isize.hxx> #include <basegfx/range/b2irange.hxx> @@ -285,7 +287,7 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(PolyTest, "PolyTest"); +CPPUNIT_TEST_SUITE_REGISTRATION(PolyTest); } diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx index 3941ee19cb42..7ce9e75c3058 100644 --- a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx +++ b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx @@ -32,6 +32,8 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/vector/b2dvector.hxx> +namespace rtl { class OUString; } + /////////////////////////////////////////////////////////////////////////////// namespace basegfx @@ -132,6 +134,7 @@ namespace basegfx rPoint.getX(), rPoint.getY(), fRadiant); } + } // end of namespace tools } // end of namespace basegfx @@ -220,6 +223,10 @@ namespace basegfx double getShearX() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return mfShearX; } }; } // end of namespace tools + + /// Returns a string with svg's "matrix(m00,m10,m01,m11,m02,m12)" representation + ::rtl::OUString exportToSvg( const B2DHomMatrix& rMatrix ); + } // end of namespace basegfx /////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx index b973adb8650b..65a6566dae25 100644 --- a/basegfx/inc/basegfx/numeric/ftools.hxx +++ b/basegfx/inc/basegfx/numeric/ftools.hxx @@ -109,7 +109,7 @@ namespace basegfx /** clamp given value against given minimum and maximum values */ - template <class T> const T& clamp(const T& value, const T& minimum, const T& maximum) + template <class T> inline const T& clamp(const T& value, const T& minimum, const T& maximum) { if(value < minimum) { @@ -175,7 +175,7 @@ namespace basegfx static bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue) { - return (fabs(rfValA) - fabs(rfValB) <= rfSmallValue); + return (fabs(rfValA - rfValB) <= rfSmallValue); } static bool less(const double& rfValA, const double& rfValB) diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx index 30f7786a6981..a12120b5f441 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx @@ -260,6 +260,12 @@ namespace basegfx /// apply transformation given in matrix form void transform(const basegfx::B2DHomMatrix& rMatrix); + + // point iterators (same iterator validity conditions as for vector) + const B2DPoint* begin() const; + const B2DPoint* end() const; + B2DPoint* begin(); + B2DPoint* end(); }; } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx b/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx index 538baa89aa81..a9d6e0a1b6fe 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx @@ -65,6 +65,14 @@ namespace basegfx B2DPolygon addPointsAtCuts(const B2DPolygon& rCandidate, const B2DPolyPolygon& rMask); B2DPolyPolygon addPointsAtCuts(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rMask); + // look for self-intersections in given polygon and add extra points there. Result will have no + // intersections on an edge + B2DPolygon addPointsAtCuts(const B2DPolygon& rCandidate); + + // add points at all self-intersections of single polygons (depends on bSelfIntersections) + // and at polygon-polygon intersections + B2DPolyPolygon addPointsAtCuts(const B2DPolyPolygon& rCandidate, bool bSelfIntersections = true); + } // end of namespace tools } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx index bea0de5c98d6..7d1d0bc9660c 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx @@ -271,6 +271,10 @@ namespace basegfx */ B2DPolygon createPolygonFromRect( const B2DRectangle& rRect ); + /** Create the unit polygon + */ + B2DPolygon createUnitPolygon(); + /** Create a circle polygon with given radius. This method creates a circle approximation consisting of diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx index 1ccaaa8330ec..0032cc47ce4e 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx @@ -125,6 +125,12 @@ namespace basegfx // apply transformation given in matrix form to the polygon void transform(const basegfx::B2DHomMatrix& rMatrix); + + // polygon iterators (same iterator validity conditions as for vector) + const B2DPolygon* begin() const; + const B2DPolygon* end() const; + B2DPolygon* begin(); + B2DPolygon* end(); }; } // end of namespace basegfx diff --git a/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx b/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx new file mode 100644 index 000000000000..70ffdf2b7339 --- /dev/null +++ b/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * 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: b2dpolygontriangulator.hxx,v $ + * $Revision: 1.5 $ + * + * 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_POLYGON_B2DTRAPEZOID_HXX +#define _BGFX_POLYGON_B2DTRAPEZOID_HXX + +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <vector> + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + // class to hold a single trapezoid + class B2DTrapezoid + { + private: + // Geometry data. YValues are down-oriented, this means bottom should + // be bigger than top to be below it. The constructor implementation + // guarantees: + // + // - mfBottomY >= mfTopY + // - mfTopXRight >= mfTopXLeft + // - mfBottomXRight >= mfBottomXLeft + double mfTopXLeft; + double mfTopXRight; + double mfTopY; + double mfBottomXLeft; + double mfBottomXRight; + double mfBottomY; + + public: + // constructor + B2DTrapezoid( + const double& rfTopXLeft, + const double& rfTopXRight, + const double& rfTopY, + const double& rfBottomXLeft, + const double& rfBottomXRight, + const double& rfBottomY); + + // data read access + const double& getTopXLeft() const { return mfTopXLeft; } + const double& getTopXRight() const { return mfTopXRight; } + const double& getTopY() const { return mfTopY; } + const double& getBottomXLeft() const { return mfBottomXLeft; } + const double& getBottomXRight() const { return mfBottomXRight; } + const double& getBottomY() const { return mfBottomY; } + + // convenience method to get content as Polygon + B2DPolygon getB2DPolygon() const; + }; + + typedef ::std::vector< B2DTrapezoid > B2DTrapezoidVector; + +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace tools + { + // convert SourcePolyPolygon to trapezoids. The trapezoids will be appended to + // ro_Result. ro_Result will not be cleared. If SourcePolyPolygon contains curves, + // it's default AdaptiveSubdivision will be used. + // CAUTION: Trapezoids are oreintation-dependent in the sense that the upper and lower + // lines have to be parallel to the X-Axis, thus this subdivision is NOT simply usable + // for primitive decompositions. To use it, the shear and rotate parts of the + // involved transformations HAVE to be taken into account. + void trapezoidSubdivide( + B2DTrapezoidVector& ro_Result, + const B2DPolyPolygon& rSourcePolyPolygon); + + // directly create trapezoids from given edge. Depending on the given geometry, + // none up to three trapezoids will be created + void createLineTrapezoidFromEdge( + B2DTrapezoidVector& ro_Result, + const B2DPoint& rPointA, + const B2DPoint& rPointB, + double fLineWidth = 1.0); + + // create trapezoids for all edges of the given polygon. The closed state of + // the polygon is taken into account. If curves are contaned, the default + // AdaptiveSubdivision will be used. + void createLineTrapezoidFromB2DPolygon( + B2DTrapezoidVector& ro_Result, + const B2DPolygon& rPolygon, + double fLineWidth = 1.0); + + // create trapezoids for all edges of the given polyPolygon. The closed state of + // the PolyPolygon is taken into account. If curves are contaned, the default + // AdaptiveSubdivision will be used. + void createLineTrapezoidFromB2DPolyPolygon( + B2DTrapezoidVector& ro_Result, + const B2DPolyPolygon& rPolyPolygon, + double fLineWidth = 1.0); + + } // end of namespace tools +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +#endif /* _BGFX_POLYGON_B2DTRAPEZOID_HXX */ diff --git a/basegfx/inc/basegfx/polygon/b3dgeometry.hxx b/basegfx/inc/basegfx/polygon/b3dgeometry.hxx deleted file mode 100644 index ec66f3e3a570..000000000000 --- a/basegfx/inc/basegfx/polygon/b3dgeometry.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************* - * - * 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_POLYGON_B3DGEOMETRY_HXX -#define _BGFX_POLYGON_B3DGEOMETRY_HXX - -////////////////////////////////////////////////////////////////////////////// -// predeclarations - -namespace basegfx -{ -} // end of namespace basegfx - -////////////////////////////////////////////////////////////////////////////// - -namespace basegfx -{ - class B3DGeometry - { - private: - B2DPolyPolygon maPolyPolygon; // the PolyPolygon geometry data, defines point number - B3DHomMatrix maPolygonTo3D; // transformation to create 3D PolyPolygon - B3DPolyPolygon maPolyNormal; // normal for each point or empty -> unified normal - B2DPolyPolygon maPolyTexture; // texture coordinate for each point or empty -> unified coordinate - B3DVector maUnifiedVector; // used when maNormal is empty - - // bitfield - unsigned mbUnifiedVectorValid : 1; // flag to know if uvec is calculated yet - - public: - B3DGeometry(); - ~B3DGeometry(); - - // compare operators - bool operator==(const B3DGeometry& rGeometry) const; - bool operator!=(const B3DGeometry& rGeometry) const { return (!operator==(rGeometry)); } - - // member count - sal_uInt32 count() const { return maPolyPolygon.count(); } - }; -} // end of namespace basegfx - -////////////////////////////////////////////////////////////////////////////// - - -#endif /* _BGFX_POLYGON_B3DPOLYGON_HXX */ diff --git a/basegfx/inc/basegfx/range/b2dmultirange.hxx b/basegfx/inc/basegfx/range/b2dmultirange.hxx deleted file mode 100644 index 4c1eb37be036..000000000000 --- a/basegfx/inc/basegfx/range/b2dmultirange.hxx +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * - * 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_RANGE_B2DMULTIRANGE_HXX -#define _BGFX_RANGE_B2DMULTIRANGE_HXX - -#include <o3tl/cow_wrapper.hxx> -#include <memory> - - -namespace basegfx -{ - class B2DTuple; - class B2DRange; - class B2DPolyPolygon; - class ImplB2DMultiRange; - - /** Multiple ranges in one object. - - This class combines multiple ranges in one object, providing a - total, enclosing range for it. - - You can use this class e.g. when updating views containing - rectangular objects. Add each modified object to a - B2DMultiRange, then test each viewable object against - intersection with the multi range. - */ - class B2DMultiRange - { - public: - B2DMultiRange(); - ~B2DMultiRange(); - - /** Create a multi range with exactly one containing range - */ - explicit B2DMultiRange( const B2DRange& rRange ); - - B2DMultiRange( const B2DMultiRange& ); - B2DMultiRange& operator=( const B2DMultiRange& ); - - /** Check whether range is empty. - - @return true, if this object either contains no ranges at - all, or all contained ranges are empty. - */ - bool isEmpty() const; - - /** Reset to empty. - - After this call, the object will not contain any ranges, - and isEmpty() will return true. - */ - void reset(); - - /** Test whether given tuple is inside one or more of the - included ranges. - */ - bool isInside( const B2DTuple& rTuple ) const; - - /** Test whether given range is inside one or more of the - included ranges. - */ - bool isInside( const B2DRange& rRange ) const; - - /** Test whether given range overlaps one or more of the - included ranges. - */ - bool overlaps( const B2DRange& rRange ) const; - - /** Add given range to the number of contained ranges. - */ - void addRange( const B2DRange& rRange ); - - /** Get overall bound rect for all included ranges. - */ - B2DRange getBounds() const; - - /** Request poly-polygon representing the added ranges. - - This method creates a poly-polygon, consisting exactly out - of the contained ranges. - */ - B2DPolyPolygon getPolyPolygon() const; - - private: - o3tl::cow_wrapper< ImplB2DMultiRange > mpImpl; - }; -} - -#endif /* _BGFX_RANGE_B2DMULTIRANGE_HXX */ diff --git a/basegfx/inc/basegfx/range/b2dpolyrange.hxx b/basegfx/inc/basegfx/range/b2dpolyrange.hxx new file mode 100644 index 000000000000..2202869dc921 --- /dev/null +++ b/basegfx/inc/basegfx/range/b2dpolyrange.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * 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: b2dmultirange.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_RANGE_B2DPOLYRANGE_HXX +#define _BGFX_RANGE_B2DPOLYRANGE_HXX + +#include <o3tl/cow_wrapper.hxx> +#include <boost/tuple/tuple.hpp> +#include <basegfx/vector/b2enums.hxx> + +namespace basegfx +{ + class B2DTuple; + class B2DRange; + class B2DPolyPolygon; + class ImplB2DPolyRange; + + /** Multiple ranges in one object. + + This class combines multiple ranges in one object, providing a + total, enclosing range for it. + + You can use this class e.g. when updating views containing + rectangular objects. Add each modified object to a + B2DMultiRange, then test each viewable object against + intersection with the multi range. + + Similar in spirit to the poly-polygon vs. polygon relationship. + + Note that comparable to polygons, a poly-range can also + contain 'holes' - this is encoded via polygon orientation at + the poly-polygon, and via explicit flags for the poly-range. + */ + class B2DPolyRange + { + public: + typedef boost::tuple<B2DRange,B2VectorOrientation> ElementType ; + + B2DPolyRange(); + ~B2DPolyRange(); + + /** Create a multi range with exactly one containing range + */ + explicit B2DPolyRange( const ElementType& rElement ); + B2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient ); + B2DPolyRange( const B2DPolyRange& ); + B2DPolyRange& operator=( const B2DPolyRange& ); + + /// unshare this poly-range with all internally shared instances + void makeUnique(); + + bool operator==(const B2DPolyRange&) const; + bool operator!=(const B2DPolyRange&) const; + + /// Number of included ranges + sal_uInt32 count() const; + + ElementType getElement(sal_uInt32 nIndex) const; + void setElement(sal_uInt32 nIndex, const ElementType& rElement ); + void setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient ); + + // insert/append a single range + void insertElement(sal_uInt32 nIndex, const ElementType& rElement, sal_uInt32 nCount = 1); + void insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1); + void appendElement(const ElementType& rElement, sal_uInt32 nCount = 1); + void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1); + + // insert/append multiple ranges + void insertPolyRange(sal_uInt32 nIndex, const B2DPolyRange&); + void appendPolyRange(const B2DPolyRange&); + + void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1); + void clear(); + + // flip range orientations - converts holes to solids, and vice versa + void flip(); + + /** Get overall range + + @return + The union range of all contained ranges + */ + B2DRange getBounds() const; + + /** Test whether given tuple is inside one or more of the + included ranges. Does *not* use overall range, but checks + individually. + */ + bool isInside( const B2DTuple& rTuple ) const; + + /** Test whether given range is inside one or more of the + included ranges. Does *not* use overall range, but checks + individually. + */ + bool isInside( const B2DRange& rRange ) const; + + /** Test whether given range overlaps one or more of the + included ranges. Does *not* use overall range, but checks + individually. + */ + bool overlaps( const B2DRange& rRange ) const; + + /** Request a poly-polygon with solved cross-overs + */ + B2DPolyPolygon solveCrossovers() const; + + // element iterators (same iterator validity conditions as for vector) + const B2DRange* begin() const; + const B2DRange* end() const; + B2DRange* begin(); + B2DRange* end(); + + private: + o3tl::cow_wrapper< ImplB2DPolyRange > mpImpl; + }; +} + +#endif /* _BGFX_RANGE_B2DPOLYRANGE_HXX */ diff --git a/basegfx/source/polygon/b3dgeometry.cxx b/basegfx/inc/basegfx/range/b2drangeclipper.hxx index 6c1537bac0a6..3285ffeaffe1 100644 --- a/basegfx/source/polygon/b3dgeometry.cxx +++ b/basegfx/inc/basegfx/range/b2drangeclipper.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: b2dmultirange.hxx,v $ + * $Revision: 1.6 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -25,31 +28,26 @@ * ************************************************************************/ -#include <osl/diagnose.h> -#include <basegfx/polygon/b3dgeometry.hxx> +#ifndef _BGFX_RANGE_B2DRANGECLIPPER_HXX +#define _BGFX_RANGE_B2DRANGECLIPPER_HXX -////////////////////////////////////////////////////////////////////////////// +#include <basegfx/range/b2dpolyrange.hxx> +#include <vector> namespace basegfx { - B3DGeometry::B3DGeometry() - : mbUnifiedVectorValid(false) + namespace tools { - } + /** Extract poly-polygon w/o self-intersections from poly-range - B3DGeometry::~B3DGeometry() - { + Similar to the solveCrossovers(const B2DPolyPolygon&) + method, this one calculates a self-intersection-free + poly-polygon with the same topology, and encoding + inside/outsidedness via polygon orientation and layering. + */ + B2DPolyPolygon solveCrossovers(const std::vector<B2DRange>& rRanges, + const std::vector<B2VectorOrientation>& rOrientations); } +} - bool B3DGeometry::operator==(const B3DGeometry& rGeometry) const - { - return (maPolyPolygon == maPolyPolygon - && maPolygonTo3D == maPolygonTo3D - && maPolyNormal == maPolyNormal - && maPolyTexture == maPolyTexture - } - -} // end of namespace basegfx - -////////////////////////////////////////////////////////////////////////////// -// eof +#endif /* _BGFX_RANGE_B2DRANGECLIPPER_HXX */ 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/gradienttools.hxx b/basegfx/inc/basegfx/tools/gradienttools.hxx index 0dab1a5117ff..2f436fa1d717 100644 --- a/basegfx/inc/basegfx/tools/gradienttools.hxx +++ b/basegfx/inc/basegfx/tools/gradienttools.hxx @@ -34,6 +34,9 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/numeric/ftools.hxx> +#include <vector> +#include <algorithm> + namespace basegfx { /** Gradient definition as used in ODF 1.2 @@ -75,6 +78,8 @@ namespace basegfx { /** 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) @@ -106,7 +111,7 @@ namespace basegfx @param rUV Current uv coordinate. Values outside [0,1] will be - clamped. + clamped. Assumes gradient color varies along the y axis. @param rGradInfo Gradient info, for transformation and number of steps @@ -126,6 +131,14 @@ namespace basegfx /** 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) @@ -157,7 +170,7 @@ namespace basegfx @param rUV Current uv coordinate. Values outside [0,1] will be - clamped. + clamped. Assumes gradient color varies along the y axis. @param rGradInfo Gradient info, for transformation and number of steps @@ -391,7 +404,6 @@ namespace basegfx { return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs } - } } 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/vcl/aqua/inc/salpixmaputils.hxx b/basegfx/inc/basegfx/tools/lerp.hxx index 18d00b9856a0..590ef34c2009 100755..100644 --- a/vcl/aqua/inc/salpixmaputils.hxx +++ b/basegfx/inc/basegfx/tools/lerp.hxx @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * 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 @@ -25,23 +28,33 @@ * ************************************************************************/ -#ifndef _SV_SALPIXMAPUTILS_HXX -#define _SV_SALPIXMAPUTILS_HXX - -#include "premac.h" -#include <ApplicationServices/ApplicationServices.h> -#include "postmac.h" +#ifndef _BGFX_TOOLS_LERP_HXX +#define _BGFX_TOOLS_LERP_HXX -#include "tools/gen.hxx" -#include "vcl/salbtype.hxx" -#include "vcl/salgtype.hxx" -#include "salconst.h" -#include "salcolorutils.hxx" +#include <sal/types.h> -// ------------------------------------------------------------------ +namespace basegfx +{ + namespace tools + { + /** Generic linear interpolator -// Empty. Do we need this? + @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 // _SV_SALPIXMAPUTILS_HXX +#endif /* _BGFX_TOOLS_LERP_HXX */ diff --git a/basegfx/inc/basegfx/tuple/b2dtuple.hxx b/basegfx/inc/basegfx/tuple/b2dtuple.hxx index e0e2438307e4..71dd227ac736 100644 --- a/basegfx/inc/basegfx/tuple/b2dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b2dtuple.hxx @@ -155,15 +155,17 @@ namespace basegfx bool equal(const B2DTuple& rTup) const { return ( - fTools::equal(mfX, rTup.mfX) && - fTools::equal(mfY, rTup.mfY)); + this == &rTup || + (fTools::equal(mfX, rTup.mfX) && + fTools::equal(mfY, rTup.mfY))); } bool equal(const B2DTuple& rTup, const double& rfSmallValue) const { return ( - fTools::equal(mfX, rTup.mfX, rfSmallValue) && - fTools::equal(mfY, rTup.mfY, rfSmallValue)); + this == &rTup || + (fTools::equal(mfX, rTup.mfX, rfSmallValue) && + fTools::equal(mfY, rTup.mfY, rfSmallValue))); } // operators diff --git a/basegfx/inc/basegfx/tuple/b2i64tuple.hxx b/basegfx/inc/basegfx/tuple/b2i64tuple.hxx index 1bd81dc0e374..9c813c07a994 100644 --- a/basegfx/inc/basegfx/tuple/b2i64tuple.hxx +++ b/basegfx/inc/basegfx/tuple/b2i64tuple.hxx @@ -182,7 +182,7 @@ namespace basegfx bool operator==( const B2I64Tuple& rTup ) const { - return rTup.mnX == mnX && rTup.mnY == mnY; + return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY); } bool operator!=( const B2I64Tuple& rTup ) const diff --git a/basegfx/inc/basegfx/tuple/b2ituple.hxx b/basegfx/inc/basegfx/tuple/b2ituple.hxx index 9fa6e7119ee7..da29b5509dec 100644 --- a/basegfx/inc/basegfx/tuple/b2ituple.hxx +++ b/basegfx/inc/basegfx/tuple/b2ituple.hxx @@ -181,7 +181,7 @@ namespace basegfx bool operator==( const B2ITuple& rTup ) const { - return rTup.mnX == mnX && rTup.mnY == mnY; + return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY); } bool operator!=( const B2ITuple& rTup ) const diff --git a/basegfx/inc/basegfx/tuple/b3dtuple.hxx b/basegfx/inc/basegfx/tuple/b3dtuple.hxx index 6ad063d124a0..11fb797ff0ff 100644 --- a/basegfx/inc/basegfx/tuple/b3dtuple.hxx +++ b/basegfx/inc/basegfx/tuple/b3dtuple.hxx @@ -179,17 +179,19 @@ namespace basegfx bool equal(const B3DTuple& rTup) const { return ( - ::basegfx::fTools::equal(mfX, rTup.mfX) && + this == &rTup || + (::basegfx::fTools::equal(mfX, rTup.mfX) && ::basegfx::fTools::equal(mfY, rTup.mfY) && - ::basegfx::fTools::equal(mfZ, rTup.mfZ)); + ::basegfx::fTools::equal(mfZ, rTup.mfZ))); } bool equal(const B3DTuple& rTup, const double& rfSmallValue) const { return ( - ::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) && + this == &rTup || + (::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) && ::basegfx::fTools::equal(mfY, rTup.mfY, rfSmallValue) && - ::basegfx::fTools::equal(mfZ, rTup.mfZ, rfSmallValue)); + ::basegfx::fTools::equal(mfZ, rTup.mfZ, rfSmallValue))); } // operators diff --git a/basegfx/inc/basegfx/tuple/b3i64tuple.hxx b/basegfx/inc/basegfx/tuple/b3i64tuple.hxx index 13a7cb87ace3..a2d754fe4f79 100644 --- a/basegfx/inc/basegfx/tuple/b3i64tuple.hxx +++ b/basegfx/inc/basegfx/tuple/b3i64tuple.hxx @@ -212,7 +212,7 @@ namespace basegfx bool operator==( const B3I64Tuple& rTup ) const { - return rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ; + return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ); } bool operator!=( const B3I64Tuple& rTup ) const diff --git a/basegfx/inc/basegfx/tuple/b3ituple.hxx b/basegfx/inc/basegfx/tuple/b3ituple.hxx index 4df462bf3f22..644ae07b6545 100644 --- a/basegfx/inc/basegfx/tuple/b3ituple.hxx +++ b/basegfx/inc/basegfx/tuple/b3ituple.hxx @@ -212,7 +212,7 @@ namespace basegfx bool operator==( const B3ITuple& rTup ) const { - return rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ; + return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ); } bool operator!=( const B3ITuple& rTup ) const diff --git a/basegfx/prj/build.lst b/basegfx/prj/build.lst index 418b3822a7ee..fe3354b3f256 100644 --- a/basegfx/prj/build.lst +++ b/basegfx/prj/build.lst @@ -1,4 +1,4 @@ -fx basegfx : o3tl sal offuh cppuhelper cppu testshl2 NULL +fx basegfx : o3tl sal offuh cppuhelper cppu CPPUNIT:cppunit NULL fx basegfx usr1 - all fx_mkout NULL fx basegfx\inc nmake - all fx_inc NULL fx basegfx\prj get - all fx_prj NULL diff --git a/basegfx/prj/d.lst b/basegfx/prj/d.lst index a58cd33e4f9c..3d4d985f3ae6 100644 --- a/basegfx/prj/d.lst +++ b/basegfx/prj/d.lst @@ -27,7 +27,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\range ..\inc\basegfx\range\basicrange.hxx %_DEST%\inc%_EXT%\basegfx\range\basicrange.hxx ..\inc\basegfx\range\basicbox.hxx %_DEST%\inc%_EXT%\basegfx\range\basicbox.hxx ..\inc\basegfx\range\b1drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b1drange.hxx -..\inc\basegfx\range\b2dmultirange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dmultirange.hxx +..\inc\basegfx\range\b2dpolyrange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dpolyrange.hxx ..\inc\basegfx\range\b2drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2drange.hxx ..\inc\basegfx\range\b2drectangle.hxx %_DEST%\inc%_EXT%\basegfx\range\b2drectangle.hxx ..\inc\basegfx\range\b2dconnectedranges.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dconnectedranges.hxx @@ -73,6 +73,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\polygon ..\inc\basegfx\polygon\b2dpolygontriangulator.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolygontriangulator.hxx ..\inc\basegfx\polygon\b2dpolygoncutandtouch.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolygoncutandtouch.hxx ..\inc\basegfx\polygon\b2dpolypolygoncutter.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dpolypolygoncutter.hxx +..\inc\basegfx\polygon\b2dtrapezoid.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b2dtrapezoid.hxx ..\inc\basegfx\polygon\b3dpolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolygon.hxx ..\inc\basegfx\polygon\b3dpolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolypolygon.hxx ..\inc\basegfx\polygon\b3dpolygontools.hxx %_DEST%\inc%_EXT%\basegfx\polygon\b3dpolygontools.hxx @@ -89,7 +90,10 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\tuple mkdir: %_DEST%\inc%_EXT%\basegfx\tools ..\inc\basegfx\tools\canvastools.hxx %_DEST%\inc%_EXT%\basegfx\tools\canvastools.hxx +..\inc\basegfx\tools\keystoplerp.hxx %_DEST%\inc%_EXT%\basegfx\tools\keystoplerp.hxx +..\inc\basegfx\tools\lerp.hxx %_DEST%\inc%_EXT%\basegfx\tools\lerp.hxx ..\inc\basegfx\tools\unopolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\tools\unopolypolygon.hxx +..\inc\basegfx\tools\b2dclipstate.hxx %_DEST%\inc%_EXT%\basegfx\tools\b2dclipstate.hxx ..\inc\basegfx\tools\rectcliptools.hxx %_DEST%\inc%_EXT%\basegfx\tools\rectcliptools.hxx ..\inc\basegfx\tools\tools.hxx %_DEST%\inc%_EXT%\basegfx\tools\tools.hxx ..\inc\basegfx\tools\gradienttools.hxx %_DEST%\inc%_EXT%\basegfx\tools\gradienttools.hxx diff --git a/basegfx/qa/mkpolygons.pl b/basegfx/qa/mkpolygons.pl new file mode 100644 index 000000000000..b465a4f845ab --- /dev/null +++ b/basegfx/qa/mkpolygons.pl @@ -0,0 +1,344 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; + +# +# 2009 Copyright Novell, Inc. & Sun Microsystems, Inc. +# +# 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. +# + +use IO::File; +use Cwd; +use File::Spec; +use File::Spec::Functions; +use File::Temp; +use File::Path; + +$TempDir = ""; + + +# all the XML package generation is a blatant rip from AF's +# write-calc-doc.pl + + +############################################################################### +# Open a file with the given name. +# First it is checked if the temporary directory, in which all files for +# the document are gathered, is already present and create it if it is not. +# Then create the path to the file inside the temporary directory. +# Finally open the file and return a file handle to it. +# +sub open_file +{ + my $filename = pop @_; + + # Create base directory of temporary directory tree if not alreay + # present. + if ($TempDir eq "") + { + $TempDir = File::Temp::tempdir (CLEANUP => 1); + } + + # Create the path to the file. + my $fullname = File::Spec->catfile ($TempDir, $filename); + my ($volume,$directories,$file) = File::Spec->splitpath ($fullname); + mkpath (File::Spec->catpath ($volume,$directories,"")); + + # Open the file and return a file handle to it. + return new IO::File ($fullname, "w"); +} + + +############################################################################### +# Zip the files in the directory tree into the given file. +# +sub zip_dirtree +{ + my $filename = pop @_; + + my $cwd = getcwd; + my $zip_name = $filename; + + # We are about to change the directory. + # Therefore create an absolute pathname for the zip archive. + + # First transfer the drive from $cwd to $zip_name. This is a + # workaround for a bug in file_name_is_absolute which thinks + # the the path \bla is an absolute path under DOS. + my ($volume,$directories,$file) = File::Spec->splitpath ($zip_name); + my ($volume_cwd,$directories_cwd,$file_cwd) = File::Spec->splitpath ($cwd); + $volume = $volume_cwd if ($volume eq ""); + $zip_name = File::Spec->catpath ($volume,$directories,$file); + + # Add the current working directory to a relative path. + if ( ! file_name_is_absolute ($zip_name)) + { + $zip_name = File::Spec->catfile ($cwd, $zip_name); + + # Try everything to clean up the name. + $zip_name = File::Spec->rel2abs ($filename); + $zip_name = File::Spec->canonpath ($zip_name); + + # Remove .. directories from the middle of the path. + while ($zip_name =~ /\/[^\/][^\.\/][^\/]*\/\.\.\//) + { + $zip_name = $` . "/" . $'; + } + } + + # Just in case the zip program gets confused by an existing file with the + # same name as the one to be written that file is removed first. + if ( -e $filename) + { + if (unlink ($filename) == 0) + { + print "Existing file $filename could not be deleted.\n"; + print "Please close the application that uses it, then try again.\n"; + return; + } + } + + # Finally create the zip file. First change into the temporary directory + # so that the resulting zip file contains only paths relative to it. + print "zipping [$ZipCmd $ZipFlags $zip_name *]\n"; + chdir ($TempDir); + system ("$ZipCmd $ZipFlags $zip_name *"); + chdir ($cwd); +} + + +sub writeHeader +{ + print $OUT qq~<?xml version="1.0" encoding="UTF-8"?> + +<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" office:version="1.0"> + <office:scripts/> + <office:automatic-styles> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties presentation:background-visible="true" presentation:background-objects-visible="true" presentation:display-footer="true" presentation:display-page-number="false" presentation:display-date-time="true"/> + </style:style> + <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard"> + <style:graphic-properties draw:textarea-horizontal-align="center" draw:fill="none" draw:stroke="none" draw:textarea-vertical-align="middle"/> + </style:style> + <style:style style:name="gr2" style:family="graphic" style:parent-style-name="standard"> + <style:graphic-properties draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle"/> + </style:style> + <style:style style:name="pr1" style:family="presentation" style:parent-style-name="Default-title"> + <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="3.508cm"/> + </style:style> + <style:style style:name="pr2" style:family="presentation" style:parent-style-name="Default-notes"> + <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="13.367cm"/> + </style:style> + <style:style style:name="P1" style:family="paragraph"> + <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm"/> + </style:style> + <style:style style:name="P2" style:family="paragraph"> + <style:paragraph-properties fo:margin-left="0.6cm" fo:margin-right="0cm" fo:text-indent="-0.6cm"/> + </style:style> + <text:list-style style:name="L1"> + <text:list-level-style-bullet text:level="1" text:bullet-char="●"> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="2" text:bullet-char="●"> + <style:list-level-properties text:space-before="0.6cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="3" text:bullet-char="●"> + <style:list-level-properties text:space-before="1.2cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="4" text:bullet-char="●"> + <style:list-level-properties text:space-before="1.8cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="5" text:bullet-char="●"> + <style:list-level-properties text:space-before="2.4cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="6" text:bullet-char="●"> + <style:list-level-properties text:space-before="3cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="7" text:bullet-char="●"> + <style:list-level-properties text:space-before="3.6cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="8" text:bullet-char="●"> + <style:list-level-properties text:space-before="4.2cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + <text:list-level-style-bullet text:level="9" text:bullet-char="●"> + <style:list-level-properties text:space-before="4.8cm" text:min-label-width="0.6cm"/> + <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/> + </text:list-level-style-bullet> + </text:list-style> + </office:automatic-styles> + <office:body> + <office:presentation> +~; + +} + +sub writeSlideHeader +{ + my $titleText = pop @_; + my $slideNum = pop @_; + + print $OUT " <draw:page draw:name=\"page1\" draw:style-name=\"dp1\" draw:master-page-name=\"Default\">\n"; + print $OUT " <office:forms form:automatic-focus=\"false\" form:apply-design-mode=\"false\"/>\n"; + print $OUT " <draw:rect draw:style-name=\"gr1\" draw:text-style-name=\"P1\" draw:id=\"id$slideNum\" draw:layer=\"layout\" svg:width=\"17.5cm\" svg:height=\"6cm\" svg:x=\"5cm\" svg:y=\"4cm\">\n"; + print $OUT " <text:p text:style-name=\"P2\">Slide: $slideNum</text:p>\n"; + print $OUT " <text:p text:style-name=\"P2\">Path: $titleText</text:p>\n"; + print $OUT " </draw:rect>\n"; +} + + +sub writeSlideFooter +{ + print $OUT " <presentation:notes draw:style-name=\"dp1\">\n"; + print $OUT " <draw:page-thumbnail draw:style-name=\"gr1\" draw:layer=\"layout\" svg:width=\"14.851cm\" svg:height=\"11.138cm\" svg:x=\"3.068cm\" svg:y=\"2.257cm\" draw:page-number=\"1\" presentation:class=\"page\"/>\n"; + print $OUT " <draw:frame presentation:style-name=\"pr3\" draw:layer=\"layout\" svg:width=\"16.79cm\" svg:height=\"13.116cm\" svg:x=\"2.098cm\" svg:y=\"14.109cm\" presentation:class=\"notes\" presentation:placeholder=\"true\">\n"; + print $OUT " <draw:text-box/>\n"; + print $OUT " </draw:frame>\n"; + print $OUT " </presentation:notes>\n"; + print $OUT " </draw:page>\n"; +} + +sub writeFooter +{ + print $OUT qq~ <presentation:settings presentation:full-screen="false"/> + </office:presentation> + </office:body> +</office:document-content> +~; + +} + +sub writePath +{ + my $pathAry = pop @_; + my $path = $pathAry->[1]; + my $viewBox = $pathAry->[0]; + + print $OUT " <draw:path draw:style-name=\"gr2\" draw:text-style-name=\"P1\" draw:layer=\"layout\" svg:width=\"10cm\" svg:height=\"10cm\" svg:x=\"5cm\" svg:y=\"5cm\" svg:viewBox=\""; + print $OUT $viewBox; + print $OUT "\" svg:d=\""; + print $OUT $path; + print $OUT "\">\n"; + print $OUT " <text:p/>\n"; + print $OUT " </draw:path>\n"; +} + +sub writeManifest +{ + my $outFile = open_file("META-INF/manifest.xml"); + + print $outFile qq~<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd"> +<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"> + <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.presentation" manifest:full-path="/"/> + <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/> +</manifest:manifest> +~; + + $outFile->close; +} + + +############################################################################### +# Print usage information. +# +sub usage () +{ + print <<END_OF_USAGE; +usage: $0 <option>* [<SvgD-values>] + +output-file-name defaults to polygons.odp. + + -h Print this usage information. + -o output-file-name +END_OF_USAGE +} + +############################################################################### +# Process the command line. +# +sub process_command_line +{ + foreach (@ARGV) + { + if (/^-h/) + { + usage; + exit 0; + } + } + + $global_output_name = "polygons.odp"; + my $j = 0, $noMoreOptions = 0; + for (my $i=0; $i<$#ARGV; $i++) + { + if ( !$noMoreOptions and $ARGV[$i] eq "-o") + { + $i++; + $global_output_name = $ARGV[$i]; + } + elsif ( !$noMoreOptions and $ARGV[$i] eq "--") + { + $noMoreOptions = 1; + } + elsif ( !$noMoreOptions and $ARGV[$i] =~ /^-/) + { + print "Unknown option $ARGV[$i]\n"; + usage; + exit 1; + } + else + { + push(@paths, [$ARGV[$i],$ARGV[$i+1]]); + $i++; + } + } + + print "output to $global_output_name\n"; +} + +############################################################################### +# Main +############################################################################### + +$ZipCmd = $ENV{LOG_FILE_ZIP_CMD}; +$ZipFlags = $ENV{LOG_FILE_ZIP_FLAGS}; +# Provide default values for the zip command and it's flags. +if ( ! defined $ZipCmd) +{ + $ZipCmd = "zip" unless defined $ZipCmd; + $ZipFlags = "-r -q" unless defined $ZipFlags; +} + +process_command_line(); + +writeManifest(); + +$OUT = open_file( "content.xml" ); + +writeHeader(); + +$pathNum=0; +foreach $path (@paths) +{ + writeSlideHeader($pathNum, $path->[1]); + writePath($path); + writeSlideFooter(); + $pathNum++; +} + +writeFooter(); + +$OUT->close; + +zip_dirtree ($global_output_name); + diff --git a/basegfx/source/color/bcolortools.cxx b/basegfx/source/color/bcolortools.cxx index f7f26c6dd843..543097de3d77 100644 --- a/basegfx/source/color/bcolortools.cxx +++ b/basegfx/source/color/bcolortools.cxx @@ -61,7 +61,7 @@ namespace basegfx { namespace tools else if( g == maxVal ) h = 2.0 + (b - r)/d; else - h = 4.0 + (r - h)/d; + h = 4.0 + (r - g)/d; h *= 60.0; diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx index 0f294d6a262f..0b85ee229ecc 100644 --- a/basegfx/source/matrix/b2dhommatrixtools.cxx +++ b/basegfx/source/matrix/b2dhommatrixtools.cxx @@ -29,11 +29,39 @@ #include "precompiled_basegfx.hxx" #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> /////////////////////////////////////////////////////////////////////////////// namespace basegfx { + ::rtl::OUString exportToSvg( const B2DHomMatrix& rMatrix ) + { + rtl::OUStringBuffer aStrBuf; + aStrBuf.appendAscii("matrix("); + + aStrBuf.append(rMatrix.get(0,0)); + aStrBuf.appendAscii(", "); + + aStrBuf.append(rMatrix.get(1,0)); + aStrBuf.appendAscii(", "); + + aStrBuf.append(rMatrix.get(0,1)); + aStrBuf.appendAscii(", "); + + aStrBuf.append(rMatrix.get(1,1)); + aStrBuf.appendAscii(", "); + + aStrBuf.append(rMatrix.get(0,2)); + aStrBuf.appendAscii(", "); + + aStrBuf.append(rMatrix.get(1,2)); + aStrBuf.appendAscii(")"); + + return aStrBuf.makeStringAndClear(); + } + namespace tools { void createSinCosOrthogonal(double& o_rSin, double& o_rCos, double fRadiant) diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index dc16938a3f99..d8255dc7ec10 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -41,38 +41,24 @@ ////////////////////////////////////////////////////////////////////////////// -class CoordinateData2D +struct CoordinateData2D : public basegfx::B2DPoint { - basegfx::B2DPoint maPoint; - public: - CoordinateData2D() - : maPoint() - {} + CoordinateData2D() {} explicit CoordinateData2D(const basegfx::B2DPoint& rData) - : maPoint(rData) + : B2DPoint(rData) {} - const basegfx::B2DPoint& getCoordinate() const + CoordinateData2D& operator=(const basegfx::B2DPoint& rData) { - return maPoint; - } - - void setCoordinate(const basegfx::B2DPoint& rValue) - { - if(rValue != maPoint) - maPoint = rValue; - } - - bool operator==(const CoordinateData2D& rData ) const - { - return (maPoint == rData.getCoordinate()); + B2DPoint::operator=(rData); + return *this; } void transform(const basegfx::B2DHomMatrix& rMatrix) { - maPoint *= rMatrix; + *this *= rMatrix; } }; @@ -112,12 +98,12 @@ public: const basegfx::B2DPoint& getCoordinate(sal_uInt32 nIndex) const { - return maVector[nIndex].getCoordinate(); + return maVector[nIndex]; } void setCoordinate(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue) { - maVector[nIndex].setCoordinate(rValue); + maVector[nIndex] = rValue; } void reserve(sal_uInt32 nCount) @@ -228,6 +214,38 @@ public: aStart->transform(rMatrix); } } + + const basegfx::B2DPoint* begin() const + { + if(maVector.empty()) + return 0; + else + return &maVector.front(); + } + + const basegfx::B2DPoint* end() const + { + if(maVector.empty()) + return 0; + else + return (&maVector.back())+1; + } + + basegfx::B2DPoint* begin() + { + if(maVector.empty()) + return 0; + else + return &maVector.front(); + } + + basegfx::B2DPoint* end() + { + if(maVector.empty()) + return 0; + else + return (&maVector.back())+1; + } }; ////////////////////////////////////////////////////////////////////////////// @@ -1149,6 +1167,28 @@ public: maPoints.transform(rMatrix); } } + + const basegfx::B2DPoint* begin() const + { + return maPoints.begin(); + } + + const basegfx::B2DPoint* end() const + { + return maPoints.end(); + } + + basegfx::B2DPoint* begin() + { + mpBufferedData.reset(); + return maPoints.begin(); + } + + basegfx::B2DPoint* end() + { + mpBufferedData.reset(); + return maPoints.end(); + } }; ////////////////////////////////////////////////////////////////////////////// @@ -1586,6 +1626,26 @@ namespace basegfx mpPolygon->transform(rMatrix); } } + + const B2DPoint* B2DPolygon::begin() const + { + return mpPolygon->begin(); + } + + const B2DPoint* B2DPolygon::end() const + { + return mpPolygon->end(); + } + + B2DPoint* B2DPolygon::begin() + { + return mpPolygon->begin(); + } + + B2DPoint* B2DPolygon::end() + { + return mpPolygon->end(); + } } // end of namespace basegfx ////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx index 9eab4b26c8b3..11955ceb22f9 100644 --- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx +++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx @@ -1200,6 +1200,96 @@ namespace basegfx return aRetval; } + B2DPolygon addPointsAtCuts(const B2DPolygon& rCandidate) + { + if(rCandidate.count()) + { + temporaryPointVector aTempPoints; + + findCuts(rCandidate, aTempPoints); + + return mergeTemporaryPointsAndPolygon(rCandidate, aTempPoints); + } + else + { + return rCandidate; + } + } + + B2DPolyPolygon addPointsAtCuts(const B2DPolyPolygon& rCandidate, bool bSelfIntersections) + { + const sal_uInt32 nCount(rCandidate.count()); + + if(nCount) + { + B2DPolyPolygon aRetval; + + if(1 == nCount) + { + if(bSelfIntersections) + { + // remove self intersections + aRetval.append(addPointsAtCuts(rCandidate.getB2DPolygon(0))); + } + else + { + // copy source + aRetval = rCandidate; + } + } + else + { + // first solve self cuts for all contained single polygons + temporaryPolygonData *pTempData = new temporaryPolygonData[nCount]; + sal_uInt32 a, b; + + for(a = 0; a < nCount; a++) + { + if(bSelfIntersections) + { + // use polygons with solved self intersections + pTempData[a].setPolygon(addPointsAtCuts(rCandidate.getB2DPolygon(a))); + } + else + { + // copy given polygons + pTempData[a].setPolygon(rCandidate.getB2DPolygon(a)); + } + } + + // now cuts and touches between the polygons + for(a = 0; a < nCount; a++) + { + for(b = 0; b < nCount; b++) + { + if(a < b) + { + // look for cuts, compare each edge polygon to following ones + if(pTempData[a].getRange().overlaps(pTempData[b].getRange())) + { + findCuts(pTempData[a].getPolygon(), pTempData[b].getPolygon(), pTempData[a].getTemporaryPointVector(), pTempData[b].getTemporaryPointVector()); + } + } + } + } + + // consolidate the result + for(a = 0L; a < nCount; a++) + { + aRetval.append(mergeTemporaryPointsAndPolygon(pTempData[a].getPolygon(), pTempData[a].getTemporaryPointVector())); + } + + delete[] pTempData; + } + + return aRetval; + } + else + { + return rCandidate; + } + } + //////////////////////////////////////////////////////////////////////////////// } // end of namespace tools diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 28e5bb1f430d..e9db491ecd48 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1835,6 +1835,24 @@ namespace basegfx return aRetval; } + B2DPolygon createUnitPolygon() + { + static B2DPolygon aRetval; + + if(!aRetval.count()) + { + aRetval.append( B2DPoint( 0.0, 0.0 ) ); + aRetval.append( B2DPoint( 1.0, 0.0 ) ); + aRetval.append( B2DPoint( 1.0, 1.0 ) ); + aRetval.append( B2DPoint( 0.0, 1.0 ) ); + + // close + aRetval.setClosed( true ); + } + + return aRetval; + } + B2DPolygon createPolygonFromCircle( const B2DPoint& rCenter, double fRadius ) { return createPolygonFromEllipse( rCenter, fRadius, fRadius ); @@ -2328,7 +2346,8 @@ namespace basegfx // polygon must be closed to resemble a rect, and contain // at least four points. if( !rPoly.isClosed() || - rPoly.count() < 4 ) + rPoly.count() < 4 || + rPoly.areControlPointsUsed() ) { return false; } diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index 767d2b25ced5..9b28dffd19af 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -163,6 +163,38 @@ public: maPolygons.end(), std::mem_fun_ref( &basegfx::B2DPolygon::makeUnique )); } + + const basegfx::B2DPolygon* begin() const + { + if(maPolygons.empty()) + return 0; + else + return &maPolygons.front(); + } + + const basegfx::B2DPolygon* end() const + { + if(maPolygons.empty()) + return 0; + else + return (&maPolygons.back())+1; + } + + basegfx::B2DPolygon* begin() + { + if(maPolygons.empty()) + return 0; + else + return &maPolygons.front(); + } + + basegfx::B2DPolygon* end() + { + if(maPolygons.empty()) + return 0; + else + return &(maPolygons.back())+1; + } }; ////////////////////////////////////////////////////////////////////////////// @@ -375,6 +407,26 @@ namespace basegfx mpPolyPolygon->transform(rMatrix); } } + + const B2DPolygon* B2DPolyPolygon::begin() const + { + return mpPolyPolygon->begin(); + } + + const B2DPolygon* B2DPolyPolygon::end() const + { + return mpPolyPolygon->end(); + } + + B2DPolygon* B2DPolyPolygon::begin() + { + return mpPolyPolygon->begin(); + } + + B2DPolygon* B2DPolyPolygon::end() + { + return mpPolyPolygon->end(); + } } // end of namespace basegfx // eof diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index bbb6db4c064a..d2815337edaf 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -65,10 +65,8 @@ namespace basegfx } } - inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true) + inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true) { - const sal_Unicode aChar(rStr[nPos]); - const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) || (bSignAllowed && sal_Unicode('+') == aChar) || (bSignAllowed && sal_Unicode('-') == aChar) ); @@ -76,6 +74,12 @@ namespace basegfx return bPredicate; } + inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true) + { + return lcl_isOnNumberChar(rStr[nPos], + bSignAllowed); + } + bool lcl_getDoubleChar(double& o_fRetval, sal_Int32& io_rPos, const ::rtl::OUString& rStr, @@ -231,16 +235,16 @@ namespace basegfx lcl_skipSpacesAndCommas(io_rPos, rStr, nLen); } - void lcl_putNumberChar( ::rtl::OUString& rStr, - double fValue ) + void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr, + double fValue ) { - rStr += ::rtl::OUString::valueOf( fValue ); + rStr.append( fValue ); } - void lcl_putNumberCharWithSpace( ::rtl::OUString& rStr, - double fValue, - double fOldValue, - bool bUseRelativeCoordinates ) + void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr, + double fValue, + double fOldValue, + bool bUseRelativeCoordinates ) { if( bUseRelativeCoordinates ) fValue -= fOldValue; @@ -248,11 +252,10 @@ namespace basegfx const sal_Int32 aLen( rStr.getLength() ); if(aLen) { - if( lcl_isOnNumberChar(rStr, aLen - 1, false) && + if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) && fValue >= 0.0 ) { - rStr += ::rtl::OUString::valueOf( - sal_Unicode(' ') ); + rStr.append( sal_Unicode(' ') ); } } @@ -876,7 +879,7 @@ namespace basegfx bool bDetectQuadraticBeziers) { const sal_uInt32 nCount(rPolyPolygon.count()); - ::rtl::OUString aResult; + ::rtl::OUStringBuffer aResult; B2DPoint aCurrentSVGPosition(0.0, 0.0); // SVG assumes (0,0) as the initial current point for(sal_uInt32 i(0); i < nCount; i++) @@ -893,7 +896,7 @@ namespace basegfx // handle polygon start point B2DPoint aEdgeStart(aPolygon.getB2DPoint(0)); - aResult += ::rtl::OUString::valueOf(lcl_getCommand('M', 'm', bUseRelativeCoordinates)); + aResult.append(lcl_getCommand('M', 'm', bUseRelativeCoordinates)); lcl_putNumberCharWithSpace(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates); lcl_putNumberCharWithSpace(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates); aLastSVGCommand = lcl_getCommand('L', 'l', bUseRelativeCoordinates); @@ -954,7 +957,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -969,7 +972,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -990,7 +993,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -1007,7 +1010,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -1046,7 +1049,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -1060,7 +1063,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -1074,7 +1077,7 @@ namespace basegfx if(aLastSVGCommand != aCommand) { - aResult += ::rtl::OUString::valueOf(aCommand); + aResult.append(aCommand); aLastSVGCommand = aCommand; } @@ -1092,12 +1095,12 @@ namespace basegfx // close path if closed poly (Z and z are equivalent here, but looks nicer when case is matched) if(aPolygon.isClosed()) { - aResult += ::rtl::OUString::valueOf(lcl_getCommand('Z', 'z', bUseRelativeCoordinates)); + aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates)); } } } - return aResult; + return aResult.makeStringAndClear(); } } } diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx new file mode 100644 index 000000000000..4cd63f938114 --- /dev/null +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -0,0 +1,1227 @@ +/************************************************************************* + * + * 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: b2dpolygontriangulator.cxx,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +#include <basegfx/polygon/b2dtrapezoid.hxx> +#include <basegfx/range/b1drange.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <list> + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace trapezoidhelper + { + ////////////////////////////////////////////////////////////////////////////// + // helper class to hold a simple ege. This is only used for horizontal edges + // currently, thus the YPositions will be equal. I did not create a special + // class for this since holdingthe pointers is more effective and also can be + // used as baseclass for the traversing edges + + class TrDeSimpleEdge + { + protected: + // pointers to start and end point + const B2DPoint* mpStart; + const B2DPoint* mpEnd; + + public: + // constructor + TrDeSimpleEdge( + const B2DPoint* pStart, + const B2DPoint* pEnd) + : mpStart(pStart), + mpEnd(pEnd) + { + } + + // data read access + const B2DPoint& getStart() const { return *mpStart; } + const B2DPoint& getEnd() const { return *mpEnd; } + }; + + ////////////////////////////////////////////////////////////////////////////// + // define vector of simple edges + + typedef ::std::vector< TrDeSimpleEdge > TrDeSimpleEdges; + + ////////////////////////////////////////////////////////////////////////////// + // helper class for holding a traversing edge. It will always have some + // distance in YPos. The slope (in a numerically useful form, see comments) is + // hold and used in SortValue to allow sorting traversing edges by Y, X and slope + // (in that order) + + class TrDeEdgeEntry : public TrDeSimpleEdge + { + private: + // the slope in a numerical useful form for sorting + sal_uInt32 mnSortValue; + + public: + // convenience data read access + double getDeltaX() const { return mpEnd->getX() - mpStart->getX(); } + double getDeltaY() const { return mpEnd->getY() - mpStart->getY(); } + + // convenience data read access. SortValue is created on demand since + // it is not always used + sal_uInt32 getSortValue() const + { + if(0 != mnSortValue) + return mnSortValue; + + // get radiant; has to be in the range ]0.0 .. pi[, thus scale to full + // sal_uInt32 range for maximum precision + const double fRadiant(atan2(getDeltaY(), getDeltaX()) * (SAL_MAX_UINT32 / F_PI)); + + // convert to sal_uInt32 value + const_cast< TrDeEdgeEntry* >(this)->mnSortValue = sal_uInt32(fRadiant); + + return mnSortValue; + } + + // constructor. SortValue can be given when known, use zero otherwise + TrDeEdgeEntry( + const B2DPoint* pStart, + const B2DPoint* pEnd, + sal_uInt32 nSortValue = 0) + : TrDeSimpleEdge(pStart, pEnd), + mnSortValue(nSortValue) + { + // force traversal of deltaY downward + if(mpEnd->getY() < mpStart->getY()) + { + std::swap(mpStart, mpEnd); + } + + // no horizontal edges allowed, all neeed to traverse vertically + OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); + } + + // data write access to StartPoint + void setStart( const B2DPoint* pNewStart) + { + OSL_ENSURE(0 != pNewStart, "No null pointer allowed here (!)"); + + if(mpStart != pNewStart) + { + mpStart = pNewStart; + + // no horizontal edges allowed, all neeed to traverse vertivally + OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); + } + } + + // data write access to EndPoint + void setEnd( const B2DPoint* pNewEnd) + { + OSL_ENSURE(0 != pNewEnd, "No null pointer allowed here (!)"); + + if(mpEnd != pNewEnd) + { + mpEnd = pNewEnd; + + // no horizontal edges allowed, all neeed to traverse vertivally + OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); + } + } + + // operator for sort support. Sort by Y, X and slope (in that order) + bool operator<(const TrDeEdgeEntry& rComp) const + { + if(fTools::equal(getStart().getY(), rComp.getStart().getY(), fTools::getSmallValue())) + { + if(fTools::equal(getStart().getX(), rComp.getStart().getX(), fTools::getSmallValue())) + { + // when start points are equal, use the direction the edge is pointing + // to. That value is created on demand and derived from atan2 in the + // range ]0.0 .. pi[ (without extremas, we always have a deltaY in this + // class) and scaled to sal_uInt32 range for best precision. 0 means no angle, + // while SAL_MAX_UINT32 means pi. Thus, the higher the value, the more left + // the edge traverses. + return (getSortValue() > rComp.getSortValue()); + } + else + { + return fTools::less(getStart().getX(), rComp.getStart().getX()); + } + } + else + { + return fTools::less(getStart().getY(), rComp.getStart().getY()); + } + } + + // method for cut support + B2DPoint getCutPointForGivenY(double fGivenY) + { + // Calculate cut point locally (do not use interpolate) since it is numerically + // necessary to guarantee the new, equal Y-coordinate + const double fFactor((fGivenY - getStart().getY()) / getDeltaY()); + const double fDeltaXNew(fFactor * getDeltaX()); + + return B2DPoint(getStart().getX() + fDeltaXNew, fGivenY); + } + }; + + ////////////////////////////////////////////////////////////////////////////// + // define double linked list of edges (for fast random insert) + + typedef ::std::list< TrDeEdgeEntry > TrDeEdgeEntries; + + } // end of anonymous namespace +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace trapezoidhelper + { + // helper class to handle the complete trapezoid subdivision of a PolyPolygon + class TrapezoidSubdivider + { + private: + // local data + sal_uInt32 mnInitialEdgeEntryCount; + TrDeEdgeEntries maTrDeEdgeEntries; + ::std::vector< B2DPoint > maPoints; + ::std::vector< B2DPoint* > maNewPoints; + + void addEdgeSorted( + TrDeEdgeEntries::iterator aCurrent, + const TrDeEdgeEntry& rNewEdge) + { + // Loop while new entry is bigger, use operator< + while(aCurrent != maTrDeEdgeEntries.end() && (*aCurrent) < rNewEdge) + { + aCurrent++; + } + + // Insert before first which is smaller or equal or at end + maTrDeEdgeEntries.insert(aCurrent, rNewEdge); + } + + bool splitEdgeAtGivenPoint( + TrDeEdgeEntries::reference aEdge, + const B2DPoint& rCutPoint, + TrDeEdgeEntries::iterator aCurrent) + { + // do not create edges without deltaY: do not split when start is identical + if(aEdge.getStart().equal(rCutPoint, fTools::getSmallValue())) + { + return false; + } + + // do not create edges without deltaY: do not split when end is identical + if(aEdge.getEnd().equal(rCutPoint, fTools::getSmallValue())) + { + return false; + } + + const double fOldDeltaYStart(rCutPoint.getY() - aEdge.getStart().getY()); + + if(fTools::lessOrEqual(fOldDeltaYStart, 0.0)) + { + // do not split: the resulting edge would be horizontal + // correct it to new start point + aEdge.setStart(&rCutPoint); + return false; + } + + const double fNewDeltaYStart(aEdge.getEnd().getY() - rCutPoint.getY()); + + if(fTools::lessOrEqual(fNewDeltaYStart, 0.0)) + { + // do not split: the resulting edge would be horizontal + // correct it to new end point + aEdge.setEnd(&rCutPoint); + return false; + } + + // Create new entry + const TrDeEdgeEntry aNewEdge( + &rCutPoint, + &aEdge.getEnd(), + aEdge.getSortValue()); + + // Correct old entry + aEdge.setEnd(&rCutPoint); + + // Insert sorted (to avoid new sort) + addEdgeSorted(aCurrent, aNewEdge); + + return true; + } + + bool testAndCorrectEdgeIntersection( + TrDeEdgeEntries::reference aEdgeA, + TrDeEdgeEntries::reference aEdgeB, + TrDeEdgeEntries::iterator aCurrent) + { + // Exclude simple cases: same start or end point + if(aEdgeA.getStart().equal(aEdgeB.getStart(), fTools::getSmallValue())) + { + return false; + } + + if(aEdgeA.getStart().equal(aEdgeB.getEnd(), fTools::getSmallValue())) + { + return false; + } + + if(aEdgeA.getEnd().equal(aEdgeB.getStart(), fTools::getSmallValue())) + { + return false; + } + + if(aEdgeA.getEnd().equal(aEdgeB.getEnd(), fTools::getSmallValue())) + { + return false; + } + + // Exclude simple cases: one of the edges has no length anymore + if(aEdgeA.getStart().equal(aEdgeA.getEnd(), fTools::getSmallValue())) + { + return false; + } + + if(aEdgeB.getStart().equal(aEdgeB.getEnd(), fTools::getSmallValue())) + { + return false; + } + + // check if one point is on the other edge (a touch, not a cut) + const B2DVector aDeltaB(aEdgeB.getDeltaX(), aEdgeB.getDeltaY()); + + if(tools::isPointOnEdge(aEdgeA.getStart(), aEdgeB.getStart(), aDeltaB)) + { + return splitEdgeAtGivenPoint(aEdgeB, aEdgeA.getStart(), aCurrent); + } + + if(tools::isPointOnEdge(aEdgeA.getEnd(), aEdgeB.getStart(), aDeltaB)) + { + return splitEdgeAtGivenPoint(aEdgeB, aEdgeA.getEnd(), aCurrent); + } + + const B2DVector aDeltaA(aEdgeA.getDeltaX(), aEdgeA.getDeltaY()); + + if(tools::isPointOnEdge(aEdgeB.getStart(), aEdgeA.getStart(), aDeltaA)) + { + return splitEdgeAtGivenPoint(aEdgeA, aEdgeB.getStart(), aCurrent); + } + + if(tools::isPointOnEdge(aEdgeB.getEnd(), aEdgeA.getStart(), aDeltaA)) + { + return splitEdgeAtGivenPoint(aEdgeA, aEdgeB.getEnd(), aCurrent); + } + + // check for cut inside edges. Use both t-values to choose the more precise + // one later + double fCutA(0.0); + double fCutB(0.0); + + if(tools::findCut( + aEdgeA.getStart(), aDeltaA, + aEdgeB.getStart(), aDeltaB, + CUTFLAG_LINE, + &fCutA, + &fCutB)) + { + // use a simple metric (length criteria) for choosing the numerically + // better cut + const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY()); + const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY()); + const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB); + B2DPoint* pNewPoint = bAIsLonger + ? new B2DPoint(aEdgeA.getStart() + (fCutA * aDeltaA)) + : new B2DPoint(aEdgeB.getStart() + (fCutB * aDeltaB)); + bool bRetval(false); + + // try to split both edges + bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent); + bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent); + + if(bRetval) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + + return bRetval; + } + + return false; + } + + void solveHorizontalEdges(TrDeSimpleEdges& rTrDeSimpleEdges) + { + if(rTrDeSimpleEdges.size() && maTrDeEdgeEntries.size()) + { + // there were horizontal edges. These can be excluded, but + // cuts with other edges need to be solved and added before + // ignoring them + sal_uInt32 a(0); + + for(a = 0; a < rTrDeSimpleEdges.size(); a++) + { + // get horizontal edge as candidate; prepare it's range and fixed Y + const TrDeSimpleEdge& rHorEdge = rTrDeSimpleEdges[a]; + const B1DRange aRange(rHorEdge.getStart().getX(), rHorEdge.getEnd().getX()); + const double fFixedY(rHorEdge.getStart().getY()); + + // loop over traversing edges + TrDeEdgeEntries::iterator aCurrent(maTrDeEdgeEntries.begin()); + + do + { + // get compare edge + TrDeEdgeEntries::reference aCompare(*aCurrent++); + + if(fTools::lessOrEqual(aCompare.getEnd().getY(), fFixedY)) + { + // edge ends above horizontal edge, continue + continue; + } + + if(fTools::moreOrEqual(aCompare.getStart().getY(), fFixedY)) + { + // edge starts below horizontal edge, continue + continue; + } + + // vertical overlap, get horizontal range + const B1DRange aCompareRange(aCompare.getStart().getX(), aCompare.getEnd().getX()); + + if(aRange.overlaps(aCompareRange)) + { + // possible cut, get cut point + const B2DPoint aSplit(aCompare.getCutPointForGivenY(fFixedY)); + + if(fTools::more(aSplit.getX(), aRange.getMinimum()) + && fTools::less(aSplit.getX(), aRange.getMaximum())) + { + // cut is in XRange of horizontal edge, potenitally needed cut + B2DPoint* pNewPoint = new B2DPoint(aSplit); + + if(splitEdgeAtGivenPoint(aCompare, *pNewPoint, aCurrent)) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + } + } + } + while(aCurrent != maTrDeEdgeEntries.end() + && fTools::less(aCurrent->getStart().getY(), fFixedY)); + } + } + } + + public: + TrapezoidSubdivider( + const B2DPolyPolygon& rSourcePolyPolygon) + : mnInitialEdgeEntryCount(0), + maTrDeEdgeEntries(), + maPoints(), + maNewPoints() + { + B2DPolyPolygon aSource(rSourcePolyPolygon); + const sal_uInt32 nPolygonCount(rSourcePolyPolygon.count()); + TrDeSimpleEdges aTrDeSimpleEdges; + sal_uInt32 a(0), b(0); + sal_uInt32 nAllPointCount(0); + + // ensure there are no curves used + if(aSource.areControlPointsUsed()) + { + aSource = aSource.getDefaultAdaptiveSubdivision(); + } + + for(a = 0; a < nPolygonCount; a++) + { + // 1st run: count points + const B2DPolygon aPolygonCandidate(aSource.getB2DPolygon(a)); + const sal_uInt32 nCount(aPolygonCandidate.count()); + + if(nCount > 2) + { + nAllPointCount += nCount; + } + } + + if(nAllPointCount) + { + // reserve needed points. CAUTION: maPoints size is NOT to be changed anymore + // after 2nd loop since pointers to it are used in the edges + maPoints.reserve(nAllPointCount); + + for(a = 0; a < nPolygonCount; a++) + { + // 2nd run: add points + const B2DPolygon aPolygonCandidate(aSource.getB2DPolygon(a)); + const sal_uInt32 nCount(aPolygonCandidate.count()); + + if(nCount > 2) + { + for(b = 0; b < nCount; b++) + { + maPoints.push_back(aPolygonCandidate.getB2DPoint(b)); + } + } + } + + // Moved the edge construction to a 3rd run: doing it in the 2nd run is + // possible(and i used it), but requires a working vector::reserve() + // implementation, else the vector will be reallocated and the pointers + // in the edges may be wrong. Security first here. + sal_uInt32 nStartIndex(0); + + for(a = 0; a < nPolygonCount; a++) + { + const B2DPolygon aPolygonCandidate(aSource.getB2DPolygon(a)); + const sal_uInt32 nCount(aPolygonCandidate.count()); + + if(nCount > 2) + { + // get the last point of the current polygon + B2DPoint* pPrev(&maPoints[nCount + nStartIndex - 1]); + + for(b = 0; b < nCount; b++) + { + // get next point + B2DPoint* pCurr(&maPoints[nStartIndex++]); + + if(fTools::equal(pPrev->getY(), pCurr->getY(), fTools::getSmallValue())) + { + // horizontal edge, check for single point + if(!fTools::equal(pPrev->getX(), pCurr->getX(), fTools::getSmallValue())) + { + // X-order not needed, just add + aTrDeSimpleEdges.push_back(TrDeSimpleEdge(pPrev, pCurr)); + + const double fMiddle((pPrev->getY() + pCurr->getY()) * 0.5); + pPrev->setY(fMiddle); + pCurr->setY(fMiddle); + } + } + else + { + // vertical edge. Positive Y-direction is guaranteed by the + // TrDeEdgeEntry constructor + maTrDeEdgeEntries.push_back(TrDeEdgeEntry(pPrev, pCurr, 0)); + mnInitialEdgeEntryCount++; + } + + // prepare next step + pPrev = pCurr; + } + } + } + } + + if(maTrDeEdgeEntries.size()) + { + // single and initial sort of traversing edges + maTrDeEdgeEntries.sort(); + + // solve horizontal edges if there are any detected + solveHorizontalEdges(aTrDeSimpleEdges); + } + } + + ~TrapezoidSubdivider() + { + // delete the extra points created for cuts + const sal_uInt32 nCount(maNewPoints.size()); + + for(sal_uInt32 a(0); a < nCount; a++) + { + delete maNewPoints[a]; + } + } + + void Subdivide(B2DTrapezoidVector& ro_Result) + { + // This is the central subdivider. The strategy is to use the first two entries + // from the traversing edges as a potential trapezoid and do the needed corrections + // and adaptions on the way. + // + // There always must be two edges with the same YStart value: When adding the polygons + // in the constructor, there is always a topmost point from which two edges start; when + // the topmost is an edge, there is a start and end of this edge from which two edges + // start. All cases have two edges with same StartY (QED). + // + // Based on this these edges get corrected when: + // - one is longer than the other + // - they intersect + // - they intersect with other edges + // - another edge starts inside the thought trapezoid + // + // All this cases again produce a valid state so that the first two edges have a common + // Ystart again. Some cases lead to a restart of the process, some allow consuming the + // edges and create the intended trapezoid. + // + // Be careful when doing chages here: It is essential to keep all possible paths + // in valid states and to be numerically correct. This is especially needed e.g. + // by using fTools::equal(..) in the more robust small-value incarnation. + B1DRange aLeftRange; + B1DRange aRightRange; + + if(!maTrDeEdgeEntries.empty()) + { + // measuring shows that the relation between edges and created trapezoids is + // mostly in the 1:1 range, thus reserve as much trapezoids as edges exist. Do + // not use maTrDeEdgeEntries.size() since that may be a non-constant time + // operation for Lists. Instead, use mnInitialEdgeEntryCount which will contain + // the roughly counted adds to the List + ro_Result.reserve(ro_Result.size() + mnInitialEdgeEntryCount); + } + + while(!maTrDeEdgeEntries.empty()) + { + // Prepare current operator and get first edge + TrDeEdgeEntries::iterator aCurrent(maTrDeEdgeEntries.begin()); + TrDeEdgeEntries::reference aLeft(*aCurrent++); + + if(aCurrent == maTrDeEdgeEntries.end()) + { + // Should not happen: No 2nd edge; consume the single edge + // to not have an endless loop and start next. During development + // i constantly had breakpoints here, so i am sure enough to add an + // assertion here + OSL_ENSURE(false, "Trapeziod decomposer in illegal state (!)"); + maTrDeEdgeEntries.pop_front(); + continue; + } + + // get second edge + TrDeEdgeEntries::reference aRight(*aCurrent++); + + if(!fTools::equal(aLeft.getStart().getY(), aRight.getStart().getY(), fTools::getSmallValue())) + { + // Should not happen: We have a 2nd edge, but YStart is on another + // line; consume the single edge to not have an endless loop and start + // next. During development i constantly had breakpoints here, so i am + // sure enough to add an assertion here + OSL_ENSURE(false, "Trapeziod decomposer in illegal state (!)"); + maTrDeEdgeEntries.pop_front(); + continue; + } + + // aLeft and aRight build a thought trapezoid now. They have a common + // start line (same Y for start points). Potentially, one of the edges + // is longer than the other. It is only needed to look at the shorter + // length which build the potential trapezoid. To do so, get the end points + // locally and adapt the evtl. longer one. Use only aLeftEnd and aRightEnd + // from here on, not the aLeft.getEnd() or aRight.getEnd() accesses. + B2DPoint aLeftEnd(aLeft.getEnd()); + B2DPoint aRightEnd(aRight.getEnd()); + + // check if end points are on the same line. If yes, no adaption + // needs to be prepared. Also remember which one actually is longer. + const bool bEndOnSameLine(fTools::equal(aLeftEnd.getY(), aRightEnd.getY(), fTools::getSmallValue())); + bool bLeftIsLonger(false); + + if(!bEndOnSameLine) + { + // check which edge is longer and correct accordingly + bLeftIsLonger = fTools::more(aLeftEnd.getY(), aRightEnd.getY()); + + if(bLeftIsLonger) + { + aLeftEnd = aLeft.getCutPointForGivenY(aRightEnd.getY()); + } + else + { + aRightEnd = aRight.getCutPointForGivenY(aLeftEnd.getY()); + } + } + + // check for same start and end points + const bool bSameStartPoint(aLeft.getStart().equal(aRight.getStart(), fTools::getSmallValue())); + const bool bSameEndPoint(aLeftEnd.equal(aRightEnd, fTools::getSmallValue())); + + // check the simple case that the edges form a 'blind' edge (deadend) + if(bSameStartPoint && bSameEndPoint) + { + // correct the longer edge if prepared + if(!bEndOnSameLine) + { + if(bLeftIsLonger) + { + B2DPoint* pNewPoint = new B2DPoint(aLeftEnd); + + if(splitEdgeAtGivenPoint(aLeft, *pNewPoint, aCurrent)) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + } + else + { + B2DPoint* pNewPoint = new B2DPoint(aRightEnd); + + if(splitEdgeAtGivenPoint(aRight, *pNewPoint, aCurrent)) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + } + } + + // consume both edges and start next run + maTrDeEdgeEntries.pop_front(); + maTrDeEdgeEntries.pop_front(); + + continue; + } + + // check if the edges self-intersect. This can only happen when + // start and end point are different + bool bRangesSet(false); + + if(!(bSameStartPoint || bSameEndPoint)) + { + // get XRanges of edges + aLeftRange = B1DRange(aLeft.getStart().getX(), aLeftEnd.getX()); + aRightRange = B1DRange(aRight.getStart().getX(), aRightEnd.getX()); + bRangesSet = true; + + // use fast range test first + if(aLeftRange.overlaps(aRightRange)) + { + // real cut test and correction. If correction was needed, + // start new run + if(testAndCorrectEdgeIntersection(aLeft, aRight, aCurrent)) + { + continue; + } + } + } + + // now we need to check if there are intersections with other edges + // or if other edges start inside the candidate trapezoid + if(aCurrent != maTrDeEdgeEntries.end() + && fTools::less(aCurrent->getStart().getY(), aLeftEnd.getY())) + { + // get XRanges of edges + if(!bRangesSet) + { + aLeftRange = B1DRange(aLeft.getStart().getX(), aLeftEnd.getX()); + aRightRange = B1DRange(aRight.getStart().getX(), aRightEnd.getX()); + } + + // build full XRange for fast check + B1DRange aAllRange(aLeftRange); + aAllRange.expand(aRightRange); + + // prepare loop iterator; aCurrent needs to stay unchanged for + // eventual sorted insertions of new EdgeNodes. Also prepare stop flag + TrDeEdgeEntries::iterator aLoop(aCurrent); + bool bDone(false); + + do + { + // get compare edge and it's XRange + TrDeEdgeEntries::reference aCompare(*aLoop++); + + // avoid edges using the same start point as one of + // the edges. These can neither have their start point + // in the thought trapezoid nor cut with one of the edges + if(aCompare.getStart().equal(aRight.getStart(), fTools::getSmallValue())) + { + continue; + } + + // get compare XRange + const B1DRange aCompareRange(aCompare.getStart().getX(), aCompare.getEnd().getX()); + + // use fast range test first + if(aAllRange.overlaps(aCompareRange)) + { + // check for start point inside thought trapezoid + if(fTools::more(aCompare.getStart().getY(), aLeft.getStart().getY())) + { + // calculate the two possible split points at compare's Y + const B2DPoint aSplitLeft(aLeft.getCutPointForGivenY(aCompare.getStart().getY())); + const B2DPoint aSplitRight(aRight.getCutPointForGivenY(aCompare.getStart().getY())); + + // check for start point of aCompare being inside thought + // trapezoid + if(aCompare.getStart().getX() >= aSplitLeft.getX() && + aCompare.getStart().getX() <= aSplitRight.getX()) + { + // is inside, correct and restart loop + B2DPoint* pNewLeft = new B2DPoint(aSplitLeft); + + if(splitEdgeAtGivenPoint(aLeft, *pNewLeft, aCurrent)) + { + maNewPoints.push_back(pNewLeft); + } + else + { + delete pNewLeft; + } + + B2DPoint* pNewRight = new B2DPoint(aSplitRight); + + if(splitEdgeAtGivenPoint(aRight, *pNewRight, aCurrent)) + { + maNewPoints.push_back(pNewRight); + } + else + { + delete pNewRight; + } + + bDone = true; + } + } + + if(!bDone && aLeftRange.overlaps(aCompareRange)) + { + // test for concrete cut of compare edge with left edge + bDone = testAndCorrectEdgeIntersection(aLeft, aCompare, aCurrent); + } + + if(!bDone && aRightRange.overlaps(aCompareRange)) + { + // test for concrete cut of compare edge with Right edge + bDone = testAndCorrectEdgeIntersection(aRight, aCompare, aCurrent); + } + } + } + while(!bDone + && aLoop != maTrDeEdgeEntries.end() + && fTools::less(aLoop->getStart().getY(), aLeftEnd.getY())); + + if(bDone) + { + // something needed to be changed; start next loop + continue; + } + } + + // when we get here, the intended trapezoid can be used. It needs to + // be corrected, eventually (if prepared); but this is no reason not to + // use it in the same loop iteration + if(!bEndOnSameLine) + { + if(bLeftIsLonger) + { + B2DPoint* pNewPoint = new B2DPoint(aLeftEnd); + + if(splitEdgeAtGivenPoint(aLeft, *pNewPoint, aCurrent)) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + } + else + { + B2DPoint* pNewPoint = new B2DPoint(aRightEnd); + + if(splitEdgeAtGivenPoint(aRight, *pNewPoint, aCurrent)) + { + maNewPoints.push_back(pNewPoint); + } + else + { + delete pNewPoint; + } + } + } + + // the two edges start at the same Y, they use the same DeltaY, they + // do not cut themselves and not any other edge in range. Create a + // B2DTrapezoid and consume both edges + ro_Result.push_back( + B2DTrapezoid( + aLeft.getStart().getX(), + aRight.getStart().getX(), + aLeft.getStart().getY(), + aLeftEnd.getX(), + aRightEnd.getX(), + aLeftEnd.getY())); + + maTrDeEdgeEntries.pop_front(); + maTrDeEdgeEntries.pop_front(); + } + } + }; + } // end of anonymous namespace +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + B2DTrapezoid::B2DTrapezoid( + const double& rfTopXLeft, + const double& rfTopXRight, + const double& rfTopY, + const double& rfBottomXLeft, + const double& rfBottomXRight, + const double& rfBottomY) + : mfTopXLeft(rfTopXLeft), + mfTopXRight(rfTopXRight), + mfTopY(rfTopY), + mfBottomXLeft(rfBottomXLeft), + mfBottomXRight(rfBottomXRight), + mfBottomY(rfBottomY) + { + // guarantee mfTopXRight >= mfTopXLeft + if(mfTopXLeft > mfTopXRight) + { + std::swap(mfTopXLeft, mfTopXRight); + } + + // guarantee mfBottomXRight >= mfBottomXLeft + if(mfBottomXLeft > mfBottomXRight) + { + std::swap(mfBottomXLeft, mfBottomXRight); + } + + // guarantee mfBottomY >= mfTopY + if(mfTopY > mfBottomY) + { + std::swap(mfTopY, mfBottomY); + std::swap(mfTopXLeft, mfBottomXLeft); + std::swap(mfTopXRight, mfBottomXRight); + } + } + + B2DPolygon B2DTrapezoid::getB2DPolygon() const + { + B2DPolygon aRetval; + + aRetval.append(B2DPoint(getTopXLeft(), getTopY())); + aRetval.append(B2DPoint(getTopXRight(), getTopY())); + aRetval.append(B2DPoint(getBottomXRight(), getBottomY())); + aRetval.append(B2DPoint(getBottomXLeft(), getBottomY())); + aRetval.setClosed(true); + + return aRetval; + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace tools + { + // convert Source PolyPolygon to trapezoids + void trapezoidSubdivide(B2DTrapezoidVector& ro_Result, const B2DPolyPolygon& rSourcePolyPolygon) + { + trapezoidhelper::TrapezoidSubdivider aTrapezoidSubdivider(rSourcePolyPolygon); + + aTrapezoidSubdivider.Subdivide(ro_Result); + } + + void createLineTrapezoidFromEdge( + B2DTrapezoidVector& ro_Result, + const B2DPoint& rPointA, + const B2DPoint& rPointB, + double fLineWidth) + { + if(fTools::lessOrEqual(fLineWidth, 0.0)) + { + // no line witdh + return; + } + + if(rPointA.equal(rPointB, fTools::getSmallValue())) + { + // points are equal, no edge + return; + } + + const double fHalfLineWidth(0.5 * fLineWidth); + + if(fTools::equal(rPointA.getX(), rPointB.getX(), fTools::getSmallValue())) + { + // vertical line + const double fLeftX(rPointA.getX() - fHalfLineWidth); + const double fRightX(rPointA.getX() + fHalfLineWidth); + + ro_Result.push_back( + B2DTrapezoid( + fLeftX, + fRightX, + std::min(rPointA.getY(), rPointB.getY()), + fLeftX, + fRightX, + std::max(rPointA.getY(), rPointB.getY()))); + } + else if(fTools::equal(rPointA.getY(), rPointB.getY(), fTools::getSmallValue())) + { + // horizontal line + const double fLeftX(std::min(rPointA.getX(), rPointB.getX())); + const double fRightX(std::max(rPointA.getX(), rPointB.getX())); + + ro_Result.push_back( + B2DTrapezoid( + fLeftX, + fRightX, + rPointA.getY() - fHalfLineWidth, + fLeftX, + fRightX, + rPointA.getY() + fHalfLineWidth)); + } + else + { + // diagonal line + // create perpendicular vector + const B2DVector aDelta(rPointB - rPointA); + B2DVector aPerpendicular(-aDelta.getY(), aDelta.getX()); + aPerpendicular.setLength(fHalfLineWidth); + + // create StartLow, StartHigh, EndLow and EndHigh + const B2DPoint aStartLow(rPointA + aPerpendicular); + const B2DPoint aStartHigh(rPointA - aPerpendicular); + const B2DPoint aEndHigh(rPointB - aPerpendicular); + const B2DPoint aEndLow(rPointB + aPerpendicular); + + // create EdgeEntries + basegfx::trapezoidhelper::TrDeEdgeEntries aTrDeEdgeEntries; + + aTrDeEdgeEntries.push_back(basegfx::trapezoidhelper::TrDeEdgeEntry(&aStartLow, &aStartHigh, 0)); + aTrDeEdgeEntries.push_back(basegfx::trapezoidhelper::TrDeEdgeEntry(&aStartHigh, &aEndHigh, 0)); + aTrDeEdgeEntries.push_back(basegfx::trapezoidhelper::TrDeEdgeEntry(&aEndHigh, &aEndLow, 0)); + aTrDeEdgeEntries.push_back(basegfx::trapezoidhelper::TrDeEdgeEntry(&aEndLow, &aStartLow, 0)); + aTrDeEdgeEntries.sort(); + + // here we know we have exactly four edges, and they do not cut, touch or + // intersect. This makes processing much easier. Get the first two as start + // edges for the thought trapezoid + basegfx::trapezoidhelper::TrDeEdgeEntries::iterator aCurrent(aTrDeEdgeEntries.begin()); + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft(*aCurrent++); + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight(*aCurrent++); + const bool bEndOnSameLine(fTools::equal(aLeft.getEnd().getY(), aRight.getEnd().getY(), fTools::getSmallValue())); + + if(bEndOnSameLine) + { + // create two triangle trapezoids + ro_Result.push_back( + B2DTrapezoid( + aLeft.getStart().getX(), + aRight.getStart().getX(), + aLeft.getStart().getY(), + aLeft.getEnd().getX(), + aRight.getEnd().getX(), + aLeft.getEnd().getY())); + + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); + + ro_Result.push_back( + B2DTrapezoid( + aLeft2.getStart().getX(), + aRight2.getStart().getX(), + aLeft2.getStart().getY(), + aLeft2.getEnd().getX(), + aRight2.getEnd().getX(), + aLeft2.getEnd().getY())); + } + else + { + // create three trapezoids. Check which edge is longer and + // correct accordingly + const bool bLeftIsLonger(fTools::more(aLeft.getEnd().getY(), aRight.getEnd().getY())); + + if(bLeftIsLonger) + { + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); + const B2DPoint aSplitLeft(aLeft.getCutPointForGivenY(aRight.getEnd().getY())); + const B2DPoint aSplitRight(aRight2.getCutPointForGivenY(aLeft.getEnd().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aLeft.getStart().getX(), + aRight.getStart().getX(), + aLeft.getStart().getY(), + aSplitLeft.getX(), + aRight.getEnd().getX(), + aRight.getEnd().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aSplitLeft.getX(), + aRight.getEnd().getX(), + aRight.getEnd().getY(), + aLeft2.getStart().getX(), + aSplitRight.getX(), + aLeft2.getStart().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aLeft2.getStart().getX(), + aSplitRight.getX(), + aLeft2.getStart().getY(), + aLeft2.getEnd().getX(), + aRight2.getEnd().getX(), + aLeft2.getEnd().getY())); + } + else + { + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); + basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); + const B2DPoint aSplitRight(aRight.getCutPointForGivenY(aLeft.getEnd().getY())); + const B2DPoint aSplitLeft(aLeft2.getCutPointForGivenY(aRight.getEnd().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aLeft.getStart().getX(), + aRight.getStart().getX(), + aLeft.getStart().getY(), + aLeft.getEnd().getX(), + aSplitRight.getX(), + aLeft.getEnd().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aLeft.getEnd().getX(), + aSplitRight.getX(), + aLeft.getEnd().getY(), + aSplitLeft.getX(), + aRight.getEnd().getX(), + aRight2.getStart().getY())); + + ro_Result.push_back( + B2DTrapezoid( + aSplitLeft.getX(), + aRight.getEnd().getX(), + aRight2.getStart().getY(), + aLeft2.getEnd().getX(), + aRight2.getEnd().getX(), + aLeft2.getEnd().getY())); + } + } + } + } + + void createLineTrapezoidFromB2DPolygon( + B2DTrapezoidVector& ro_Result, + const B2DPolygon& rPolygon, + double fLineWidth) + { + if(fTools::lessOrEqual(fLineWidth, 0.0)) + { + return; + } + + // ensure there are no curves used + B2DPolygon aSource(rPolygon); + + if(aSource.areControlPointsUsed()) + { + aSource = aSource.getDefaultAdaptiveSubdivision(); + } + + const sal_uInt32 nPointCount(aSource.count()); + + if(!nPointCount) + { + return; + } + + const sal_uInt32 nEdgeCount(aSource.isClosed() ? nPointCount : nPointCount - 1); + B2DPoint aCurrent(aSource.getB2DPoint(0)); + + ro_Result.reserve(ro_Result.size() + (3 * nEdgeCount)); + + for(sal_uInt32 a(0); a < nEdgeCount; a++) + { + const sal_uInt32 nNextIndex((a + 1) % nPointCount); + const B2DPoint aNext(aSource.getB2DPoint(nNextIndex)); + + createLineTrapezoidFromEdge(ro_Result, aCurrent, aNext, fLineWidth); + aCurrent = aNext; + } + } + + void createLineTrapezoidFromB2DPolyPolygon( + B2DTrapezoidVector& ro_Result, + const B2DPolyPolygon& rPolyPolygon, + double fLineWidth) + { + if(fTools::lessOrEqual(fLineWidth, 0.0)) + { + return; + } + + // ensure there are no curves used + B2DPolyPolygon aSource(rPolyPolygon); + + if(aSource.areControlPointsUsed()) + { + aSource = aSource.getDefaultAdaptiveSubdivision(); + } + + const sal_uInt32 nCount(aSource.count()); + + if(!nCount) + { + return; + } + + for(sal_uInt32 a(0); a < nCount; a++) + { + createLineTrapezoidFromB2DPolygon( + ro_Result, + aSource.getB2DPolygon(a), + fLineWidth); + } + } + + } // end of namespace tools +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/basegfx/source/polygon/makefile.mk b/basegfx/source/polygon/makefile.mk index aeb0af6c5d1b..7ac71ada5e8e 100644 --- a/basegfx/source/polygon/makefile.mk +++ b/basegfx/source/polygon/makefile.mk @@ -51,6 +51,7 @@ SLOFILES= \ $(SLO)$/b2dpolygonclipper.obj \ $(SLO)$/b2dpolygontriangulator.obj \ $(SLO)$/b2dpolygoncutandtouch.obj \ + $(SLO)$/b2dtrapezoid.obj \ $(SLO)$/b3dpolygon.obj \ $(SLO)$/b3dpolygontools.obj \ $(SLO)$/b3dpolypolygon.obj \ diff --git a/basegfx/source/range/b2dmultirange.cxx b/basegfx/source/range/b2dmultirange.cxx deleted file mode 100644 index 3a47be3b7dc9..000000000000 --- a/basegfx/source/range/b2dmultirange.cxx +++ /dev/null @@ -1,279 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_basegfx.hxx" -#include <basegfx/range/b2drange.hxx> -#include <basegfx/tuple/b2dtuple.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> -#include <basegfx/range/b2dmultirange.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/polygon/b2dpolypolygoncutter.hxx> -#include <boost/bind.hpp> -#include <boost/mem_fn.hpp> -#include <algorithm> -#include <vector> - - -namespace basegfx -{ - class ImplB2DMultiRange - { - public: - ImplB2DMultiRange() : - maBounds(), - maRanges() - { - } - - explicit ImplB2DMultiRange( const B2DRange& rRange ) : - maBounds(), - maRanges( 1, rRange ) - { - } - - bool isEmpty() const - { - // no ranges at all, or all ranges empty - return maRanges.empty() || - ::std::count_if( maRanges.begin(), - maRanges.end(), - ::boost::mem_fn( &B2DRange::isEmpty ) ) - == static_cast<VectorOfRanges::difference_type>(maRanges.size()); - } - - void reset() - { - // swap in empty vector - VectorOfRanges aTmp; - maRanges.swap( aTmp ); - - maBounds.reset(); - } - - template< typename ValueType > bool isInside( const ValueType& rValue ) const - { - if( !maBounds.isInside( rValue ) ) - return false; - - // cannot use ::boost::bind here, since isInside is overloaded. - // It is currently not possible to resolve the overload - // by considering one of the other template arguments. - VectorOfRanges::const_iterator aCurr( maRanges.begin() ); - const VectorOfRanges::const_iterator aEnd ( maRanges.end() ); - while( aCurr != aEnd ) - if( aCurr->isInside( rValue ) ) - return true; - - return false; - } - - bool overlaps( const B2DRange& rRange ) const - { - if( !maBounds.overlaps( rRange ) ) - return false; - - const VectorOfRanges::const_iterator aEnd( maRanges.end() ); - return ::std::find_if( maRanges.begin(), - aEnd, - ::boost::bind<bool>( ::boost::mem_fn( &B2DRange::overlaps ), - _1, - rRange ) ) != aEnd; - } - - void addRange( const B2DRange& rRange ) - { - maRanges.push_back( rRange ); - maBounds.expand( rRange ); - } - - B2DRange getBounds() const - { - return maBounds; - } - - B2DPolyPolygon getPolyPolygon() const - { - B2DPolyPolygon aRes; - - // Make range vector unique ( have to avoid duplicate - // rectangles. The polygon clipper will return an empty - // result in this case). - VectorOfRanges aUniqueRanges; - aUniqueRanges.reserve( maRanges.size() ); - - VectorOfRanges::const_iterator aCurr( maRanges.begin() ); - const VectorOfRanges::const_iterator aEnd ( maRanges.end() ); - while( aCurr != aEnd ) - { - // TODO(F3): It's plain wasted resources to apply a - // general clipping algorithm to the problem at - // hand. Go for a dedicated, scan-line-based approach. - VectorOfRanges::const_iterator aCurrScan( aCurr+1 ); - VectorOfRanges::const_iterator aFound( aEnd ); - while( aCurrScan != aEnd ) - { - if( aCurrScan->equal( *aCurr ) || - aCurrScan->isInside( *aCurr ) ) - { - // current probe is equal to aCurr, or - // completely contains aCurr. Thus, stop - // searching, because aCurr is definitely not - // a member of the unique rect list - aFound = aCurrScan; - break; - } - - ++aCurrScan; - } - - if( aFound == aEnd ) - { - // check whether aCurr is fully contained in one - // of the already added rects. If yes, we can skip - // it. - bool bUnique( true ); - VectorOfRanges::const_iterator aCurrUnique( aUniqueRanges.begin() ); - VectorOfRanges::const_iterator aEndUnique ( aUniqueRanges.end() ); - while( aCurrUnique != aEndUnique ) - { - if( aCurrUnique->isInside( *aCurr ) ) - { - // fully contained, no need to add - bUnique = false; - break; - } - - ++aCurrUnique; - } - - if( bUnique ) - aUniqueRanges.push_back( *aCurr ); - } - - ++aCurr; - } - - VectorOfRanges::const_iterator aCurrUnique( aUniqueRanges.begin() ); - const VectorOfRanges::const_iterator aEndUnique ( aUniqueRanges.end() ); - while( aCurrUnique != aEndUnique ) - { - // simply merge all unique parts (OR) - aRes.append( tools::createPolygonFromRect( *aCurrUnique++ ) ); - } - - // remove redundant intersections. Note: since all added - // rectangles are positively oriented, this method cannot - // generate any holes. - aRes = basegfx::tools::solveCrossovers(aRes); - aRes = basegfx::tools::stripNeutralPolygons(aRes); - aRes = basegfx::tools::stripDispensablePolygons(aRes, false); - - return aRes; - } - - private: - typedef ::std::vector< B2DRange > VectorOfRanges; - - B2DRange maBounds; - VectorOfRanges maRanges; - }; - - - // ==================================================================== - - - B2DMultiRange::B2DMultiRange() : - mpImpl() - { - } - - B2DMultiRange::B2DMultiRange( const B2DRange& rRange ) : - mpImpl( ImplB2DMultiRange( rRange ) ) - { - } - - B2DMultiRange::~B2DMultiRange() - { - // otherwise, ImplB2DMultiRange would be an incomplete type - } - - B2DMultiRange::B2DMultiRange( const B2DMultiRange& rSrc ) : - mpImpl( rSrc.mpImpl ) - { - } - - B2DMultiRange& B2DMultiRange::operator=( const B2DMultiRange& rSrc ) - { - mpImpl = rSrc.mpImpl; - return *this; - } - - bool B2DMultiRange::isEmpty() const - { - return mpImpl->isEmpty(); - } - - void B2DMultiRange::reset() - { - mpImpl->reset(); - } - - bool B2DMultiRange::isInside( const B2DTuple& rTuple ) const - { - return mpImpl->isInside( rTuple ); - } - - bool B2DMultiRange::isInside( const B2DRange& rRange ) const - { - return mpImpl->isInside( rRange ); - } - - bool B2DMultiRange::overlaps( const B2DRange& rRange ) const - { - return mpImpl->overlaps( rRange ); - } - - void B2DMultiRange::addRange( const B2DRange& rRange ) - { - mpImpl->addRange( rRange ); - } - - B2DRange B2DMultiRange::getBounds() const - { - return mpImpl->getBounds(); - } - - B2DPolyPolygon B2DMultiRange::getPolyPolygon() const - { - return mpImpl->getPolyPolygon(); - } - -} // end of namespace basegfx - -// eof diff --git a/basegfx/source/range/b2dpolyrange.cxx b/basegfx/source/range/b2dpolyrange.cxx new file mode 100644 index 000000000000..e212e083ef55 --- /dev/null +++ b/basegfx/source/range/b2dpolyrange.cxx @@ -0,0 +1,423 @@ +/************************************************************************* + * + * 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: b2dmultirange.cxx,v $ + * $Revision: 1.8 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +#include <basegfx/range/b2dpolyrange.hxx> + +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/b2drangeclipper.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +#include <boost/bind.hpp> +#include <boost/tuple/tuple.hpp> +#include <algorithm> +#include <vector> + +static basegfx::B2VectorOrientation flipOrientation( + basegfx::B2VectorOrientation eOrient) +{ + return eOrient == basegfx::ORIENTATION_POSITIVE ? + basegfx::ORIENTATION_NEGATIVE : basegfx::ORIENTATION_POSITIVE; +} + +namespace basegfx +{ + class ImplB2DPolyRange + { + void updateBounds() + { + maBounds.reset(); + std::for_each(maRanges.begin(), + maRanges.end(), + boost::bind( + (void (B2DRange::*)(const B2DRange&))( + &B2DRange::expand), + boost::ref(maBounds), + _1)); + } + + public: + ImplB2DPolyRange() : + maBounds(), + maRanges(), + maOrient() + {} + + explicit ImplB2DPolyRange( const B2DPolyRange::ElementType& rElem ) : + maBounds( boost::get<0>(rElem) ), + maRanges( 1, boost::get<0>(rElem) ), + maOrient( 1, boost::get<1>(rElem) ) + {} + + explicit ImplB2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient ) : + maBounds( rRange ), + maRanges( 1, rRange ), + maOrient( 1, eOrient ) + {} + + bool operator==(const ImplB2DPolyRange& rRHS) const + { + return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient; + } + + sal_uInt32 count() const + { + return maRanges.size(); + } + + B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const + { + return boost::make_tuple(maRanges[nIndex], + maOrient[nIndex]); + } + + void setElement(sal_uInt32 nIndex, const B2DPolyRange::ElementType& rElement ) + { + maRanges[nIndex] = boost::get<0>(rElement); + maOrient[nIndex] = boost::get<1>(rElement); + updateBounds(); + } + + void setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient ) + { + maRanges[nIndex] = rRange; + maOrient[nIndex] = eOrient; + updateBounds(); + } + + void insertElement(sal_uInt32 nIndex, const B2DPolyRange::ElementType& rElement, sal_uInt32 nCount) + { + maRanges.insert(maRanges.begin()+nIndex, nCount, boost::get<0>(rElement)); + maOrient.insert(maOrient.begin()+nIndex, nCount, boost::get<1>(rElement)); + maBounds.expand(boost::get<0>(rElement)); + } + + void insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount) + { + maRanges.insert(maRanges.begin()+nIndex, nCount, rRange); + maOrient.insert(maOrient.begin()+nIndex, nCount, eOrient); + maBounds.expand(rRange); + } + + void appendElement(const B2DPolyRange::ElementType& rElement, sal_uInt32 nCount) + { + maRanges.insert(maRanges.end(), nCount, boost::get<0>(rElement)); + maOrient.insert(maOrient.end(), nCount, boost::get<1>(rElement)); + maBounds.expand(boost::get<0>(rElement)); + } + + void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount) + { + maRanges.insert(maRanges.end(), nCount, rRange); + maOrient.insert(maOrient.end(), nCount, eOrient); + maBounds.expand(rRange); + } + + void insertPolyRange(sal_uInt32 nIndex, const ImplB2DPolyRange& rPolyRange) + { + maRanges.insert(maRanges.begin()+nIndex, rPolyRange.maRanges.begin(), rPolyRange.maRanges.end()); + maOrient.insert(maOrient.begin()+nIndex, rPolyRange.maOrient.begin(), rPolyRange.maOrient.end()); + updateBounds(); + } + + void appendPolyRange(const ImplB2DPolyRange& rPolyRange) + { + maRanges.insert(maRanges.end(), + rPolyRange.maRanges.begin(), + rPolyRange.maRanges.end()); + maOrient.insert(maOrient.end(), + rPolyRange.maOrient.begin(), + rPolyRange.maOrient.end()); + updateBounds(); + } + + void remove(sal_uInt32 nIndex, sal_uInt32 nCount) + { + maRanges.erase(maRanges.begin()+nIndex,maRanges.begin()+nIndex+nCount); + maOrient.erase(maOrient.begin()+nIndex,maOrient.begin()+nIndex+nCount); + updateBounds(); + } + + void clear() + { + std::vector<B2DRange> aTmpRanges; + std::vector<B2VectorOrientation> aTmpOrient; + + maRanges.swap(aTmpRanges); + maOrient.swap(aTmpOrient); + + maBounds.reset(); + } + + void flip() + { + std::for_each(maOrient.begin(), + maOrient.end(), + boost::bind( + &flipOrientation, + _1)); + } + + B2DRange getBounds() const + { + return maBounds; + } + + template< typename ValueType > bool isInside( const ValueType& rValue ) const + { + if( !maBounds.isInside( rValue ) ) + return false; + + // cannot use boost::bind here, since isInside is overloaded. + // It is currently not possible to resolve the overload + // by considering one of the other template arguments. + std::vector<B2DRange>::const_iterator aCurr( maRanges.begin() ); + const std::vector<B2DRange>::const_iterator aEnd ( maRanges.end() ); + while( aCurr != aEnd ) + if( aCurr->isInside( rValue ) ) + return true; + + return false; + } + + bool overlaps( const B2DRange& rRange ) const + { + if( !maBounds.overlaps( rRange ) ) + return false; + + const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() ); + return std::find_if( maRanges.begin(), + aEnd, + boost::bind<bool>( boost::mem_fn( &B2DRange::overlaps ), + _1, + boost::cref(rRange) ) ) != aEnd; + } + + B2DPolyPolygon solveCrossovers() const + { + return tools::solveCrossovers(maRanges,maOrient); + } + + const B2DRange* begin() const + { + if(maRanges.empty()) + return 0; + else + return &maRanges.front(); + } + + const B2DRange* end() const + { + if(maRanges.empty()) + return 0; + else + return (&maRanges.back())+1; + } + + B2DRange* begin() + { + if(maRanges.empty()) + return 0; + else + return &maRanges.front(); + } + + B2DRange* end() + { + if(maRanges.empty()) + return 0; + else + return (&maRanges.back())+1; + } + + private: + B2DRange maBounds; + std::vector<B2DRange> maRanges; + std::vector<B2VectorOrientation> maOrient; + }; + + B2DPolyRange::B2DPolyRange() : + mpImpl() + {} + + B2DPolyRange::~B2DPolyRange() + {} + + B2DPolyRange::B2DPolyRange( const ElementType& rElem ) : + mpImpl( ImplB2DPolyRange( rElem ) ) + {} + + B2DPolyRange::B2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient ) : + mpImpl( ImplB2DPolyRange( rRange, eOrient ) ) + {} + + B2DPolyRange::B2DPolyRange( const B2DPolyRange& rRange ) : + mpImpl( rRange.mpImpl ) + {} + + B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& rRange ) + { + mpImpl = rRange.mpImpl; + return *this; + } + + void B2DPolyRange::makeUnique() + { + mpImpl.make_unique(); + } + + bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const + { + if(mpImpl.same_object(rRange.mpImpl)) + return true; + + return ((*mpImpl) == (*rRange.mpImpl)); + } + + bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const + { + return !(*this == rRange); + } + + sal_uInt32 B2DPolyRange::count() const + { + return mpImpl->count(); + } + + B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const + { + return mpImpl->getElement(nIndex); + } + + void B2DPolyRange::setElement(sal_uInt32 nIndex, const ElementType& rElement ) + { + mpImpl->setElement(nIndex, rElement); + } + + void B2DPolyRange::setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient ) + { + mpImpl->setElement(nIndex, rRange, eOrient ); + } + + void B2DPolyRange::insertElement(sal_uInt32 nIndex, const ElementType& rElement, sal_uInt32 nCount) + { + mpImpl->insertElement(nIndex, rElement, nCount ); + } + + void B2DPolyRange::insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount) + { + mpImpl->insertElement(nIndex, rRange, eOrient, nCount ); + } + + void B2DPolyRange::appendElement(const ElementType& rElement, sal_uInt32 nCount) + { + mpImpl->appendElement(rElement, nCount); + } + + void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount) + { + mpImpl->appendElement(rRange, eOrient, nCount ); + } + + void B2DPolyRange::insertPolyRange(sal_uInt32 nIndex, const B2DPolyRange& rRange) + { + mpImpl->insertPolyRange(nIndex, *rRange.mpImpl); + } + + void B2DPolyRange::appendPolyRange(const B2DPolyRange& rRange) + { + mpImpl->appendPolyRange(*rRange.mpImpl); + } + + void B2DPolyRange::remove(sal_uInt32 nIndex, sal_uInt32 nCount) + { + mpImpl->remove(nIndex, nCount); + } + + void B2DPolyRange::clear() + { + mpImpl->clear(); + } + + void B2DPolyRange::flip() + { + mpImpl->flip(); + } + + B2DRange B2DPolyRange::getBounds() const + { + return mpImpl->getBounds(); + } + + bool B2DPolyRange::isInside( const B2DTuple& rTuple ) const + { + return mpImpl->isInside(rTuple); + } + + bool B2DPolyRange::isInside( const B2DRange& rRange ) const + { + return mpImpl->isInside(rRange); + } + + bool B2DPolyRange::overlaps( const B2DRange& rRange ) const + { + return mpImpl->overlaps(rRange); + } + + B2DPolyPolygon B2DPolyRange::solveCrossovers() const + { + return mpImpl->solveCrossovers(); + } + + const B2DRange* B2DPolyRange::begin() const + { + return mpImpl->begin(); + } + + const B2DRange* B2DPolyRange::end() const + { + return mpImpl->end(); + } + + B2DRange* B2DPolyRange::begin() + { + return mpImpl->begin(); + } + + B2DRange* B2DPolyRange::end() + { + return mpImpl->end(); + } + +} // end of namespace basegfx + +// eof diff --git a/basegfx/source/range/b2drangeclipper.cxx b/basegfx/source/range/b2drangeclipper.cxx new file mode 100644 index 000000000000..524479b4fde0 --- /dev/null +++ b/basegfx/source/range/b2drangeclipper.cxx @@ -0,0 +1,950 @@ +/************************************************************************* + * + * 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: b2dmultirange.cxx,v $ + * $Revision: 1.8 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" + +#include <rtl/math.hxx> + +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/b2dpolyrange.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> + +#include <o3tl/vector_pool.hxx> +#include <boost/bind.hpp> +#include <boost/utility.hpp> + +#include <algorithm> +#include <deque> +#include <list> + + +namespace basegfx +{ + namespace + { + // Generating a poly-polygon from a bunch of rectangles + // + // Helper functionality for sweep-line algorithm + // ==================================================== + + typedef std::vector<B2DRange> VectorOfRanges; + + class ImplPolygon; + typedef o3tl::vector_pool<ImplPolygon> VectorOfPolygons; + + + /** This class represents an active edge + + As the sweep line traverses across the overall area, + rectangle edges parallel to it generate events, and + rectangle edges orthogonal to it generate active + edges. This class represents the latter. + */ + class ActiveEdge + { + public: + /** The two possible active rectangle edges differ by one + coordinate value - the upper edge has the lower, the + lower edge the higher value. + */ + enum EdgeType { + /// edge with lower coordinate value + UPPER=0, + /// edge with higher coordinate value + LOWER=1 + }; + + enum EdgeDirection { + /// edge proceeds to the left + PROCEED_LEFT=0, + /// edge proceeds to the right + PROCEED_RIGHT=1 + }; + + /** Create active edge + + @param rRect + Rectangle this edge is part of + + @param fInvariantCoord + The invariant ccordinate value of this edge + + @param eEdgeType + Is fInvariantCoord the lower or the higher value, for + this rect? + */ + ActiveEdge( const B2DRectangle& rRect, + const double& fInvariantCoord, + std::ptrdiff_t nPolyIdx, + EdgeType eEdgeType, + EdgeDirection eEdgeDirection ) : + mfInvariantCoord(fInvariantCoord), + mpAssociatedRect( &rRect ), + mnPolygonIdx( nPolyIdx ), + meEdgeType( eEdgeType ), + meEdgeDirection( eEdgeDirection ) + {} + + double getInvariantCoord() const { return mfInvariantCoord; } + const B2DRectangle& getRect() const { return *mpAssociatedRect; } + std::ptrdiff_t getTargetPolygonIndex() const { return mnPolygonIdx; } + void setTargetPolygonIndex( std::ptrdiff_t nIdx ) { mnPolygonIdx = nIdx; } + EdgeType getEdgeType() const { return meEdgeType; } + EdgeDirection getEdgeDirection() const { return meEdgeDirection; } + + /// For STL sort + bool operator<( const ActiveEdge& rRHS ) const { return mfInvariantCoord < rRHS.mfInvariantCoord; } + + private: + /** The invariant coordinate value of this edge (e.g. the + common y value, for a horizontal edge) + */ + double mfInvariantCoord; + + /** Associated rectangle + + This on the one hand saves some storage space (the + vector of rectangles is persistent, anyway), and on + the other hand provides an identifier to match active + edges and x events (see below) + + Ptr because class needs to be assignable + */ + const B2DRectangle* mpAssociatedRect; + + /** Index of the polygon this edge is currently involved + with. + + Note that this can change for some kinds of edge + intersection, as the algorithm tends to swap + associated polygons there. + + -1 denotes no assigned polygon + */ + std::ptrdiff_t mnPolygonIdx; + + /// 'upper' or 'lower' edge of original rectangle. + EdgeType meEdgeType; + + /// 'left' or 'right' + EdgeDirection meEdgeDirection; + }; + + // Needs to be list - various places hold ptrs to elements + typedef std::list< ActiveEdge > ListOfEdges; + + + /** Element of the sweep line event list + + As the sweep line traverses across the overall area, + rectangle edges parallel to it generate events, and + rectangle edges orthogonal to it generate active + edges. This class represents the former. + + The class defines an element of the sweep line list. The + sweep line's position jumps in steps defined by the + coordinates of the sorted SweepLineEvent entries. + */ + class SweepLineEvent + { + public: + /** The two possible sweep line rectangle edges differ by + one coordinate value - the starting edge has the + lower, the finishing edge the higher value. + */ + enum EdgeType { + /// edge with lower coordinate value + STARTING_EDGE=0, + /// edge with higher coordinate value + FINISHING_EDGE=1 + }; + + /** The two possible sweep line directions + */ + enum EdgeDirection { + PROCEED_UP=0, + PROCEED_DOWN=1 + }; + + /** Create sweep line event + + @param fPos + Coordinate position of the event + + @param rRect + Rectangle this event is generated for. + + @param eEdgeType + Is fPos the lower or the higher value, for the + rectangle this event is generated for? + */ + SweepLineEvent( double fPos, + const B2DRectangle& rRect, + EdgeType eEdgeType, + EdgeDirection eDirection) : + mfPos( fPos ), + mpAssociatedRect( &rRect ), + meEdgeType( eEdgeType ), + meEdgeDirection( eDirection ) + {} + + double getPos() const { return mfPos; } + const B2DRectangle& getRect() const { return *mpAssociatedRect; } + EdgeType getEdgeType() const { return meEdgeType; } + EdgeDirection getEdgeDirection() const { return meEdgeDirection; } + + /// For STL sort + bool operator<( const SweepLineEvent& rRHS ) const { return mfPos < rRHS.mfPos; } + + private: + /// position of the event, in the direction of the line sweep + double mfPos; + + /** Rectangle this event is generated for + + This on the one hand saves some storage space (the + vector of rectangles is persistent, anyway), and on + the other hand provides an identifier to match active + edges and events (see below) + + Ptr because class needs to be assignable + */ + const B2DRectangle* mpAssociatedRect; + + /// 'upper' or 'lower' edge of original rectangle. + EdgeType meEdgeType; + + /// 'up' or 'down' + EdgeDirection meEdgeDirection; + }; + + typedef std::vector< SweepLineEvent > VectorOfEvents; + + + /** Smart point container for B2DMultiRange::getPolyPolygon() + + This class provides methods needed only here, and is used + as a place to store some additional information per + polygon. Also, most of the intersection logic is + implemented here. + */ + class ImplPolygon + { + public: + /** Create polygon + */ + ImplPolygon() : + mpLeadingRightEdge(NULL), + mnIdx(-1), + maPoints(), + mbIsFinished(false) + { + // completely ad-hoc. but what the hell. + maPoints.reserve(11); + } + + void setPolygonPoolIndex( std::ptrdiff_t nIdx ) { mnIdx = nIdx; } + bool isFinished() const { return mbIsFinished; } + + /// Add point to the end of the existing points + void append( const B2DPoint& rPoint ) + { + OSL_PRECOND( maPoints.empty() || + maPoints.back().getX() == rPoint.getX() || + maPoints.back().getY() == rPoint.getY(), + "ImplPolygon::append(): added point violates 90 degree line angle constraint!" ); + + if( maPoints.empty() || + maPoints.back() != rPoint ) + { + // avoid duplicate points + maPoints.push_back( rPoint ); + } + } + + /** Perform the intersection of this polygon with an + active edge. + + @param rEvent + The vertical line event that generated the + intersection + + @param rActiveEdge + The active edge that generated the intersection + + @param rPolygonPool + Polygon pool, we sometimes need to allocate a new one + + @param bIsFinishingEdge + True, when this is hitting the last edge of the + vertical sweep - every vertical sweep starts and ends + with upper and lower edge of the _same_ rectangle. + + @return the new current polygon (that's the one + processing must proceed with, when going through the + list of upcoming active edges). + */ + std::ptrdiff_t intersect( SweepLineEvent& rEvent, + ActiveEdge& rActiveEdge, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes, + bool isFinishingEdge ) + { + OSL_PRECOND( !isFinished(), + "ImplPolygon::intersect(): called on already finished polygon!" ); + OSL_PRECOND( !isFinishingEdge + || (isFinishingEdge && &rEvent.getRect() == &rActiveEdge.getRect()), + "ImplPolygon::intersect(): inconsistent ending!" ); + + const B2DPoint aIntersectionPoint( rEvent.getPos(), + rActiveEdge.getInvariantCoord() ); + + // intersection point, goes to our polygon + // unconditionally + append(aIntersectionPoint); + + const bool isSweepLineEnteringRect( + rEvent.getEdgeType() == SweepLineEvent::STARTING_EDGE); + if( isFinishingEdge ) + { + if( isSweepLineEnteringRect ) + handleFinalOwnRightEdge(rActiveEdge); + else + handleFinalOwnLeftEdge(rActiveEdge, + rPolygonPool, + rRes); + + // we're done with this rect & sweep line + return -1; + } + else if( metOwnEdge(rEvent,rActiveEdge) ) + { + handleInitialOwnEdge(rEvent, rActiveEdge); + + // point already added, all init done, continue + // with same poly + return mnIdx; + } + else + { + OSL_ENSURE( rActiveEdge.getTargetPolygonIndex() != -1, + "ImplPolygon::intersect(): non-trivial intersection hit empty polygon!" ); + + const bool isHittingLeftEdge( + rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT); + + if( isHittingLeftEdge ) + return handleComplexLeftEdge(rActiveEdge, + aIntersectionPoint, + rPolygonPool, + rRes); + else + return handleComplexRightEdge(rActiveEdge, + aIntersectionPoint, + rPolygonPool); + } + } + + private: + std::ptrdiff_t getPolygonPoolIndex() const { return mnIdx; } + + void handleInitialOwnEdge(SweepLineEvent& rEvent, + ActiveEdge& rActiveEdge) + { + const bool isActiveEdgeProceedLeft( + rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT); + const bool isSweepLineEnteringRect( + rEvent.getEdgeType() == SweepLineEvent::STARTING_EDGE); + (void)isActiveEdgeProceedLeft; + (void)isSweepLineEnteringRect; + + OSL_ENSURE( isSweepLineEnteringRect == isActiveEdgeProceedLeft, + "ImplPolygon::intersect(): sweep initial own edge hit: wrong polygon order" ); + + OSL_ENSURE( isSweepLineEnteringRect || + mpLeadingRightEdge == &rActiveEdge, + "ImplPolygon::intersect(): sweep initial own edge hit: wrong leading edge" ); + } + + void handleFinalOwnRightEdge(ActiveEdge& rActiveEdge) + { + OSL_ENSURE( rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_RIGHT, + "ImplPolygon::handleInitialOwnRightEdge(): start edge wrong polygon order" ); + + rActiveEdge.setTargetPolygonIndex(mnIdx); + mpLeadingRightEdge = &rActiveEdge; + } + + void handleFinalOwnLeftEdge(ActiveEdge& rActiveEdge, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes) + { + OSL_ENSURE( rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT, + "ImplPolygon::handleFinalOwnLeftEdge(): end edge wrong polygon order" ); + + const bool isHittingOurTail( + rActiveEdge.getTargetPolygonIndex() == mnIdx); + + if( isHittingOurTail ) + finish(rRes); // just finish. no fuss. + else + { + // temp poly hits final left edge + const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex(); + ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx); + + // active edge's polygon has points + // already. ours need to go in front of them. + maPoints.insert(maPoints.end(), + rTmp.maPoints.begin(), + rTmp.maPoints.end()); + + // adjust leading edges, we're switching the polygon + ActiveEdge* const pFarEdge=rTmp.mpLeadingRightEdge; + + mpLeadingRightEdge = pFarEdge; + pFarEdge->setTargetPolygonIndex(mnIdx); + + // nTmpIdx is an empty shell, get rid of it + rPolygonPool.free(nTmpIdx); + } + } + + std::ptrdiff_t handleComplexLeftEdge(ActiveEdge& rActiveEdge, + const B2DPoint& rIntersectionPoint, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes) + { + const bool isHittingOurTail( + rActiveEdge.getTargetPolygonIndex() == mnIdx); + if( isHittingOurTail ) + { + finish(rRes); + + // so "this" is done - need new polygon to collect + // further points + const std::ptrdiff_t nIdxNewPolygon=rPolygonPool.alloc(); + rPolygonPool.get(nIdxNewPolygon).setPolygonPoolIndex(nIdxNewPolygon); + rPolygonPool.get(nIdxNewPolygon).append(rIntersectionPoint); + + rActiveEdge.setTargetPolygonIndex(nIdxNewPolygon); + + return nIdxNewPolygon; + } + else + { + const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex(); + ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx); + + // active edge's polygon has points + // already. ours need to go in front of them. + maPoints.insert(maPoints.end(), + rTmp.maPoints.begin(), + rTmp.maPoints.end()); + + rTmp.maPoints.clear(); + rTmp.append(rIntersectionPoint); + + // adjust leading edges, we're switching the polygon + ActiveEdge* const pFarEdge=rTmp.mpLeadingRightEdge; + ActiveEdge* const pNearEdge=&rActiveEdge; + + rTmp.mpLeadingRightEdge = NULL; + pNearEdge->setTargetPolygonIndex(nTmpIdx); + + mpLeadingRightEdge = pFarEdge; + pFarEdge->setTargetPolygonIndex(mnIdx); + + return nTmpIdx; + } + } + + std::ptrdiff_t handleComplexRightEdge(ActiveEdge& rActiveEdge, + const B2DPoint& rIntersectionPoint, + VectorOfPolygons& rPolygonPool) + { + const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex(); + ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx); + + rTmp.append(rIntersectionPoint); + + rActiveEdge.setTargetPolygonIndex(mnIdx); + mpLeadingRightEdge = &rActiveEdge; + + rTmp.mpLeadingRightEdge = NULL; + + return nTmpIdx; + } + + /// True when sweep line hits our own active edge + bool metOwnEdge(const SweepLineEvent& rEvent, + ActiveEdge& rActiveEdge) + { + const bool bHitOwnEdge=&rEvent.getRect() == &rActiveEdge.getRect(); + return bHitOwnEdge; + } + + /// Retrieve B2DPolygon from this object + B2DPolygon getPolygon() const + { + B2DPolygon aRes; + std::for_each( maPoints.begin(), + maPoints.end(), + boost::bind( + &B2DPolygon::append, + boost::ref(aRes), + _1, + 1 ) ); + aRes.setClosed( true ); + return aRes; + } + + /** Finish this polygon, push to result set. + */ + void finish(B2DPolyPolygon& rRes) + { + OSL_PRECOND( maPoints.empty() || + maPoints.front().getX() == maPoints.back().getX() || + maPoints.front().getY() == maPoints.back().getY(), + "ImplPolygon::finish(): first and last point violate 90 degree line angle constraint!" ); + + mbIsFinished = true; + mpLeadingRightEdge = NULL; + + rRes.append(getPolygon()); + } + + /** Refers to the current leading edge element of this + polygon, or NULL. The leading edge denotes the 'front' + of the polygon vertex sequence, i.e. the coordinates + at the polygon's leading edge are returned from + maPoints.front() + */ + ActiveEdge* mpLeadingRightEdge; + + /// current index into vector pool + std::ptrdiff_t mnIdx; + + /// Container for the actual polygon points + std::vector<B2DPoint> maPoints; + + /// When true, this polygon is 'done', i.e. nothing must be added anymore. + bool mbIsFinished; + }; + + /** Init sweep line event list + + This method fills the event list with the sweep line + events generated from the input rectangles, and sorts them + with increasing x. + */ + void setupSweepLineEventListFromRanges( VectorOfEvents& o_rEventVector, + const std::vector<B2DRange>& rRanges, + const std::vector<B2VectorOrientation>& rOrientations ) + { + // we need exactly 2*rectVec.size() events: one for the + // left, and one for the right edge of each rectangle + o_rEventVector.clear(); + o_rEventVector.reserve( 2*rRanges.size() ); + + // generate events + // =============== + + // first pass: add all left edges in increasing order + std::vector<B2DRange>::const_iterator aCurrRect=rRanges.begin(); + std::vector<B2VectorOrientation>::const_iterator aCurrOrientation=rOrientations.begin(); + const std::vector<B2DRange>::const_iterator aEnd=rRanges.end(); + const std::vector<B2VectorOrientation>::const_iterator aEndOrientation=rOrientations.end(); + while( aCurrRect != aEnd && aCurrOrientation != aEndOrientation ) + { + const B2DRectangle& rCurrRect( *aCurrRect++ ); + + o_rEventVector.push_back( + SweepLineEvent( rCurrRect.getMinX(), + rCurrRect, + SweepLineEvent::STARTING_EDGE, + (*aCurrOrientation++) == ORIENTATION_POSITIVE ? + SweepLineEvent::PROCEED_UP : SweepLineEvent::PROCEED_DOWN) ); + } + + // second pass: add all right edges in reversed order + std::vector<B2DRange>::const_reverse_iterator aCurrRectR=rRanges.rbegin(); + std::vector<B2VectorOrientation>::const_reverse_iterator aCurrOrientationR=rOrientations.rbegin(); + const std::vector<B2DRange>::const_reverse_iterator aEndR=rRanges.rend(); + const std::vector<B2VectorOrientation>::const_reverse_iterator aEndOrientationR=rOrientations.rend(); + while( aCurrRectR != aEndR ) + { + const B2DRectangle& rCurrRect( *aCurrRectR++ ); + + o_rEventVector.push_back( + SweepLineEvent( rCurrRect.getMaxX(), + rCurrRect, + SweepLineEvent::FINISHING_EDGE, + (*aCurrOrientationR++) == ORIENTATION_POSITIVE ? + SweepLineEvent::PROCEED_DOWN : SweepLineEvent::PROCEED_UP ) ); + } + + // sort events + // =========== + + // since we use stable_sort, the order of events with the + // same x value will not change. The elaborate two-pass + // add above thus ensures, that for each two rectangles + // with similar left and right x coordinates, the + // rectangle whose left event comes first will have its + // right event come last. This is advantageous for the + // clip algorithm below, see handleRightEdgeCrossing(). + + // TODO(P3): Use radix sort (from + // b2dpolypolygonrasterconverter, or have your own + // templatized version). + std::stable_sort( o_rEventVector.begin(), + o_rEventVector.end() ); + } + + /** Insert two active edge segments for the given rectangle. + + This method creates two active edge segments from the + given rect, and inserts them into the active edge list, + such that this stays sorted (if it was before). + + @param io_rEdgeList + Active edge list to insert into + + @param io_rPolygons + Vector of polygons. Each rectangle added creates one + tentative result polygon in this vector, and the edge list + entries holds a reference to that polygon (this _requires_ + that the polygon vector does not reallocate, i.e. it must + have at least the maximal number of rectangles reserved) + + @param o_CurrentPolygon + The then-current polygon when processing this sweep line + event + + @param rCurrEvent + The actual event that caused this call + */ + void createActiveEdgesFromStartEvent( ListOfEdges& io_rEdgeList, + VectorOfPolygons& io_rPolygonPool, + SweepLineEvent& rCurrEvent ) + { + ListOfEdges aNewEdges; + const B2DRectangle& rRect=rCurrEvent.getRect(); + const bool bGoesDown=rCurrEvent.getEdgeDirection() == SweepLineEvent::PROCEED_DOWN; + + // start event - new rect starts here, needs polygon to + // collect points into + const std::ptrdiff_t nIdxPolygon=io_rPolygonPool.alloc(); + io_rPolygonPool.get(nIdxPolygon).setPolygonPoolIndex(nIdxPolygon); + + // upper edge + aNewEdges.push_back( + ActiveEdge( + rRect, + rRect.getMinY(), + bGoesDown ? nIdxPolygon : -1, + ActiveEdge::UPPER, + bGoesDown ? ActiveEdge::PROCEED_LEFT : ActiveEdge::PROCEED_RIGHT) ); + // lower edge + aNewEdges.push_back( + ActiveEdge( + rRect, + rRect.getMaxY(), + bGoesDown ? -1 : nIdxPolygon, + ActiveEdge::LOWER, + bGoesDown ? ActiveEdge::PROCEED_RIGHT : ActiveEdge::PROCEED_LEFT ) ); + + // furthermore, have to respect a special tie-breaking + // rule here, for edges which share the same y value: + // newly added upper edges must be inserted _before_ any + // other edge with the same y value, and newly added lower + // edges must be _after_ all other edges with the same + // y. This ensures that the left vertical edge processing + // below encounters the upper edge of the current rect + // first, and the lower edge last, which automatically + // starts and finishes this rect correctly (as only then, + // the polygon will have their associated active edges + // set). + const double nMinY( rRect.getMinY() ); + const double nMaxY( rRect.getMaxY() ); + ListOfEdges::iterator aCurr( io_rEdgeList.begin() ); + const ListOfEdges::iterator aEnd ( io_rEdgeList.end() ); + while( aCurr != aEnd ) + { + const double nCurrY( aCurr->getInvariantCoord() ); + + if( nCurrY >= nMinY && + aNewEdges.size() == 2 ) // only add, if not yet done. + { + // insert upper edge _before_ aCurr. Thus, it will + // be the first entry for a range of equal y + // values. Using splice here, since we hold + // references to the moved list element! + io_rEdgeList.splice( aCurr, + aNewEdges, + aNewEdges.begin() ); + } + + if( nCurrY > nMaxY ) + { + // insert lower edge _before_ aCurr. Thus, it will + // be the last entry for a range of equal y values + // (aCurr is the first entry strictly larger than + // nMaxY). Using splice here, since we hold + // references to the moved list element! + io_rEdgeList.splice( aCurr, + aNewEdges, + aNewEdges.begin() ); + // done with insertion, can early-exit here. + return; + } + + ++aCurr; + } + + // append remainder of aNewList (might still contain 2 or + // 1 elements, depending of the contents of io_rEdgeList). + io_rEdgeList.splice( aCurr, + aNewEdges ); + } + + inline bool isSameRect(ActiveEdge& rEdge, + const basegfx::B2DRange& rRect) + { + return &rEdge.getRect() == &rRect; + } + + // wow what a hack. necessary because stl's list::erase does + // not eat reverse_iterator + template<typename Cont, typename Iter> Iter eraseFromList(Cont&, Iter); + template<> inline ListOfEdges::iterator eraseFromList( + ListOfEdges& rList, ListOfEdges::iterator aIter) + { + return rList.erase(aIter); + } + template<> inline ListOfEdges::reverse_iterator eraseFromList( + ListOfEdges& rList, ListOfEdges::reverse_iterator aIter) + { + return ListOfEdges::reverse_iterator( + rList.erase(boost::prior(aIter.base()))); + } + + template<int bPerformErase, + typename Iterator> inline void processActiveEdges( + Iterator first, + Iterator last, + ListOfEdges& rActiveEdgeList, + SweepLineEvent& rCurrEvent, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes ) + { + const basegfx::B2DRange& rCurrRect=rCurrEvent.getRect(); + + // fast-forward to rCurrEvent's first active edge (holds + // for both starting and finishing sweep line events, a + // rect is regarded _outside_ any rects whose events have + // started earlier + first = std::find_if(first, last, + boost::bind( + &isSameRect, + _1, + boost::cref(rCurrRect))); + + if(first == last) + return; + + int nCount=0; + std::ptrdiff_t nCurrPolyIdx=-1; + while(first != last) + { + if( nCurrPolyIdx == -1 ) + nCurrPolyIdx=first->getTargetPolygonIndex(); + + OSL_ASSERT(nCurrPolyIdx != -1); + + // second encounter of my rect -> second edge + // encountered, done + const bool bExit= + nCount && + isSameRect(*first, + rCurrRect); + + // deal with current active edge + nCurrPolyIdx = + rPolygonPool.get(nCurrPolyIdx).intersect( + rCurrEvent, + *first, + rPolygonPool, + rRes, + bExit); + + // prune upper & lower active edges, if requested + if( bPerformErase && (bExit || !nCount) ) + first = eraseFromList(rActiveEdgeList,first); + else + ++first; + + // delayed exit, had to prune first + if( bExit ) + return; + + ++nCount; + } + } + + template<int bPerformErase> inline void processActiveEdgesTopDown( + SweepLineEvent& rCurrEvent, + ListOfEdges& rActiveEdgeList, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes ) + { + processActiveEdges<bPerformErase>( + rActiveEdgeList. begin(), + rActiveEdgeList. end(), + rActiveEdgeList, + rCurrEvent, + rPolygonPool, + rRes); + } + + template<int bPerformErase> inline void processActiveEdgesBottomUp( + SweepLineEvent& rCurrEvent, + ListOfEdges& rActiveEdgeList, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes ) + { + processActiveEdges<bPerformErase>( + rActiveEdgeList. rbegin(), + rActiveEdgeList. rend(), + rActiveEdgeList, + rCurrEvent, + rPolygonPool, + rRes); + } + + enum{ NoErase=0, PerformErase=1 }; + + void handleStartingEdge( SweepLineEvent& rCurrEvent, + ListOfEdges& rActiveEdgeList, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes) + { + // inject two new active edges for rect + createActiveEdgesFromStartEvent( rActiveEdgeList, + rPolygonPool, + rCurrEvent ); + + if( SweepLineEvent::PROCEED_DOWN == rCurrEvent.getEdgeDirection() ) + processActiveEdgesTopDown<NoErase>( + rCurrEvent, rActiveEdgeList, rPolygonPool, rRes); + else + processActiveEdgesBottomUp<NoErase>( + rCurrEvent, rActiveEdgeList, rPolygonPool, rRes); + } + + void handleFinishingEdge( SweepLineEvent& rCurrEvent, + ListOfEdges& rActiveEdgeList, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes) + { + if( SweepLineEvent::PROCEED_DOWN == rCurrEvent.getEdgeDirection() ) + processActiveEdgesTopDown<PerformErase>( + rCurrEvent, rActiveEdgeList, rPolygonPool, rRes); + else + processActiveEdgesBottomUp<PerformErase>( + rCurrEvent, rActiveEdgeList, rPolygonPool, rRes); + } + + inline void handleSweepLineEvent( SweepLineEvent& rCurrEvent, + ListOfEdges& rActiveEdgeList, + VectorOfPolygons& rPolygonPool, + B2DPolyPolygon& rRes) + { + if( SweepLineEvent::STARTING_EDGE == rCurrEvent.getEdgeType() ) + handleStartingEdge(rCurrEvent,rActiveEdgeList,rPolygonPool,rRes); + else + handleFinishingEdge(rCurrEvent,rActiveEdgeList,rPolygonPool,rRes); + } + } + + namespace tools + { + B2DPolyPolygon solveCrossovers(const std::vector<B2DRange>& rRanges, + const std::vector<B2VectorOrientation>& rOrientations) + { + // sweep-line algorithm to generate a poly-polygon + // from a bunch of rectangles + // =============================================== + // + // This algorithm uses the well-known sweep line + // concept, explained in every good text book about + // computational geometry. + // + // We start with creating two structures for every + // rectangle, one representing the left x coordinate, + // one representing the right x coordinate (and both + // referencing the original rect). These structs are + // sorted with increasing x coordinates. + // + // Then, we start processing the resulting list from + // the beginning. Every entry in the list defines a + // point in time of the line sweeping from left to + // right across all rectangles. + VectorOfEvents aSweepLineEvents; + setupSweepLineEventListFromRanges( aSweepLineEvents, + rRanges, + rOrientations ); + + B2DPolyPolygon aRes; + VectorOfPolygons aPolygonPool; + ListOfEdges aActiveEdgeList; + + // sometimes not enough, but a usable compromise + aPolygonPool.reserve( rRanges.size() ); + + std::for_each( aSweepLineEvents.begin(), + aSweepLineEvents.end(), + boost::bind( + &handleSweepLineEvent, + _1, + boost::ref(aActiveEdgeList), + boost::ref(aPolygonPool), + boost::ref(aRes)) ); + + return aRes; + } + } +} + diff --git a/basegfx/source/range/makefile.mk b/basegfx/source/range/makefile.mk index 04d8e8e66fa2..5e05eeda94d9 100644 --- a/basegfx/source/range/makefile.mk +++ b/basegfx/source/range/makefile.mk @@ -43,7 +43,8 @@ SLOFILES= \ $(SLO)$/b1drange.obj \ $(SLO)$/b2drange.obj \ $(SLO)$/b2xrange.obj \ - $(SLO)$/b2dmultirange.obj \ + $(SLO)$/b2dpolyrange.obj \ + $(SLO)$/b2drangeclipper.obj \ $(SLO)$/b3drange.obj # --- Targets ---------------------------------- diff --git a/basegfx/source/tools/b2dclipstate.cxx b/basegfx/source/tools/b2dclipstate.cxx new file mode 100644 index 000000000000..005dca1aa66a --- /dev/null +++ b/basegfx/source/tools/b2dclipstate.cxx @@ -0,0 +1,662 @@ +/************************************************************************* + * + * 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: b2dmultirange.cxx,v $ + * $Revision: 1.8 $ + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +#include <basegfx/tools/b2dclipstate.hxx> + +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/b2dpolyrange.hxx> +#include <basegfx/range/b2drangeclipper.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygoncutter.hxx> + +namespace basegfx +{ +namespace tools +{ + struct ImplB2DClipState + { + public: + enum Operation {UNION, INTERSECT, XOR, SUBTRACT}; + + ImplB2DClipState() : + maPendingPolygons(), + maPendingRanges(), + maClipPoly(), + mePendingOps(UNION) + {} + + explicit ImplB2DClipState( const B2DRange& rRange ) : + maPendingPolygons(), + maPendingRanges(), + maClipPoly( + tools::createPolygonFromRect(rRange)), + mePendingOps(UNION) + {} + + explicit ImplB2DClipState( const B2DPolygon& rPoly ) : + maPendingPolygons(), + maPendingRanges(), + maClipPoly(rPoly), + mePendingOps(UNION) + {} + + explicit ImplB2DClipState( const B2DPolyPolygon& rPoly ) : + maPendingPolygons(), + maPendingRanges(), + maClipPoly(rPoly), + mePendingOps(UNION) + {} + + bool isCleared() const + { + return !maClipPoly.count() + && !maPendingPolygons.count() + && !maPendingRanges.count(); + } + + void makeClear() + { + maPendingPolygons.clear(); + maPendingRanges.clear(); + maClipPoly.clear(); + mePendingOps = UNION; + } + + bool isNullClipPoly() const + { + return maClipPoly.count() == 1 + && !maClipPoly.getB2DPolygon(0).count(); + } + + bool isNull() const + { + return !maPendingPolygons.count() + && !maPendingRanges.count() + && isNullClipPoly(); + } + + void makeNull() + { + maPendingPolygons.clear(); + maPendingRanges.clear(); + maClipPoly.clear(); + maClipPoly.append(B2DPolygon()); + mePendingOps = UNION; + } + + bool operator==(const ImplB2DClipState& rRHS) const + { + return maPendingPolygons == rRHS.maPendingPolygons + && maPendingRanges == rRHS.maPendingRanges + && maClipPoly == rRHS.maClipPoly + && mePendingOps == rRHS.mePendingOps; + } + + void addRange(const B2DRange& rRange, Operation eOp) + { + if( rRange.isEmpty() ) + return; + + commitPendingPolygons(); + if( mePendingOps != eOp ) + commitPendingRanges(); + + mePendingOps = eOp; + maPendingRanges.appendElement( + rRange, + ORIENTATION_POSITIVE); + } + + void addPolygon(B2DPolygon aPoly, Operation eOp) + { + commitPendingRanges(); + if( mePendingOps != eOp ) + commitPendingPolygons(); + + mePendingOps = eOp; + maPendingPolygons.append(aPoly); + } + + void addPolyPolygon(B2DPolyPolygon aPoly, Operation eOp) + { + commitPendingRanges(); + if( mePendingOps != eOp ) + commitPendingPolygons(); + + mePendingOps = eOp; + maPendingPolygons.append(aPoly); + } + + void addClipState(const ImplB2DClipState& rOther, Operation eOp) + { + if( rOther.mePendingOps == mePendingOps + && !rOther.maClipPoly.count() + && !rOther.maPendingPolygons.count() ) + { + maPendingRanges.appendPolyRange( rOther.maPendingRanges ); + } + else + { + commitPendingRanges(); + commitPendingPolygons(); + rOther.commitPendingRanges(); + rOther.commitPendingPolygons(); + + maPendingPolygons = rOther.maClipPoly; + mePendingOps = eOp; + } + } + + void unionRange(const B2DRange& rRange) + { + if( isCleared() ) + return; + + addRange(rRange,UNION); + } + + void unionPolygon(const B2DPolygon& rPoly) + { + if( isCleared() ) + return; + + addPolygon(rPoly,UNION); + } + + void unionPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + if( isCleared() ) + return; + + addPolyPolygon(rPolyPoly,UNION); + } + + void unionClipState(const ImplB2DClipState& rOther) + { + if( isCleared() ) + return; + + addClipState(rOther, UNION); + } + + void intersectRange(const B2DRange& rRange) + { + if( isNull() ) + return; + + addRange(rRange,INTERSECT); + } + + void intersectPolygon(const B2DPolygon& rPoly) + { + if( isNull() ) + return; + + addPolygon(rPoly,INTERSECT); + } + + void intersectPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + if( isNull() ) + return; + + addPolyPolygon(rPolyPoly,INTERSECT); + } + + void intersectClipState(const ImplB2DClipState& rOther) + { + if( isNull() ) + return; + + addClipState(rOther, INTERSECT); + } + + void subtractRange(const B2DRange& rRange ) + { + if( isNull() ) + return; + + addRange(rRange,SUBTRACT); + } + + void subtractPolygon(const B2DPolygon& rPoly) + { + if( isNull() ) + return; + + addPolygon(rPoly,SUBTRACT); + } + + void subtractPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + if( isNull() ) + return; + + addPolyPolygon(rPolyPoly,SUBTRACT); + } + + void subtractClipState(const ImplB2DClipState& rOther) + { + if( isNull() ) + return; + + addClipState(rOther, SUBTRACT); + } + + void xorRange(const B2DRange& rRange) + { + addRange(rRange,XOR); + } + + void xorPolygon(const B2DPolygon& rPoly) + { + addPolygon(rPoly,XOR); + } + + void xorPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + addPolyPolygon(rPolyPoly,XOR); + } + + void xorClipState(const ImplB2DClipState& rOther) + { + addClipState(rOther, XOR); + } + + B2DPolyPolygon getClipPoly() const + { + commitPendingRanges(); + commitPendingPolygons(); + + return maClipPoly; + } + + private: + void commitPendingPolygons() const + { + if( !maPendingPolygons.count() ) + return; + + // assumption: maClipPoly has kept polygons prepared for + // clipping; i.e. no neutral polygons & correct + // orientation + maPendingPolygons = tools::prepareForPolygonOperation(maPendingPolygons); + const bool bIsEmpty=isNullClipPoly(); + const bool bIsCleared=!maClipPoly.count(); + switch(mePendingOps) + { + case UNION: + OSL_ASSERT( !bIsCleared ); + + if( bIsEmpty ) + maClipPoly = maPendingPolygons; + else + maClipPoly = tools::solvePolygonOperationOr( + maClipPoly, + maPendingPolygons); + break; + case INTERSECT: + OSL_ASSERT( !bIsEmpty ); + + if( bIsCleared ) + maClipPoly = maPendingPolygons; + else + maClipPoly = tools::solvePolygonOperationAnd( + maClipPoly, + maPendingPolygons); + break; + case XOR: + if( bIsEmpty ) + maClipPoly = maPendingPolygons; + else if( bIsCleared ) + { + // not representable, strictly speaking, + // using polygons with the common even/odd + // or nonzero winding number fill rule. If + // we'd want to represent it, fill rule + // would need to be "non-negative winding + // number" (and we then would return + // 'holes' here) + + // going for an ugly hack meanwhile + maClipPoly = tools::solvePolygonOperationXor( + B2DPolyPolygon( + tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))), + maPendingPolygons); + } + else + maClipPoly = tools::solvePolygonOperationXor( + maClipPoly, + maPendingPolygons); + break; + case SUBTRACT: + OSL_ASSERT( !bIsEmpty ); + + // first union all pending ones, subtract en bloc then + maPendingPolygons = solveCrossovers(maPendingPolygons); + maPendingPolygons = stripNeutralPolygons(maPendingPolygons); + maPendingPolygons = stripDispensablePolygons(maPendingPolygons, false); + + if( bIsCleared ) + { + // not representable, strictly speaking, + // using polygons with the common even/odd + // or nonzero winding number fill rule. If + // we'd want to represent it, fill rule + // would need to be "non-negative winding + // number" (and we then would return + // 'holes' here) + + // going for an ugly hack meanwhile + maClipPoly = tools::solvePolygonOperationDiff( + B2DPolyPolygon( + tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))), + maPendingPolygons); + } + else + maClipPoly = tools::solvePolygonOperationDiff( + maClipPoly, + maPendingPolygons); + break; + } + + maPendingPolygons.clear(); + mePendingOps = UNION; + } + + void commitPendingRanges() const + { + if( !maPendingRanges.count() ) + return; + + // use the specialized range clipper for the win + B2DPolyPolygon aCollectedRanges; + const bool bIsEmpty=isNullClipPoly(); + const bool bIsCleared=!maClipPoly.count(); + switch(mePendingOps) + { + case UNION: + OSL_ASSERT( !bIsCleared ); + + aCollectedRanges = maPendingRanges.solveCrossovers(); + aCollectedRanges = stripNeutralPolygons(aCollectedRanges); + aCollectedRanges = stripDispensablePolygons(aCollectedRanges, false); + if( bIsEmpty ) + maClipPoly = aCollectedRanges; + else + maClipPoly = tools::solvePolygonOperationOr( + maClipPoly, + aCollectedRanges); + break; + case INTERSECT: + OSL_ASSERT( !bIsEmpty ); + + aCollectedRanges = maPendingRanges.solveCrossovers(); + aCollectedRanges = stripNeutralPolygons(aCollectedRanges); + if( maPendingRanges.count() > 1 ) + aCollectedRanges = stripDispensablePolygons(aCollectedRanges, true); + + if( bIsCleared ) + maClipPoly = aCollectedRanges; + else + maClipPoly = tools::solvePolygonOperationAnd( + maClipPoly, + aCollectedRanges); + break; + case XOR: + aCollectedRanges = maPendingRanges.solveCrossovers(); + aCollectedRanges = stripNeutralPolygons(aCollectedRanges); + aCollectedRanges = correctOrientations(aCollectedRanges); + + if( bIsEmpty ) + maClipPoly = aCollectedRanges; + else if( bIsCleared ) + { + // not representable, strictly speaking, + // using polygons with the common even/odd + // or nonzero winding number fill rule. If + // we'd want to represent it, fill rule + // would need to be "non-negative winding + // number" (and we then would return + // 'holes' here) + + // going for an ugly hack meanwhile + maClipPoly = tools::solvePolygonOperationXor( + B2DPolyPolygon( + tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))), + aCollectedRanges); + } + else + maClipPoly = tools::solvePolygonOperationXor( + maClipPoly, + aCollectedRanges); + break; + case SUBTRACT: + OSL_ASSERT( !bIsEmpty ); + + // first union all pending ranges, subtract en bloc then + aCollectedRanges = maPendingRanges.solveCrossovers(); + aCollectedRanges = stripNeutralPolygons(aCollectedRanges); + aCollectedRanges = stripDispensablePolygons(aCollectedRanges, false); + + if( bIsCleared ) + { + // not representable, strictly speaking, + // using polygons with the common even/odd + // or nonzero winding number fill rule. If + // we'd want to represent it, fill rule + // would need to be "non-negative winding + // number" (and we then would return + // 'holes' here) + + // going for an ugly hack meanwhile + maClipPoly = tools::solvePolygonOperationDiff( + B2DPolyPolygon( + tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))), + aCollectedRanges); + } + else + maClipPoly = tools::solvePolygonOperationDiff( + maClipPoly, + aCollectedRanges); + break; + } + + maPendingRanges.clear(); + mePendingOps = UNION; + } + + mutable B2DPolyPolygon maPendingPolygons; + mutable B2DPolyRange maPendingRanges; + mutable B2DPolyPolygon maClipPoly; + mutable Operation mePendingOps; + }; + + B2DClipState::B2DClipState() : + mpImpl() + {} + + B2DClipState::~B2DClipState() + {} + + B2DClipState::B2DClipState( const B2DClipState& rOrig ) : + mpImpl(rOrig.mpImpl) + {} + + B2DClipState::B2DClipState( const B2DRange& rRange ) : + mpImpl( ImplB2DClipState(rRange) ) + {} + + B2DClipState::B2DClipState( const B2DPolygon& rPoly ) : + mpImpl( ImplB2DClipState(rPoly) ) + {} + + B2DClipState::B2DClipState( const B2DPolyPolygon& rPolyPoly ) : + mpImpl( ImplB2DClipState(rPolyPoly) ) + {} + + B2DClipState& B2DClipState::operator=( const B2DClipState& rRHS ) + { + mpImpl = rRHS.mpImpl; + return *this; + } + + void B2DClipState::makeUnique() + { + mpImpl.make_unique(); + } + + void B2DClipState::makeNull() + { + mpImpl->makeNull(); + } + + bool B2DClipState::isNull() const + { + return mpImpl->isNull(); + } + + void B2DClipState::makeClear() + { + mpImpl->makeClear(); + } + + bool B2DClipState::isCleared() const + { + return mpImpl->isCleared(); + } + + bool B2DClipState::operator==(const B2DClipState& rRHS) const + { + if(mpImpl.same_object(rRHS.mpImpl)) + return true; + + return ((*mpImpl) == (*rRHS.mpImpl)); + } + + bool B2DClipState::operator!=(const B2DClipState& rRHS) const + { + return !(*this == rRHS); + } + + void B2DClipState::unionRange(const B2DRange& rRange) + { + mpImpl->unionRange(rRange); + } + + void B2DClipState::unionPolygon(const B2DPolygon& rPoly) + { + mpImpl->unionPolygon(rPoly); + } + + void B2DClipState::unionPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + mpImpl->unionPolyPolygon(rPolyPoly); + } + + void B2DClipState::unionClipState(const B2DClipState& rState) + { + mpImpl->unionClipState(*rState.mpImpl); + } + + void B2DClipState::intersectRange(const B2DRange& rRange) + { + mpImpl->intersectRange(rRange); + } + + void B2DClipState::intersectPolygon(const B2DPolygon& rPoly) + { + mpImpl->intersectPolygon(rPoly); + } + + void B2DClipState::intersectPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + mpImpl->intersectPolyPolygon(rPolyPoly); + } + + void B2DClipState::intersectClipState(const B2DClipState& rState) + { + mpImpl->intersectClipState(*rState.mpImpl); + } + + void B2DClipState::subtractRange(const B2DRange& rRange) + { + mpImpl->subtractRange(rRange); + } + + void B2DClipState::subtractPolygon(const B2DPolygon& rPoly) + { + mpImpl->subtractPolygon(rPoly); + } + + void B2DClipState::subtractPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + mpImpl->subtractPolyPolygon(rPolyPoly); + } + + void B2DClipState::subtractClipState(const B2DClipState& rState) + { + mpImpl->subtractClipState(*rState.mpImpl); + } + + void B2DClipState::xorRange(const B2DRange& rRange) + { + mpImpl->xorRange(rRange); + } + + void B2DClipState::xorPolygon(const B2DPolygon& rPoly) + { + mpImpl->xorPolygon(rPoly); + } + + void B2DClipState::xorPolyPolygon(const B2DPolyPolygon& rPolyPoly) + { + mpImpl->xorPolyPolygon(rPolyPoly); + } + + void B2DClipState::xorClipState(const B2DClipState& rState) + { + mpImpl->xorClipState(*rState.mpImpl); + } + + B2DPolyPolygon B2DClipState::getClipPoly() const + { + return mpImpl->getClipPoly(); + } + +} // end of namespace tools +} // end of namespace basegfx + +// eof diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 89293cfcb61c..857b668da68e 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -49,6 +49,8 @@ namespace basegfx o_rGradientInfo.maBackTextureTransform.identity(); o_rGradientInfo.mnSteps = nSteps; + fAngle = -fAngle; + double fTargetSizeX(rTargetRange.getWidth()); double fTargetSizeY(rTargetRange.getHeight()); double fTargetOffsetX(rTargetRange.getMinX()); @@ -67,17 +69,30 @@ namespace basegfx fTargetSizeY = fNewY; } - // add object scale before rotate + const double fSizeWithoutBorder=1.0 - fBorder; + if( bAxial ) + { + o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder * .5); + o_rGradientInfo.maTextureTransform.translate(0.0, 0.5); + } + else + { + if(!fTools::equal(fSizeWithoutBorder, 1.0)) + { + o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder); + o_rGradientInfo.maTextureTransform.translate(0.0, fBorder); + } + } + o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); // add texture rotate after scale to keep perpendicular angles if(0.0 != fAngle) { - B2DPoint aCenter(0.5, 0.5); - aCenter *= o_rGradientInfo.maTextureTransform; - - o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) - * o_rGradientInfo.maTextureTransform; + const B2DPoint aCenter(0.5*fTargetSizeX, + 0.5*fTargetSizeY); + o_rGradientInfo.maTextureTransform *= + basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add object translate @@ -86,24 +101,9 @@ namespace basegfx // prepare aspect for texture o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; - // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform + // build transform from u,v to [0.0 .. 1.0]. o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; o_rGradientInfo.maBackTextureTransform.invert(); - - double fSizeWithoutBorder=0; - if( bAxial ) - { - fSizeWithoutBorder = (1.0 - fBorder) * 0.5; - o_rGradientInfo.maBackTextureTransform.translate(0.0, -0.5); - } - else - { - fSizeWithoutBorder = 1.0 - fBorder; - o_rGradientInfo.maBackTextureTransform.translate(0.0, -fBorder); - } - - if(!fTools::equal(fSizeWithoutBorder, 0.0)) - o_rGradientInfo.maBackTextureTransform.scale(1.0, 1.0 / fSizeWithoutBorder); } /** Most of the setup for radial & ellipsoidal gradient is the same, @@ -121,6 +121,8 @@ namespace basegfx o_rGradientInfo.maBackTextureTransform.identity(); o_rGradientInfo.mnSteps = nSteps; + fAngle = -fAngle; + double fTargetSizeX(rTargetRange.getWidth()); double fTargetSizeY(rTargetRange.getHeight()); double fTargetOffsetX(rTargetRange.getMinX()); @@ -143,20 +145,19 @@ namespace basegfx fTargetSizeY = 1.4142 * fTargetSizeY; } - // add object scale before rotate + const double fHalfBorder((1.0 - fBorder) * 0.5); + o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder); + + o_rGradientInfo.maTextureTransform.translate(0.5, 0.5); o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); - if( !bCircular ) + // add texture rotate after scale to keep perpendicular angles + if( !bCircular && 0.0 != fAngle) { - // add texture rotate after scale to keep perpendicular angles - if(0.0 != fAngle) - { - B2DPoint aCenter(0.5, 0.5); - aCenter *= o_rGradientInfo.maTextureTransform; - - o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) - * o_rGradientInfo.maTextureTransform; - } + const B2DPoint aCenter(0.5*fTargetSizeX, + 0.5*fTargetSizeY); + o_rGradientInfo.maTextureTransform *= + basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add defined offsets after rotation @@ -173,17 +174,9 @@ namespace basegfx // prepare aspect for texture o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; - // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform + // build transform from u,v to [0.0 .. 1.0]. o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; o_rGradientInfo.maBackTextureTransform.invert(); - o_rGradientInfo.maBackTextureTransform.translate(-0.5, -0.5); - const double fHalfBorder((1.0 - fBorder) * 0.5); - - if(!fTools::equal(fHalfBorder, 0.0)) - { - const double fFactor(1.0 / fHalfBorder); - o_rGradientInfo.maBackTextureTransform.scale(fFactor, fFactor); - } } /** Setup for rect & square gradient is exactly the same. Factored out @@ -200,6 +193,8 @@ namespace basegfx o_rGradientInfo.maBackTextureTransform.identity(); o_rGradientInfo.mnSteps = nSteps; + fAngle = -fAngle; + double fTargetSizeX(rTargetRange.getWidth()); double fTargetSizeY(rTargetRange.getHeight()); double fTargetOffsetX(rTargetRange.getMinX()); @@ -218,17 +213,19 @@ namespace basegfx fTargetSizeY = fNewY; } - // add object scale before rotate + const double fHalfBorder((1.0 - fBorder) * 0.5); + o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder); + + o_rGradientInfo.maTextureTransform.translate(0.5, 0.5); o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); // add texture rotate after scale to keep perpendicular angles if(0.0 != fAngle) { - B2DPoint aCenter(0.5, 0.5); - aCenter *= o_rGradientInfo.maTextureTransform; - - o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) - * o_rGradientInfo.maTextureTransform; + const B2DPoint aCenter(0.5*fTargetSizeX, + 0.5*fTargetSizeY); + o_rGradientInfo.maTextureTransform *= + basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add defined offsets after rotation @@ -248,14 +245,6 @@ namespace basegfx // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; o_rGradientInfo.maBackTextureTransform.invert(); - o_rGradientInfo.maBackTextureTransform.translate(-0.5, -0.5); - const double fHalfBorder((1.0 - fBorder) * 0.5); - - if(!fTools::equal(fHalfBorder, 0.0)) - { - const double fFactor(1.0 / fHalfBorder); - o_rGradientInfo.maBackTextureTransform.scale(fFactor, fFactor); - } } namespace tools diff --git a/basegfx/source/tools/keystoplerp.cxx b/basegfx/source/tools/keystoplerp.cxx new file mode 100644 index 000000000000..883bfec6bc96 --- /dev/null +++ b/basegfx/source/tools/keystoplerp.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" + +#include "basegfx/tools/keystoplerp.hxx" +#include <com/sun/star/uno/Sequence.hxx> + +#include <algorithm> + +static void validateInput(const std::vector<double>& rKeyStops) +{ + (void)rKeyStops; +#ifdef DBG_UTIL + OSL_ENSURE( rKeyStops.size() > 1, + "KeyStopLerp::KeyStopLerp(): key stop vector must have two entries or more" ); + + // rKeyStops must be sorted in ascending order + for( ::std::size_t i=1, len=rKeyStops.size(); i<len; ++i ) + { + if( rKeyStops[i-1] > rKeyStops[i] ) + OSL_ENSURE( false, + "KeyStopLerp::KeyStopLerp(): time vector is not sorted in ascending order!" ); + } +#endif +} + +namespace basegfx +{ + namespace tools + { + KeyStopLerp::KeyStopLerp( const std::vector<double>& rKeyStops ) : + maKeyStops(rKeyStops), + mnLastIndex(0) + { + validateInput(maKeyStops); + } + + KeyStopLerp::KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops ) : + maKeyStops(rKeyStops.getLength()), + mnLastIndex(0) + { + std::copy( rKeyStops.getConstArray(), + rKeyStops.getConstArray()+rKeyStops.getLength(), + maKeyStops.begin() ); + validateInput(maKeyStops); + } + + KeyStopLerp::ResultType KeyStopLerp::lerp(double fAlpha) const + { + // cached value still okay? + if( maKeyStops.at(mnLastIndex) < fAlpha || + maKeyStops.at(mnLastIndex+1) >= fAlpha ) + { + // nope, find new index + mnLastIndex = std::min<std::ptrdiff_t>( + maKeyStops.size()-2, + // range is ensured by max below + std::max<std::ptrdiff_t>( + 0, + std::distance( maKeyStops.begin(), + std::lower_bound( maKeyStops.begin(), + maKeyStops.end(), + fAlpha )) - 1 )); + } + + // lerp between stop and stop+1 + const double fRawLerp= + (fAlpha-maKeyStops.at(mnLastIndex)) / + (maKeyStops.at(mnLastIndex+1) - maKeyStops.at(mnLastIndex)); + + // clamp to permissible range (input fAlpha might be + // everything) + return ResultType( + mnLastIndex, + clamp(fRawLerp,0.0,1.0)); + } + } +} diff --git a/basegfx/source/tools/makefile.mk b/basegfx/source/tools/makefile.mk index c70b78be5d4b..0a0977f7305d 100755 --- a/basegfx/source/tools/makefile.mk +++ b/basegfx/source/tools/makefile.mk @@ -37,9 +37,11 @@ ENABLE_EXCEPTIONS=TRUE # --- Files ------------------------------------- -SLOFILES= $(SLO)$/canvastools.obj \ +SLOFILES= $(SLO)$/b2dclipstate.obj \ + $(SLO)$/canvastools.obj \ $(SLO)$/gradienttools.obj \ $(SLO)$/debugplotter.obj \ + $(SLO)$/keystoplerp.obj \ $(SLO)$/liangbarsky.obj \ $(SLO)$/tools.obj \ $(SLO)$/unopolypolygon.obj diff --git a/basegfx/test/basegfx1d.cxx b/basegfx/test/basegfx1d.cxx index 5cc823d3daca..41ac65da56e3 100644 --- a/basegfx/test/basegfx1d.cxx +++ b/basegfx/test/basegfx1d.cxx @@ -30,7 +30,10 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" namespace basegfx1d { @@ -52,7 +55,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -65,13 +67,7 @@ public: }; // class b1drange // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx1d::b1drange, "basegfx1d"); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx1d::b1drange); } // namespace basegfx1d - -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -NOADDITIONAL; - +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index b169d35ed96a..31005a158982 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -30,7 +30,9 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -38,7 +40,9 @@ #include <basegfx/curve/b2dcubicbezier.hxx> #include <basegfx/curve/b2dbeziertools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/range/b2dmultirange.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/range/b2dpolyrange.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/color/bcolor.hxx> #include <basegfx/color/bcolortools.hxx> @@ -53,214 +57,6 @@ using namespace ::basegfx; namespace basegfx2d { -/// Gets a random ordinal [0,n) -inline double getRandomOrdinal( const ::std::size_t n ) -{ - return double(n) * rand() / (RAND_MAX + 1.0); -} - -class b2dmultirange : public CppUnit::TestFixture -{ -private: - B2DMultiRange aDisjunctRanges; - B2DMultiRange aEqualRanges; - B2DMultiRange aIntersectionN; - B2DMultiRange aIntersectionE; - B2DMultiRange aIntersectionS; - B2DMultiRange aIntersectionW; - B2DMultiRange aIntersectionNE; - B2DMultiRange aIntersectionSE; - B2DMultiRange aIntersectionSW; - B2DMultiRange aIntersectionNW; - B2DMultiRange aRingIntersection; - B2DMultiRange aComplexIntersections; - B2DMultiRange aRandomIntersections; - -public: - // initialise your test code values here. - void setUp() - { - B2DRange aCenter(1.0, 1.0, -1.0, -1.0); - B2DRange aOffside(9.0, 9.0, 11.0, 11.0); - B2DRange aNorth(1.0, 0.0, -1.0, -2.0); - B2DRange aSouth(1.0, 2.0, -1.0, 0.0); - B2DRange aEast(0.0, 1.0, 2.0, -1.0); - B2DRange aWest(-2.0, 1.0, 0.0, -1.0); - B2DRange aNorthEast(0.0, 0.0, 2.0, -2.0); - B2DRange aSouthEast(0.0, 0.0, 2.0, 2.0); - B2DRange aSouthWest(0.0, 0.0, -2.0, 2.0); - B2DRange aNorthWest(0.0, 0.0, -2.0, -2.0); - - B2DRange aNorth2(-1.5, 0.5, 1.5, 3.5); - B2DRange aSouth2(-1.5, -0.5, 1.5, -3.5); - B2DRange aEast2 (0.5, -1.5, 3.5, 1.5); - B2DRange aWest2 (-0.5, -1.5,-3.5, 1.5); - - ::std::ofstream output("multirange_testcases.gnuplot"); - DebugPlotter aPlotter( "multirange testcases", - output ); - - aPlotter.plot( aCenter, "center" ); - aPlotter.plot( aOffside, "offside" ); - aPlotter.plot( aNorth, "north" ); - aPlotter.plot( aSouth, "south" ); - aPlotter.plot( aEast, "east" ); - aPlotter.plot( aWest, "west" ); - aPlotter.plot( aNorthEast, "northeast" ); - aPlotter.plot( aSouthEast, "southeast" ); - aPlotter.plot( aSouthWest, "southwest" ); - aPlotter.plot( aNorthWest, "northwest" ); - - aDisjunctRanges.addRange( aCenter ); - aDisjunctRanges.addRange( aOffside ); - - aEqualRanges.addRange( aCenter ); - aEqualRanges.addRange( aCenter ); - - aIntersectionN.addRange( aCenter ); - aIntersectionN.addRange( aNorth ); - - aIntersectionE.addRange( aCenter ); - aIntersectionE.addRange( aEast ); - - aIntersectionS.addRange( aCenter ); - aIntersectionS.addRange( aSouth ); - - aIntersectionW.addRange( aCenter ); - aIntersectionW.addRange( aWest ); - - aIntersectionNE.addRange( aCenter ); - aIntersectionNE.addRange( aNorthEast ); - - aIntersectionSE.addRange( aCenter ); - aIntersectionSE.addRange( aSouthEast ); - - aIntersectionSW.addRange( aCenter ); - aIntersectionSW.addRange( aSouthWest ); - - aIntersectionNW.addRange( aCenter ); - aIntersectionNW.addRange( aNorthWest ); - - aRingIntersection.addRange( aNorth2 ); - aRingIntersection.addRange( aEast2 ); - aRingIntersection.addRange( aSouth2 ); - aRingIntersection.addRange( aWest2 ); - - aComplexIntersections.addRange( aCenter ); - aComplexIntersections.addRange( aOffside ); - aComplexIntersections.addRange( aCenter ); - aComplexIntersections.addRange( aNorth ); - aComplexIntersections.addRange( aEast ); - aComplexIntersections.addRange( aSouth ); - aComplexIntersections.addRange( aWest ); - aComplexIntersections.addRange( aNorthEast ); - aComplexIntersections.addRange( aSouthEast ); - aComplexIntersections.addRange( aSouthWest ); - aComplexIntersections.addRange( aNorthWest ); - -/* - for( int i=0; i<10; ++i ) - { - B2DRange aRandomRange( - getRandomOrdinal( 10 ), - getRandomOrdinal( 10 ), - getRandomOrdinal( 10 ), - getRandomOrdinal( 10 ) ); - - aRandomIntersections.addRange( aRandomRange ); - } -*/ - } - - void tearDown() - { - } - - ::basegfx::B2DPolyPolygon shiftPoly( int nCount, - const ::basegfx::B2DPolyPolygon& rPoly ) - { - B2DHomMatrix aMatrix; - aMatrix.translate( nCount*4.0, - 10.0-nCount*2.0 ); - - ::basegfx::B2DPolyPolygon aRes( rPoly ); - aRes.transform( aMatrix ); - - return aRes; - } - - void getPolyPolygon() - { - ::std::ofstream output("multirange_getpolypolygon.gnuplot"); - DebugPlotter aPlotter( "multirange getPolyPolygon", - output ); - - B2DPolyPolygon result; - - aPlotter.plot( shiftPoly( - 0, - aDisjunctRanges.getPolyPolygon() ), - "disjunct" ); - aPlotter.plot( shiftPoly( - 1, - aEqualRanges.getPolyPolygon() ), - "equal" ); - aPlotter.plot( shiftPoly( - 2, - aIntersectionN.getPolyPolygon() ), - "intersectionN" ); - aPlotter.plot( shiftPoly( - 3, - aIntersectionE.getPolyPolygon() ), - "intersectionE" ); - aPlotter.plot( shiftPoly( - 4, - aIntersectionS.getPolyPolygon() ), - "intersectionS" ); - aPlotter.plot( shiftPoly( - 5, - aIntersectionW.getPolyPolygon() ), - "intersectionW" ); - aPlotter.plot( shiftPoly( - 6, - aIntersectionNE.getPolyPolygon() ), - "intersectionNE" ); - aPlotter.plot( shiftPoly( - 7, - aIntersectionSE.getPolyPolygon() ), - "intersectionSE" ); - aPlotter.plot( shiftPoly( - 8, - aIntersectionSW.getPolyPolygon() ), - "intersectionSW" ); - aPlotter.plot( shiftPoly( - 9, - aIntersectionNW.getPolyPolygon() ), - "intersectionNW" ); - aPlotter.plot( shiftPoly( - 10, - aRingIntersection.getPolyPolygon() ), - "intersection ring" ); - aPlotter.plot( shiftPoly( - 11, - aComplexIntersections.getPolyPolygon() ), - "intersection complex" ); - aPlotter.plot( shiftPoly( - 12, - aRandomIntersections.getPolyPolygon() ), - "intersection random" ); - - CPPUNIT_ASSERT_MESSAGE("getPolyPolygon", true ); - } - - // Change the following lines only, if you add, remove or rename - // member functions of the current class, - // because these macros are need by auto register mechanism. - - CPPUNIT_TEST_SUITE(b2dmultirange); - CPPUNIT_TEST(getPolyPolygon); - CPPUNIT_TEST_SUITE_END(); -}; // class b2dmultirange class b2dsvgdimpex : public CppUnit::TestFixture { @@ -465,33 +261,6 @@ public: CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)", !aExport.compareToAscii(sExportString2)); - const B2DPolygon aCircle( - tools::createPolygonFromEllipse( B2DPoint(4000,4000), - 1000.0, 2000.0 )); - aExport = tools::exportToSvgD( B2DPolyPolygon(aCircle), false, false); - - // count number of spaces, in lieu of a better way - no real - // point in comparing with a gold standard, as fractional - // parts of the coordinates will differ between systems. - sal_Int32 nIndex=0, nCount=0; - do - { - rtl::OUString aToken = aExport.getToken( 0, ' ', nIndex ); - ++nCount; - } - while ( nIndex >= 0 ); - - // Adapted number of spaces to 50 and 67 because of the new circle construction - // methods which produce more points and thus more spaces, too. Use both since - // depending on float precision and the getContinuity() implemetation using - // fTools::equal, linux and mac produce more 'C' than 'S' statements, while WIN32 - // uses more 'S' statements (as it should be for circles) -#ifdef S390X - CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", nCount==61 ); -#else - CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", nCount==67 || nCount==50 ); -#endif - const B2DPolygon aRect( tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) )); aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false); @@ -510,6 +279,45 @@ public: CPPUNIT_TEST_SUITE_END(); }; // class b2dsvgdimpex +class b2dpolyrange : public CppUnit::TestFixture +{ +private: +public: + void setUp() + {} + + void tearDown() + {} + + void check() + { + B2DPolyRange aRange; + aRange.appendElement(B2DRange(0,0,1,1),ORIENTATION_POSITIVE); + aRange.appendElement(B2DRange(2,2,3,3),ORIENTATION_POSITIVE); + + CPPUNIT_ASSERT_MESSAGE("simple poly range - count", + aRange.count() == 2); + CPPUNIT_ASSERT_MESSAGE("simple poly range - first element", + aRange.getElement(0).head == B2DRange(0,0,1,1)); + CPPUNIT_ASSERT_MESSAGE("simple poly range - second element", + aRange.getElement(1).head == B2DRange(2,2,3,3)); + + // B2DPolyRange relies on correctly orientated rects + const B2DRange aRect(0,0,1,1); + CPPUNIT_ASSERT_MESSAGE("createPolygonFromRect - correct orientation", + tools::getOrientation( + tools::createPolygonFromRect(aRect)) == ORIENTATION_POSITIVE ); + } + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE(b2dpolyrange); + CPPUNIT_TEST(check); + CPPUNIT_TEST_SUITE_END(); +}; + class b2dbeziertools : public CppUnit::TestFixture { private: @@ -758,7 +566,6 @@ public: { // this is demonstration code // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1110,7 +917,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1140,7 +946,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1283,6 +1088,14 @@ public: aNonRect4.append( B2DPoint(1,1) ); aNonRect4.append( B2DPoint(0,1) ); + B2DPolygon aNonRect5; + aNonRect5.append( B2DPoint(0,0) ); + aNonRect5.append( B2DPoint(1,0) ); + aNonRect5.append( B2DPoint(1,1) ); + aNonRect5.append( B2DPoint(0,1) ); + aNonRect5.setControlPoints(1,B2DPoint(1,0),B2DPoint(-11,0)); + aNonRect5.setClosed(true); + CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1", tools::isRectangle( aRect1 )); CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 2", @@ -1295,6 +1108,8 @@ public: !tools::isRectangle( aNonRect3 )); CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 4", !tools::isRectangle( aNonRect4 )); + CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 5", + !tools::isRectangle( aNonRect5 )); } // Change the following lines only, if you add, remove or rename @@ -1322,7 +1137,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1352,7 +1166,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1380,7 +1193,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1410,7 +1222,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1438,7 +1249,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -1502,6 +1312,8 @@ public: tools::rgb2hsl(maMagenta) == BColor(300,1,0.5)); CPPUNIT_ASSERT_MESSAGE("cyan", tools::rgb2hsl(maCyan) == BColor(180,1,0.5)); + CPPUNIT_ASSERT_MESSAGE("third hue case", + tools::rgb2hsl(BColor(0,0.5,1)) == BColor(210,1,0.5)); CPPUNIT_ASSERT_MESSAGE("roundtrip white", tools::hsl2rgb(tools::rgb2hsl(maWhite)) == maWhite); @@ -1623,21 +1435,21 @@ public: }; // class b2dvector // ----------------------------------------------------------------------------- -//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dmultirange, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dsvgdimpex, "basegfx2d"); -//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dbeziertools, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dcubicbezier, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dhommatrix, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dhompoint, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpoint, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolygon, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolygontools, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolypolygon, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dquadraticbezier, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2drange, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dtuple, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dvector, "basegfx2d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::bcolor, "basegfx2d"); + +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dsvgdimpex); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolyrange); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dcubicbezier); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhommatrix); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhompoint); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpoint); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygon); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygontools); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolypolygon); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dquadraticbezier); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2drange); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dtuple); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dvector); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::bcolor); } // namespace basegfx2d diff --git a/basegfx/test/basegfx3d.cxx b/basegfx/test/basegfx3d.cxx index 23d3542e2d4a..a16132e0810f 100644 --- a/basegfx/test/basegfx3d.cxx +++ b/basegfx/test/basegfx3d.cxx @@ -30,7 +30,9 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" namespace basegfx3d { @@ -52,7 +54,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -80,7 +81,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -110,7 +110,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -138,7 +137,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -168,7 +166,6 @@ public: void EmptyMethod() { // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -196,7 +193,6 @@ public: // insert your test code here. void EmptyMethod() { - CPPUNIT_ASSERT_STUB(); } // Change the following lines only, if you add, remove or rename @@ -209,12 +205,12 @@ public: }; // class b3dvector // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dhommatrix, "basegfx3d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dhompoint, "basegfx3d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dpoint, "basegfx3d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3drange, "basegfx3d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dtuple, "basegfx3d"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dvector, "basegfx3d"); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dhommatrix); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dhompoint); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dpoint); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3drange); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dtuple); +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dvector); } // namespace basegfx3d diff --git a/basegfx/test/basegfxtools.cxx b/basegfx/test/basegfxtools.cxx new file mode 100644 index 000000000000..1a8b97a559b2 --- /dev/null +++ b/basegfx/test/basegfxtools.cxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +// autogenerated file with codegen.pl + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include <basegfx/tools/keystoplerp.hxx> +#include <basegfx/numeric/ftools.hxx> + +#include <boost/tuple/tuple.hpp> + +using namespace ::basegfx; +using namespace ::boost::tuples; + +namespace basegfxtools +{ + +class KeyStopLerpTest : public CppUnit::TestFixture +{ + tools::KeyStopLerp maKeyStops; + + static std::vector<double> getTestVector() + { + std::vector<double> aStops(3); + aStops[0] = 0.1; + aStops[1] = 0.5; + aStops[2] = 0.9; + return aStops; + } + +public: + KeyStopLerpTest() : + maKeyStops(getTestVector()) + {} + + void setUp() + {} + + void tearDown() + {} + + void test() + { + double fAlpha; + std::ptrdiff_t nIndex; + + tie(nIndex,fAlpha) = maKeyStops.lerp(-1.0); + CPPUNIT_ASSERT_MESSAGE("-1.0", nIndex==0 && fAlpha==0.0); + + tie(nIndex,fAlpha) = maKeyStops.lerp(0.1); + CPPUNIT_ASSERT_MESSAGE("0.1", nIndex==0 && fAlpha==0.0); + + tie(nIndex,fAlpha) = maKeyStops.lerp(0.3); + CPPUNIT_ASSERT_MESSAGE("0.3", nIndex==0 && fTools::equal(fAlpha,0.5)); + + tie(nIndex,fAlpha) = maKeyStops.lerp(0.5); + CPPUNIT_ASSERT_MESSAGE("0.5", nIndex==0 && fTools::equal(fAlpha,1.0)); + + tie(nIndex,fAlpha) = maKeyStops.lerp(0.51); + CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,0.025)); + + tie(nIndex,fAlpha) = maKeyStops.lerp(0.9); + CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,1.0)); + + tie(nIndex,fAlpha) = maKeyStops.lerp(1.0); + CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fAlpha==1.0); + } + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE(KeyStopLerpTest); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); +}; + +// ----------------------------------------------------------------------------- +CPPUNIT_TEST_SUITE_REGISTRATION(basegfxtools::KeyStopLerpTest); +} // namespace basegfxtools diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx new file mode 100644 index 000000000000..d52218a51ee0 --- /dev/null +++ b/basegfx/test/boxclipper.cxx @@ -0,0 +1,419 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +// autogenerated file with codegen.pl + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/curve/b2dcubicbezier.hxx> +#include <basegfx/curve/b2dbeziertools.hxx> +#include <basegfx/range/b2dpolyrange.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygoncutter.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/numeric/ftools.hxx> + +#include <boost/bind.hpp> + +using namespace ::basegfx; + + +namespace basegfx2d +{ +/// Gets a random ordinal [0,n) +inline double getRandomOrdinal( const ::std::size_t n ) +{ + // use this one when displaying polygons in OOo, which still sucks + // great rocks when trying to import non-integer svg:d attributes + // return sal_Int64(double(n) * rand() / (RAND_MAX + 1.0)); + return double(n) * rand() / (RAND_MAX + 1.0); +} + +inline bool compare(const B2DPoint& left, const B2DPoint& right) +{ + return left.getX()<right.getX() + || (left.getX()==right.getX() && left.getY()<right.getY()); +} + + +class boxclipper : public CppUnit::TestFixture +{ +private: + B2DPolyRange aDisjunctRanges; + B2DPolyRange aEqualRanges; + B2DPolyRange aIntersectionN; + B2DPolyRange aIntersectionE; + B2DPolyRange aIntersectionS; + B2DPolyRange aIntersectionW; + B2DPolyRange aIntersectionNE; + B2DPolyRange aIntersectionSE; + B2DPolyRange aIntersectionSW; + B2DPolyRange aIntersectionNW; + B2DPolyRange aRingIntersection; + B2DPolyRange aRingIntersection2; + B2DPolyRange aRingIntersectExtraStrip; + B2DPolyRange aComplexIntersections; + B2DPolyRange aRandomIntersections; + +public: + // initialise your test code values here. + void setUp() + { + B2DRange aCenter(100, 100, -100, -100); + B2DRange aOffside(800, 800, 1000, 1000); + B2DRange aNorth(100, 0, -100, -200); + B2DRange aSouth(100, 200, -100, 0); + B2DRange aEast(0, 100, 200, -100); + B2DRange aWest(-200, 100, 0, -100); + B2DRange aNorthEast(0, 0, 200, -200); + B2DRange aSouthEast(0, 0, 200, 200); + B2DRange aSouthWest(0, 0, -200, 200); + B2DRange aNorthWest(0, 0, -200, -200); + + B2DRange aNorth2(-150, 50, 150, 350); + B2DRange aSouth2(-150, -50, 150, -350); + B2DRange aEast2 (50, -150, 350, 150); + B2DRange aWest2 (-50, -150,-350, 150); + + aDisjunctRanges.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aDisjunctRanges.appendElement( aOffside, ORIENTATION_NEGATIVE ); + + aEqualRanges.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aEqualRanges.appendElement( aCenter, ORIENTATION_NEGATIVE ); + + aIntersectionN.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionN.appendElement( aNorth, ORIENTATION_NEGATIVE ); + + aIntersectionE.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionE.appendElement( aEast, ORIENTATION_NEGATIVE ); + + aIntersectionS.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionS.appendElement( aSouth, ORIENTATION_NEGATIVE ); + + aIntersectionW.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionW.appendElement( aWest, ORIENTATION_NEGATIVE ); + + aIntersectionNE.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionNE.appendElement( aNorthEast, ORIENTATION_NEGATIVE ); + + aIntersectionSE.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionSE.appendElement( aSouthEast, ORIENTATION_NEGATIVE ); + + aIntersectionSW.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionSW.appendElement( aSouthWest, ORIENTATION_NEGATIVE ); + + aIntersectionNW.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aIntersectionNW.appendElement( aNorthWest, ORIENTATION_NEGATIVE ); + + aRingIntersection.appendElement( aNorth2, ORIENTATION_NEGATIVE ); + aRingIntersection.appendElement( aEast2, ORIENTATION_NEGATIVE ); + aRingIntersection.appendElement( aSouth2, ORIENTATION_NEGATIVE ); + + aRingIntersection2 = aRingIntersection; + aRingIntersection2.appendElement( aWest2, ORIENTATION_NEGATIVE ); + + aRingIntersectExtraStrip = aRingIntersection2; + aRingIntersectExtraStrip.appendElement( B2DRange(0, -25, 200, 25), + ORIENTATION_NEGATIVE ); + + aComplexIntersections.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aOffside, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aCenter, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aNorth, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aEast, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aSouth, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aWest, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aNorthEast, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aSouthEast, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aSouthWest, ORIENTATION_NEGATIVE ); + aComplexIntersections.appendElement( aNorthWest, ORIENTATION_NEGATIVE ); + +#ifdef GENERATE_RANDOM + for( int i=0; i<800; ++i ) + { + B2DRange aRandomRange( + getRandomOrdinal( 1000 ), + getRandomOrdinal( 1000 ), + getRandomOrdinal( 1000 ), + getRandomOrdinal( 1000 ) ); + + aRandomIntersections.appendElement( aRandomRange, ORIENTATION_NEGATIVE ); + } +#else + const char* randomSvg="m394 783h404v57h-404zm-197-505h571v576h-571zm356-634h75v200h-75zm-40-113h403v588h-403zm93-811h111v494h-111zm-364-619h562v121h-562zm-134-8h292v27h-292zm110 356h621v486h-621zm78-386h228v25h-228zm475-345h201v201h-201zm-2-93h122v126h-122zm-417-243h567v524h-567zm-266-738h863v456h-863zm262-333h315v698h-315zm-328-826h43v393h-43zm830-219h120v664h-120zm-311-636h221v109h-221zm-500 137h628v19h-628zm681-94h211v493h-211zm-366-646h384v355h-384zm-189-199h715v247h-715zm165-459h563v601h-563zm258-479h98v606h-98zm270-517h65v218h-65zm-44-259h96v286h-96zm-599-202h705v468h-705zm216-803h450v494h-450zm-150-22h26v167h-26zm-55-599h50v260h-50zm190-278h490v387h-490zm-290-453h634v392h-634zm257 189h552v300h-552zm-151-690h136v455h-136zm12-597h488v432h-488zm501-459h48v39h-48zm-224-112h429v22h-429zm-281 102h492v621h-492zm519-158h208v17h-208zm-681-563h56v427h-56zm126-451h615v392h-615zm-47-410h598v522h-598zm-32 316h79v110h-79zm-71-129h18v127h-18zm126-993h743v589h-743zm211-430h428v750h-428zm61-554h100v220h-100zm-353-49h658v157h-658zm778-383h115v272h-115zm-249-541h119v712h-119zm203 86h94v40h-94z"; + B2DPolyPolygon randomPoly; + tools::importFromSvgD( + randomPoly, + rtl::OUString::createFromAscii(randomSvg)); + std::for_each(randomPoly.begin(), + randomPoly.end(), + boost::bind( + &B2DPolyRange::appendElement, + boost::ref(aRandomIntersections), + boost::bind( + &B2DPolygon::getB2DRange, + _1), + ORIENTATION_NEGATIVE, + 1)); +#endif + } + + void tearDown() + { + } + + B2DPolyPolygon normalizePoly( const B2DPolyPolygon& rPoly ) + { + B2DPolyPolygon aRes; + for( sal_uInt32 i=0; i<rPoly.count(); ++i ) + { + B2DPolygon aTmp=rPoly.getB2DPolygon(i); + if( ORIENTATION_NEGATIVE == tools::getOrientation(aTmp) ) + aTmp.flip(); + + aTmp=tools::removeNeutralPoints(aTmp); + + B2DPoint* pSmallest=0; + for(B2DPoint* pCurr=aTmp.begin(); pCurr!=aTmp.end(); ++pCurr) + { + if( ! pSmallest || compare(*pCurr, *pSmallest) ) + { + pSmallest=pCurr; + } + } + + if( pSmallest ) + std::rotate(aTmp.begin(),pSmallest,aTmp.end()); + + aRes.append(aTmp); + } + + // boxclipper & generic clipper disagree slightly on area-less + // polygons (one or two points only) + aRes = tools::stripNeutralPolygons(aRes); + + // now, sort all polygons with increasing 0th point + std::sort(aRes.begin(), + aRes.end(), + boost::bind( + &compare, + boost::bind( + &B2DPolygon::getB2DPoint, + _1,0), + boost::bind( + &B2DPolygon::getB2DPoint, + _2,0))); + + return aRes; + } + + void verifyPoly(const char* sName, const char* sSvg, const B2DPolyRange& toTest) + { + B2DPolyPolygon aTmp1; + CPPUNIT_ASSERT_MESSAGE(sName, + tools::importFromSvgD( + aTmp1, + rtl::OUString::createFromAscii(sSvg))); + + const rtl::OUString aSvg= + tools::exportToSvgD(toTest.solveCrossovers()); + B2DPolyPolygon aTmp2; + CPPUNIT_ASSERT_MESSAGE(sName, + tools::importFromSvgD( + aTmp2, + aSvg)); + + CPPUNIT_ASSERT_MESSAGE( + sName, + normalizePoly(aTmp2) == normalizePoly(aTmp1)); + } + + void verifyPoly() + { + const char* disjunct="m100 100v-200h-200v200zm1100 900v-200h-200v200z"; + const char* equal="m100 100v-200h-200v200zm200 0v-200h-200v200h200z"; + const char* intersectionN="m100 0v-100h-200v100zm200 100v-200-100h-200v100 200z"; + const char* intersectionE="m100 100v-200h-100v200zm200 0v-200h-200-100v200h100z"; + const char* intersectionS="m100 100v-200h-200v200 100h200v-100zm0 0v-100h-200v100z"; + const char* intersectionW="m0 100v-200h-100v200zm200 0v-200h-200-100v200h100z"; + const char* intersectionNE="m100 0v-100h-100v100zm200 0v-200h-200v100h-100v200h200v-100z"; + const char* intersectionSE="m200 200v-200h-100v-100h-200v200h100v100zm100-100v-100h-100v100z"; + const char* intersectionSW="m0 100v-100h-100v100zm200 0v-200h-200v100h-100v200h200v-100z"; + const char* intersectionNW="m100 100v-200h-100v-100h-200v200h100v100zm100-100v-100h-100v100z"; + const char* ringIntersection="m150 150v-100h-100v100zm300 0v-300h-200v-200h-300v300h200v100h-200v300h300v-200zm0-200v-100h-100v100z"; + const char* ringIntersection2="m-50-50v-100h-100v100zm100 200v-100h-100v100zm500 0v-300h-200v-200h-300v200h-200v300h200v200h300v-200zm-200-100v-100h100v100zm100-100v-100h-100v100zm100 200v-100h-100v100z"; + const char* ringIntersectExtraStrip="m-50-50v-100h-100v100zm100 200v-100h-100v100zm500 0v-300h-200v-200h-300v200h-200v300h200v200h300v-200zm-200-100v-100h100v25h-50v50h50v25zm150-25v-50h-150v50zm100-75v-100h-100v100zm100 200v-100h-100v100z"; + // TODO: old clipper impl. debug difference + //const char* complexIntersections="m100 0h-100v-100 100h-100 100v100-100zm0 0zm200 0h-100v-100h-100v-100 100h-100v100h-100 100v100h100v100-100h100v-100zm0 0h-100v-100 100h-100 100v100-100h100zm0 0v-100h-100-100v100 100h100 100v-100zm100 0v-100h-100v-100h-100-100v100h-100v100 100h100v100h100 100v-100h100v-100zm-200 0zm100 0v-100h-100-100v100 100h100 100v-100zm100 100v-200-100h-200-100-100v100 200 100h100 100 200v-100zm-200-100zm1000 1000v-200h-200v200z"; + const char* complexIntersections="m0 0zm0 0zm0 0zm0 0v-100 100h-100 100v100-100h100zm-100 0v-100 100h-100 100v100-100h100zm0 0v-100h-100-100v100 100h100 100v-100zm0 0v-100h-100-100v100 100h100 100v-100zm0 0v-100h-100v-100 100h-100v100h-100 100v100h100v100-100h100v-100h100zm-100-100v-100h-100-100v100h-100v100 100h100v100h100 100v-100h100v-100-100zm0 0v-100h-200-100-100v100 200 100h100 100 200v-100-200zm600 900v200h200v-200z"; + const char* randomIntersections="m63 457v-393h-43v393zm114 63v-8h-48v8zm-14 477v-127h-18v127zm693-923v-5h-119v5zm-260 457v-1h-14v1zm-220-375v-27h-8v27zm78 755v-22h-7v22zm203-774v-8h-158v8zm-108 375v-17h23v17zm813-19v-189h-21v-12h-26v-54h-17v-69h-25v-22h-62v-73h104v-5h-104-15v-17h-49v-1h-8v-16h-119v16h-386v18h-38-24v34h-23v26h-23v-26h-8v26h-18v27h18v339h8v-339h23v339h8v17h-8v13h8v5h-8v1h8v42h15v20h17v94h18 3v224h165v39h130v2h75v4h98v-4h153v-2h77v-20h4v-28h11v-218h-11v-27h3v-1h8v-17h-8v-63h8v-51h18v-32zm-581 32v-13h-14v13zm-78-78v-7h-32v7zm124 14v-21h-14v21zm595 32v-189h-26v-12h-4v-9h-13v-45h-13v-10h-12v-59h-62v-22h-26v-10h11v-63h15v-5h-15-49v-17h-8v-1h-119v1h-107v17h-279-38v34h-24v26h-23v27h23v284h-15v55h15v17h-15v13h15v5h-15v1h15v42h17v20h18v94h3 14v62h8v48h90v32h18v61h35v21h8v2h122v37h75v2h98v-2h153v-20h77v-28h4v-29h5v-40h-5v-149h-1v-27h1v-1h3v-17h-3v-46h3v-17-51h8v-32zm-563 2v-13h-14v13zm198 30v-13h-39v13zm204-43v-21h3v21zm-168-21v-21h-39v21zm306 0v-21h-5v21zm178 115v-272h-20v-12h-2v-54h-21v-164h1v-22h-27v-48h-743v47h-23v18h-71v24h-8v419h-39v19h60v156h66 32v202h-72v110h79v-88h11v39h3v48h621v-14h96v-82h35v-326zm-570-420v-4h-156v4zm63 481v-18h-11v18zm72 0v-25h-14v25zm465-112v-13h-5v13zm-46-43v-21h1v21zm-37-21v-21h-12v21zm-352 21v-21h23v21zm-23 30v-17h23v17zm-23 18v-5h23v5zm-23 82v-19h23v19zm272 75v-3h-35v3zm-76-192v-13h-39v13zm150 30v-13h-35v13zm-76 6v-1h-39v1zm11 106v-25h-11v25zm150 160v-14h-75v14zm318-304v-11h-13v-43h-2v-2h-10v-37h-4v37h-27v3h-31v-3-37h-5v37h-43v3h-2v21h2v21h-2v30h-1v-30h-8v-21h8v-21h-8v-3h-5v-62h5v-11h-5v-29h-8v-52h-15v-17-38h-15v-52h-89v16h-22v36h-175v55h-15v1h-25v51h-23v-41h-14v41h-2v105h-4v21h4v21h-4v13h4v17h-4-18v13h18v5h-18v1h18v42h4v11h2v9h14v-9h23v9h40v19h-40v25h40v2h82v2h75v43h-75v3h75 40v60h35v-60h23 34 12 15v-3h-15v-43h15v-48h10v-37h11v-31h1v1h45v30h5v-30h20v-1h11v1h8v30h19v20h3v-20h1v-30h10v-1h2v-32zm-146-329v-1h-2v1zm-117 211v-11 11zm-76 0v-11h-13v11zm13 65v-65h1v65zm-1 42v-21h1v16h35v5zm-36 30v-17h36v17zm-36 18v-5h36v5zm180-5v-13h-13v-17h5v-13h-5v-21h5v-21h-5v-3h-8v-62h8v-11h-8v-29h-9v-51h-6v-1-17h-15v-38h-54v-36h-35v36h-22v38h-67v17h-108v1h-15v51h-25v105h-23v-105h-14v105h-2v21h2v21h-2v13h2v17h-2-4v13h4v5h-4v1h4v42h2v11h14v-11h23v11h40v9h82v19h-82v25h82v2h75v2h40v43h-40v3h40 35 23v-3h-23v-43h23v-2h34v2h12v-2h6v-46h9v-20h8v-17h2v-26h-2v-5zm-127-64v-21 21zm89 51v-17h3v17zm-57-17v-13h-35v13zm58 61v-26h-19v-5h19v-13h-23v-17h23v-13h-23v-21h23v-21h-23v-65h23v-11h-23v-14h-35v-15 15h-22v14h-18v11h18v65h-18v21h18v16h22v5h-22v13h22v17h-22-18v13h18v5h-18v1h18v25h22v17h35v-17zm0-25v-1h-35v1zm-22-390v6h-175v5h-31v-15h228v4zm344 352v-189h-2v-12h-21v-54h-26v-164h26v-5h-26v-17h-119v-36h-562v35h-62v18h-23v34h-23v-10h-48v419h-8v8h8v5h71v5h-58v1h58v42h8v114h32 18v224h3v39h165v34h456v-32h77v-2h4v-20h11v-28h4v-218h-4v-28h36v-17h-36v-63h39v-83zm-50 0v-11h-1v-43h-3v-2h-6v-39h-4v-34h-13v-60h-12v-12h-31v72h-31v-72-9h-59v-17-38h-5v-59h-8v-5h8v-1h-8v-16h-2v16h-13v-11h-15v-5h-89v5h-22v11h-175v6h-15v7h-25v16h-43v36h-18v66h-54v-107h-32v107h-4v41h-8v105h-6v7h6v14h8v21h-8v13h8v17h-8-14v13h14v5h-14v1h14v42h8v20h90v19h-34v7h-15v68h26v-50h23v50h18 4v62h16v-62h15v110h8v10h3v22h119v11h75v50h75v-50h23v-11h34v11h48v-11h30v-22h21v-120h20v-3h11v3h30v-3h13-13v-27h13v-1h17v-17h-17v-46h17v-17h6v-51h3v-32zm-256-32v-21h-35v-65h35v-11h-35v-14 14h-22v11h22v65h-22v21h22v16-16zm89 69v-5h3v5zm-3 26v-26h-31v-5h31v-13h-31v-17h31v-13h-31v-21h31v-21h-31v-65h31v-11h-31v-14h-23v-15h-35v-51 51h-22v15h-18v14h-35v11h35v65h-35v21h35v16h18v5h-18v13h18v17h-18-36-39-61v13h61v5h-61v1h61v25h39v-25h36v25h18v17h22v11h35v-11h23v-17zm-19-25v-1h-4v-5h4v-13h-4-35-22v13h22v5h-22v1h22v25h35v-25zm23 252v-36h34v36zm-34-99v-43h34v43zm35-128v-26h-8v-5h8v-13h-8v-17h8v-13h-8v-21h8v-21h-8v-3h-9v-62h9v-11h-9v-29h-6v-51-1h-15v-17h-54v-38h-35v38h-22v11h-53v6h-14v1h-108v51h-15v105h-25v21h25v21h-25v13h25v17h-25-23-14-2v13h2v5h-2v1h2v42h14v-42h23v42h40v11h82v9h75v46h40v2h35v-2h23v-4h31v-42h3v46h12v-46h6v-20h9v-17zm-15-61v-13h-12v13zm12 30v-13h-12v13zm12 31v-26h-12v26zm12 131v-3h-12v3zm12 110v-14h-12v14zm27-241v-26h-9v-5h9v-13h-9v-17h9v-13h-9v-21h9v-21h-9v-3h-6v-62h6v-11h-6v-29-51h-15v-1h-54v-17h-35v11h-22v6h-53v1h-14v51h-108v105h-15v21h15v21h-15v13h15v17h-15-25v13h25v5h-25v1h25v25h15v17h21v6h61v5h75v9h18v42h22v4h35v-4h23v-42h31v-9h3v9h12v-9-11h6v-17zm0 0v-26h-6v-5h6v-13h-6v-17h6v-13h-6v-21h6v-21h-6v-3-62-11-29h-15v-51h-54v-1h-35v-6 6h-22v1h-53v51h-14v24h-87v81h-21v21h21v21h-21v13h21v17h-21-15v13h15v5h-15v1h15v25h21v17h61v6h39v-6h36v11h18v9h22v42h35v-42h23v-9h31v-11h3v11h12v-11-17zm0 0v-26-5-13-17-13-21-21-3h-12v3h-3v-65h15v-11h-15v-29h-54v-51h-35v-1 1h-22v51h-53v29h-1v-5h-13v5h-26v76h-61v21h61v21h-61v13h61v17h-61-21v13h21v5h-21v1h21v25h61v17h39v-17h36v17h18v11h22v9h35v-9h23v-11h31v-17h3v17h12v-17zm15-419v-12h-2v12zm186 356v-56h-8v-133h-4v-12h-13v-9h-13v-45h-12v-10h-62v-59-6h-26v-16h-33v-10h33v-12h-33v-22h-5v-29h49v-5h-49-8v-17h-119v17h-107-279v34h-38v26h-24v27h24v179h-7v105h-17v55h17v17h-17v13h17v5h-17v1h17v42h18v20h3v94h14 8v62h41v37h26v-37h23v48h18v32h35v61h8v21h122v2h75v37h98v-37h34v17h119v-57h11v29h66v-29h4v-40h-4v-26h3v-123h-3v-27h3v-1h1v-17h-1v-46h1v-17h3v-51-32zm0 0v-54h-4v-2h-3v-73h-10v-60h-13v-12h-12v-9h-31v9h-31v-9-55h-59v-59h-5v-5h5v-1h-5v-16h-8v-10h8v-12h-8v-22h-119v34h117v10h-28v-6h-89v6h-22v5h-175v11h-40v13h-147v11h-4v107h-8v41h-6v105h-22v21h28v21h-17v13h17v17h-14-3v13h3v5h-3v1h3v42h14v20h8v94h41 26 23 18v62h4v48h31v10h8v22h3v11h119v50h75v21h98v-71h34v71h48v-71h30v-11h21v-22h20v-120h11v120h43v-123h17-17v-27h17v-1h6v-17h-6v-46h6v-17h3v-51h1v-32zm-4 0v-11h-6v-43h-4v-2h-13v-39h-12v-34h-4v34h-27v2h-31v-2-34h-48v36h-2v37h-1v-73h-8v-29-52h-5v-17h-8v-38h-15v-59h-15v-6h-89v6h-22v7h-175v16h-15v36h-25v55h-39v11h-4v41h-18v105h-54v-105h-32v105h-4v7h4v14h86v21h-86v13h86v17h-86-4v13h4v5h-4v1h4v42h86v11h18v9h4v19h-4v25h4v50h16v-48h23v45h-8v3h8 122v96h-119v14h119v10h75v22h75v-22h23v-10h34v10h48v-24h-36v-36h15v-60h21v-3h-11v-43h2v15h9v-15h46v15h5v-15h20v-2h-20v-46h20v-37h11v37h8v46h-8v2h8v15h22v-15h1v-2h-1v-46h1v-17h12v-20h13v-31h4v-32zm-142 148v-2h-9v2zm9-2v-46h46v46zm-46 45v-28h46v28zm67-191v-11h-1v-42h-3v42h-19v11h19v32h3v-32zm-61 0v-11h-5v11zm96 0v-11h-4v-43h-13v-2h-2v-37h-10v-2h-4v2h-27v37h-31v-37-2h-5v2h-43v37h-2v3h-1v-3h-8v-62-11-29h-5v-52h-8v-17h-15v-38-52h-15v-7h-89v7h-22v16h-175v36h-15v55h-25v1h-37v10h-2v41h-4v105h-18v21h18v21h-18v13h18v17h-18-86v13h86v5h-86v1h86v42h18v11h4v9h2v19h-2v25h2v2h14v-2h23v2h40v2h82v43h-122v3h122 75v96h-75v14h75v10h75v-10h23v-14h-23v-36h23v-60h34v60h12v-60h15 10v-3h-10v-43h10v-48h11v-37h46v37h5v-37h20v-30h11v30h8v37h22v-17h1v-20h12v-31h13v-32zm-13 0v-11h-2v-43h-10v-2h-4v2h-19v1h-8v42h-31v-21-21-3h-5v3h-43v21h43v21h-43v11h43v19h-45v13h45v1h5v-1h20v-13h-20v-19h31v32h8v1h19v30h3v-30h1v-1h10v-32zm-72 148v-2h-5v2zm5 43h-5zm66-191v-11h-3v11zm-38 146v-46h11v46zm-11 45v-28h11v28zm-11 149v-4h11v4zm-11 40v-40h-8v40zm92-380v-54-2h-4v-133h-13v-12h-13v-9h-12v-45h-31v45h-31v-55-59h-59v-5h33v-1h-33v-16h-5v-10h5v-12h-5v-22h-8v-29h8v-5h-8-119-107v5h107v29h-386v26h-38v27h40v20h-4v11h-14v148h-22v105h-7v55h18v17h-18v13h18v5h-18v1h18v42h3v20h14v94h8 41v62h26v-62h23v62h18v48h4v10h31v22h8v61h122v21h75v2h98v-2h34v2h99v-84h20v-22h11v22h43v-22h23v-123h-6v-27h6v-1h3v-17h-3v-46h3v-17h1v-51h3v-32zm-43 148v-2h-22v2zm22 43h-30zm66 189v-40h-66v40zm41-380v-11h-10v-43h-4v1h-19v42h-8v11h8v32h19v1h3v-1h1v-32zm38 0v-11h-3v-43h-6v-2h-4v-39h-13v-34h-12v-60h-4v60h-27v34h-31v-34-72h-48v72h-3v-29h-8v-52-17h-5v-38h-8v-59h-15v-6h-15v-11h-89v11h-22v6h-175v7h-15v16h-25v36h-43v66h-18v41h-54v-41h-32v41h-4v105h-8v7h8v14h4v21h-4v13h4v17h-4-8v13h8v5h-8v1h8v42h4v11h86v9h18v19h-18v25h18v50h4 16 15 8v110h3v10h119v22h75v11h75v-11h23v-22h34v22h48v-22h30v-24h-30v-96h51v-3h20-20v-28h20v-15h11v15h8v1h22v-1h13v-17h-12v-46h12v-17h17v-51h6v-32z"; + + verifyPoly("disjunct", disjunct, aDisjunctRanges); + verifyPoly("equal", equal, aEqualRanges); + verifyPoly("intersectionN", intersectionN, aIntersectionN); + verifyPoly("intersectionE", intersectionE, aIntersectionE); + verifyPoly("intersectionS", intersectionS, aIntersectionS); + verifyPoly("intersectionW", intersectionW, aIntersectionW); + verifyPoly("intersectionNE", intersectionNE, aIntersectionNE); + verifyPoly("intersectionSE", intersectionSE, aIntersectionSE); + verifyPoly("intersectionSW", intersectionSW, aIntersectionSW); + verifyPoly("intersectionNW", intersectionNW, aIntersectionNW); + verifyPoly("ringIntersection", ringIntersection, aRingIntersection); + verifyPoly("ringIntersection2", ringIntersection2, aRingIntersection2); + verifyPoly("ringIntersectExtraStrip", ringIntersectExtraStrip, aRingIntersectExtraStrip); + verifyPoly("complexIntersections", complexIntersections, aComplexIntersections); + verifyPoly("randomIntersections", randomIntersections, aRandomIntersections); + } + + void dumpSvg(const char* pName, + const ::basegfx::B2DPolyPolygon& rPoly) + { + (void)pName; (void)rPoly; +#if defined(VERBOSE) + fprintf(stderr, "%s - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD(rPoly), + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + } + + void getPolyPolygon() + { + dumpSvg("disjunct",aDisjunctRanges.solveCrossovers()); + dumpSvg("equal",aEqualRanges.solveCrossovers()); + dumpSvg("intersectionN",aIntersectionN.solveCrossovers()); + dumpSvg("intersectionE",aIntersectionE.solveCrossovers()); + dumpSvg("intersectionS",aIntersectionS.solveCrossovers()); + dumpSvg("intersectionW",aIntersectionW.solveCrossovers()); + dumpSvg("intersectionNE",aIntersectionNE.solveCrossovers()); + dumpSvg("intersectionSE",aIntersectionSE.solveCrossovers()); + dumpSvg("intersectionSW",aIntersectionSW.solveCrossovers()); + dumpSvg("intersectionNW",aIntersectionNW.solveCrossovers()); + dumpSvg("ringIntersection",aRingIntersection.solveCrossovers()); + dumpSvg("ringIntersection2",aRingIntersection2.solveCrossovers()); + dumpSvg("aRingIntersectExtraStrip",aRingIntersectExtraStrip.solveCrossovers()); + dumpSvg("complexIntersections",aComplexIntersections.solveCrossovers()); + dumpSvg("randomIntersections",aRandomIntersections.solveCrossovers()); + + CPPUNIT_ASSERT_MESSAGE("getPolyPolygon", true ); + } + + void validatePoly( const char* pName, const B2DPolyRange& rRange ) + { + B2DPolyPolygon genericClip; + const sal_uInt32 nCount=rRange.count(); + for( sal_uInt32 i=0; i<nCount; ++i ) + { + B2DPolygon aRect=tools::createPolygonFromRect( + rRange.getElement(i).head); + if( rRange.getElement(i).tail.head == ORIENTATION_NEGATIVE ) + aRect.flip(); + + genericClip.append(aRect); + } + +#if defined(VERBOSE) + fprintf(stderr, "%s input - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD( + genericClip), + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + const B2DPolyPolygon boxClipResult=rRange.solveCrossovers(); + const rtl::OUString boxClipSvg( + basegfx::tools::exportToSvgD( + normalizePoly( + boxClipResult))); +#if defined(VERBOSE) + fprintf(stderr, "%s boxclipper - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + boxClipSvg, + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + genericClip = tools::solveCrossovers(genericClip); + const rtl::OUString genericClipSvg( + basegfx::tools::exportToSvgD( + normalizePoly( + genericClip))); +#if defined(VERBOSE) + fprintf(stderr, "%s genclipper - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + genericClipSvg, + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + CPPUNIT_ASSERT_MESSAGE(pName, + genericClipSvg == boxClipSvg); + } + + void validatePoly() + { + validatePoly("disjunct", aDisjunctRanges); + validatePoly("equal", aEqualRanges); + validatePoly("intersectionN", aIntersectionN); + validatePoly("intersectionE", aIntersectionE); + validatePoly("intersectionS", aIntersectionS); + validatePoly("intersectionW", aIntersectionW); + validatePoly("intersectionNE", aIntersectionNE); + validatePoly("intersectionSE", aIntersectionSE); + validatePoly("intersectionSW", aIntersectionSW); + validatePoly("intersectionNW", aIntersectionNW); + // subtle differences on Solaris Intel, comparison not smart enough + // (due to floating point inaccuracies) + //validatePoly("ringIntersection", aRingIntersection); + //validatePoly("ringIntersection2", aRingIntersection2); + //validatePoly("ringIntersectExtraStrip", aRingIntersectExtraStrip); + // generic clipper buggy here, likely + //validatePoly("complexIntersections", aComplexIntersections); + //validatePoly("randomIntersections", aRandomIntersections); + } + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE(boxclipper); + CPPUNIT_TEST(validatePoly); + CPPUNIT_TEST(verifyPoly); + CPPUNIT_TEST(getPolyPolygon); + CPPUNIT_TEST_SUITE_END(); +}; + +// ----------------------------------------------------------------------------- +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::boxclipper); +} // namespace basegfx2d diff --git a/basegfx/test/clipstate.cxx b/basegfx/test/clipstate.cxx new file mode 100644 index 000000000000..3d9f59979aa7 --- /dev/null +++ b/basegfx/test/clipstate.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +// autogenerated file with codegen.pl + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include <basegfx/tools/b2dclipstate.hxx> +#include <basegfx/range/b2dpolyrange.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/numeric/ftools.hxx> + +#include <boost/bind.hpp> + +using namespace ::basegfx; + + +namespace basegfx2d +{ + +class clipstate : public CppUnit::TestFixture +{ +private: + tools::B2DClipState aUnion1; + tools::B2DClipState aUnion2; + tools::B2DClipState aIntersect; + tools::B2DClipState aXor; + tools::B2DClipState aSubtract; + +public: + void setUp() + { + B2DRange aCenter(100, 100, -100, -100); + B2DRange aNorth(-10, -110, 10, -90); + B2DRange aWest(-110, -10, -90, 10); + B2DRange aSouth(-10, 110, 10, 90); + B2DRange aEast(110, -10, 90, 10); + + aUnion1.unionRange(aCenter); + aUnion1.unionRange(aNorth); + aUnion1.unionRange(aWest); + aUnion1.unionRange(aSouth); + aUnion1.unionRange(aEast); + + aUnion2.makeNull(); + aUnion2.unionRange(aCenter); + aUnion2.unionRange(aNorth); + aUnion2.unionRange(aWest); + aUnion2.unionRange(aSouth); + aUnion2.unionRange(aEast); + + aIntersect.intersectRange(aCenter); + aIntersect.intersectRange(aNorth); + aIntersect.intersectRange(aWest); + aIntersect.intersectRange(aSouth); + aIntersect.intersectRange(aEast); + + aXor.makeNull(); + aXor.xorRange(aCenter); + aXor.xorRange(aNorth); + aXor.xorRange(aWest); + aXor.xorRange(aSouth); + aXor.xorRange(aEast); + + aSubtract.intersectRange(aCenter); + aSubtract.subtractRange(aNorth); + aSubtract.subtractRange(aWest); + aSubtract.subtractRange(aSouth); + aSubtract.subtractRange(aEast); + } + + void tearDown() + {} + + void verifyPoly(const char* sName, const char* sSvg, const tools::B2DClipState& toTest) + { +#if defined(VERBOSE) + fprintf(stderr, "%s - svg:d=\"%s\"\n", + sName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD(toTest.getClipPoly()), + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + B2DPolyPolygon aTmp1; + CPPUNIT_ASSERT_MESSAGE(sName, + tools::importFromSvgD( + aTmp1, + rtl::OUString::createFromAscii(sSvg))); + + const rtl::OUString aSvg= + tools::exportToSvgD(toTest.getClipPoly()); + B2DPolyPolygon aTmp2; + CPPUNIT_ASSERT_MESSAGE(sName, + tools::importFromSvgD( + aTmp2, + aSvg)); + + CPPUNIT_ASSERT_MESSAGE( + sName, + aTmp2 == aTmp1); + } + + void verifySimpleRange() + { + const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z"; + const char* intersectSvg="m-100 10v-20h10v20zm80 90v-10h20v10zm-20-190v-10h20v10zm80 100v-20h10v20z"; + const char* xorSvg="m-100 10h10v-20h-10zm90 110h20v-10h-20zm0-180h20v-10h-20zm100 110h10v-20h-10zm10 20v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z"; + const char* subtractSvg="m-90 10v-20h-10v-90h90v10h20v-10h90v90h-10v20h10v90h-90v-10h-20v10h-90v-90z"; + + CPPUNIT_ASSERT_MESSAGE("cleared clip stays empty under union operation", + aUnion1.isCleared()); + verifyPoly("union", unionSvg, aUnion2); + verifyPoly("intersect", intersectSvg, aIntersect); + verifyPoly("xor", xorSvg, aXor); + verifyPoly("subtract", subtractSvg, aSubtract); + } + + void verifyMixedClips() + { + tools::B2DClipState aMixedClip; + + const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z"; + + B2DPolyPolygon aTmp1; + tools::importFromSvgD( + aTmp1, + rtl::OUString::createFromAscii(unionSvg)); + + aMixedClip.intersectPolyPolygon(aTmp1); + aMixedClip.subtractRange(B2DRange(-20,-150,20,0)); + aMixedClip.subtractRange(B2DRange(-150,-20,0,20)); + aMixedClip.xorRange(B2DRange(-150,-150,150,150)); + + const char* mixedClipSvg="m0 0v20h-100v80h90v10h20v-10h90v-90h10v-20h-10v-90h-80v100zm-40-20v-80h-80v80zm-50 170v-300h300v300z"; + verifyPoly("mixed clip", mixedClipSvg, aMixedClip); + } + + CPPUNIT_TEST_SUITE(clipstate); + CPPUNIT_TEST(verifySimpleRange); + CPPUNIT_TEST(verifyMixedClips); + CPPUNIT_TEST_SUITE_END(); +}; + +// ----------------------------------------------------------------------------- +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::clipstate); +} // namespace basegfx2d diff --git a/basegfx/test/export.map b/basegfx/test/export.map index 709047ae63e5..3308588ef6f8 100644 --- a/basegfx/test/export.map +++ b/basegfx/test/export.map @@ -25,9 +25,9 @@ # #************************************************************************* -UDK_3.1 { +UDK_3_0_0 { global: - registerAllTestFunction; + cppunitTestPlugIn; local: *; diff --git a/basegfx/test/genericclipper.cxx b/basegfx/test/genericclipper.cxx new file mode 100644 index 000000000000..84230a084493 --- /dev/null +++ b/basegfx/test/genericclipper.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_basegfx.hxx" +// autogenerated file with codegen.pl + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/curve/b2dcubicbezier.hxx> +#include <basegfx/curve/b2dbeziertools.hxx> +#include <basegfx/range/b2dpolyrange.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygoncutter.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/numeric/ftools.hxx> + +#include <boost/bind.hpp> + +using namespace ::basegfx; + + +namespace basegfx2d +{ + +class genericclipper : public CppUnit::TestFixture +{ +private: + B2DPolygon aSelfIntersecting; + B2DPolygon aShiftedRectangle; + +public: + // initialise your test code values here. + void setUp() + { + aSelfIntersecting.append(B2DPoint(0, 0)); + aSelfIntersecting.append(B2DPoint(0, 100)); + aSelfIntersecting.append(B2DPoint(75, 100)); + aSelfIntersecting.append(B2DPoint(75, 50)); + aSelfIntersecting.append(B2DPoint(25, 50)); + aSelfIntersecting.append(B2DPoint(25, 150)); + aSelfIntersecting.append(B2DPoint(100,150)); + aSelfIntersecting.append(B2DPoint(100,0)); + aSelfIntersecting.setClosed(true); + + aShiftedRectangle = tools::createPolygonFromRect( + B2DRange(0,90,20,150)); + } + + void tearDown() + {} + + void validate(const char* pName, + const char* pValidSvgD, + B2DPolyPolygon (*pFunc)(const B2DPolyPolygon&, const B2DPolyPolygon&)) + { + const B2DPolyPolygon aSelfIntersect( + tools::prepareForPolygonOperation(aSelfIntersecting)); + const B2DPolyPolygon aRect( + tools::prepareForPolygonOperation(aShiftedRectangle)); +#if defined(VERBOSE) + fprintf(stderr, "%s input LHS - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD( + aSelfIntersect), + RTL_TEXTENCODING_UTF8).getStr() ); + fprintf(stderr, "%s input RHS - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD( + aRect), + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + const B2DPolyPolygon aRes= + pFunc(aSelfIntersect, aRect); + +#if defined(VERBOSE) + fprintf(stderr, "%s - svg:d=\"%s\"\n", + pName, rtl::OUStringToOString( + basegfx::tools::exportToSvgD(aRes), + RTL_TEXTENCODING_UTF8).getStr() ); +#endif + + rtl::OUString aValid=rtl::OUString::createFromAscii(pValidSvgD); + + CPPUNIT_ASSERT_MESSAGE(pName, + basegfx::tools::exportToSvgD(aRes) == aValid); + } + + void validateOr() + { + const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm75 10v-50h-50v50z"; + validate("validateOr", pValid, &tools::solvePolygonOperationOr); + } + + void validateXor() + { + const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm0 10h20v-10h-20zm75 10v-50h-50v50z"; + validate("validateXor", pValid, &tools::solvePolygonOperationXor); + } + + void validateAnd() + { + const char* pValid="m0 100v-10h20v10z"; + validate("validateAnd", pValid, &tools::solvePolygonOperationAnd); + } + + void validateDiff() + { + const char* pValid="m0 90v-90h100v150h-75v-50h-5v-10zm55 10v-50h-50v50z"; + validate("validateDiff", pValid, &tools::solvePolygonOperationDiff); + } + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE(genericclipper); + CPPUNIT_TEST(validateOr); + CPPUNIT_TEST(validateXor); + CPPUNIT_TEST(validateAnd); + CPPUNIT_TEST(validateDiff); + CPPUNIT_TEST_SUITE_END(); +}; + +// ----------------------------------------------------------------------------- +CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::genericclipper); +} // namespace basegfx2d diff --git a/basegfx/test/makefile.mk b/basegfx/test/makefile.mk index dd92dfedaa0c..2c0f30c291a9 100644 --- a/basegfx/test/makefile.mk +++ b/basegfx/test/makefile.mk @@ -36,39 +36,33 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +CFLAGSCXX += $(CPPUNIT_CFLAGS) + # --- Common ---------------------------------------------------------- SHL1OBJS= \ - $(SLO)$/basegfx1d.obj \ - $(SLO)$/basegfx2d.obj \ - $(SLO)$/basegfx3d.obj \ - $(SLO)$/testtools.obj - -# linking statically against basegfx parts -SHL1LIBS=\ - $(SLB)$/curve.lib \ - $(SLB)$/matrix.lib \ - $(SLB)$/numeric.lib \ - $(SLB)$/point.lib \ - $(SLB)$/polygon.lib \ - $(SLB)$/range.lib \ - $(SLB)$/tuple.lib \ - $(SLB)$/tools.lib \ - $(SLB)$/color.lib \ - $(SLB)$/vector.lib + $(SLO)$/basegfx1d.obj \ + $(SLO)$/basegfx2d.obj \ + $(SLO)$/basegfx3d.obj \ + $(SLO)$/boxclipper.obj \ + $(SLO)$/basegfxtools.obj \ + $(SLO)$/clipstate.obj \ + $(SLO)$/genericclipper.obj \ + $(SLO)$/testtools.obj SHL1TARGET= basegfx_tests SHL1STDLIBS= \ + $(BASEGFXLIB) \ $(SALLIB) \ $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(TESTSHL2LIB) \ + $(CPPULIB) \ $(CPPUNITLIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) SHL1VERSIONMAP = export.map +SHL1RPATH = NONE # END ------------------------------------------------------------------ @@ -81,13 +75,6 @@ SLOFILES=$(SHL1OBJS) .INCLUDE : target.mk .INCLUDE : _cppunit.mk -# --- Enable testshl2 execution in normal build ------------------------ - -$(MISC)$/unittest_succeeded : $(SHL1TARGETN) - @echo ---------------------------------------------------------- - @echo - start unit test on library $(SHL1TARGETN) - @echo ---------------------------------------------------------- - $(TESTSHL2) -sf $(mktmp ) -forward $(BIN)$/ $(SHL1TARGETN) - $(TOUCH) $@ - -ALLTAR : $(MISC)$/unittest_succeeded +.IF "$(verbose)"!="" || "$(VERBOSE)"!="" +CDEFS+= -DVERBOSE +.ENDIF diff --git a/basegfx/test/tests.txt b/basegfx/test/tests.txt deleted file mode 100644 index fc2d33ab51d5..000000000000 --- a/basegfx/test/tests.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Jobfile -basegfx1d.b1drange -basegfx2d.b2dcubicbezier -basegfx2d.b2dhommatrix -basegfx2d.b2dhompoint -basegfx2d.b2dpoint -basegfx2d.b2dpolygon -basegfx2d.b2dpolygontools -basegfx2d.b2dpolypolygon -basegfx2d.b2dquadraticbezier -basegfx2d.b2drange -basegfx2d.b2dtuple -basegfx2d.b2dvector -basegfx3d.b3dhommatrix -basegfx3d.b3dhompoint -basegfx3d.b3dhompoint -basegfx3d.b3dpoint -basegfx3d.b3drange -basegfx3d.b3dtuple -basegfx3d.b3dvector diff --git a/canvas/inc/canvas/base/graphicdevicebase.hxx b/canvas/inc/canvas/base/graphicdevicebase.hxx index 20de68094028..6750c28e22c8 100644 --- a/canvas/inc/canvas/base/graphicdevicebase.hxx +++ b/canvas/inc/canvas/base/graphicdevicebase.hxx @@ -30,11 +30,11 @@ #include <rtl/ref.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XColorSpace.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <canvas/parametricpolypolygon.hxx> #include <canvas/propertysethelper.hxx> @@ -47,8 +47,7 @@ namespace canvas /** Helper template base class for XGraphicDevice implementations. This base class provides partial implementations of the - XGraphicDevice-related interface, such as - XParametricPolyPolygon2DFactory and XColorSpace. + XGraphicDevice-related interface, such as XColorSpace. This template basically interposes itself between the full interface you implement (i.e. not restricted to XGraphicDevice @@ -246,7 +245,7 @@ namespace canvas return maDeviceHelper.createVolatileAlphaBitmap( this, size ); } - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2DFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException) + virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException) { return this; } @@ -265,79 +264,26 @@ namespace canvas return maDeviceHelper.enterFullScreenMode( bEnter ); } - // XParametricPolyPolygon2DFactory - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createLinearHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) + // XMultiServiceFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( - ParametricPolyPolygon::createLinearHorizontalGradient( this, - colors, - stops ) ); + ParametricPolyPolygon::create(this, + aServiceSpecifier, + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >())); } - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createAxialHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) { return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( - ParametricPolyPolygon::createAxialHorizontalGradient( this, - colors, - stops ) ); + ParametricPolyPolygon::create(this, + aServiceSpecifier, + Arguments)); } - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createEllipticalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException) { - return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( - ParametricPolyPolygon::createEllipticalGradient( this, - colors, - stops, - boundRect ) ); - } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createRectangularGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( - ParametricPolyPolygon::createRectangularGradient( this, - colors, - stops, - boundRect ) ); - } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createVerticalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftColor*/, - const ::com::sun::star::uno::Sequence< double >& /*rightColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - // TODO(F1): hatch factory NYI - return ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XParametricPolyPolygon2D >(); - } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createOrthogonalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftTopColor*/, - const ::com::sun::star::uno::Sequence< double >& /*rightBottomColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - // TODO(F1): hatch factory NYI - return ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XParametricPolyPolygon2D >(); - } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createThreeCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/, - const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - // TODO(F1): hatch factory NYI - return ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XParametricPolyPolygon2D >(); - } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createFourCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/, - const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - // TODO(F1): hatch factory NYI - return ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XParametricPolyPolygon2D >(); + return ParametricPolyPolygon::getAvailableServiceNames(); } diff --git a/canvas/inc/canvas/canvastools.hxx b/canvas/inc/canvas/canvastools.hxx index de4785346909..6c9fdfee484a 100644..100755 --- a/canvas/inc/canvas/canvastools.hxx +++ b/canvas/inc/canvas/canvastools.hxx @@ -66,6 +66,7 @@ namespace com { namespace sun { namespace star { namespace rendering struct ViewState; struct IntegerBitmapLayout; class XCanvas; + struct Texture; class XIntegerBitmapColorSpace; class XPolyPolygon2D; @@ -414,28 +415,6 @@ namespace canvas */ ::basegfx::B2IRange spritePixelAreaFromB2DRange( const ::basegfx::B2DRange& rRange ); - /** This method clamps the given value to the specified range - - @param val - The value to clamp - - @param minVal - The minimal value val is allowed to attain - - @param maxVal - The maximal value val is allowed to attain - - @return the clamped value - */ - template< typename T > T clamp( T val, - T minVal, - T maxVal ) - { - return ::std::max( minVal, - ::std::min( maxVal, - val ) ); - } - /** Retrieve various internal properties of the actual canvas implementation. This method retrieves a bunch of internal, implementation- @@ -518,6 +497,18 @@ namespace canvas */ ::basegfx::B2DPolyPolygon getBoundMarksPolyPolygon( const ::basegfx::B2DRange& rRange ); + /** Calculate number of gradient "strips" to generate (takes + into account device resolution) + + @param nColorSteps + Maximal integer difference between all color stops, needed + for smooth gradient color differences + */ + int calcGradientStepCount( ::basegfx::B2DHomMatrix& rTotalTransform, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::rendering::Texture& texture, + int nColorSteps ); /** A very simplistic map for ASCII strings and arbitrary value types. diff --git a/canvas/inc/canvas/parametricpolypolygon.hxx b/canvas/inc/canvas/parametricpolypolygon.hxx index 4bd7e14b0229..aac98a67a713 100644 --- a/canvas/inc/canvas/parametricpolypolygon.hxx +++ b/canvas/inc/canvas/parametricpolypolygon.hxx @@ -30,7 +30,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> +#include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp> #include <cppuhelper/compbase2.hxx> #include <comphelper/broadcasthelper.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -59,7 +59,6 @@ namespace canvas enum GradientType { GRADIENT_LINEAR, - GRADIENT_AXIAL, GRADIENT_ELLIPTICAL, GRADIENT_RECTANGULAR }; @@ -100,24 +99,11 @@ namespace canvas const GradientType meType; }; - static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XGraphicDevice >& rDevice, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, - const ::com::sun::star::uno::Sequence< double >& stops ); - static ParametricPolyPolygon* createAxialHorizontalGradient( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XGraphicDevice >& rDevice, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, - const ::com::sun::star::uno::Sequence< double >& stops ); - static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XGraphicDevice >& rDevice, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, - const ::com::sun::star::uno::Sequence< double >& stops, - const ::com::sun::star::geometry::RealRectangle2D& boundRect ); - static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XGraphicDevice >& rDevice, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, - const ::com::sun::star::uno::Sequence< double >& stops, - const ::com::sun::star::geometry::RealRectangle2D& boundRect ); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getAvailableServiceNames(); + static ParametricPolyPolygon* create( + const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, + const ::rtl::OUString& rServiceName, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs ); /// Dispose all internal references virtual void SAL_CALL disposing(); @@ -140,6 +126,20 @@ namespace canvas ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves. private: + static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& rDevice, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, + const ::com::sun::star::uno::Sequence< double >& stops ); + static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& rDevice, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, + const ::com::sun::star::uno::Sequence< double >& stops, + double fAspect ); + static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& rDevice, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, + const ::com::sun::star::uno::Sequence< double >& stops, + double fAspect ); /// Private, because objects can only be created from the static factories ParametricPolyPolygon( const ::com::sun::star::uno::Reference< diff --git a/canvas/prj/build.lst b/canvas/prj/build.lst index 28e8524a9b38..cacbdb5bb894 100644 --- a/canvas/prj/build.lst +++ b/canvas/prj/build.lst @@ -7,5 +7,4 @@ cv canvas\source\simplecanvas nmake - all cv_simplecanvas cv_tools cv_inc cv canvas\source\cairo nmake - all cv_cairo cv_tools cv_inc NULL cv canvas\source\directx nmake - w cv_directx cv_tools cv_inc NULL cv canvas\source\null nmake - all cv_null cv_tools cv_inc NULL -cv canvas\source\java nmake - all cv_java cv_inc NULL cv canvas\source\factory nmake - all cv_factory cv_inc NULL diff --git a/canvas/source/cairo/cairo_canvas.hxx b/canvas/source/cairo/cairo_canvas.hxx index 26e2904cf71f..bbcb89c54c7d 100644 --- a/canvas/source/cairo/cairo_canvas.hxx +++ b/canvas/source/cairo/cairo_canvas.hxx @@ -41,7 +41,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase7.hxx> #include <comphelper/uno3.hxx> @@ -65,7 +64,7 @@ namespace cairocanvas typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::util::XUpdatable, ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base; diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 17d187d46b27..eec6a09fb215 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -53,6 +53,8 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/tools/canvastools.hxx> +#include <basegfx/tools/keystoplerp.hxx> +#include <basegfx/tools/lerp.hxx> #include <comphelper/sequence.hxx> #include <cppuhelper/compbase1.hxx> @@ -70,6 +72,7 @@ #include "cairo_canvashelper.hxx" #include "cairo_canvasbitmap.hxx" +#include <boost/tuple/tuple.hpp> #include <algorithm> using namespace ::cairo; @@ -119,9 +122,29 @@ namespace cairocanvas mpCairo = pSurface->getCairo(); } + static void setColor( Cairo* pCairo, + const uno::Sequence<double>& rColor ) + { + if( rColor.getLength() > 3 ) + { + const double alpha = rColor[3]; + + cairo_set_source_rgba( pCairo, + alpha*rColor[0], + alpha*rColor[1], + alpha*rColor[2], + alpha ); + } + else if( rColor.getLength() == 3 ) + cairo_set_source_rgb( pCairo, + rColor[0], + rColor[1], + rColor[2] ); + } + void CanvasHelper::useStates( const rendering::ViewState& viewState, const rendering::RenderState& renderState, - bool setColor ) + bool bSetColor ) { Matrix aViewMatrix; Matrix aRenderMatrix; @@ -155,19 +178,8 @@ namespace cairocanvas OSL_TRACE ("render clip END"); } - if( setColor ) { - if( renderState.DeviceColor.getLength() > 3 ) - cairo_set_source_rgba( mpCairo.get(), - renderState.DeviceColor [0], - renderState.DeviceColor [1], - renderState.DeviceColor [2], - renderState.DeviceColor [3] ); - else if (renderState.DeviceColor.getLength() == 3) - cairo_set_source_rgb( mpCairo.get(), - renderState.DeviceColor [0], - renderState.DeviceColor [1], - renderState.DeviceColor [2] ); - } + if( bSetColor ) + setColor(mpCairo.get(),renderState.DeviceColor); cairo_operator_t compositingMode( CAIRO_OPERATOR_OVER ); switch( renderState.CompositeOperation ) @@ -662,11 +674,33 @@ namespace cairocanvas double alpha = rColor[3]; // cairo expects premultiplied alpha cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0]*alpha, rColor[1]*alpha, rColor[2]*alpha, alpha ); - //cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0], rColor[1], rColor[2], alpha ); } } } + static uno::Sequence<double> lerp(const uno::Sequence<double>& rLeft, const uno::Sequence<double>& rRight, double fAlpha) + { + if( rLeft.getLength() == 3 ) + { + uno::Sequence<double> aRes(3); + aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha); + aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha); + aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha); + return aRes; + } + else if( rLeft.getLength() == 4 ) + { + uno::Sequence<double> aRes(4); + aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha); + aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha); + aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha); + aRes[3] = basegfx::tools::lerp(rLeft[3],rRight[3],fAlpha); + return aRes; + } + + return uno::Sequence<double>(); + } + static Pattern* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon& rPolygon ) { Pattern* pPattern = NULL; @@ -675,7 +709,6 @@ namespace cairocanvas // undef macros from vclenum.hxx which conflicts with GradientType enum values #undef GRADIENT_LINEAR -#undef GRADIENT_AXIAL #undef GRADIENT_ELLIPTICAL switch( aValues.meType ) { @@ -688,26 +721,17 @@ namespace cairocanvas addColorStops( pPattern, aValues.maColors, aValues.maStops ); break; - // FIXME: NYI - case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR: - case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL: - x0 = 0; - y0 = 0; - x1 = 1; - y1 = 0; - pPattern = cairo_pattern_create_linear( x0, y0, x1, y1 ); - addColorStops( pPattern, aValues.maColors, aValues.maStops ); - break; - case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL: - cx = 0.5; - cy = 0.5; + cx = 0; + cy = 0; r0 = 0; - r1 = 0.5; + r1 = 1; - pPattern = cairo_pattern_create_radial( cx, cy, r0, cx, cy, r1 ); + pPattern = cairo_pattern_create_radial( cx, cy, r0, cy, cy, r1 ); addColorStops( pPattern, aValues.maColors, aValues.maStops, true ); break; + default: + break; } return pPattern; @@ -716,7 +740,8 @@ namespace cairocanvas static void doOperation( Operation aOperation, Cairo* pCairo, const uno::Sequence< rendering::Texture >* pTextures, - const SurfaceProviderRef& pDevice ) + const SurfaceProviderRef& pDevice, + const basegfx::B2DRange& rBounds ) { switch( aOperation ) { case Fill: @@ -751,7 +776,20 @@ namespace cairocanvas if( aTexture.RepeatModeX == rendering::TexturingMode::REPEAT && aTexture.RepeatModeY == rendering::TexturingMode::REPEAT ) + { cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_REPEAT ); + } + else if ( aTexture.RepeatModeX == rendering::TexturingMode::NONE && + aTexture.RepeatModeY == rendering::TexturingMode::NONE ) + { + cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_NONE ); + } + else if ( aTexture.RepeatModeX == rendering::TexturingMode::CLAMP && + aTexture.RepeatModeY == rendering::TexturingMode::CLAMP ) + { + cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_PAD ); + } + aScaledTextureMatrix.x0 = basegfx::fround( aScaledTextureMatrix.x0 ); aScaledTextureMatrix.y0 = basegfx::fround( aScaledTextureMatrix.y0 ); cairo_pattern_set_matrix( pPattern, &aScaledTextureMatrix ); @@ -787,19 +825,70 @@ namespace cairocanvas cairo_matrix_init( &aTextureMatrix, aTransform.m00, aTransform.m10, aTransform.m01, aTransform.m11, aTransform.m02, aTransform.m12); - Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl ); + if( pPolyImpl->getValues().meType == canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR ) + { + // no general path gradient yet in cairo; emulate then + cairo_save( pCairo ); + cairo_clip( pCairo ); + + // fill bound rect with start color + cairo_rectangle( pCairo, rBounds.getMinX(), rBounds.getMinY(), + rBounds.getWidth(), rBounds.getHeight() ); + setColor(pCairo,pPolyImpl->getValues().maColors[0]); + cairo_fill(pCairo); + + cairo_transform( pCairo, &aTextureMatrix ); + + // longest line in gradient bound rect + const unsigned int nGradientSize( + static_cast<unsigned int>( + ::basegfx::B2DVector(rBounds.getMinimum() - rBounds.getMaximum()).getLength() + 1.0 ) ); + + // typical number for pixel of the same color (strip size) + const unsigned int nStripSize( nGradientSize < 50 ? 2 : 4 ); + + // use at least three steps, and at utmost the number of color + // steps + const unsigned int nStepCount( + ::std::max( + 3U, + ::std::min( + nGradientSize / nStripSize, + 128U )) + 1 ); + + const uno::Sequence<double>* pColors=&pPolyImpl->getValues().maColors[0]; + basegfx::tools::KeyStopLerp aLerper(pPolyImpl->getValues().maStops); + for( unsigned int i=1; i<nStepCount; ++i ) + { + const double fT( i/double(nStepCount) ); - if( pPattern ) { - OSL_TRACE( "filling with pattern" ); + std::ptrdiff_t nIndex; + double fAlpha; + boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT); - cairo_save( pCairo ); + setColor(pCairo, lerp(pColors[nIndex], pColors[nIndex+1], fAlpha)); + cairo_rectangle( pCairo, -1+fT, -1+fT, 2-2*fT, 2-2*fT ); + cairo_fill(pCairo); + } - cairo_transform( pCairo, &aTextureMatrix ); - cairo_set_source( pCairo, pPattern ); - cairo_fill( pCairo ); cairo_restore( pCairo ); + } + else + { + Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl ); + + if( pPattern ) { + OSL_TRACE( "filling with pattern" ); - cairo_pattern_destroy( pPattern ); + cairo_save( pCairo ); + + cairo_transform( pCairo, &aTextureMatrix ); + cairo_set_source( pCairo, pPattern ); + cairo_fill( pCairo ); + cairo_restore( pCairo ); + + cairo_pattern_destroy( pPattern ); + } } } } @@ -932,7 +1021,7 @@ namespace cairocanvas if( aOperation == Fill && pTextures ) { cairo_set_matrix( pCairo, &aOrigMatrix ); - doOperation( aOperation, pCairo, pTextures, pDevice ); + doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() ); cairo_set_matrix( pCairo, &aIdentityMatrix ); } } else { @@ -945,7 +1034,7 @@ namespace cairocanvas } } if( bOpToDo && ( aOperation != Fill || !pTextures ) ) - doOperation( aOperation, pCairo, pTextures, pDevice ); + doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() ); cairo_set_matrix( pCairo, &aOrigMatrix ); @@ -980,11 +1069,11 @@ namespace cairocanvas aEdge.append(aCandidate.getB2DPoint(0)); aEdge.append(basegfx::B2DPoint(0.0, 0.0)); - for(sal_uInt32 a(0); a < nEdgeCount; a++) + for(sal_uInt32 b(0); b < nEdgeCount; b++) { - const sal_uInt32 nNextIndex((a + 1) % nPointCount); + const sal_uInt32 nNextIndex((b + 1) % nPointCount); aEdge.setB2DPoint(1, aCandidate.getB2DPoint(nNextIndex)); - aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a)); + aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(b)); aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex)); doPolyPolygonImplementation( basegfx::B2DPolyPolygon(aEdge), @@ -1209,12 +1298,12 @@ namespace cairocanvas const rendering::ViewState& viewState, const rendering::RenderState& renderState, const geometry::IntegerSize2D& rSize, - bool /*bModulateColors*/, + bool bModulateColors, bool bHasAlpha ) { SurfaceSharedPtr pSurface=pInputSurface; uno::Reference< rendering::XCachedPrimitive > rv = uno::Reference< rendering::XCachedPrimitive >(NULL); - geometry::IntegerSize2D aBitmapSize = rSize; + geometry::IntegerSize2D aBitmapSize = rSize; if( mpCairo ) { cairo_save( mpCairo.get() ); @@ -1236,38 +1325,38 @@ namespace cairocanvas ::rtl::math::approxEqual( aMatrix.y0, 0 ) && basegfx::fround( rSize.Width * aMatrix.xx ) > 8 && basegfx::fround( rSize.Height* aMatrix.yy ) > 8 ) - { - double dWidth, dHeight; - - dWidth = basegfx::fround( rSize.Width * aMatrix.xx ); - dHeight = basegfx::fround( rSize.Height* aMatrix.yy ); - aBitmapSize.Width = static_cast<sal_Int32>( dWidth ); - aBitmapSize.Height = static_cast<sal_Int32>( dHeight ); - - SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface( - ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ), - bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR ); - CairoSharedPtr pCairo = pScaledSurface->getCairo(); - - cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE ); - // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders - cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height ); - cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 ); - cairo_paint( pCairo.get() ); - - pSurface = pScaledSurface; - - aMatrix.xx = aMatrix.yy = 1; - cairo_set_matrix( mpCairo.get(), &aMatrix ); - - rv = uno::Reference< rendering::XCachedPrimitive >( - new CachedBitmap( pSurface, viewState, renderState, - // cast away const, need to - // change refcount (as this is - // ~invisible to client code, - // still logically const) - const_cast< rendering::XCanvas* >(pCanvas)) ); - } + { + double dWidth, dHeight; + + dWidth = basegfx::fround( rSize.Width * aMatrix.xx ); + dHeight = basegfx::fround( rSize.Height* aMatrix.yy ); + aBitmapSize.Width = static_cast<sal_Int32>( dWidth ); + aBitmapSize.Height = static_cast<sal_Int32>( dHeight ); + + SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface( + ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ), + bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR ); + CairoSharedPtr pCairo = pScaledSurface->getCairo(); + + cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE ); + // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders + cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height ); + cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 ); + cairo_paint( pCairo.get() ); + + pSurface = pScaledSurface; + + aMatrix.xx = aMatrix.yy = 1; + cairo_set_matrix( mpCairo.get(), &aMatrix ); + + rv = uno::Reference< rendering::XCachedPrimitive >( + new CachedBitmap( pSurface, viewState, renderState, + // cast away const, need to + // change refcount (as this is + // ~invisible to client code, + // still logically const) + const_cast< rendering::XCanvas* >(pCanvas)) ); + } if( !bHasAlpha && mbHaveAlpha ) { @@ -1308,7 +1397,11 @@ namespace cairocanvas cairo_set_operator( mpCairo.get(), CAIRO_OPERATOR_SOURCE ); cairo_rectangle( mpCairo.get(), 0, 0, aBitmapSize.Width, aBitmapSize.Height ); cairo_clip( mpCairo.get() ); - cairo_paint( mpCairo.get() ); + + if( bModulateColors ) + cairo_paint_with_alpha( mpCairo.get(), renderState.DeviceColor[3] ); + else + cairo_paint( mpCairo.get() ); cairo_restore( mpCairo.get() ); } else OSL_TRACE ("CanvasHelper called after it was disposed"); @@ -1347,15 +1440,35 @@ namespace cairocanvas return rv; } - uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* , - const uno::Reference< rendering::XBitmap >& /*xBitmap*/, - const rendering::ViewState& /*viewState*/, - const rendering::RenderState& /*renderState*/ ) + uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* pCanvas, + const uno::Reference< rendering::XBitmap >& xBitmap, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState ) { - // TODO(F3): Implement modulated bitmap! +#ifdef CAIRO_CANVAS_PERF_TRACE + struct timespec aTimer; + mxDevice->startPerfTrace( &aTimer ); +#endif - // TODO(P1): Provide caching here. - return uno::Reference< rendering::XCachedPrimitive >(NULL); + uno::Reference< rendering::XCachedPrimitive > rv; + unsigned char* data = NULL; + bool bHasAlpha = false; + SurfaceSharedPtr pSurface = surfaceFromXBitmap( xBitmap, mpSurfaceProvider, data, bHasAlpha ); + geometry::IntegerSize2D aSize = xBitmap->getSize(); + + if( pSurface ) { + rv = implDrawBitmapSurface( pCanvas, pSurface, viewState, renderState, aSize, true, bHasAlpha ); + + if( data ) + free( data ); + } else + rv = uno::Reference< rendering::XCachedPrimitive >(NULL); + +#ifdef CAIRO_CANVAS_PERF_TRACE + mxDevice->stopPerfTrace( &aTimer, "drawBitmap" ); +#endif + + return rv; } uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice() @@ -1678,12 +1791,12 @@ namespace cairocanvas rendering::RGBColor* pOut( aRes.getArray() ); for( sal_Size i=0; i<nLen; i+=4 ) { - const sal_Int8 nAlpha(pIn[3]); - if( nAlpha ) + const double fAlpha((sal_uInt8)pIn[3]); + if( fAlpha ) *pOut++ = rendering::RGBColor( - vcl::unotools::toDoubleColor(pIn[2]/nAlpha), - vcl::unotools::toDoubleColor(pIn[1]/nAlpha), - vcl::unotools::toDoubleColor(pIn[0]/nAlpha)); + pIn[2]/fAlpha, + pIn[1]/fAlpha, + pIn[0]/fAlpha); else *pOut++ = rendering::RGBColor(0,0,0); pIn += 4; @@ -1703,13 +1816,13 @@ namespace cairocanvas rendering::ARGBColor* pOut( aRes.getArray() ); for( sal_Size i=0; i<nLen; i+=4 ) { - const sal_Int8 nAlpha(pIn[3]); - if( nAlpha ) + const double fAlpha((sal_uInt8)pIn[3]); + if( fAlpha ) *pOut++ = rendering::ARGBColor( - vcl::unotools::toDoubleColor(nAlpha), - vcl::unotools::toDoubleColor(pIn[2]/nAlpha), - vcl::unotools::toDoubleColor(pIn[1]/nAlpha), - vcl::unotools::toDoubleColor(pIn[0]/nAlpha)); + fAlpha/255.0, + pIn[2]/fAlpha, + pIn[1]/fAlpha, + pIn[0]/fAlpha); else *pOut++ = rendering::ARGBColor(0,0,0,0); pIn += 4; diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx index 0c942cac1ed3..fcc0ae76839b 100644 --- a/canvas/source/cairo/cairo_spritecanvas.hxx +++ b/canvas/source/cairo/cairo_spritecanvas.hxx @@ -39,7 +39,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase9.hxx> #include <comphelper/uno3.hxx> @@ -63,7 +62,7 @@ namespace cairocanvas typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::rendering::XBufferController, ::com::sun::star::awt::XWindowListener, ::com::sun::star::util::XUpdatable, diff --git a/canvas/source/cairo/exports.map b/canvas/source/cairo/exports.map deleted file mode 100644 index 4101b0d761a9..000000000000 --- a/canvas/source/cairo/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -CAN_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/canvas/source/cairo/makefile.mk b/canvas/source/cairo/makefile.mk index 2c568a4efdbd..b0ff10fe96b0 100644 --- a/canvas/source/cairo/makefile.mk +++ b/canvas/source/cairo/makefile.mk @@ -87,7 +87,7 @@ SHL1STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELP .IF "$(SYSTEM_CAIRO)" == "YES" SHL1STDLIBS+= $(CAIRO_LIBS) .ELSE -SHL1STDLIBS+= -lcairo +SHL1STDLIBS+= -lcairo -lpixman-1 .ENDIF .IF "$(GUIBASE)"=="aqua" @@ -98,7 +98,7 @@ CFLAGSCXX+=$(OBJCXXFLAGS) # Xlib SLOFILES+= $(SLO)$/cairo_xlib_cairo.obj -SHL1STDLIBS+= -lfontconfig -lX11 -lXrender -lpixman-1 $(FREETYPE_LIBS) +SHL1STDLIBS+= -lfontconfig -lX11 -lXrender $(FREETYPE_LIBS) CFLAGS+=$(FREETYPE_CFLAGS) .ENDIF # "$(GUIBASE)"=="aqua" @@ -121,7 +121,7 @@ SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp diff --git a/canvas/source/directx/dx_5rm.cxx b/canvas/source/directx/dx_5rm.cxx index bf3045e52678..642ef7bd7db6 100755 --- a/canvas/source/directx/dx_5rm.cxx +++ b/canvas/source/directx/dx_5rm.cxx @@ -1005,7 +1005,7 @@ namespace dxcanvas break; default: - ENSURE_OR_RETURN(false, + ENSURE_OR_RETURN_FALSE(false, "DXSurface::update(): Unknown/unimplemented buffer format" ); break; } diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx index 849ac3713885..a0f485befa12 100755 --- a/canvas/source/directx/dx_9rm.cxx +++ b/canvas/source/directx/dx_9rm.cxx @@ -541,7 +541,7 @@ namespace dxcanvas break; default: - ENSURE_OR_RETURN(false, + ENSURE_OR_RETURN_FALSE(false, "DXSurface::update(): Unknown/unimplemented buffer format" ); break; } diff --git a/canvas/source/directx/dx_canvas.hxx b/canvas/source/directx/dx_canvas.hxx index aca9873387dc..be15b875c4b6 100644 --- a/canvas/source/directx/dx_canvas.hxx +++ b/canvas/source/directx/dx_canvas.hxx @@ -38,7 +38,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase7.hxx> #include <cppuhelper/compbase6.hxx> @@ -59,7 +58,7 @@ namespace dxcanvas { typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::rendering::XCanvas, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::util::XUpdatable, ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceName > GraphicDeviceBase1_Base; @@ -116,7 +115,7 @@ namespace dxcanvas typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::util::XUpdatable, ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceName > GraphicDeviceBase2_Base; diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx index 8aa21853db1a..60d62dad338a 100755 --- a/canvas/source/directx/dx_canvashelper_texturefill.cxx +++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx @@ -38,7 +38,10 @@ #include <basegfx/point/b2dpoint.hxx> #include <basegfx/range/b2drectangle.hxx> #include <basegfx/numeric/ftools.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/tools/tools.hxx> +#include <basegfx/tools/lerp.hxx> +#include <basegfx/tools/keystoplerp.hxx> #include <basegfx/tools/canvastools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> @@ -49,6 +52,8 @@ #include "dx_impltools.hxx" #include <boost/scoped_ptr.hpp> +#include <boost/bind.hpp> +#include <boost/tuple/tuple.hpp> using namespace ::com::sun::star; @@ -59,26 +64,31 @@ namespace dxcanvas { typedef ::boost::shared_ptr< Gdiplus::PathGradientBrush > PathGradientBrushSharedPtr; - bool fillLinearGradient( GraphicsSharedPtr& rGraphics, - const Gdiplus::Color& rColor1, - const Gdiplus::Color& rColor2, - const GraphicsPathSharedPtr& rFillPath, - const rendering::Texture& texture ) + bool fillLinearGradient( GraphicsSharedPtr& rGraphics, + const ::canvas::ParametricPolyPolygon::Values& /*rValues*/, + const std::vector< Gdiplus::Color >& rColors, + const std::vector< Gdiplus::REAL >& rStops, + const GraphicsPathSharedPtr& rFillPath, + const rendering::Texture& texture ) { - // setup a linear gradient with two colors - // --------------------------------------- + // setup a linear gradient with given colors + // ----------------------------------------- Gdiplus::LinearGradientBrush aBrush( Gdiplus::PointF(0.0f, 0.5f), Gdiplus::PointF(1.0f, 0.5f), - rColor1, - rColor2 ); + rColors[0], + rColors[1] ); + + aBrush.SetInterpolationColors(&rColors[0], + &rStops[0], + rColors.size()); // render background color, as LinearGradientBrush does not // properly support the WrapModeClamp repeat mode - Gdiplus::SolidBrush aBackgroundBrush( rColor1 ); + Gdiplus::SolidBrush aBackgroundBrush( rColors[0] ); rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() ); // TODO(F2): This does not yet support other repeat modes @@ -152,7 +162,7 @@ namespace dxcanvas return false; } - Gdiplus::SolidBrush aBackgroundBrush2( rColor2 ); + Gdiplus::SolidBrush aBackgroundBrush2( rColors.back() ); rGraphics->FillPath( &aBackgroundBrush2, &aSolidFillPath ); // generate clip polygon from the extended parallelogram @@ -188,167 +198,33 @@ namespace dxcanvas return true; } - bool fillAxialGradient( GraphicsSharedPtr& rGraphics, - const Gdiplus::Color& rColor1, - const Gdiplus::Color& rColor2, - const GraphicsPathSharedPtr& rFillPath, - const rendering::Texture& texture ) + int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 ) { - // setup a linear gradient with three colors - // ----------------------------------------- - - Gdiplus::LinearGradientBrush aBrush( - Gdiplus::PointF(0.0f, - 0.5f), - Gdiplus::PointF(1.0f, - 0.5f), - rColor1, - rColor1 ); - - Gdiplus::Color aColors[] = - { - rColor1, // at 0.0 - rColor2, // at 0.5 - rColor1 // at 1.0 - }; - - Gdiplus::REAL aPositions[] = - { - 0.0, - 0.5, - 1.0 - }; - - if( Gdiplus::Ok != aBrush.SetInterpolationColors( aColors, - aPositions, - sizeof( aPositions ) / sizeof(Gdiplus::REAL) ) ) - { - return false; - } - - // render background color, as LinearGradientBrush does not - // properly support the WrapModeClamp repeat mode - Gdiplus::SolidBrush aBackgroundBrush( rColor1 ); - rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() ); - - // TODO(F2): This does not yet support other repeat modes - // except clamp, and probably also no multi-texturing - - // calculate parallelogram of gradient in object space, extend - // top and bottom of it such that they cover the whole fill - // path bound area - ::basegfx::B2DHomMatrix aTextureTransform; - ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform, - texture.AffineTransform ); - - ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 ); - ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 ); - ::basegfx::B2DPoint aRightTop( 1.0, 0.0 ); - ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 ); - - aLeftTop *= aTextureTransform; - aLeftBottom *= aTextureTransform; - aRightTop *= aTextureTransform; - aRightBottom*= aTextureTransform; - - Gdiplus::RectF aBounds; - rFillPath->GetBounds( &aBounds, NULL, NULL ); - - // now, we potentially have to enlarge our gradient area - // atop and below the transformed [0,1]x[0,1] unit rect, - // for the gradient to fill the complete bound rect. - ::basegfx::tools::infiniteLineFromParallelogram( aLeftTop, - aLeftBottom, - aRightTop, - aRightBottom, - tools::b2dRangeFromGdiPlusRectF( aBounds ) ); - - // generate clip polygon from the extended parallelogram - // (exploit the feature that distinct lines in a figure are - // automatically closed by a straight line) - Gdiplus::GraphicsPath aClipPath; - aClipPath.AddLine( static_cast<Gdiplus::REAL>(aLeftTop.getX()), - static_cast<Gdiplus::REAL>(aLeftTop.getY()), - static_cast<Gdiplus::REAL>(aRightTop.getX()), - static_cast<Gdiplus::REAL>(aRightTop.getY()) ); - aClipPath.AddLine( static_cast<Gdiplus::REAL>(aRightBottom.getX()), - static_cast<Gdiplus::REAL>(aRightBottom.getY()), - static_cast<Gdiplus::REAL>(aLeftBottom.getX()), - static_cast<Gdiplus::REAL>(aLeftBottom.getY()) ); - aClipPath.CloseFigure(); - - // limit output to a _single_ strip of the gradient (have to - // clip here, since GDI+ wrapmode clamp does not work here) - if( Gdiplus::Ok != rGraphics->SetClip( rFillPath.get(), - Gdiplus::CombineModeIntersect ) ) - { - return false; - } - if( Gdiplus::Ok != rGraphics->SetClip( &aClipPath, - Gdiplus::CombineModeIntersect ) ) - { - return false; - } - - // now, finally, output the gradient - Gdiplus::Matrix aMatrix; - tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix, - texture.AffineTransform ); - aBrush.SetTransform( &aMatrix ); - - rGraphics->FillRectangle( &aBrush, aBounds ); - - return true; - } - - PathGradientBrushSharedPtr createPathGradientBrush( const GraphicsPathSharedPtr& rGradientPath, - const Gdiplus::Color& rColor1, - const Gdiplus::Color& rColor2 ) - { - PathGradientBrushSharedPtr pGradientBrush( - new Gdiplus::PathGradientBrush( rGradientPath.get() ) ); - - Gdiplus::Color aColors[] = - { - rColor1 - }; - - INT nCount(1); - - pGradientBrush->SetSurroundColors( aColors, - &nCount ); - pGradientBrush->SetCenterColor( rColor2 ); - - return pGradientBrush; + return ::std::max( + labs( rColor1.GetRed() - rColor2.GetRed() ), + ::std::max( + labs( rColor1.GetGreen() - rColor2.GetGreen() ), + labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); } bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues, + const std::vector< Gdiplus::Color >& rColors, + const std::vector< Gdiplus::REAL >& rStops, GraphicsSharedPtr& rGraphics, - const Gdiplus::Color& rColor1, - const Gdiplus::Color& rColor2, const GraphicsPathSharedPtr& rPath, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState, const rendering::Texture& texture ) { - Gdiplus::Matrix aMatrix; - tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix, - texture.AffineTransform ); - // copy original fill path object, might have to change it // below GraphicsPathSharedPtr pFillPath( rPath ); - - // clone original gradient path object, we need to change it - // below - GraphicsPathSharedPtr pGradientPath( - tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) ); - - ENSURE_OR_RETURN( pGradientPath.get(), - "ParametricPolyPolygon::fillPolygonalGradient(): Could not clone path" ); + const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly ); PathGradientBrushSharedPtr pGradientBrush; // fill background uniformly with end color - Gdiplus::SolidBrush aBackgroundBrush( rColor1 ); + Gdiplus::SolidBrush aBackgroundBrush( rColors[0] ); rGraphics->FillPath( &aBackgroundBrush, pFillPath.get() ); // scale focus according to aspect ratio: for wider-than-tall @@ -377,8 +253,6 @@ namespace dxcanvas return false; } - rGraphics->MultiplyTransform( &aMatrix ); - // disable anti-aliasing, if any const Gdiplus::SmoothingMode eOldAAMode( rGraphics->GetSmoothingMode() ); rGraphics->SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed ); @@ -388,105 +262,107 @@ namespace dxcanvas // -------------------------------- // TODO(Q2): Unify step calculations with VCL canvas - const int nColorSteps( - ::std::max( - labs( rColor1.GetRed() - rColor2.GetRed() ), - ::std::max( - labs( rColor1.GetGreen() - rColor2.GetGreen() ), - labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ) ); - - Gdiplus::Matrix aWorldTransformMatrix; - rGraphics->GetTransform( &aWorldTransformMatrix ); - - Gdiplus::RectF aBounds; - pGradientPath->GetBounds( &aBounds, &aWorldTransformMatrix, NULL ); - - // longest line in gradient bound rect - const int nGradientSize( - static_cast<int>( hypot( aBounds.Width, aBounds.Height ) + 1.0 ) ); - - // typical number for pixel of the same color (strip size) - const int nStripSize( 2 ); - - // use at least three steps, and at utmost the number of - // color steps. - const int nStepCount( - ::std::max( - 3, - ::std::min( - nGradientSize / nStripSize, - nColorSteps ) ) + 1 ); - - - Gdiplus::SolidBrush aFillBrush( rColor1 ); - Gdiplus::Matrix aGDIScaleMatrix; - ::basegfx::B2DHomMatrix aScaleMatrix; - - // calc relative size for anisotrophic polygon scaling: - // when the aspect ratio is e.g. 2.0, that denotes a - // gradient which is twice as wide as high. Then, to - // generate a symmetric gradient, the x direction is only - // scaled to 0.5 times the gradient width. Similarly, when - // the aspect ratio is 4.0, the focus has 3/4 the width of - // the overall gradient. - const double nRelativeFocusSize( rValues.mnAspectRatio > 1.0 ? - 1.0 - 1.0/rValues.mnAspectRatio : - 1.0 - rValues.mnAspectRatio ); + int nColorSteps = 0; + for( size_t i=0; i<rColors.size()-1; ++i ) + nColorSteps += numColorSteps(rColors[i],rColors[i+1]); + ::basegfx::B2DHomMatrix aTotalTransform; + const int nStepCount= + ::canvas::tools::calcGradientStepCount(aTotalTransform, + viewState, + renderState, + texture, + nColorSteps); + + ::basegfx::B2DHomMatrix aTextureTransform; + ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform, + texture.AffineTransform ); + // determine overall transformation for inner polygon (might + // have to be prefixed by anisotrophic scaling) + ::basegfx::B2DHomMatrix aInnerPolygonTransformMatrix; + + // For performance reasons, we create a temporary VCL polygon + // here, keep it all the way and only change the vertex values + // in the loop below (as ::Polygon is a pimpl class, creating + // one every loop turn would really stress the mem allocator) + ::basegfx::B2DPolygon aOuterPoly( rGradientPoly ); + ::basegfx::B2DPolygon aInnerPoly; + + // subdivide polygon _before_ rendering, would otherwise have + // to be performed on every loop turn. + if( aOuterPoly.areControlPointsUsed() ) + aOuterPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aOuterPoly); + + aInnerPoly = aOuterPoly; + aOuterPoly.transform(aTextureTransform); + + + // apply scaling (possibly anisotrophic) to inner polygon + // ------------------------------------------------------ + + // scale inner polygon according to aspect ratio: for + // wider-than-tall bounds (nAspectRatio > 1.0), the inner + // polygon, representing the gradient focus, must have + // non-zero width. Specifically, a bound rect twice as wide as + // tall has a focus polygon of half it's width. + const double nAspectRatio( rValues.mnAspectRatio ); + if( nAspectRatio > 1.0 ) + { + // width > height case + aInnerPolygonTransformMatrix.scale( 1.0 - 1.0/nAspectRatio, + 0.0 ); + } + else if( nAspectRatio < 1.0 ) + { + // width < height case + aInnerPolygonTransformMatrix.scale( 0.0, + 1.0 - nAspectRatio ); + } + else + { + // isotrophic case + aInnerPolygonTransformMatrix.scale( 0.0, 0.0 ); + } + + // and finally, add texture transform to it. + aInnerPolygonTransformMatrix *= aTextureTransform; + // apply final matrix to polygon + aInnerPoly.transform( aInnerPolygonTransformMatrix ); + + Gdiplus::GraphicsPath aCurrPath; + Gdiplus::SolidBrush aFillBrush( rColors[0] ); + const sal_uInt32 nNumPoints( aOuterPoly.count() ); + basegfx::tools::KeyStopLerp aLerper(rValues.maStops); for( int i=1; i<nStepCount; ++i ) { - // lerp color. Funnily, the straight-forward integer - // lerp ((nStepCount - i)*val + i*val)/nStepCount gets - // fully botched by MSVC, at least for anything that - // really inlines inlines (i.e. every compile without - // debug=t) - const double nFrac( (double)i/nStepCount ); + std::ptrdiff_t nIndex; + double fAlpha; + const double fT( i/double(nStepCount) ); + boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT); const Gdiplus::Color aFillColor( - static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetRed() + nFrac*rColor2.GetRed() ), - static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetGreen() + nFrac*rColor2.GetGreen() ), - static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetBlue() + nFrac*rColor2.GetBlue() ) ); + static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha) ), + static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha) ), + static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha) ) ); aFillBrush.SetColor( aFillColor ); - - const double nCurrScale( (nStepCount-i)/(double)nStepCount ); - aScaleMatrix = basegfx::tools::createTranslateB2DHomMatrix(-0.5, -0.5); - - // handle anisotrophic polygon scaling - if( rValues.mnAspectRatio < 1.0 ) - { - // height > width case - aScaleMatrix.scale( nCurrScale, - // lerp with nCurrScale - // between 1.0 and - // relative focus height - nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize ); - } - else if( rValues.mnAspectRatio > 1.0 ) - { - // width > height case - aScaleMatrix.scale( nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize, - // lerp with nCurrScale - // between 1.0 and - // relative focus width - nCurrScale ); - } - else + aCurrPath.Reset(); aCurrPath.StartFigure(); + for( unsigned int p=1; p<nNumPoints; ++p ) { - aScaleMatrix.scale( nCurrScale, - nCurrScale ); + const ::basegfx::B2DPoint& rOuterPoint1( aOuterPoly.getB2DPoint(p-1) ); + const ::basegfx::B2DPoint& rInnerPoint1( aInnerPoly.getB2DPoint(p-1) ); + const ::basegfx::B2DPoint& rOuterPoint2( aOuterPoly.getB2DPoint(p) ); + const ::basegfx::B2DPoint& rInnerPoint2( aInnerPoly.getB2DPoint(p) ); + + aCurrPath.AddLine( + Gdiplus::REAL(fT*rInnerPoint1.getX() + (1-fT)*rOuterPoint1.getX()), + Gdiplus::REAL(fT*rInnerPoint1.getY() + (1-fT)*rOuterPoint1.getY()), + Gdiplus::REAL(fT*rInnerPoint2.getX() + (1-fT)*rOuterPoint2.getX()), + Gdiplus::REAL(fT*rInnerPoint2.getY() + (1-fT)*rOuterPoint2.getY())); } + aCurrPath.CloseFigure(); - aScaleMatrix.translate( 0.5, 0.5 ); - - tools::gdiPlusMatrixFromB2DHomMatrix( aGDIScaleMatrix, - aScaleMatrix ); - - GraphicsPathSharedPtr pScaledGradientPath( - tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) ); - pScaledGradientPath->Transform( &aGDIScaleMatrix ); - - rGraphics->FillPath( &aFillBrush, pScaledGradientPath.get() ); + rGraphics->FillPath( &aFillBrush, &aCurrPath ); } // reset to old anti-alias mode @@ -507,18 +383,24 @@ namespace dxcanvas // one sets both, only the translational components of the // texture is respected. + Gdiplus::Matrix aMatrix; + tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix, + texture.AffineTransform ); + GraphicsPathSharedPtr pGradientPath( + tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly )); pGradientPath->Transform( &aMatrix ); - pGradientBrush = createPathGradientBrush( - pGradientPath, - rColor1, - rColor2 ); + pGradientBrush.reset( + new Gdiplus::PathGradientBrush( pGradientPath.get() ) ); + pGradientBrush->SetInterpolationColors( &rColors[0], + &rStops[0], + rStops.size() ); // explicitely setup center point. Since the center of GDI+ // gradients are by default the _centroid_ of the path // (i.e. the weighted sum of edge points), it will not // necessarily coincide with our notion of center. - Gdiplus::PointF aCenterPoint(0.5, 0.5); + Gdiplus::PointF aCenterPoint(0, 0); aMatrix.TransformPoints( &aCenterPoint ); pGradientBrush->SetCenterPoint( aCenterPoint ); @@ -554,38 +436,35 @@ namespace dxcanvas } bool fillGradient( const ::canvas::ParametricPolyPolygon::Values& rValues, - const Gdiplus::Color& rColor1, - const Gdiplus::Color& rColor2, + const std::vector< Gdiplus::Color >& rColors, + const std::vector< Gdiplus::REAL >& rStops, GraphicsSharedPtr& rGraphics, const GraphicsPathSharedPtr& rPath, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState, const rendering::Texture& texture ) { switch( rValues.meType ) { case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR: fillLinearGradient( rGraphics, - rColor1, - rColor2, + rValues, + rColors, + rStops, rPath, texture ); break; - case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL: - fillAxialGradient( rGraphics, - rColor1, - rColor2, - rPath, - texture ); - break; - case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL: // FALLTHROUGH intended case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR: fillPolygonalGradient( rValues, + rColors, + rStops, rGraphics, - rColor1, - rColor2, rPath, + viewState, + renderState, texture ); break; @@ -606,13 +485,13 @@ namespace dxcanvas rTexture.RepeatModeY, "CanvasHelper::fillBitmap(): GDI+ cannot handle differing X/Y repeat mode." ); - const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::CLAMP && - rTexture.RepeatModeY == rendering::TexturingMode::CLAMP ); + const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::NONE && + rTexture.RepeatModeY == rendering::TexturingMode::NONE ); const geometry::IntegerSize2D aBmpSize( xBitmap->getSize() ); ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 && - aBmpSize.Height != 0, - "CanvasHelper::fillBitmap(): zero-sized texture bitmap" ); + aBmpSize.Height != 0, + "CanvasHelper::fillBitmap(): zero-sized texture bitmap" ); // TODO(P3): Detect case that path is rectangle and // bitmap is just scaled into that. Then, we can @@ -624,7 +503,6 @@ namespace dxcanvas tools::bitmapFromXBitmap( xBitmap ) ); TextureBrushSharedPtr pBrush; - if( ::rtl::math::approxEqual( rTexture.Alpha, 1.0 ) ) { @@ -662,9 +540,9 @@ namespace dxcanvas // scale down bitmap to [0,1]x[0,1] rect, as required // from the XCanvas interface. + pBrush->MultiplyTransform( &aTextureTransform ); pBrush->ScaleTransform( static_cast< Gdiplus::REAL >(1.0/aBmpSize.Width), static_cast< Gdiplus::REAL >(1.0/aBmpSize.Height) ); - pBrush->MultiplyTransform( &aTextureTransform ); // TODO(F1): FillRule ENSURE_OR_THROW( @@ -706,17 +584,29 @@ namespace dxcanvas const ::canvas::ParametricPolyPolygon::Values& rValues( pGradient->getValues() ); - // TODO: use all the colors and place them on given positions/stops - const Gdiplus::Color aColor1(tools::sequenceToArgb(rValues.maColors[0])); - const Gdiplus::Color aColor2(tools::sequenceToArgb(rValues.maColors[rValues.maColors.getLength () - 1] )); + OSL_ASSERT(rValues.maColors.getLength() == rValues.maStops.getLength() + && rValues.maColors.getLength() > 1); + + std::vector< Gdiplus::Color > aColors(rValues.maColors.getLength()); + std::transform(&rValues.maColors[0], + &rValues.maColors[0]+rValues.maColors.getLength(), + aColors.begin(), + boost::bind( + (Gdiplus::ARGB (*)( const uno::Sequence< double >& ))( + &tools::sequenceToArgb), + _1)); + std::vector< Gdiplus::REAL > aStops; + comphelper::sequenceToContainer(aStops,rValues.maStops); // TODO(E1): Return value // TODO(F1): FillRule fillGradient( rValues, - aColor1, - aColor2, + aColors, + aStops, pGraphics, tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon ), + viewState, + renderState, textures[0] ); } } diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx index 30bd11a2271a..c298fb9238f9 100755 --- a/canvas/source/directx/dx_impltools.cxx +++ b/canvas/source/directx/dx_impltools.cxx @@ -196,7 +196,7 @@ namespace dxcanvas { const sal_uInt32 nPoints( rPoly.count() ); - if( !nPoints ) + if( nPoints < 2 ) return; rOutput->StartFigure(); diff --git a/canvas/source/directx/dx_spritecanvas.hxx b/canvas/source/directx/dx_spritecanvas.hxx index 5d5e65c23230..b14d79050ccf 100755 --- a/canvas/source/directx/dx_spritecanvas.hxx +++ b/canvas/source/directx/dx_spritecanvas.hxx @@ -39,7 +39,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase9.hxx> #include <comphelper/uno3.hxx> @@ -58,14 +57,14 @@ namespace dxcanvas { typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, - ::com::sun::star::rendering::XIntegerBitmap, - ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, - ::com::sun::star::rendering::XBufferController, - ::com::sun::star::awt::XWindowListener, - ::com::sun::star::util::XUpdatable, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; + ::com::sun::star::rendering::XIntegerBitmap, + ::com::sun::star::rendering::XGraphicDevice, + ::com::sun::star::lang::XMultiServiceFactory, + ::com::sun::star::rendering::XBufferController, + ::com::sun::star::awt::XWindowListener, + ::com::sun::star::util::XUpdatable, + ::com::sun::star::beans::XPropertySet, + ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >, SpriteDeviceHelper, ::osl::MutexGuard, diff --git a/canvas/source/factory/canvasfactory.map b/canvas/source/factory/canvasfactory.map deleted file mode 100644 index 44fb01f37126..000000000000 --- a/canvas/source/factory/canvasfactory.map +++ /dev/null @@ -1,8 +0,0 @@ -CAN_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/canvas/source/factory/makefile.mk b/canvas/source/factory/makefile.mk index 94e3f0d04255..fc6d423192d6 100644 --- a/canvas/source/factory/makefile.mk +++ b/canvas/source/factory/makefile.mk @@ -43,7 +43,7 @@ SHL1STDLIBS = \ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(SALLIB) -SHL1VERSIONMAP = canvasfactory.map +SHL1VERSIONMAP = $(SOLARENV)/src/component.map SHL1DEPN = SHL1IMPLIB = i$(TARGET) diff --git a/canvas/source/java/BackBuffer.java b/canvas/source/java/BackBuffer.java deleted file mode 100644 index 472f6603c33c..000000000000 --- a/canvas/source/java/BackBuffer.java +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Java AWT -import java.awt.*; -import java.awt.image.*; - -public class BackBuffer -{ - private BufferedImage backBuffer; - //private VolatileImage backBuffer; - private Graphics2D backBufferGraphics; - private Graphics2D referenceDevice; - - public BackBuffer( Graphics2D _referenceDevice, - int width, - int height ) - { - referenceDevice = _referenceDevice; - setSize( width, height ); - } - - public Graphics2D getGraphics() - { - return backBufferGraphics; - } - - public void setSize( int width, - int height ) - { - if( backBuffer != null && - width == backBuffer.getWidth() && - height == backBuffer.getHeight() ) - { - return; - } - - if( backBufferGraphics != null ) - backBufferGraphics.dispose(); - - if( backBuffer != null ) - backBuffer.flush(); - - // TODO: Maybe VolatileImage with another BufferedImage as a backup is - // a tad faster here. - backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleImage(width, - height); -// backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleVolatileImage(width, -// height); - - backBufferGraphics = backBuffer.createGraphics(); - CanvasUtils.initGraphics( backBufferGraphics ); - - // clear the buffer to white (to have a defined state here) - backBufferGraphics.setColor( java.awt.Color.white ); - backBufferGraphics.fillRect( 0,0,width,height ); - } - - public void redraw( Graphics2D graph ) - { - if( graph != null && - backBuffer != null ) - { - CanvasUtils.printLog("BackBuffer.redraw(): using buffer of size (" + - backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" ); - - graph.drawImage(backBuffer, 0, 0, null); - - // TODO: this is just twiddled to work. I cannot be sure - // that this volatile backbuffer will survive in the first - // place, nor that it wise to leave it in VRAM. - - // only flush non-volatile images - // CanvasUtils.postRenderImageTreatment( backBuffer ); - } - } - - public java.awt.Image getBackBuffer() - { - return backBuffer; - } - - public void dispose() - { - backBufferGraphics.dispose(); - backBuffer.flush(); - } -} diff --git a/canvas/source/java/BezierPolyPolygon.java b/canvas/source/java/BezierPolyPolygon.java deleted file mode 100644 index ed6c08a21abc..000000000000 --- a/canvas/source/java/BezierPolyPolygon.java +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class BezierPolyPolygon - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XBezierPolyPolygon2D -{ - private java.awt.geom.GeneralPath path; - - //---------------------------------------------------------------------------------- - - public BezierPolyPolygon( RealBezierSegment2D[][] points ) - { - setBezierSegments( points, 0 ); - } - - public java.awt.geom.GeneralPath getJavaPath() - { - return path; - } - - //---------------------------------------------------------------------------------- - - // - // XPolyPolygon implementation - // =========================== - // - public void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon ) - { - } - - public int getNumberOfPolygons( ) - { - return 0; - } - - public int getNumberOfPolygonPoints( int polygon ) - { - return 0; - } - - public FillRule getFillRule( ) - { - if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD ) - return FillRule.EVEN_ODD; - else - return FillRule.NON_ZERO; - } - - public void setFillRule( FillRule fillRule ) - { - if( fillRule == FillRule.EVEN_ODD ) - path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD ); - else - path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO ); - } - - public boolean isClosed( int index ) - { - // TODO - return false; - } - - public void setClosed( int index, boolean closedState ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - // - // XBezierPolyPolygon implementation - // ================================= - // - public RealBezierSegment2D[][] getBezierSegments( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints ) - { - return null; - } - - public void setBezierSegments( RealBezierSegment2D[][] points, int nPolygonIndex ) - { - if( nPolygonIndex != 0 ) - CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" ); - - path = CanvasUtils.makeGenPathFromBezierPoints( points ); - } - - public RealBezierSegment2D getBezierSegment( int nPolygonIndex, int nPointIndex ) - { - return null; - } - - public void setBezierSegment( RealBezierSegment2D point, int nPolygonIndex, int nPointIndex ) - { - CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" ); - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XBezierPolyPolygon2D.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.BezierPolyPolygon2D"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/BitmapCanvas.java b/canvas/source/java/BitmapCanvas.java deleted file mode 100644 index f40c9bf34c3a..000000000000 --- a/canvas/source/java/BitmapCanvas.java +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.IQueryInterface; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - -public class BitmapCanvas - extends CanvasBase - implements com.sun.star.rendering.XBitmapCanvas, - com.sun.star.lang.XServiceInfo -{ - private Graphics2D graphics; - - public Graphics2D getGraphics() - { - return graphics; - } - - //---------------------------------------------------------------------------------- - - public BitmapCanvas( Graphics2D _graphics ) - { - graphics = _graphics; - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - graphics.copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( graphics, destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - // TODO: really extract correct source rect here - BufferedImage backBuffer = ((BufferedGraphics2D)((JavaCanvas)sourceCanvas).getGraphics()).getBackBuffer(); - graphics.drawImage( backBuffer, 0, 0, null ); - CanvasUtils.postRenderImageTreatment( backBuffer ); - - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XBitmapCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.BitmapCanvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/BufferedGraphics2D.java b/canvas/source/java/BufferedGraphics2D.java deleted file mode 100644 index 88691351809e..000000000000 --- a/canvas/source/java/BufferedGraphics2D.java +++ /dev/null @@ -1,600 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Java AWT -import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.awt.image.renderable.*; -import java.awt.font.*; -import java.text.*; -import java.util.*; - - -public class BufferedGraphics2D - extends java.awt.Graphics2D -{ - // TODO: Somehow, get rid of this duplicate graphics (the graphics member, - // and this object itself, extending a Graphics2D) - private Graphics2D graphics; - private BufferedImage backBuffer; - private Graphics2D backBufferGraphics; - - //---------------------------------------------------------------------------------- - - public BufferedGraphics2D( java.awt.Graphics2D _graphics, int width, int height ) - { - setGraphics( _graphics, Math.max(1,width), Math.max(1,height) ); - } - - public void redraw( Graphics2D graph ) - { - if( graph != null && - backBuffer != null ) - { - CanvasUtils.printLog("BufferedGraphics2D.redraw: using buffer of size (" + - backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" ); - - // set transform to identity - graph.setTransform( new AffineTransform() ); - graph.drawImage(backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - } - - public BufferedImage getBackBuffer() - { - return backBuffer; - } - - public void setSize( int width, int height ) - { - if( backBuffer != null && - width == backBuffer.getWidth() && - height == backBuffer.getHeight() ) - { - return; - } - - if( backBufferGraphics != null ) - backBufferGraphics.dispose(); - - if( backBuffer != null ) - backBuffer.flush(); - - // TODO: Maybe VolatileImage with another BufferedImage as a backup is - // a tad faster here. - backBuffer = graphics.getDeviceConfiguration().createCompatibleImage(width, - height); - - backBufferGraphics = backBuffer.createGraphics(); - CanvasUtils.initGraphics( backBufferGraphics ); - - // clear the buffer to white (to have a defined state here) - backBufferGraphics.setColor( java.awt.Color.white ); - backBufferGraphics.fillRect( 0,0,width,height ); - } - - public void setGraphics( Graphics2D _graphics, int width, int height ) - { - if( graphics != null ) - graphics.dispose(); - - graphics = _graphics; - - setSize(width,height); - } - - //---------------------------------------------------------------------------------- - - // - // Graphics - // ======== - // - public void clearRect(int x, int y, int width, int height) - { - graphics.clearRect(x,y,width,height); - backBufferGraphics.clearRect(x,y,width,height); - } - - public void clipRect(int x, int y, int width, int height) - { - graphics.clipRect(x,y,width,height); - backBufferGraphics.clipRect(x,y,width,height); - } - - public void copyArea(int x, int y, int width, int height, int dx, int dy) - { - graphics.copyArea(x,y,width,height,dx,dy); - backBufferGraphics.copyArea(x,y,width,height,dx,dy); - } - - public Graphics create() - { - return null; - } - - public Graphics create(int x, int y, int width, int height) - { - return null; - } - - public void dispose() - { - graphics.dispose(); - backBufferGraphics.dispose(); - backBuffer.flush(); - } - - public void draw3DRect(int x, int y, int width, int height, boolean raised) - { - graphics.draw3DRect(x,y,width,height,raised); - backBufferGraphics.draw3DRect(x,y,width,height,raised); - } - - public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) - { - graphics.drawArc(x,y,width,height,startAngle,arcAngle); - backBufferGraphics.drawArc(x,y,width,height,startAngle,arcAngle); - } - - public void drawBytes(byte[] data, int offset, int length, int x, int y) - { - graphics.drawBytes(data,offset,length,x,y); - backBufferGraphics.drawBytes(data,offset,length,x,y); - } - - public void drawChars(char[] data, int offset, int length, int x, int y) - { - graphics.drawChars(data,offset,length,x,y); - backBufferGraphics.drawChars(data,offset,length,x,y); - } - - public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,bgcolor,observer); - return graphics.drawImage(img,x,y,bgcolor,observer); - } - - public boolean drawImage(Image img, int x, int y, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,observer); - return graphics.drawImage(img,x,y,observer); - } - - public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,width,height,bgcolor,observer); - return graphics.drawImage(img,x,y,width,height,bgcolor,observer); - } - - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) - { - backBufferGraphics.drawImage(img,x,y,width,height,observer); - return graphics.drawImage(img,x,y,width,height,observer); - } - - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) - { - backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer); - return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer); - } - - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) - { - backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer); - return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer); - } - - public void drawLine(int x1, int y1, int x2, int y2) - { - graphics.drawLine(x1,y1,x2,y2); - backBufferGraphics.drawLine(x1,y1,x2,y2); - } - - public void drawOval(int x, int y, int width, int height) - { - graphics.drawOval(x,y,width,height); - backBufferGraphics.drawOval(x,y,width,height); - } - - public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.drawPolygon(xPoints,yPoints,nPoints); - backBufferGraphics.drawPolygon(xPoints,yPoints,nPoints); - } - - public void drawPolygon(Polygon p) - { - graphics.drawPolygon(p); - backBufferGraphics.drawPolygon(p); - } - - public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.drawPolyline(xPoints,yPoints,nPoints); - backBufferGraphics.drawPolyline(xPoints,yPoints,nPoints); - } - - public void drawRect(int x, int y, int width, int height) - { - graphics.drawRect(x,y,width,height); - backBufferGraphics.drawRect(x,y,width,height); - } - - public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - { - graphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight); - backBufferGraphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight); - } - - public void drawString(AttributedCharacterIterator iterator, int x, int y) - { - graphics.drawString(iterator,x,y); - backBufferGraphics.drawString(iterator,x,y); - } - - public void drawString(String str, int x, int y) - { - graphics.drawString(str,x,y); - backBufferGraphics.drawString(str,x,y); - } - - public void fill3DRect(int x, int y, int width, int height, boolean raised) - { - graphics.fill3DRect(x,y,width,height,raised); - backBufferGraphics.fill3DRect(x,y,width,height,raised); - } - - public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) - { - graphics.fillArc(x,y,width,height,startAngle,arcAngle); - backBufferGraphics.fillArc(x,y,width,height,startAngle,arcAngle); - } - - public void fillOval(int x, int y, int width, int height) - { - graphics.fillOval(x,y,width,height); - backBufferGraphics.fillOval(x,y,width,height); - } - - public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - { - graphics.fillPolygon(xPoints,yPoints,nPoints); - backBufferGraphics.fillPolygon(xPoints,yPoints,nPoints); - } - - public void fillPolygon(Polygon p) - { - graphics.fillPolygon(p); - backBufferGraphics.fillPolygon(p); - } - - public void fillRect(int x, int y, int width, int height) - { - graphics.fillRect(x,y,width,height); - backBufferGraphics.fillRect(x,y,width,height); - } - - public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - { - graphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight); - backBufferGraphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight); - } - - public Shape getClip() - { - return graphics.getClip(); - } - - public Rectangle getClipBounds() - { - return graphics.getClipBounds(); - } - - public Rectangle getClipBounds(Rectangle r) - { - return graphics.getClipBounds(r); - } - - public Rectangle getClipRect() - { - return graphics.getClipRect(); - } - - public Color getColor() - { - return getColor(); - } - - public Font getFont() - { - return getFont(); - } - - public FontMetrics getFontMetrics() - { - return getFontMetrics(); - } - - public FontMetrics getFontMetrics(Font f) - { - return getFontMetrics(f); - } - - public boolean hitClip(int x, int y, int width, int height) - { - return graphics.hitClip(x,y,width,height); - } - - public void setClip(int x, int y, int width, int height) - { - graphics.setClip(x,y,width,height); - backBufferGraphics.setClip(x,y,width,height); - } - - public void setClip(Shape clip) - { - graphics.setClip(clip); - backBufferGraphics.setClip(clip); - } - - public void setColor(Color c) - { - graphics.setColor(c); - backBufferGraphics.setColor(c); - } - - public void setFont(Font font) - { - graphics.setFont(font); - backBufferGraphics.setFont(font); - } - - public void setPaintMode() - { - graphics.setPaintMode(); - backBufferGraphics.setPaintMode(); - } - - public void setXORMode(Color c1) - { - graphics.setXORMode(c1); - backBufferGraphics.setXORMode(c1); - } - - public String toString() - { - return graphics.toString(); - } - - public void translate(int x, int y) - { - graphics.translate(x,y); - backBufferGraphics.translate(x,y); - } - - //---------------------------------------------------------------------------------- - - // - // Graphics2D - // ========== - // - public void addRenderingHints(Map hints) - { - graphics.addRenderingHints(hints); - backBufferGraphics.addRenderingHints(hints); - } - - public void clip(Shape s) - { - graphics.clip(s); - backBufferGraphics.clip(s); - } - - public void draw(Shape s) - { - graphics.draw(s); - backBufferGraphics.draw(s); - } - - public void drawGlyphVector(GlyphVector g, float x, float y) - { - graphics.drawGlyphVector(g,x,y); - backBufferGraphics.drawGlyphVector(g,x,y); - } - - public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) - { - graphics.drawImage(img,op,x,y); - backBufferGraphics.drawImage(img,op,x,y); - } - - public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) - { - backBufferGraphics.drawImage(img,xform,obs); - return graphics.drawImage(img,xform,obs); - } - - public void drawRenderableImage(RenderableImage img, AffineTransform xform) - { - graphics.drawRenderableImage(img,xform); - backBufferGraphics.drawRenderableImage(img,xform); - } - - public void drawRenderedImage(RenderedImage img, AffineTransform xform) - { - graphics.drawRenderedImage(img,xform); - backBufferGraphics.drawRenderedImage(img,xform); - } - - public void drawString(AttributedCharacterIterator iterator, float x, float y) - { - graphics.drawString(iterator,x,y); - backBufferGraphics.drawString(iterator,x,y); - } - - public void drawString(String s, float x, float y) - { - graphics.drawString(s,x,y); - backBufferGraphics.drawString(s,x,y); - } - - public void fill(Shape s) - { - graphics.fill(s); - backBufferGraphics.fill(s); - } - - public Color getBackground() - { - return graphics.getBackground(); - } - - public Composite getComposite() - { - return graphics.getComposite(); - } - - public GraphicsConfiguration getDeviceConfiguration() - { - return graphics.getDeviceConfiguration(); - } - - public FontRenderContext getFontRenderContext() - { - return graphics.getFontRenderContext(); - } - - public Paint getPaint() - { - return graphics.getPaint(); - } - - public Object getRenderingHint(RenderingHints.Key hintKey) - { - return graphics.getRenderingHint(hintKey); - } - - public RenderingHints getRenderingHints() - { - return graphics.getRenderingHints(); - } - - public Stroke getStroke() - { - return graphics.getStroke(); - } - - public AffineTransform getTransform() - { - return graphics.getTransform(); - } - - public boolean hit(Rectangle rect, Shape s, boolean onStroke) - { - return graphics.hit(rect,s,onStroke); - } - - public void rotate(double theta) - { - graphics.rotate(theta); - backBufferGraphics.rotate(theta); - } - - public void rotate(double theta, double x, double y) - { - graphics.rotate(theta,x,y); - backBufferGraphics.rotate(theta,x,y); - } - - public void scale(double sx, double sy) - { - graphics.scale(sx,sy); - backBufferGraphics.scale(sx,sy); - } - - public void setBackground(Color color) - { - graphics.setBackground(color); - backBufferGraphics.setBackground(color); - } - - public void setComposite(Composite comp) - { - graphics.setComposite(comp); - backBufferGraphics.setComposite(comp); - } - - public void setPaint(Paint paint) - { - graphics.setPaint(paint); - backBufferGraphics.setPaint(paint); - } - - public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) - { - graphics.setRenderingHint(hintKey,hintValue); - backBufferGraphics.setRenderingHint(hintKey,hintValue); - } - - public void setRenderingHints(Map hints) - { - graphics.setRenderingHints(hints); - backBufferGraphics.setRenderingHints(hints); - } - - public void setStroke(Stroke s) - { - graphics.setStroke(s); - backBufferGraphics.setStroke(s); - } - - public void setTransform(AffineTransform Tx) - { - graphics.setTransform(Tx); - backBufferGraphics.setTransform(Tx); - } - - public void shear(double shx, double shy) - { - graphics.shear(shx,shy); - backBufferGraphics.shear(shx,shy); - } - - public void transform(AffineTransform Tx) - { - graphics.transform(Tx); - backBufferGraphics.transform(Tx); - } - - public void translate(double tx, double ty) - { - graphics.translate(tx,ty); - backBufferGraphics.translate(tx,ty); - } -} diff --git a/canvas/source/java/CanvasBase.java b/canvas/source/java/CanvasBase.java deleted file mode 100644 index 2df796d06f84..000000000000 --- a/canvas/source/java/CanvasBase.java +++ /dev/null @@ -1,341 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public abstract class CanvasBase - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XCanvas -{ - // to be overridden - public abstract Graphics2D getGraphics(); - - //---------------------------------------------------------------------------------- - - // - // XCanvas interface - // ================= - // - public synchronized void clear() - { - Graphics2D graphics = getGraphics(); - // TODO(F3): retrieve true dimensions of the Graphics - graphics.clearRect(0,0,1000,1000); - } - - public synchronized void drawPoint( RealPoint2D aPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - // calculate the domain value for a single device pixel. we're - // using delta mapping here, to avoid later subtraction of two - // mapped values (as we really only need a transformed size, - // not a transformed point). - AffineTransform transform = graphics.getTransform(); - AffineTransform inverse; - try - { - inverse = transform.createInverse(); - } - catch( NoninvertibleTransformException e ) - { - // transformation not invertible. Nothing to render then. - return; - } - - java.awt.geom.Point2D.Double pointSize = new java.awt.geom.Point2D.Double(1.0,1.0); - java.awt.geom.Point2D.Double domainPointSize = new java.awt.geom.Point2D.Double(); - inverse.deltaTransform( pointSize, domainPointSize ); - - // render a circle one device pixel wide - Ellipse2D.Double ellipse = new Ellipse2D.Double(aPoint.X, aPoint.Y, domainPointSize.x, domainPointSize.y); - - // render, at last - graphics.fill( ellipse ); - - CanvasUtils.printLog( "XCanvas: drawPoint called" ); - } - - public synchronized void drawLine( RealPoint2D aStartPoint, - RealPoint2D aEndPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // setup line object - Line2D.Double line = new Line2D.Double(aStartPoint.X, aStartPoint.Y, aEndPoint.X, aEndPoint.Y); - - // render, at last - graphics.draw( line ); - - CanvasUtils.printLog( "XCanvas: drawLine called" ); - } - - public synchronized void drawBezier( RealBezierSegment2D aBezierSegment, - RealPoint2D aEndPoint, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // setup bezier object - CubicCurve2D.Double curve = new CubicCurve2D.Double(aBezierSegment.Px, aBezierSegment.Py, - aBezierSegment.C1x, aBezierSegment.C1y, - aBezierSegment.C2x, aBezierSegment.C2y, - aEndPoint.X, aEndPoint.Y); - - // render, at last - graphics.draw( curve ); - - CanvasUtils.printLog( "XCanvas: drawbezier called" ); - } - - public synchronized XCachedPrimitive drawPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawPolyPolygon() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - graphics.setStroke( new BasicStroke() ); - - // render the polygon - // TODO: maybe use Graphics.drawPolyline here! - graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: drawPolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive strokePolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException - { - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.applyStrokeAttributes( graphics, strokeAttributes ); - - // stroke the polygon - graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: strokePolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive strokeTexturedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XCachedPrimitive strokeTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - com.sun.star.geometry.XMapping2D xMapping, - StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XPolyPolygon2D queryStrokeShapes( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState, - com.sun.star.rendering.StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException - { - return null; - } - - public synchronized XCachedPrimitive fillPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.fillPolyPolygon() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - // initialize the Graphics2D - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - // fill the polygon - graphics.fill( CanvasUtils.makeGeneralPath(xPolyPolygon) ); - - CanvasUtils.printLog( "XCanvas: fillPolyPolygon called" ); - - return null; - } - - public synchronized XCachedPrimitive fillTexturedPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState, - com.sun.star.rendering.Texture [] textures ) throws com.sun.star.lang.IllegalArgumentException - { - return null; - } - - public synchronized XCachedPrimitive fillTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon, - ViewState viewState, - RenderState renderState, - Texture[] textures, - com.sun.star.geometry.XMapping2D xMapping ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return null; - } - - public synchronized XCanvasFont createFont( FontRequest fontRequest, com.sun.star.beans.PropertyValue[] extraFontProperties, com.sun.star.geometry.Matrix2D fontMatrix ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO: support extra arguments - return new CanvasFont( fontRequest, this ); - } - - public FontInfo[] queryAvailableFonts( FontInfo aFilter, com.sun.star.beans.PropertyValue[] aFontProperties ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return null; - } - - public XCachedPrimitive drawText( StringContext text, XCanvasFont xFont, ViewState viewState, RenderState renderState, byte textDirection ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawText() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.printLog( "XCanvas: drawText called" ); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, xFont ); - - CanvasUtils.printLog( "XCanvas: drawText rendering \""+ text.Text.substring(text.StartPosition, text.StartPosition+text.Length) + "\"" ); - - graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition+text.Length), (float)0.0, (float)0.0 ); - return null; - } - - public XCachedPrimitive drawTextLayout( XTextLayout layoutetText, ViewState viewState, RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawOffsettedText() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.printLog( "XCanvas: drawOffsettedText called" ); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, layoutetText.getFont() ); - - CanvasUtils.printLog( "XCanvas: drawOffsettedText canvas setup done" ); - - if( layoutetText instanceof TextLayout ) - { - ((TextLayout)layoutetText).draw( graphics ); - } - else - { - CanvasUtils.printLog( "drawTextLayout: mismatching TextLayout object." ); - throw new com.sun.star.lang.IllegalArgumentException(); - } - - return null; - } - - public synchronized XCachedPrimitive drawBitmap( com.sun.star.rendering.XBitmap xBitmap, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawBitmap() called" ); - - // cache - Graphics2D graphics = getGraphics(); - - CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint ); - - java.awt.image.BufferedImage bitmap = CanvasUtils.getBufferedImage( xBitmap ); - - if( !graphics.drawImage(bitmap, 0, 0, null) ) - CanvasUtils.printLog( "CanvasBase.drawBitmap: image paint incomplete" ); - - CanvasUtils.postRenderImageTreatment( bitmap ); - - return null; - } - - public synchronized XCachedPrimitive drawBitmapModulated( com.sun.star.rendering.XBitmap xBitmap, - com.sun.star.rendering.ViewState viewState, - com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException - { - CanvasUtils.printLog( "CanvasBase.drawBitmapModulated() called" ); - - // TODO(F3): Implement channel modulation - return drawBitmap(xBitmap, - viewState, - renderState); - } - - public synchronized XGraphicDevice getDevice() - { - CanvasUtils.printLog( "CanvasBase.getDevice() called" ); - return new CanvasGraphicDevice( getGraphics() ); - } -} diff --git a/canvas/source/java/CanvasBitmap.java b/canvas/source/java/CanvasBitmap.java deleted file mode 100644 index cfb7617dc094..000000000000 --- a/canvas/source/java/CanvasBitmap.java +++ /dev/null @@ -1,252 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class CanvasBitmap - extends CanvasBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XBitmapCanvas, - com.sun.star.rendering.XIntegerBitmap -{ - private java.awt.image.BufferedImage bitmap; - private java.awt.Graphics2D graphics; - - public CanvasBitmap( java.awt.image.BufferedImage _bitmap ) - { - bitmap = _bitmap; - graphics = bitmap.createGraphics(); - } - - public CanvasBitmap( IntegerSize2D mySize ) - { - bitmap = new java.awt.image.BufferedImage(mySize.Width, mySize.Height, - java.awt.image.BufferedImage.TYPE_4BYTE_ABGR); - graphics = bitmap.createGraphics(); - } - - public CanvasBitmap( RealSize2D newSize, boolean beFast, CanvasBitmap source ) - { -// java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform(); -// transform.scale( newSize.width/size.Width, newSize.height/size.Height ); - -// // TODO: Maybe keep the image returned via -// // bitmap.getScaledInstance, and do scaling lazy. -// bitmap = new java.awt.image.BufferedImage((int)(newSize.width+.5), -// (int)(newSize.height+.5), -// java.awt.image.BufferedImage.TYPE_4BYTE_ABGR); - -// java.awt.image.AffineTransformOp transformer = -// new java.awt.image.AffineTransformOp( transform, -// java.awt.image.AffineTransformOp.TYPE_BILINEAR); - -// transformer.filter(source.getBufferedImage(), bitmap); - } - - public synchronized java.awt.image.BufferedImage getBufferedImage() - { - return bitmap; - } - - public java.awt.Graphics2D getGraphics() - { - return graphics; - } - - // - // XBitmap implementation - // ====================== - // - - public synchronized IntegerSize2D getSize() - { - return new IntegerSize2D( bitmap.getWidth(), - bitmap.getHeight() ); - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapCanvas queryBitmapCanvas() - { - return this; - } - - //---------------------------------------------------------------------------------- - - public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - return new CanvasBitmap( newSize, beFast, this ); - } - - //---------------------------------------------------------------------------------- - - public synchronized boolean hasAlpha() - { - // TODO - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "JavaCanvas.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // - // XIntegerBitmap implementation - // ============================= - // - - public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout, - IntegerRectangle2D rect ) - { - int [] pixelData = bitmap.getRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y1 - rect.Y2, null, 0, 0 ); - - return CanvasUtils.int2byte( pixelData ); - } - - //---------------------------------------------------------------------------------- - - public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect ) - { - int [] pixelData = CanvasUtils.byte2int( data ); - bitmap.setRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, pixelData, 0, bitmap.getWidth() ); - } - - //---------------------------------------------------------------------------------- - - public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos ) - { - if( color.length != 4 ) - CanvasUtils.printLog( "CanvasBitmap.setPixel: Wrong color format" ); - - int pixel = color[0] + (color[1] + (color[2] + color[3]*256)*256)*256; - bitmap.setRGB( pos.X, pos.Y, pixel ); - } - - //---------------------------------------------------------------------------------- - - public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout, - IntegerPoint2D pos ) - { - int pixel = bitmap.getRGB( pos.X, pos.Y ); - - byte[] res = new byte[4]; - res[0] = (byte)(pixel & 255); - res[1] = (byte)((pixel/256) & 255); - res[2] = (byte)((pixel/256/256) & 255); - res[3] = (byte)((pixel/256/256/256) & 255); - - return res; - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapPalette getPalette() - { - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized IntegerBitmapLayout getMemoryLayout() - { - // TODO: finish that one - IntegerBitmapLayout layout = new IntegerBitmapLayout(); - - return layout; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XIntegerBitmap.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.IntegerBitmap"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasClonedSprite.java b/canvas/source/java/CanvasClonedSprite.java deleted file mode 100644 index d5f85678db4f..000000000000 --- a/canvas/source/java/CanvasClonedSprite.java +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.geom.*; - -public class CanvasClonedSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private JavaCanvas canvas; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - private SpriteBase original; - - //---------------------------------------------------------------------------------- - - public CanvasClonedSprite( JavaCanvas _canvas, - XSprite _original ) - { - CanvasUtils.printLog( "CanvasClonesSprite constructor called!" ); - - canvas = _canvas; - - if( _original instanceof SpriteBase ) - { - original = (SpriteBase)_original; - } - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - - // TODO: throw on error here! - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep( original.getSpriteRep() ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - - // TODO: Check for spriteRep.buffer != null here, throw otherwise - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - canvas = null; - spriteRep = null; - original = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XSprite impl - // ================== - // - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState ) - { - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - canvas.hideSprite( this ); - } - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Sprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasCustomSprite.java b/canvas/source/java/CanvasCustomSprite.java deleted file mode 100644 index c3165fa68e80..000000000000 --- a/canvas/source/java/CanvasCustomSprite.java +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasCustomSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XCustomSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private JavaCanvas canvas; - private RealSize2D spriteSize; - private Graphics2D referenceGraphics; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - - //---------------------------------------------------------------------------------- - - public CanvasCustomSprite( RealSize2D _spriteSize, - JavaCanvas _canvas, - Graphics2D _referenceGraphics ) - { - CanvasUtils.printLog( "CanvasCustomSprite constructor called, size is (" + _spriteSize.Width + ", " + _spriteSize.Height + ")" ); - - canvas = _canvas; - spriteSize = _spriteSize; - referenceGraphics = _referenceGraphics; - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public synchronized SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep(); - - spriteRep.setupBuffer(referenceGraphics, (int)(spriteSize.Width+.5), (int)(spriteSize.Height+.5) ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - if( spriteRep != null ) - spriteRep.dispose(); - - canvas = null; - referenceGraphics = null; - spriteRep = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XCustomSprite impl - // ================== - // - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - CanvasUtils.printLog( "CanvasCustomSprite.setAlpha() called" ); - - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState ) - { - CanvasUtils.printLog( "CanvasCustomSprite.move() called" ); - - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - CanvasUtils.printLog( "CanvasCustomSprite.show() called" ); - - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - CanvasUtils.printLog( "CanvasCustomSprite.hide() called" ); - - canvas.hideSprite( this ); - - // do _not_ dispose clear SpriteRep, since we cannot actively - // repaint ourselves - } - - public synchronized com.sun.star.rendering.XCanvas getContentCanvas() - { - CanvasUtils.printLog( "CanvasCustomSprite.getContentCanvas() called" ); - - return getSpriteRep().getContentCanvas(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCustomSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.CustomSprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasFont.java b/canvas/source/java/CanvasFont.java deleted file mode 100644 index 1ca2cc1aa3ec..000000000000 --- a/canvas/source/java/CanvasFont.java +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -public class CanvasFont - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XCanvasFont -{ - private CanvasBase associatedCanvas; - private com.sun.star.rendering.FontRequest fontRequest; - private java.awt.Font font; - - //---------------------------------------------------------------------------------- - - public CanvasFont( com.sun.star.rendering.FontRequest _fontRequest, - CanvasBase _canvas ) - { - associatedCanvas = _canvas; - fontRequest = _fontRequest; - - // TODO: Use proper attributes here, first of all, use fractional point font size - font = new java.awt.Font( fontRequest.FontDescription.FamilyName, java.awt.Font.PLAIN, (int)(fontRequest.CellSize + .5) ); - } - - public java.awt.Font getFont() - { - return font; - } - - //---------------------------------------------------------------------------------- - - // - // XCanvasFont implementation - // =========================== - // - - public XTextLayout createTextLayout( StringContext aText, byte nDirection, long nRandomSeed ) - { - return new TextLayout( aText, nDirection, nRandomSeed, this, associatedCanvas ); - } - - public FontRequest getFontRequest( ) - { - return fontRequest; - } - - public FontMetrics getFontMetrics( ) - { - // TODO - return null; - } - - public double[] getAvailableSizes( ) - { - // TODO - return null; - } - - public com.sun.star.beans.PropertyValue[] getExtraFontProperties( ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "CanvasFont.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasGraphicDevice.java b/canvas/source/java/CanvasGraphicDevice.java deleted file mode 100644 index c521d627f1a9..000000000000 --- a/canvas/source/java/CanvasGraphicDevice.java +++ /dev/null @@ -1,222 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; - -public class CanvasGraphicDevice - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.beans.XPropertySet, - com.sun.star.rendering.XGraphicDevice -{ - private java.awt.Graphics2D graphics; - private java.awt.GraphicsConfiguration graphicsConfig; - - //---------------------------------------------------------------------------------- - - public CanvasGraphicDevice( java.awt.Graphics2D _graphics ) - { - graphics = _graphics; - graphicsConfig = graphics.getDeviceConfiguration(); - } - - //---------------------------------------------------------------------------------- - - // - // GraphicsDevice implementation - // ============================= - // - public synchronized XBufferController getBufferController() - { - // Use java.awt.image.BufferStrategy to implement XBufferController - CanvasUtils.printLog( "CanvasGraphicDevice.getBufferController!" ); - return null; - } - - public synchronized XColorSpace getDeviceColorSpace() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getDeviceColorSpace!" ); - return null; - } - - public synchronized com.sun.star.geometry.RealSize2D getPhysicalResolution() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getPhysicalResolution!" ); - // TODO: getDefaultTransform + getNormalizingTransform - return new com.sun.star.geometry.RealSize2D(100,100); - } - - public synchronized com.sun.star.geometry.RealSize2D getPhysicalSize() - { - CanvasUtils.printLog( "CanvasGraphicDevice.getSize!" ); - java.awt.Rectangle bounds = graphicsConfig.getBounds(); - - return new com.sun.star.geometry.RealSize2D(bounds.width, bounds.height); - } - - public synchronized XLinePolyPolygon2D createCompatibleLinePolyPolygon( RealPoint2D[][] points ) - { - CanvasUtils.printLog( "createCompatibleLinePolyPolygon" ); - return new LinePolyPolygon( points ); - } - - public synchronized XBezierPolyPolygon2D createCompatibleBezierPolyPolygon( RealBezierSegment2D[][] points ) - { - CanvasUtils.printLog( "createCompatibleBezierPolyPolygon" ); - return new BezierPolyPolygon( points ); - } - - public synchronized com.sun.star.rendering.XBitmap createCompatibleBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width, - size.Height, - Transparency.OPAQUE ) ); - } - - public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) ); - return null; - } - - public synchronized com.sun.star.rendering.XBitmap createCompatibleAlphaBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width, - size.Height, - Transparency.TRANSLUCENT ) ); - } - - public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileAlphaBitmap( IntegerSize2D size ) - { - CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" ); - //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) ); - return null; - } - - public synchronized com.sun.star.rendering.XParametricPolyPolygon2DFactory getParametricPolyPolygonFactory() - { - // TODO - return null; - } - - public synchronized com.sun.star.beans.XPropertySetInfo getPropertySetInfo() - { - // This is a stealth property set - return null; - } - - public synchronized void setPropertyValue( String aPropertyName, java.lang.Object aValue ) throws com.sun.star.beans.PropertyVetoException - { - // all our properties are read-only - throw new com.sun.star.beans.PropertyVetoException(); - } - - public synchronized java.lang.Object getPropertyValue( String PropertyName ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return graphics; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void addPropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( aPropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void removePropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( aPropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void addVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - public synchronized void removeVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException - { - if( PropertyName == "DeviceHandle" ) - return; - - throw new com.sun.star.beans.UnknownPropertyException(); - } - - - public synchronized boolean hasFullScreenMode() - { - return graphicsConfig.getDevice().isFullScreenSupported(); - } - - public synchronized boolean enterFullScreenMode( boolean bEnter ) - { - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XGraphicsDevice.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.GraphicsDevice"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - -} diff --git a/canvas/source/java/CanvasSprite.java b/canvas/source/java/CanvasSprite.java deleted file mode 100644 index 9b2cfc0debad..000000000000 --- a/canvas/source/java/CanvasSprite.java +++ /dev/null @@ -1,308 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasSprite - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.rendering.XAnimatedSprite, - com.sun.star.lang.XServiceInfo, - SpriteBase -{ - private XAnimation spriteAnimation; - private JavaCanvas canvas; - private Graphics2D referenceGraphics; - private SpriteRunner runner; - private ViewState viewState; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private SpriteRep spriteRep; - - //---------------------------------------------------------------------------------- - - public CanvasSprite( XAnimation _animation, JavaCanvas _canvas, Graphics2D _referenceGraphics ) - { - CanvasUtils.printLog( "CanvasSprite constructor called!" ); - - spriteAnimation = _animation; - canvas = _canvas; - referenceGraphics = _referenceGraphics; - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - - runner = new SpriteRunner( this, spriteAnimation, canvas ); - } - - public synchronized ViewState getViewState() - { - return viewState; - } - - //---------------------------------------------------------------------------------- - - // - // SpriteBase - // ========== - // - public synchronized SpriteRep getSpriteRep() - { - if( spriteRep == null ) - { - spriteRep = new SpriteRep(); - - setupSpriteBuffering( CanvasUtils.makeTransform( getViewState().AffineTransform ) ); - - spriteRep.moveSprite( outputPosition ); - spriteRep.setSpriteAlpha( alpha ); - - // render initial sprite content - updateAnimation(); - } - return spriteRep; - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - // end the animation thread - if( runner != null ) - { - runner.quit(); - try - { - runner.join(0); // and wait until it's really over - } - catch( java.lang.InterruptedException e ) {} - } - - if( spriteRep != null ) - spriteRep.dispose(); - - canvas = null; - spriteAnimation = null; - runner = null; - referenceGraphics = null; - spriteRep = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XSprite impl - // ============ - // - - public synchronized void startAnimation( double speed ) - { - runner.startAnimation( speed ); - } - - public synchronized void stopAnimation() - { - runner.stopAnimation(); - } - - public synchronized void resetAnimation() - { - runner.resetAnimation(); - } - - public synchronized void updateAnimation() - { - // only call render explicitely, if animation not - // running. Otherwise, next animation render will update - // anyway. - if( spriteRep != null && - !runner.isAnimationActive() ) - { - spriteRep.renderAnimation( spriteAnimation, getViewState(), runner.getCurrentT() ); - } - } - - public synchronized void setPriority( double nPriority ) - { - // TODO - } - - public synchronized void setAlpha( double _alpha ) - { - alpha = _alpha; - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - } - } - - public synchronized void move( com.sun.star.geometry.RealPoint2D _aNewPos, - com.sun.star.rendering.ViewState _viewState, - com.sun.star.rendering.RenderState _renderState ) - { - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.moveSprite( outputPosition ); - } - } - - public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - } - - public synchronized void clip( XPolyPolygon2D aClip ) - { - // TODO - } - - public synchronized void show() - { - canvas.showSprite( this ); - canvas.updateScreen( false ); - } - - public synchronized void hide() - { - canvas.hideSprite( this ); - - // dispose and clear SpriteRep, animation content can be - // regenerated at any time - if( spriteRep != null ) - spriteRep.dispose(); - - spriteRep = null; - } - - public synchronized void setViewState( ViewState _viewState ) - { - viewState = CanvasUtils.createAnimationViewState(_viewState, - getAnimationAttributes()); - - CanvasUtils.printTransform( CanvasUtils.makeTransform( viewState.AffineTransform ), - "CanvasSprite.setViewState" ); - - if( spriteRep != null ) - { - // calculate bounds of view-transformed animation output rectangle - setupSpriteBuffering( CanvasUtils.makeTransform(getViewState().AffineTransform) ); - updateAnimation(); - } - } - - public synchronized AnimationAttributes getAnimationAttributes() - { - return spriteAnimation.getAnimationAttributes(); - } - - public synchronized void setAll( RealPoint2D _aNewPos, - ViewState _viewState, - RenderState _renderState, - double _alpha, - boolean bUpdateAnimation ) - { - alpha = _alpha; - - // transform given point with concatenated transformation - AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState ); - transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X, - _aNewPos.Y), - outputPosition ); - - if( spriteRep != null ) - { - spriteRep.setSpriteAlpha( alpha ); - spriteRep.moveSprite( outputPosition ); - - if( bUpdateAnimation ) - updateAnimation(); - } - } - - //---------------------------------------------------------------------------------- - - private void setupSpriteBuffering( AffineTransform _viewTransform ) - { - // determine bounds of view-transformed animation output rectangle - com.sun.star.geometry.RealSize2D animSize = getAnimationAttributes().UntransformedSize; - - java.awt.geom.Rectangle2D.Double aTransformedBounds = - CanvasUtils.calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0,0.0, - animSize.Width, - animSize.Height), - _viewTransform ); - CanvasUtils.printTransform( _viewTransform, "setupSpriteBuffering" ); - CanvasUtils.printLog( "setupSpriteBuffering: bounds are (" + aTransformedBounds.width + ", " + aTransformedBounds.height + ")" ); - - // create a buffer of the appropriate size - spriteRep.setupBuffer(referenceGraphics, (int)(aTransformedBounds.width+.5), - (int)(aTransformedBounds.height+.5) ); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XSprite.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Sprite"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/CanvasTest_perftest.java b/canvas/source/java/CanvasTest_perftest.java deleted file mode 100644 index 047c9de3b16b..000000000000 --- a/canvas/source/java/CanvasTest_perftest.java +++ /dev/null @@ -1,676 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.IQueryInterface; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; - -// Java AWT -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - -public class CanvasTest - extends CanvasBase - implements com.sun.star.awt.XWindow, - com.sun.star.rendering.XSpriteCanvas, - com.sun.star.lang.XServiceInfo, - com.sun.star.lang.XInitialization -{ - private WindowAdapter dummyFrame; - private BackBuffer backBuffer; - private java.awt.image.BufferStrategy bufferStrategy; - - private java.awt.Font fpsFont; - private long lastTime; - - - // TEST ONLY { - private static int testWidth = 1600; - private static int testHeight = 1200; - private BufferedImage backgroundBuffer; - private BufferedImage buffer; - private BufferedImage buffer2; - private Graphics2D backBufGraphics; - private Graphics2D bufferGraphics; - private Graphics2D buffer2Graphics; - private float currAlpha; - // TEST ONLY } - - - - public Graphics2D getGraphics() - { - return backBuffer.getGraphics(); - } - - //---------------------------------------------------------------------------------- - - // - // XInitialization - // =============== - // - public void initialize( java.lang.Object[] arguments ) - { - CanvasUtils.printLog( "CanvasTest.initialize called!" ); - - // Do that as the very first thing. The Java2D internal - // classes choose their render path at initialization time, - // thus this must happen before doing _any_ GUI. - - // TODO: Put those flags into javarc/java.ini, we're maybe - // coming late into a running JVM! - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - CanvasUtils.printLog( "System detected: " + os ); - - // tweak some speed knobs... - if( os.startsWith("Windows") ) - { - System.setProperty("sun.java2d.translaccel", "true"); - System.setProperty("sun.java2d.ddforcevram", "true"); - //System.setProperty("sun.java2d.accthreshold", "0"); - - CanvasUtils.printLog( "Optimizing for Windows" ); - } - else - { - System.setProperty("sun.java2d.opengl", "true"); - - CanvasUtils.printLog( "Optimizing for Unix" ); - } - - /* we're initialized with the following array of anys: - - arguments[0] = pointer to VCL window - arguments[1] = Integer (operating system window handle) - arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window) - arguments[3] = boolean (fullsize window or not) - - We then generate a dummy Java frame with that window as the - parent, to fake a root window for the Java implementation. - */ - try - { - com.sun.star.awt.Rectangle boundRect = (com.sun.star.awt.Rectangle) arguments[2]; - - //boolean isFullScreen = arguments[1]; - boolean isFullScreen = true; - //AnyConverter.toBoolean( arguments[3] ) ); - - // fake a root for Java in VCL window. Pass the flag - // whether we shall run fullscreen, too. - dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen ); - - if( isFullScreen ) - { - // blow window up to fullscreen. Otherwise, we cannot clear the whole screen, - // which results in ugly flickering - Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize(); - boundRect.X = 0; - boundRect.Y = 0; - boundRect.Width = screenSize.width-1; - boundRect.Height = screenSize.height-1; - } - - dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 ); - CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height ); - - // TEST - if( true ) - { - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - Math.max(1,boundRect.Width), - Math.max(1,boundRect.Height) ); - } - else - { - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - 10, 10 ); - } - - // TODO: Maybe delay double buffer init until first sprite creation - dummyFrame.frame.createBufferStrategy(2); - bufferStrategy = dummyFrame.frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - CanvasUtils.printLog( "CanvasTest.initialize double buffering is using page flipping!" ); - else - CanvasUtils.printLog( "CanvasTest.initialize double buffering is using blitting!" ); - - lastTime = System.currentTimeMillis(); - fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 ); - - - if( false ) - { - // TEST ONLY { - Graphics2D frameGraphics= (Graphics2D) dummyFrame.frame.getGraphics(); - backgroundBuffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight); // TODO: size dynamic - buffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight, - Transparency.TRANSLUCENT); - buffer2 = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight, - Transparency.TRANSLUCENT); - bufferGraphics = (Graphics2D)buffer.getGraphics(); - buffer2Graphics = (Graphics2D)buffer2.getGraphics(); - backBufGraphics = (Graphics2D)backgroundBuffer.getGraphics(); - currAlpha = 0.1f; - - // init content - Font font = new Font( "Times", Font.PLAIN, 100 ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - bufferGraphics.fillRect( 0,0,testWidth,testHeight ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); - bufferGraphics.setColor( Color.red ); - bufferGraphics.fillRect( 0,0,testWidth/2,testHeight/2 ); - bufferGraphics.setColor( Color.green ); - bufferGraphics.fillRect( testWidth/2,0,testWidth,testHeight/2 ); - bufferGraphics.setColor( Color.blue ); - bufferGraphics.fillRect( 0,testHeight/2,testWidth/2,testHeight ); - - buffer2Graphics.setColor( Color.red ); - buffer2Graphics.fillRect( 0,0,testWidth/2,testHeight/2 ); - buffer2Graphics.setColor( Color.green ); - buffer2Graphics.fillRect( testWidth/2,0,testWidth,testHeight/2 ); - buffer2Graphics.setColor( Color.blue ); - buffer2Graphics.fillRect( 0,testHeight/2,testWidth/2,testHeight ); - - backBufGraphics.setColor( Color.white ); - backBufGraphics.fillRect(0,0,testWidth,testHeight); - backBufGraphics.setColor( Color.red ); - backBufGraphics.setFont( font ); - int i, turns=15; - for(i=0; i<turns; ++i) - { - backBufGraphics.drawString( "Crossfade test", testWidth*i/turns, testHeight*i/turns ); - } - // TEST ONLY } - } - - CanvasUtils.printLog( "CanvasTest.initialize finished!" ); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - CanvasUtils.printLog( "CanvasTest: disposed!" ); - - // destroy all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).dispose(); - } - - if( bufferStrategy != null ) - bufferStrategy.getDrawGraphics().dispose(); // really necessary? - - if( dummyFrame != null ) - dummyFrame.dispose(); - - if( backBuffer != null) - backBuffer.dispose(); - - bufferStrategy = null; - dummyFrame = null; - backBuffer = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - public CanvasTest( XComponentContext xContext ) - { - CanvasUtils.printLog( "CanvasTest constructor called!" ); - activeSprites = new java.util.HashMap( 33 ); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - // This is delegated to WindowAdapter! - // - public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - if( dummyFrame != null ) - { - dummyFrame.setPosSize( X, Y, Width, Height, Flags ); - - Width = Math.max(1,Width); - Height= Math.max(1,Height); - - CanvasUtils.printLog( "CanvasTest graphics set to " + Width + "," + Height ); - backBuffer.setSize(Width,Height); - } - } - - public synchronized com.sun.star.awt.Rectangle getPosSize( ) - { - if( dummyFrame != null ) - return dummyFrame.getPosSize(); - - return new com.sun.star.awt.Rectangle(); - } - - public synchronized void setVisible( boolean visible ) - { - if( dummyFrame != null ) - dummyFrame.setVisible( visible ); - } - - public synchronized void setEnable( boolean enable ) - { - if( dummyFrame != null ) - dummyFrame.setEnable( enable ); - } - - public synchronized void setFocus() - { - if( dummyFrame != null ) - dummyFrame.setFocus(); - } - - public synchronized void addWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addWindowListener( xListener ); - } - - public synchronized void removeWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeWindowListener( xListener ); - } - - public synchronized void addFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addFocusListener( xListener ); - } - - public synchronized void removeFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeFocusListener( xListener ); - } - - public synchronized void addKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addKeyListener( xListener ); - } - - public synchronized void removeKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeKeyListener( xListener ); - } - - public synchronized void addMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseListener( xListener ); - } - - public synchronized void removeMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseListener( xListener ); - } - - public synchronized void addMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseMotionListener( xListener ); - } - - public synchronized void removeMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseMotionListener( xListener ); - } - - public synchronized void addPaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addPaintListener( xListener ); - } - - public synchronized void removePaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removePaintListener( xListener ); - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.rendering.Rectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.rendering.Rectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "CanvasTest.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.x1, - (int)sourceRect.y1, - (int)(sourceRect.x2 - sourceRect.x1), - (int)(sourceRect.y2 - sourceRect.y1), - (int)(destRect.x1 - sourceRect.x1), - (int)(destRect.y1 - sourceRect.y1) ); - } - else - { - if( sourceCanvas instanceof CanvasTest ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((CanvasTest)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // a map of SpriteReps, with Sprite object as keys. Contains all - // active (i.e. visible) sprites, the SpriteReps are used to - // repaint the sprite content at any time. - private java.util.HashMap activeSprites; - - // - // XSpriteCanvas impl - // ================== - // - - public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation ) - { - CanvasUtils.printLog( "CanvasTest.createSpriteFromAnimation called" ); - - return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps, - short interpolationMode ) - { - return null; - } - - public synchronized XCustomSprite createCustomSprite( Size2D spriteSize ) - { - CanvasUtils.printLog( "CanvasTest.createCustomSprite called" ); - - return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XSprite createClonedSprite( XSprite original ) - { - return new CanvasClonedSprite( this, original ); - } - - public synchronized void updateScreen() - { - redrawAllLayers(); - } - - //---------------------------------------------------------------------------------- - - // - // XSpriteCanvas helper - // ==================== - // - public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t ) - { - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - //Graphics2D graph = getWindowGraphics(); - - // TODO: ensure update of graphics object externally, e.g. when - // VCL moves the toplevel window. - //java.awt.Rectangle bounds = dummyFrame.frame.getBounds(); - //graphics.setGraphics(graph, bounds.width, bounds.height); - - spriteRep.renderAnimation( animation, sprite.getViewState(), t ); - } - else - { - CanvasUtils.printLog( "CanvasTest.renderAnimation sprite not active!" ); - } - } - - public synchronized void showSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "CanvasTest.showSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - CanvasUtils.printLog( "CanvasTest.showSprite sprite already active!" ); - } - else - { - spriteRep = sprite.getSpriteRep(); - - // a valid SpriteRep for a given Sprite in the - // activeSprites hash denotes 'sprite active' - activeSprites.put( sprite, spriteRep ); - - // TODO: TEMP! Just for testing! Set empty cursor for presentation -// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0, -// java.awt.image.BufferedImage.TYPE_INT_RGB), -// new java.awt.Point(0,0), -// "") ); - } - } - - public synchronized void hideSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "CanvasTest.hideSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - activeSprites.put( sprite, null ); - redrawAllLayers(); - } - else - { - CanvasUtils.printLog( "CanvasTest.hideSprite sprite not active!" ); - } - } - - private void redrawAllLayers() - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - GraphicsDevice device = graph.getDeviceConfiguration().getDevice(); - CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() ); - - if( false ) - { - // TEST ONLY { - // repaint background - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.drawImage(backgroundBuffer, 0, 0, null); - //backgroundBuffer.flush(); - - // alpha-composite foreground on top of that - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, currAlpha) ); - - graph.drawImage(buffer, 0, 0, null); - //buffer.flush(); - - currAlpha += 0.1f; if( currAlpha > 1.0 ) currAlpha = 0.1f; - // TEST ONLY } - } - - if( true ) - { - // repaint background - backBuffer.redraw( graph ); - - // repaint all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).redraw(graph); - } - } - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( java.awt.Color.black ); - - try - { - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - CanvasUtils.printLog( fps.substring(0,5) + " fps" ); - } - catch( Exception e ) - { - graph.drawString( "0 fps", 0, 20); - } - - lastTime = currTime; - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.Canvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public synchronized String getImplementationName() - { - return s_implName; - } - - public synchronized String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public synchronized boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - CanvasTest.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/CanvasUtils.java b/canvas/source/java/CanvasUtils.java deleted file mode 100644 index 8b2245176e03..000000000000 --- a/canvas/source/java/CanvasUtils.java +++ /dev/null @@ -1,627 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class CanvasUtils -{ - // - // Canvas utilities - // ================ - // - public static java.awt.geom.AffineTransform makeTransform( AffineMatrix2D ooTransform ) - { - return new AffineTransform( ooTransform.m00, - ooTransform.m10, - ooTransform.m01, - ooTransform.m11, - ooTransform.m02, - ooTransform.m12 ); - } - - public static AffineMatrix2D makeAffineMatrix2D( java.awt.geom.AffineTransform transform ) - { - double[] matrix = new double[6]; - transform.getMatrix( matrix ); - - return new AffineMatrix2D( matrix[0], matrix[2], matrix[4], - matrix[1], matrix[3], matrix[5] ); - } - - public static void initGraphics( Graphics2D graphics ) - { - if( graphics != null ) - { - java.awt.RenderingHints hints = new java.awt.RenderingHints(null); - boolean hq = true; - - if( hq ) - { - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS, - java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON ) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, -// java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, - java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, -// java.awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, - java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, -// java.awt.RenderingHints.VALUE_RENDER_QUALITY) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, - java.awt.RenderingHints.VALUE_RENDER_SPEED) ); -// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, -// java.awt.RenderingHints.VALUE_STROKE_NORMALIZE) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, - java.awt.RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING, - java.awt.RenderingHints.VALUE_ANTIALIAS_ON) ); - } - else - { - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, - java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION, - java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING, - java.awt.RenderingHints.VALUE_RENDER_SPEED) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL, - java.awt.RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING, - java.awt.RenderingHints.VALUE_ANTIALIAS_OFF) ); - } - - // the least common denominator standard - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS, - java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON) ); - hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, - java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON) ); - - graphics.setRenderingHints( hints ); - } - } - - //---------------------------------------------------------------------------------- - - public static java.awt.geom.GeneralPath makeGenPathFromBezierPoints( RealBezierSegment2D [][] points ) - { - java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath(); - - // extract every polygon into GeneralPath object - for( int i=0; i<points.length; ++i ) - { - if( points[i].length > 0 ) - path.moveTo((float) points[i][0].Px, (float) points[i][0].Py); - - for( int j=1; j<points[i].length; ++j ) - { - CanvasUtils.printLog( "makeGenPathFromBezierPoints: point added." ); - path.curveTo((float)(points[i][j-1].C1x), (float)(points[i][j-1].C1y), - (float)(points[i][j-1].C2x), (float)(points[i][j-1].C2y), - (float) points[i][j].Px, (float) points[i][j].Py ); - } - - // TODO: closePath? - } - - return path; - } - - public static java.awt.geom.GeneralPath makeGenPathFromBezierPoly( com.sun.star.rendering.XBezierPolyPolygon2D poly ) - { - try - { - com.sun.star.geometry.RealBezierSegment2D [][] points = poly.getBezierSegments(0,-1,0,-1); - - return makeGenPathFromBezierPoints( points ); - } - catch( com.sun.star.lang.IndexOutOfBoundsException e ) - { - } - - return new java.awt.geom.GeneralPath(); - } - - public static java.awt.geom.GeneralPath makeGenPathFromLinePoints( RealPoint2D [][] points ) - { - java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath(); - - // extract every polygon into GeneralPath object - for( int i=0; i<points.length; ++i ) - { - if( points[i].length > 0 ) - path.moveTo((float) points[i][0].X, (float) points[i][0].Y); - - for( int j=1; j<points[i].length; ++j ) - { - CanvasUtils.printLog( "makeGenPathFromLinePoints: point (" + - points[i][j].X + "," + points[i][j].Y + ") added." ); - path.lineTo((float) points[i][j].X, (float) points[i][j].Y ); - } - - // TODO: closePath? - } - - return path; - } - - public static java.awt.geom.GeneralPath makeGenPathFromLinePoly( com.sun.star.rendering.XLinePolyPolygon2D poly ) - { - try - { - com.sun.star.geometry.RealPoint2D [][] points = poly.getPoints(0,-1,0,-1); - - return makeGenPathFromLinePoints( points ); - } - catch( com.sun.star.lang.IndexOutOfBoundsException e ) - { - } - - return new java.awt.geom.GeneralPath(); - } - - public static java.awt.geom.GeneralPath makeGeneralPath( com.sun.star.rendering.XPolyPolygon2D poly ) - { - if( poly instanceof BezierPolyPolygon ) - { - CanvasUtils.printLog( "makeGeneralPath: bezier impl used." ); - return ((BezierPolyPolygon)poly).getJavaPath(); - } - - if( poly instanceof LinePolyPolygon ) - { - CanvasUtils.printLog( "makeGeneralPath: line impl used." ); - return ((LinePolyPolygon)poly).getJavaPath(); - } - - XBezierPolyPolygon2D bezierPoly = (XBezierPolyPolygon2D) UnoRuntime.queryInterface(XBezierPolyPolygon2D.class, poly); - - if( bezierPoly != null ) - { - // extract polygon data. Prefer bezier interface, because - // that's the more high-level data. - return makeGenPathFromBezierPoly( bezierPoly ); - } - - XLinePolyPolygon2D linePoly = (XLinePolyPolygon2D) UnoRuntime.queryInterface(XLinePolyPolygon2D.class, poly); - - if( linePoly != null ) - { - // extract polygon data. Fallback to line polygon, if no - // curves are available. - return makeGenPathFromLinePoly( linePoly ); - } - - // Only opaque general interface. No chance to get to the - // data. Empty path, then - CanvasUtils.printLog( "makeGeneralPath: Cannot access polygon data, given interface has class" + poly.getClass().getName() ); - return new GeneralPath(); - } - - public static java.awt.image.BufferedImage getBufferedImage( com.sun.star.rendering.XBitmap bitmap ) - { - if( bitmap instanceof CanvasBitmap ) - { - CanvasUtils.printLog( "getBufferedImage: CanvasBitmap impl used." ); - return ((CanvasBitmap)bitmap).getBufferedImage(); - } - - XIntegerBitmap integerBitmap = (XIntegerBitmap) UnoRuntime.queryInterface(XIntegerBitmap.class, bitmap); - - if( integerBitmap != null ) - { - // extract bitmap data. TODO. - return null; - } - - // check other types. TODO. - return null; - } - - public static byte [] int2byte( int [] input ) - { - byte [] output = new byte[4*input.length]; - - int i, j; - for( i=0, j=0; i<input.length; ++i ) - { - output[j] = (byte)(input[i] & 255); - output[j+1] = (byte)((input[i]/256) & 255); - output[j+2] = (byte)((input[i]/256/256) & 255); - output[j+3] = (byte)((input[i]/256/256/256) & 255); - j += 4; - } - - return output; - } - - public static int [] byte2int( byte [] input ) - { - int [] output = new int[(input.length+3)/4]; - - int i, j; - for( i=0,j=0; j<output.length; ++j ) - { - output[j] = input[i] + (input[i+1] + (input[i+2] + input[i+3]*256)*256)*256; - i += 4; - } - - return output; - } - - public static int javaRuleFromCompositeOp( byte compositeOp ) - { - // TODO: Finish mapping of Canvas and Java compositing magics - int rule = java.awt.AlphaComposite.SRC_OVER; - switch( compositeOp ) - { - case com.sun.star.rendering.CompositeOperation.CLEAR: - CanvasUtils.printLog( "javaRuleFromCompositeOp: clear selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.SOURCE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: src selected" ); - rule = java.awt.AlphaComposite.SRC; - break; - - case com.sun.star.rendering.CompositeOperation.DESTINATION: - CanvasUtils.printLog( "javaRuleFromCompositeOp: dst selected" ); - rule = java.awt.AlphaComposite.DST; - break; - - case com.sun.star.rendering.CompositeOperation.OVER: - CanvasUtils.printLog( "javaRuleFromCompositeOp: over selected" ); - rule = java.awt.AlphaComposite.SRC_OVER; - break; - - case com.sun.star.rendering.CompositeOperation.UNDER: - CanvasUtils.printLog( "javaRuleFromCompositeOp: under selected" ); - rule = java.awt.AlphaComposite.DST_OVER; - break; - - case com.sun.star.rendering.CompositeOperation.INSIDE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: inside selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.INSIDE_REVERSE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: inReverse selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.OUTSIDE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: outside selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.OUTSIDE_REVERSE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: outReverse selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.XOR: - CanvasUtils.printLog( "javaRuleFromCompositeOp: xor selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.ADD: - CanvasUtils.printLog( "javaRuleFromCompositeOp: add selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - case com.sun.star.rendering.CompositeOperation.SATURATE: - CanvasUtils.printLog( "javaRuleFromCompositeOp: saturate selected" ); - rule = java.awt.AlphaComposite.CLEAR; - break; - - default: - CanvasUtils.printLog( "javaRuleFromCompositeOp: Unexpected compositing rule" ); - break; - } - - return rule; - } - - public static java.awt.AlphaComposite makeAlphaComposite( byte compositeOp ) - { - return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ) ); - } - - public static java.awt.AlphaComposite makeAlphaCompositeAlpha( byte compositeOp, double alpha ) - { - return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ), (float)alpha ); - } - - // when given to setupGraphicsState, makes that method to also - // setup the Paint with the color specified in the render state. - public static final byte alsoSetupPaint=0; - - // when given to setupGraphicsState, makes that method to _not_ - // setup the Paint with the color specified in the render state. - public static final byte dontSetupPaint=1; - - public static java.awt.geom.AffineTransform ViewConcatRenderTransform( ViewState viewState, - RenderState renderState ) - { - // calculate overall affine transform - AffineTransform transform = makeTransform( viewState.AffineTransform ); - transform.concatenate( makeTransform( renderState.AffineTransform ) ); - - printTransform( transform, "ViewConcatRenderTransform" ); - - return transform; - } - - public static void setupGraphicsState( java.awt.Graphics2D graphics, - ViewState viewState, - RenderState renderState, - byte paintTouchMode ) - { - // calculate overall affine transform - graphics.setTransform( ViewConcatRenderTransform(viewState, renderState ) ); - - // setup overall clip polyPolygon - if( viewState.Clip != null ) - { - Area clipArea = new Area( makeGeneralPath( viewState.Clip ) ); - - if( renderState.Clip != null ) - clipArea.intersect( new Area( makeGeneralPath( renderState.Clip ) ) ); - - graphics.setClip( clipArea ); - } - else if( renderState.Clip != null ) - { - Area clipArea = new Area( makeGeneralPath( renderState.Clip ) ); - graphics.setClip( clipArea ); - } - else - { - // TODO: HACK! Use true visible area here! - graphics.setClip( new java.awt.Rectangle(-1000000,-1000000,2000000,2000000) ); - } - - // setup current output color - // TODO: Complete color handling here - if( paintTouchMode == alsoSetupPaint ) - { - switch( renderState.DeviceColor.length ) - { - case 3: - CanvasUtils.printLog( "setupGraphicsState: Color(" + - renderState.DeviceColor[0] + "," + - renderState.DeviceColor[1] + "," + - renderState.DeviceColor[2] + ") set." ); - graphics.setColor( new Color( (float)renderState.DeviceColor[0], - (float)renderState.DeviceColor[1], - (float)renderState.DeviceColor[2] ) ); - break; - - case 4: - CanvasUtils.printLog( "setupGraphicsState: Color(" + - renderState.DeviceColor[0] + "," + - renderState.DeviceColor[1] + "," + - renderState.DeviceColor[2] + "," + - renderState.DeviceColor[3] + ") set." ); - graphics.setColor( new Color( (float)renderState.DeviceColor[0], - (float)renderState.DeviceColor[1], - (float)renderState.DeviceColor[2], - (float)renderState.DeviceColor[3] ) ); - break; - - default: - CanvasUtils.printLog( "setupGraphicsState: unexpected number of " + - renderState.DeviceColor.length + " color components!" ); - break; - } - } - - // setup current composite mode - graphics.setComposite( makeAlphaComposite( renderState.CompositeOperation ) ); - } - - public static void applyStrokeAttributes( java.awt.Graphics2D graphics, - StrokeAttributes attributes ) - { - int cap = java.awt.BasicStroke.CAP_BUTT; - - if( attributes.StartCapType != attributes.EndCapType ) - CanvasUtils.printLog( "applyStrokeAttributes: different start and end caps are not yet supported!" ); - - if( attributes.LineArray.length != 0 ) - CanvasUtils.printLog( "applyStrokeAttributes: multi-strokes are not yet supported!" ); - - if( attributes.StartCapType == PathCapType.BUTT ) - cap = java.awt.BasicStroke.CAP_BUTT; - else if( attributes.StartCapType == PathCapType.ROUND ) - cap = java.awt.BasicStroke.CAP_ROUND; - else if( attributes.StartCapType == PathCapType.SQUARE ) - cap = java.awt.BasicStroke.CAP_SQUARE; - - int join = java.awt.BasicStroke.JOIN_MITER; - - if( attributes.JoinType == PathJoinType.MITER ) - cap = java.awt.BasicStroke.JOIN_MITER; - else if( attributes.JoinType == PathJoinType.ROUND ) - cap = java.awt.BasicStroke.JOIN_ROUND; - else if( attributes.JoinType == PathJoinType.BEVEL ) - cap = java.awt.BasicStroke.JOIN_BEVEL; - else - CanvasUtils.printLog( "applyStrokeAttributes: current join type not yet supported!" ); - - float [] dashArray = null; - - if( attributes.DashArray.length != 0 ) - { - dashArray = new float [attributes.DashArray.length]; - - for( int i=0; i<attributes.DashArray.length; ++i ) - dashArray[i] = (float)attributes.DashArray[i]; - } - - graphics.setStroke( new java.awt.BasicStroke( (float)attributes.StrokeWidth, - cap, - join, - (float)attributes.MiterLimit, - dashArray, - 0) ); - } - - public static void setupGraphicsFont( java.awt.Graphics2D graphics, - ViewState viewState, - RenderState renderState, - com.sun.star.rendering.XCanvasFont xFont ) - { - if( xFont instanceof CanvasFont ) - { - CanvasUtils.printLog( "setupGraphicsFont: font impl used." ); - graphics.setFont( ((CanvasFont)xFont).getFont() ); - } - else - { - CanvasUtils.printLog( "setupGraphicsFont: creating Java font anew." ); - CanvasFont canvasFont; - canvasFont = new CanvasFont( xFont.getFontRequest(), null ); - graphics.setFont( canvasFont.getFont() ); - } - } - - static java.awt.geom.Rectangle2D.Double calcTransformedRectBounds( java.awt.geom.Rectangle2D.Double aRect, - AffineTransform aTransform ) - { - // transform rect by given transformation - java.awt.geom.Point2D.Double aPointTopLeft = new java.awt.geom.Point2D.Double(aRect.x, aRect.y); - aTransform.transform(aPointTopLeft, aPointTopLeft); - - java.awt.geom.Point2D.Double aPointTopRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width, - aRect.y); - aTransform.transform(aPointTopRight, aPointTopRight); - - java.awt.geom.Point2D.Double aPointBottomLeft = new java.awt.geom.Point2D.Double(aRect.x, - aRect.y + aRect.height); - aTransform.transform(aPointBottomLeft, aPointBottomLeft); - - java.awt.geom.Point2D.Double aPointBottomRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width, - aRect.y + aRect.height); - aTransform.transform(aPointBottomRight, aPointBottomRight); - - // calc bounding rect of those four points - java.awt.geom.Point2D.Double aResTopLeft = new java.awt.geom.Point2D.Double( Math.min(aPointTopLeft.x, - Math.min(aPointTopRight.x, - Math.min(aPointBottomLeft.x,aPointBottomRight.x))), - Math.min(aPointTopLeft.y, - Math.min(aPointTopRight.y, - Math.min(aPointBottomLeft.y,aPointBottomRight.y))) ); - - java.awt.geom.Point2D.Double aResBottomRight = new java.awt.geom.Point2D.Double( Math.max(aPointTopLeft.x, - Math.max(aPointTopRight.x, - Math.max(aPointBottomLeft.x,aPointBottomRight.x))), - Math.max(aPointTopLeft.y, - Math.max(aPointTopRight.y, - Math.max(aPointBottomLeft.y,aPointBottomRight.y))) ); - return new java.awt.geom.Rectangle2D.Double( aResTopLeft.x, aResTopLeft.y, - aResBottomRight.x - aResTopLeft.x, - aResBottomRight.y - aResTopLeft.y ); - } - - // Create a corrected view transformation out of the give one, - // which ensures that the rectangle given by (0,0) and - // attributes.untransformedSize is mapped with its left,top corner - // to (0,0) again. This is required to properly render sprite - // animations to buffer bitmaps. - public static ViewState createAnimationViewState( ViewState inputViewState, - AnimationAttributes attributes ) - { - // TODO: Properly respect clip here. Might have to be transformed, too. - - AffineTransform aViewTransform = makeTransform( inputViewState.AffineTransform ); - - // transform Rect(0,0,attributes.untransformedSize) by - // viewTransform - java.awt.geom.Rectangle2D.Double aTransformedRect = - calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0, 0.0, - attributes.UntransformedSize.Width, - attributes.UntransformedSize.Height), - aViewTransform ); - - printTransform( aViewTransform, "createAnimationViewState" ); - - CanvasUtils.printLog( "createAnimationViewState: transformed origin is: (" + aTransformedRect.x + ", " + aTransformedRect.y + ")" ); - - // now move resulting left,top point of bounds to (0,0) - AffineTransform animationViewTransform = new AffineTransform(); - animationViewTransform.translate( -aTransformedRect.x, -aTransformedRect.y ); - animationViewTransform.concatenate( aViewTransform ); - - printTransform( animationViewTransform, "createAnimationViewState" ); - - return new ViewState( makeAffineMatrix2D( animationViewTransform ), inputViewState.Clip ); - } - - public static void postRenderImageTreatment( Image buffer ) - { - // TODO: This is specific to Sun's JREs 1.4 and upwards. Make this more portable - buffer.flush(); // as long as we force images to VRAM, - // we need to flush them afterwards, to - // avoid eating up all VRAM. - } - - public static void printTransform( AffineTransform transform, - String stringPrefix ) - { - CanvasUtils.printLog( stringPrefix + ": Transform is" ); - double [] matrix = new double[6]; - transform.getMatrix(matrix); - int i; - for( i=0; i<6; ++i ) - System.err.print( matrix[i] + ", " ); - CanvasUtils.printLog( "" ); - } - - public static void preCondition( boolean bCondition, - String methodName ) - { - if( !bCondition ) - printLog("Precondition violated: " + methodName); - } - - public static void printLog( String s ) - { - System.err.println( s ); - } -} diff --git a/canvas/source/java/JavaCanvas.java b/canvas/source/java/JavaCanvas.java deleted file mode 100644 index fbee763fc272..000000000000 --- a/canvas/source/java/JavaCanvas.java +++ /dev/null @@ -1,675 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; - -// OOo AWT -import com.sun.star.awt.*; - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -// Java AWT -import java.awt.*; - -public class JavaCanvas - extends CanvasBase - implements com.sun.star.awt.XWindow, - com.sun.star.rendering.XSpriteCanvas, - com.sun.star.rendering.XIntegerBitmap, - com.sun.star.lang.XServiceInfo, - com.sun.star.lang.XInitialization -{ - private WindowAdapter dummyFrame; - public BackBuffer backBuffer; - private java.awt.image.BufferStrategy bufferStrategy; - - private java.awt.Font fpsFont; - private long lastTime; - private com.sun.star.awt.Rectangle boundRect; - - public Graphics2D getGraphics() - { - return backBuffer.getGraphics(); - } - - //---------------------------------------------------------------------------------- - - // - // XInitialization - // =============== - // - public void initialize( java.lang.Object[] arguments ) - { - CanvasUtils.printLog( "JavaCanvas.initialize called!" ); - - // Do that as the very first thing. The Java2D internal - // classes choose their render path at initialization time, - // thus this must happen before doing _any_ GUI. - - // TODO: Put those flags into javarc/java.ini, we're maybe - // coming late into a running JVM! - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - CanvasUtils.printLog( "System detected: " + os ); - - // tweak some speed knobs... -// if( os.startsWith("Windows") ) -// { -// System.setProperty("sun.java2d.translaccel", "true"); -// System.setProperty("sun.java2d.ddforcevram", "true"); -// //System.setProperty("sun.java2d.accthreshold", "0"); - -// CanvasUtils.printLog( "Optimizing for Windows" ); -// } -// else -// { -// System.setProperty("sun.java2d.opengl", "true"); - -// CanvasUtils.printLog( "Optimizing for Unix" ); -// } - - /* we're initialized with the following array of anys: - - arguments[0] = pointer to VCL window - arguments[1] = Integer (operating system window handle) - arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window) - arguments[3] = boolean (fullsize window or not) - - We then generate a dummy Java frame with that window as the - parent, to fake a root window for the Java implementation. - */ - try - { - boundRect = (com.sun.star.awt.Rectangle) arguments[2]; - - //boolean isFullScreen = arguments[1]; - boolean isFullScreen = true; - //AnyConverter.toBoolean( arguments[3] ) ); - - // fake a root for Java in VCL window. Pass the flag - // whether we shall run fullscreen, too. - dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen ); - - if( isFullScreen ) - { - // blow window up to fullscreen. Otherwise, we cannot clear the whole screen, - // which results in ugly flickering - Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize(); - boundRect.X = 0; - boundRect.Y = 0; - boundRect.Width = screenSize.width-1; - boundRect.Height = screenSize.height-1; - } - - dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 ); - CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height ); - - backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(), - Math.max(1,boundRect.Width), - Math.max(1,boundRect.Height) ); - - // TODO: Maybe delay double buffer init until first sprite creation - dummyFrame.frame.createBufferStrategy(2); - bufferStrategy = dummyFrame.frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using page flipping!" ); - else - CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using blitting!" ); - - lastTime = System.currentTimeMillis(); - fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 ); - - CanvasUtils.printLog( "JavaCanvas.initialize finished!" ); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - - //---------------------------------------------------------------------------------- - - // - // XComponent - // ========== - // - public void dispose() - { - CanvasUtils.printLog( "JavaCanvas: disposed!" ); - - // destroy all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).dispose(); - } - - if( bufferStrategy != null ) - bufferStrategy.getDrawGraphics().dispose(); // really necessary? - - if( dummyFrame != null ) - dummyFrame.dispose(); - - if( backBuffer != null) - backBuffer.dispose(); - - bufferStrategy = null; - dummyFrame = null; - backBuffer = null; - - super.dispose(); - } - - //---------------------------------------------------------------------------------- - - public JavaCanvas( XComponentContext xContext ) - { - CanvasUtils.printLog( "JavaCanvas constructor called!" ); - activeSprites = new java.util.HashMap( 33 ); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - // This is delegated to WindowAdapter! - // - public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - if( dummyFrame != null ) - { - dummyFrame.setPosSize( X, Y, Width, Height, Flags ); - - Width = Math.max(1,Width); - Height= Math.max(1,Height); - - CanvasUtils.printLog( "JavaCanvas graphics set to " + Width + "," + Height ); - backBuffer.setSize(Width,Height); - } - } - - public synchronized com.sun.star.awt.Rectangle getPosSize( ) - { - if( dummyFrame != null ) - return dummyFrame.getPosSize(); - - return new com.sun.star.awt.Rectangle(); - } - - public synchronized void setVisible( boolean visible ) - { - if( dummyFrame != null ) - dummyFrame.setVisible( visible ); - } - - public synchronized void setEnable( boolean enable ) - { - if( dummyFrame != null ) - dummyFrame.setEnable( enable ); - } - - public synchronized void setFocus() - { - if( dummyFrame != null ) - dummyFrame.setFocus(); - } - - public synchronized void addWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addWindowListener( xListener ); - } - - public synchronized void removeWindowListener( XWindowListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeWindowListener( xListener ); - } - - public synchronized void addFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addFocusListener( xListener ); - } - - public synchronized void removeFocusListener( XFocusListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeFocusListener( xListener ); - } - - public synchronized void addKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addKeyListener( xListener ); - } - - public synchronized void removeKeyListener( XKeyListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeKeyListener( xListener ); - } - - public synchronized void addMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseListener( xListener ); - } - - public synchronized void removeMouseListener( XMouseListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseListener( xListener ); - } - - public synchronized void addMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addMouseMotionListener( xListener ); - } - - public synchronized void removeMouseMotionListener( XMouseMotionListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removeMouseMotionListener( xListener ); - } - - public synchronized void addPaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.addPaintListener( xListener ); - } - - public synchronized void removePaintListener( XPaintListener xListener ) - { - if( dummyFrame != null ) - dummyFrame.removePaintListener( xListener ); - } - - //---------------------------------------------------------------------------------- - - // - // XBitmapCanvas impl - // ================== - // - - public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas, - com.sun.star.geometry.RealRectangle2D sourceRect, - com.sun.star.rendering.ViewState sourceViewState, - com.sun.star.rendering.RenderState sourceRenderState, - com.sun.star.geometry.RealRectangle2D destRect, - com.sun.star.rendering.ViewState destViewState, - com.sun.star.rendering.RenderState destRenderState ) - { - CanvasUtils.printLog( "JavaCanvas.copyRect() called" ); - - // TODO: create temp image when transform is non-trivial - - if( sourceCanvas == this ) - { - // copy rectangle within the canvas - getGraphics().copyArea((int)sourceRect.X1, - (int)sourceRect.Y1, - (int)(sourceRect.X2 - sourceRect.X1), - (int)(sourceRect.Y2 - sourceRect.Y1), - (int)(destRect.X1 - sourceRect.X1), - (int)(destRect.Y1 - sourceRect.Y1) ); - } - else - { - if( sourceCanvas instanceof JavaCanvas ) - { - // cache - CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint ); - - java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer(); - - // TODO: really extract correct source rect here - getGraphics().drawImage( backBuffer, 0, 0, null); - CanvasUtils.postRenderImageTreatment( backBuffer ); - } - // TODO: foreign canvas - } - } - - //---------------------------------------------------------------------------------- - - // a map of SpriteReps, with Sprite object as keys. Contains all - // active (i.e. visible) sprites, the SpriteReps are used to - // repaint the sprite content at any time. - private java.util.HashMap activeSprites; - - // - // XSpriteCanvas impl - // ================== - // - - public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation ) - { - CanvasUtils.printLog( "JavaCanvas.createSpriteFromAnimation called" ); - - return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps, - byte interpolationMode ) - { - return null; - } - - public synchronized XCustomSprite createCustomSprite( RealSize2D spriteSize ) - { - CanvasUtils.printLog( "JavaCanvas.createCustomSprite called" ); - - return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() ); - } - - public synchronized XSprite createClonedSprite( XSprite original ) - { - return new CanvasClonedSprite( this, original ); - } - - public synchronized boolean updateScreen( boolean bUpdateAll ) - { - redrawAllLayers(); - - return true; - } - - // - // XBitmap implementation - // ====================== - // - - public synchronized IntegerSize2D getSize() - { - return new IntegerSize2D( boundRect.Width, - boundRect.Height ); - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapCanvas queryBitmapCanvas() - { - return this; - } - - //---------------------------------------------------------------------------------- - - public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized boolean hasAlpha() - { - // TODO - return false; - } - - //---------------------------------------------------------------------------------- - - // - // XIntegerBitmap implementation - // ============================= - // - - public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout, - IntegerRectangle2D rect ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout, - IntegerPoint2D pos ) - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized XBitmapPalette getPalette() - { - // TODO - return null; - } - - //---------------------------------------------------------------------------------- - - public synchronized IntegerBitmapLayout getMemoryLayout() - { - // TODO: finish that one - IntegerBitmapLayout layout = new IntegerBitmapLayout(); - - return layout; - } - - //---------------------------------------------------------------------------------- - - // - // XSpriteCanvas helper - // ==================== - // - public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t ) - { - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - //Graphics2D graph = getWindowGraphics(); - - // TODO: ensure update of graphics object externally, e.g. when - // VCL moves the toplevel window. - //java.awt.Rectangle bounds = dummyFrame.frame.getBounds(); - //graphics.setGraphics(graph, bounds.width, bounds.height); - - spriteRep.renderAnimation( animation, sprite.getViewState(), t ); - } - else - { - CanvasUtils.printLog( "JavaCanvas.renderAnimation sprite not active!" ); - } - } - - public synchronized void showSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "JavaCanvas.showSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - CanvasUtils.printLog( "JavaCanvas.showSprite sprite already active!" ); - } - else - { - spriteRep = sprite.getSpriteRep(); - - // a valid SpriteRep for a given Sprite in the - // activeSprites hash denotes 'sprite active' - activeSprites.put( sprite, spriteRep ); - - // TODO: TEMP! Just for testing! Set empty cursor for presentation -// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0, -// java.awt.image.BufferedImage.TYPE_INT_RGB), -// new java.awt.Point(0,0), -// "") ); - } - } - - public synchronized void hideSprite( SpriteBase sprite ) - { - CanvasUtils.printLog( "JavaCanvas.hideSprite() called" ); - - SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite ); - if( spriteRep != null ) - { - activeSprites.put( sprite, null ); - redrawAllLayers(); - } - else - { - CanvasUtils.printLog( "JavaCanvas.hideSprite sprite not active!" ); - } - } - - private void redrawAllLayers() - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - GraphicsDevice device = graph.getDeviceConfiguration().getDevice(); - CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() ); - - // repaint background - backBuffer.redraw( graph ); - - // repaint all active sprites - java.util.Set entries = activeSprites.entrySet(); - java.util.Iterator iter = entries.iterator(); - while( iter.hasNext() ) - { - java.util.Map.Entry entry = (java.util.Map.Entry)iter.next(); - if( entry.getValue() != null ) - ((SpriteRep)entry.getValue()).redraw(graph); - } - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( java.awt.Color.black ); - - try - { - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - CanvasUtils.printLog( fps.substring(0,5) + " fps" ); - } - catch( Exception e ) - { - graph.drawString( "0 fps", 0, 20); - } - - lastTime = currTime; - } - catch( Exception e ) - { - CanvasUtils.printLog( "Exception thrown in redrawAllLayers" ); - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - //---------------------------------------------------------------------------------- - - private static final String s_implName = "XCanvas.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.JavaCanvas"; - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - public synchronized String getImplementationName() - { - return s_implName; - } - - public synchronized String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public synchronized boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - JavaCanvas.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/LinePolyPolygon.java b/canvas/source/java/LinePolyPolygon.java deleted file mode 100644 index 3ab19d97ba19..000000000000 --- a/canvas/source/java/LinePolyPolygon.java +++ /dev/null @@ -1,192 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; -import com.sun.star.geometry.*; - -public class LinePolyPolygon - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XLinePolyPolygon2D -{ - private java.awt.geom.GeneralPath path; - - //---------------------------------------------------------------------------------- - - public LinePolyPolygon( RealPoint2D[][] points ) - { - setPoints( points, 0 ); - } - - public java.awt.geom.GeneralPath getJavaPath() - { - return path; - } - - //---------------------------------------------------------------------------------- - - // - // XPolyPolygon implementation - // =========================== - // - public synchronized void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon ) - { - } - - public synchronized int getNumberOfPolygons( ) - { - return 0; - } - - public synchronized int getNumberOfPolygonPoints( int polygon ) - { - return 0; - } - - public synchronized FillRule getFillRule( ) - { - if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD ) - return FillRule.EVEN_ODD; - else - return FillRule.NON_ZERO; - } - - public synchronized void setFillRule( FillRule fillRule ) - { - if( fillRule == FillRule.EVEN_ODD ) - path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD ); - else - path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO ); - } - - public synchronized boolean isClosed( int index ) - { - // TODO - return false; - } - - public synchronized void setClosed( int index, boolean closedState ) - { - // TODO - } - - //---------------------------------------------------------------------------------- - - // - // XLinePolyPolygon implementation - // =============================== - // - public synchronized RealPoint2D[][] getPoints( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints ) - { - // TODO: Implement subsetting - -// double [] points = new double[6]; - -// // BAH! Use util.Vector here! - -// // find number of subpaths -// PathIterator aIter = path.getPathIterator( new AffineTransform() ); -// int nNumSubPaths = 0; -// while( !aIter.isDone() ) -// { -// if( aIter.currentSegment(points) == SEG_MOVETO ) -// ++nNumSubPaths; - -// aIter.next(); -// } - -// Point2D [][] aRes = new Point2D[nNumSubPaths][]; -// aIter = path.getPathIterator( new AffineTransform() ); -// while( !aIter.isDone() ) -// { -// switch( aIter.currentSegment(points) ) -// { -// case SEG_MOVETO: -// break; - -// case SEG_LINETO: -// break; - -// case SEG_CLOSE: -// break; - -// default: -// CanvasUtils.printLog( "LinePolyPolygon.getPoints(): unexpected path type" ); -// break; -// } - -// aIter.next(); -// } -// double [] points = new double[6]; - - return null; - } - - public synchronized void setPoints( RealPoint2D[][] points, int nPolygonIndex ) - { - if( nPolygonIndex != 0 ) - CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" ); - - path = CanvasUtils.makeGenPathFromLinePoints( points ); - } - - public synchronized RealPoint2D getPoint( int nPolygonIndex, int nPointIndex ) - { - return null; - } - - public synchronized void setPoint( RealPoint2D point, int nPolygonIndex, int nPointIndex ) - { - CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" ); - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "XLinePolyPolygon2D.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.LinePolyPolygon2D"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/SpriteRep.java b/canvas/source/java/SpriteRep.java deleted file mode 100644 index 046a45f2d9bb..000000000000 --- a/canvas/source/java/SpriteRep.java +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -// Java AWT -import java.awt.*; -import java.awt.geom.*; - -public class SpriteRep -{ - private java.awt.image.BufferedImage buffer; - private CanvasBitmap canvasBitmap; - private double alpha; - private java.awt.geom.Point2D.Double outputPosition; - private boolean bufferOwned; - - //---------------------------------------------------------------------------------- - - // TODO: Everything in this class - // TODO: Implement lifetime control for buffer object, which is shared between SpriteReps - public SpriteRep() - { - CanvasUtils.printLog( "SpriteRep constructor called!" ); - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - bufferOwned = true; // the buffer member is our own, and has to be disposed - } - - public SpriteRep( SpriteRep original ) - { - CanvasUtils.printLog( "SpriteRep clone constructor called!" ); - - alpha = 0.0; - outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0); - cloneBuffer( original ); - bufferOwned = false; // the buffer member is not our own, and must not be disposed - } - - //---------------------------------------------------------------------------------- - - public synchronized void renderAnimation( XAnimation animation, ViewState viewState, double t ) - { - if( canvasBitmap != null ) - { - // clear buffer with all transparent - Graphics2D bitmapGraphics = canvasBitmap.getGraphics(); - - // before that, setup _everything_ we might have changed in CanvasUtils.setupGraphicsState - bitmapGraphics.setColor( new Color( 0.0f, 0.0f, 0.0f, 1.0f ) ); - bitmapGraphics.setComposite( - java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.CLEAR)); - bitmapGraphics.setTransform( new AffineTransform() ); - bitmapGraphics.setClip( new java.awt.Rectangle(0,0,buffer.getWidth(),buffer.getHeight()) ); - bitmapGraphics.fillRect(0,0,buffer.getWidth(),buffer.getHeight()); - - try - { - // now push the animation at time instance t into the - // virginal graphics - animation.render(canvasBitmap, viewState, t); - } - catch( com.sun.star.lang.IllegalArgumentException e ) - { - CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" ); - } - } - } - - public synchronized void setSpriteAlpha( double _alpha ) - { - CanvasUtils.printLog("SpriteRep.setSpriteAlpha called with alpha=" + alpha); - alpha = _alpha; - } - - public synchronized void moveSprite( java.awt.geom.Point2D.Double aNewPos ) - { - outputPosition = aNewPos; - CanvasUtils.printLog( "SpriteRep.moveSprite: moving to (" + outputPosition.x + ", " + outputPosition.y + ")" ); - } - - public synchronized void redraw( Graphics2D output ) - { - if( buffer != null ) - { - CanvasUtils.printLog( "SpriteRep.redraw: compositing with alpha=" + alpha ); - output.setComposite( java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, (float)alpha) ); - - output.drawImage( buffer, - (int)(outputPosition.getX() + .5), - (int)(outputPosition.getY() + .5), - null ); - - //CanvasUtils.postRenderImageTreatment( buffer ); - - CanvasUtils.printLog( "SpriteRep.redraw called, output rect is (" + - outputPosition.getX() + ", " + - outputPosition.getY() + ", " + - buffer.getWidth() + ", " + - buffer.getHeight() + ")" ); - } - } - - public synchronized void setupBuffer( java.awt.Graphics2D graphics, int width, int height ) - { - if( canvasBitmap != null ) - canvasBitmap.dispose(); - - if( buffer != null ) - buffer.flush(); - - buffer = graphics.getDeviceConfiguration().createCompatibleImage(Math.max(1,width), - Math.max(1,height), - Transparency.TRANSLUCENT); - canvasBitmap = new CanvasBitmap( buffer ); - CanvasUtils.initGraphics( canvasBitmap.getGraphics() ); - - CanvasUtils.printLog( "SpriteRep.setupBuffer called, with dimensions (" + width + ", " + height + ")" ); - } - - public synchronized void cloneBuffer( SpriteRep original ) - { - buffer = original.buffer; - } - - public synchronized com.sun.star.rendering.XCanvas getContentCanvas() - { - CanvasUtils.printLog( "SpriteRep.getContentCanvas() called" ); - - Graphics2D graphics = canvasBitmap.getGraphics(); - graphics.setTransform( new AffineTransform() ); - graphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - graphics.fillRect( 0,0,buffer.getWidth(),buffer.getHeight() ); - - return canvasBitmap; - } - - public void dispose() - { - if( canvasBitmap != null ) - canvasBitmap.dispose(); - - if( buffer != null && bufferOwned ) - buffer.flush(); - - canvasBitmap = null; - buffer = null; - } -} diff --git a/canvas/source/java/SpriteRunner.java b/canvas/source/java/SpriteRunner.java deleted file mode 100644 index 17e472e7e5c7..000000000000 --- a/canvas/source/java/SpriteRunner.java +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -// -// HOWTO get a Graphics2D from a window -// - -// import javax.swing.*; -// import java.awt.*; -// import java.awt.geom.*; - -// public class Stroke1 extends JFrame { -// Stroke drawingStroke = new BasicStroke(5); -// Rectangle2D rect = -// new Rectangle2D.Double(20, 40, 100, 40); - -// public void paint(Graphics g) { -// Graphics2D g2d = (Graphics2D)g; -// g2d.setStroke(drawingStroke); -// g2d.draw(rect); -// } - -// public static void main(String args[]) { -// JFrame frame = new Stroke1(); -// frame.setDefaultCloseOperation(EXIT_ON_CLOSE); -// frame.setSize(200, 100); -// frame.show(); -// } -// } - - -public class SpriteRunner - extends Thread -{ - private CanvasSprite sprite; - private XAnimation spriteAnimation; - private JavaCanvas canvas; - private double startTime; - private double currentSpeed; - private double currentT; - private boolean animationActive; - private boolean stayAlive; - - //---------------------------------------------------------------------------------- - - public SpriteRunner( CanvasSprite _sprite, XAnimation _animation, JavaCanvas _canvas ) - { - CanvasUtils.printLog( "SpriteRunner constructor called!" ); - - sprite = _sprite; - spriteAnimation = _animation; - canvas = _canvas; - startTime = 0.0; - currentSpeed = 0.0; - currentT = 0.0; - animationActive = false; - stayAlive = true; - - // Set priority to lower-than-normal, as this thread runs the - // animation in a busy loop. - setPriority( MIN_PRIORITY ); - } - - //---------------------------------------------------------------------------------- - - // - // Thread - // ====== - // - // Overriding - // - public void run() - { - // perform the animation rendering (as fast as possible, for now) - - while( stayAlive ) - { - while( animationActive ) - { - // to determine the current animation step to render, calc the - // elapsed time since this animation was started - double elapsedTime = getCurrentTime() - startTime; - - // the frame to render is determined by mapping the cycle - // duration (currentSpeed) to the [0,1] range of the animation. - currentT = (elapsedTime % currentSpeed) / currentSpeed; - - // delegate animation rendering to SpriteCanvas, as - // only this instance can enforce consistency (on-time - // saving of background etc.) - canvas.renderAnimation( sprite, spriteAnimation, currentT ); - - // TODO: Consolidate _all_ sprites per canvas into one - // thread, call updateScreen() only after all sprites - // have been processed. - - //Make changes visible - canvas.updateScreen( false ); - - // TODO: Evaluate vs. setPriority and other means -// try -// { -// // give other tasks some time to breathe (10ms - this is only meant symbolically) -// sleep(10); -// } catch( InterruptedException e ) { } - } - - // wait until animation is activated again - try - { - wait(); - } - catch( InterruptedException e ) { } - catch( IllegalMonitorStateException e ) { } - } - } - - public synchronized void startAnimation( double speed ) - { - resetAnimation(); - currentSpeed = speed; - - // start us, if not done already - if( !isAlive() ) - start(); - - // enable animation thread - animationActive = true; - - try - { - notify(); - } catch( IllegalMonitorStateException e ) { } - } - - public synchronized void stopAnimation() - { - // stop animation after the current frame has been completely - // rendered - animationActive = false; - } - - public synchronized void resetAnimation() - { - startTime = getCurrentTime(); - } - - public synchronized boolean isAnimationActive() - { - return animationActive; - } - - public synchronized void quit() - { - stayAlive = false; - stopAnimation(); - } - - public synchronized double getCurrentT() - { - return currentT; - } - - //---------------------------------------------------------------------------------- - - // helper - static double getCurrentTime() - { - // determine current time in seconds - java.util.Calendar cal = new java.util.GregorianCalendar(); - return cal.getTimeInMillis() / 1000.0; - } -} diff --git a/canvas/source/java/TextLayout.java b/canvas/source/java/TextLayout.java deleted file mode 100644 index 1a443fcbeeac..000000000000 --- a/canvas/source/java/TextLayout.java +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// Canvas -import com.sun.star.rendering.*; - -public class TextLayout - extends com.sun.star.lib.uno.helper.ComponentBase - implements com.sun.star.lang.XServiceInfo, - com.sun.star.rendering.XTextLayout -{ - private double[] advancements; - private StringContext text; - private byte direction; - private CanvasBase associatedCanvas; - private CanvasFont font; - - //---------------------------------------------------------------------------------- - - public TextLayout( StringContext aText, - byte nDirection, - long nRandomSeed, - CanvasFont _font, - CanvasBase _canvas ) - { - text = aText; - direction = nDirection; - associatedCanvas = _canvas; - font = _font; - } - - // - // XTextLayout implementation - // ========================== - // - - public XPolyPolygon2D[] queryTextShapes( ) - { - // TODO - return null; - } - - public com.sun.star.geometry.RealRectangle2D[] queryInkMeasures( ) - { - // TODO - return null; - } - - public com.sun.star.geometry.RealRectangle2D[] queryMeasures( ) - { - // TODO - return null; - } - - public double[] queryLogicalAdvancements( ) - { - // TODO - return null; - } - - public void applyLogicalAdvancements( double[] aAdvancements ) throws com.sun.star.lang.IllegalArgumentException - { - if( aAdvancements.length != text.Length ) - throw new com.sun.star.lang.IllegalArgumentException(); - - advancements = aAdvancements; - } - - public com.sun.star.geometry.RealRectangle2D queryTextBounds( ) - { - // TODO - return null; - } - - public double justify( double nSize ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return 0; - } - - public double combinedJustify( XTextLayout[] aNextLayouts, double nSize ) throws com.sun.star.lang.IllegalArgumentException - { - // TODO - return 0; - } - - public TextHit getTextHit( /*IN*/com.sun.star.geometry.RealPoint2D aHitPoint ) - { - // TODO - return null; - } - - public Caret getCaret( int nInsertionIndex, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public int getNextInsertionIndex( int nStartIndex, int nCaretAdvancement, boolean bExcludeLigatures ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return 0; - } - - public XPolyPolygon2D queryVisualHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public XPolyPolygon2D queryLogicalHighlighting( int nStartIndex, int nEndIndex ) throws com.sun.star.lang.IndexOutOfBoundsException - { - // TODO - return null; - } - - public double getBaselineOffset( ) - { - // TODO - return 0.0; - } - - public byte getMainTextDirection( ) - { - return direction; - } - - public XCanvasFont getFont( ) - { - return font; - } - - public StringContext getText( ) - { - return text; - } - - public boolean draw( java.awt.Graphics2D graphics ) - { - // TODO: use proper advancement. Text direction need not be horizontal! - // TODO: given text string need not have a one-to-one relationship between code point and glyph (offset)! - graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition + 1), (float)0.0, (float)0.0 ); - for( int i=1; i<advancements.length && i<text.Length; ++i ) - { - CanvasUtils.printLog( "XCanvas: drawOffsettedText rendering a \"" + - text.Text.substring(text.StartPosition + i, - text.StartPosition + i + 1) + - "\" (position " + (text.StartPosition + i) + - " of " + text.Text + ", offset " + advancements[i] + ")" ); - - graphics.drawString( text.Text.substring(text.StartPosition + i, text.StartPosition + i + 1), (float)advancements[i-1], (float)0.0 ); - } - - return true; - } - - //---------------------------------------------------------------------------------- - - // - // XServiceInfo impl - // ================= - // - - private static final String s_implName = "CanvasFont.java.impl"; - private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont"; - - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } -} diff --git a/canvas/source/java/aqua/WindowAdapter.java b/canvas/source/java/aqua/WindowAdapter.java deleted file mode 100644 index 2529bb56e55c..000000000000 --- a/canvas/source/java/aqua/WindowAdapter.java +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// system-dependent stuff -import sun.awt.*; - -//Apple specifics -import apple.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Aqua): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(Aqua): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - // create the embedded frame - if( os.startsWith("Mac OS X") ) - frame = new apple.awt.CEmbeddedFrame( windowHandle ); - else - throw new com.sun.star.uno.RuntimeException(); - - -// frame = new javax.swing.JFrame( "Test window" ); - -// // resize it according to the given bounds -// frame.setBounds( boundRect ); -// frame.setVisible( true ); - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Aqua): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/java_Service.java b/canvas/source/java/java_Service.java deleted file mode 100644 index 6fcaa1581ca8..000000000000 --- a/canvas/source/java/java_Service.java +++ /dev/null @@ -1,118 +0,0 @@ - -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.awt.*; - -public class java_Service - extends com.sun.star.lib.uno.helper.WeakBase - implements com.sun.star.lang.XServiceInfo, foo.XBar -{ - private XToolkit m_xToolkit; - private XVclWindowPeer m_xPeer; - private javax.swing.JFrame m_frame; - - public java_Service( XComponentContext xContext ) - { - try - { - m_xToolkit = - (XToolkit) UnoRuntime.queryInterface( - XToolkit.class, - xContext.getServiceManager().createInstanceWithContext( - "com.sun.star.awt.Toolkit", xContext ) ); - } - catch (com.sun.star.uno.Exception exc) - { - throw new com.sun.star.uno.RuntimeException( - "exception occured gettin toolkit: " + exc, this ); - } - } - - // XBar impl - public void raiseAndCloseWindows( foo.XBar [] seq ) - throws com.sun.star.uno.Exception - { - for ( int nPos = 0; nPos < seq.length; ++nPos ) - seq[ nPos ].raiseWindows( "called by Java code" ); - - // modal dialog before closing - javax.swing.JOptionPane.showMessageDialog( - null, "[Java] all windows created." ); - - for ( int nPos = 0; nPos < seq.length; ++nPos ) - seq[ nPos ].closeWindows(); - } - - public void raiseWindows( String msg ) - throws com.sun.star.uno.Exception - { - // create java frame - m_frame = new javax.swing.JFrame( - "[java frame created by Java code] " + msg ); - m_frame.setSize( 500, 50 ); - m_frame.setLocation( 200, 500 ); - m_frame.setVisible( true ); - - // create office workwindow - m_xPeer = (XVclWindowPeer) UnoRuntime.queryInterface( - XVclWindowPeer.class, - m_xToolkit.createWindow( - new WindowDescriptor( - WindowClass.TOP, "workwindow", null, (short) -1, - new Rectangle( 800, 500, 500, 50 ), - WindowAttribute.SHOW | - WindowAttribute.BORDER | - WindowAttribute.SIZEABLE | - WindowAttribute.MOVEABLE | - WindowAttribute.CLOSEABLE ) ) ); - m_xPeer.setProperty( - "Title", "[office window created by Java code] " + msg ); - } - - public void closeWindows() - throws com.sun.star.uno.Exception - { - m_frame.dispose(); - m_xPeer.dispose(); - } - - - private static final String s_implName = "foo.java.impl"; - private static final String s_serviceName = "foo.java"; - - // XServiceInfo impl - public String getImplementationName() - { - return s_implName; - } - - public String [] getSupportedServiceNames() - { - return new String [] { s_serviceName }; - } - - public boolean supportsService( String serviceName ) - { - return serviceName.equals( s_serviceName ); - } - - public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory( - String implName, - com.sun.star.lang.XMultiServiceFactory multiFactory, - com.sun.star.registry.XRegistryKey regKey ) - { - if (implName.equals( s_implName )) - { - return com.sun.star.comp.loader.FactoryHelper.getServiceFactory( - java_Service.class, s_serviceName, multiFactory, regKey ); - } - return null; - } - - public static boolean __writeRegistryServiceInfo( - com.sun.star.registry.XRegistryKey regKey ) - { - return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo( - s_implName, s_serviceName, regKey ); - } -} diff --git a/canvas/source/java/makefile.mk b/canvas/source/java/makefile.mk deleted file mode 100644 index 86f329e4fe3b..000000000000 --- a/canvas/source/java/makefile.mk +++ /dev/null @@ -1,93 +0,0 @@ -#************************************************************************* -# -# 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. -# -#************************************************************************* - -# Builds the Java Canvas implementation. - -PRJNAME = canvas -PRJ = ..$/.. -TARGET = javacanvas -PACKAGE = canvas - -USE_JAVAVER:=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE: settings.mk - -.IF "$(SOLAR_JAVA)"=="TRUE" -# Since Canvas needs newer features like -# e.g. java.awt.image.BufferStrategy, -# disabled for now for everything <1.4 -.IF "$(JAVANUMVER:s/.//)" >= "000100040000" - -JAVAFILES = \ - SpriteBase.java \ - JavaCanvas.java \ - CanvasGraphicDevice.java \ - CanvasUtils.java \ - CanvasFont.java \ - CanvasBitmap.java \ - CanvasSprite.java \ - CanvasCustomSprite.java \ - CanvasClonedSprite.java \ - TextLayout.java \ - BackBuffer.java \ - LinePolyPolygon.java \ - BezierPolyPolygon.java \ - SpriteRunner.java - -.IF "$(GUIBASE)"=="unx" - -JAVAFILES += x11/WindowAdapter.java - -.ELIF "$(GUIBASE)"=="aqua" - -JAVAFILES += aqua/WindowAdapter.java - -.ELSE - -JAVAFILES += win/WindowAdapter.java - -.ENDIF # "$(GUIBASE)"=="unx" - -JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar -#JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -JARTARGET = $(TARGET).uno.jar -JARCOMPRESS = TRUE -#JARCLASSDIRS = $(PACKAGE) -CUSTOMMANIFESTFILE = manifest - -.ENDIF # "$(JAVANUMVER:s/.//)" >= "000100040000" -.ENDIF # "$(SOLAR_JAVA)"=="TRUE" - -# --- Targets ------------------------------------------------------ - -.INCLUDE: target.mk - -#dist: $(JAVA_FILES:b:+".class") -# +jar -cvfm $(CLASSDIR)/JavaCanvas.jar $(JARMANIFEST) $(JAVACLASSFILES) diff --git a/canvas/source/java/manifest b/canvas/source/java/manifest deleted file mode 100644 index 6ddc3ab0ae51..000000000000 --- a/canvas/source/java/manifest +++ /dev/null @@ -1 +0,0 @@ -RegistrationClassName: JavaCanvas diff --git a/canvas/source/java/perftest/PerfTest.java b/canvas/source/java/perftest/PerfTest.java deleted file mode 100644 index 98e3cc5c3de5..000000000000 --- a/canvas/source/java/perftest/PerfTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; - - -public class PerfTest -{ - // the frame object we're generating. TODO: Remove public access. - private Frame frame; - private boolean fullscreen; - - public PerfTest() - { - fullscreen = false; - - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "PerformanceTest" ); - frame.setBounds( new Rectangle(0,0,1600,1200) ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - System.err.println( "entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - System.err.println( "fullscreen not supported" ); - } - - graphics.dispose(); - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - System.err.println( "leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - public static void initGraphics( Graphics2D graphics ) - { - if( graphics != null ) - { - RenderingHints hints = new RenderingHints(null); - boolean hq = true; - - if( hq ) - { - hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON ) ); -// hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, -// RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) ); - hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, - RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); -// hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, -// RenderingHints.VALUE_INTERPOLATION_BICUBIC) ); - hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); -// hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, -// RenderingHints.VALUE_RENDER_QUALITY) ); - hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_SPEED) ); -// hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, -// RenderingHints.VALUE_STROKE_NORMALIZE) ); - hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, - RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON) ); - } - else - { - hints.add( new RenderingHints( RenderingHints.KEY_ALPHA_INTERPOLATION, - RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) ); - hints.add( new RenderingHints( RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR) ); - hints.add( new RenderingHints( RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_SPEED) ); - hints.add( new RenderingHints( RenderingHints.KEY_STROKE_CONTROL, - RenderingHints.VALUE_STROKE_DEFAULT) ); - hints.add( new RenderingHints( RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_OFF) ); - } - - // the least common denominator standard - hints.add( new RenderingHints( RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON) ); - hints.add( new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON) ); - - graphics.setRenderingHints( hints ); - } - } - - public void run() - { - frame.createBufferStrategy(2); - BufferStrategy bufferStrategy = frame.getBufferStrategy(); - - if( bufferStrategy.getCapabilities().isPageFlipping() ) - System.err.println( "double buffering is using page flipping" ); - else - System.err.println( "double buffering is using blitting" ); - - int width = 1600; - int height = 1200; - Graphics2D graphics = (Graphics2D)frame.getGraphics(); - VolatileImage backBuffer = graphics.getDeviceConfiguration().createCompatibleVolatileImage(width,height); // TODO: size dynamic - BufferedImage buffer = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - BufferedImage buffer2 = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - BufferedImage buffer3 = graphics.getDeviceConfiguration().createCompatibleImage(width,height, - Transparency.TRANSLUCENT); - - GraphicsDevice device = graphics.getDeviceConfiguration().getDevice(); - System.err.println( "Images generated. Available vram: " + device.getAvailableAcceleratedMemory() ); - - Graphics2D bufferGraphics = (Graphics2D)buffer.getGraphics(); - Graphics2D buffer2Graphics = (Graphics2D)buffer2.getGraphics(); - Graphics2D buffer3Graphics = (Graphics2D)buffer3.getGraphics(); - Graphics2D backBufGraphics = (Graphics2D)backBuffer.getGraphics(); - - System.err.println( "Image graphics generated. Available vram: " + device.getAvailableAcceleratedMemory() ); - - // init Graphics - initGraphics( graphics ); - initGraphics( bufferGraphics ); - initGraphics( buffer2Graphics ); - initGraphics( backBufGraphics ); - - // init content - Font font = new Font( "Times", Font.PLAIN, 100 ); - Font fpsFont = new Font( "Times", Font.PLAIN, 20 ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR)); - bufferGraphics.fillRect( 0,0,width,height ); - - bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); - bufferGraphics.setColor( Color.red ); - bufferGraphics.fillRect( 0,0,width/2,height/2 ); - bufferGraphics.setColor( Color.green ); - bufferGraphics.fillRect( width/2,0,width,height/2 ); - bufferGraphics.setColor( Color.blue ); - bufferGraphics.fillRect( 0,height/2,width/2,height ); - - buffer2Graphics.setColor( Color.red ); - buffer2Graphics.fillRect( 0,0,width/2,height/2 ); - buffer2Graphics.setColor( Color.green ); - buffer2Graphics.fillRect( width/2,0,width,height/2 ); - buffer2Graphics.setColor( Color.blue ); - buffer2Graphics.fillRect( 0,height/2,width/2,height ); - - buffer3Graphics.setColor( Color.blue ); - buffer3Graphics.fillRect( 0,0,width/2,height/2 ); - buffer3Graphics.setColor( Color.white ); - buffer3Graphics.fillRect( width/2,0,width,height/2 ); - buffer3Graphics.setColor( Color.gray ); - buffer3Graphics.fillRect( 0,height/2,width/2,height ); - - backBufGraphics.setColor( Color.white ); - backBufGraphics.fillRect(0,0,width,height); - backBufGraphics.setColor( Color.red ); - backBufGraphics.setFont( font ); - int i, turns=15; - for(i=0; i<turns; ++i) - { - backBufGraphics.drawString( "Crossfade test", width*i/turns, height*i/turns ); - } - - System.err.println( "Images filled with content. Available vram: " + device.getAvailableAcceleratedMemory() ); - - long lastTime = System.currentTimeMillis(); - int turn, numTurns = 100; - for(turn=0; turn<numTurns; ++turn) - { - // fetch the Graphics object to draw into (we're doing double - // buffering here, the content is later shown via - // bufferStrategy.show(). - Graphics2D graph = null; - - try - { - graph = (Graphics2D)bufferStrategy.getDrawGraphics(); - - try - { - // repaint background - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.drawImage(backBuffer, 0, 0, null); - - // alpha-composite foreground on top of that - float alpha = turn/(float)numTurns; - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha) ); - - graph.drawImage(buffer, 0, 0, null); - buffer.flush(); - graph.drawImage(buffer2, 100, 100, null); - buffer2.flush(); - - long currTime = System.currentTimeMillis(); - graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) ); - graph.setFont( fpsFont ); - graph.setColor( Color.black ); - String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) ); - System.err.println( "Images composited. Framerate: " + fps + " fps" ); - graph.drawString( fps.substring(0,5) + " fps", 0, 20); - lastTime = currTime; - - System.err.println( "Available vram: " + device.getAvailableAcceleratedMemory() ); - } - catch( Exception e ) - { - } - - System.err.println( "Turn: " + turn ); - } - finally - { - if( graph != null ) - graph.dispose(); - } - - bufferStrategy.show(); - } - - try - { - Thread.sleep(2000); - } - catch( Exception e ) - { - } - } - - //---------------------------------------------------------------------------------- - - public static void main(String[] args) - { - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println( "System detected: " + os ); - - // tweak some speed knobs... - if( os.startsWith("Windows") ) - { - System.setProperty("sun.java2d.translaccel", "true"); - System.setProperty("sun.java2d.ddforcevram", "true"); - //System.setProperty("sun.java2d.accthreshold", "0"); - - System.err.println( "Optimizing for Windows" ); - } - else - { - System.setProperty("sun.java2d.opengl", "true"); - - System.err.println( "Optimizing for Unix" ); - } - - PerfTest test = new PerfTest(); - - test.run(); - - test.dispose(); - } - - //---------------------------------------------------------------------------------- - -} diff --git a/canvas/source/java/perftest/WindowAdapter.java b/canvas/source/java/perftest/WindowAdapter.java deleted file mode 100644 index fa34e6720fc7..000000000000 --- a/canvas/source/java/perftest/WindowAdapter.java +++ /dev/null @@ -1,197 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -import sun.awt.*; -import com.sun.star.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - // the frame object we're generating. TODO: Remove public access. - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - CanvasUtils.printLog( "WindowAdapter(X11): constructor called" ); - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println("WindowAdapter created"); - - // create the embedded frame - if( os.startsWith("Linux") ) - { - // create a java frame from that - // TODO: Maybe that's the reason why we crash on Linux 1.5beta - // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame - - //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); - //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile - CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" ); - frame = null; - } - else - { - throw new com.sun.star.uno.RuntimeException(); - } - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/perftest/makefile.mk b/canvas/source/java/perftest/makefile.mk deleted file mode 100644 index 787a42adfb74..000000000000 --- a/canvas/source/java/perftest/makefile.mk +++ /dev/null @@ -1,55 +0,0 @@ -#************************************************************************* -# -# 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. -# -#************************************************************************* - -# Builds the Java Canvas implementation. - -PRJNAME = canvas -PRJ = ../../.. -TARGET = PerfTest -PACKAGE = test - -# --- Settings ----------------------------------------------------- - -.INCLUDE: settings.mk - -JAVAFILES = \ - PerfTest.java - -JARFILES = jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE -#JARCLASSDIRS = $(PACKAGE) -CUSTOMMANIFESTFILE = manifest - -# --- Targets ------------------------------------------------------ - -.INCLUDE: target.mk - -#dist: $(JAVA_FILES:b:+".class") -# +jar -cvfm $(CLASSDIR)/PerfTest.jar $(JARMANIFEST) $(JAVACLASSFILES) diff --git a/canvas/source/java/perftest/manifest b/canvas/source/java/perftest/manifest deleted file mode 100644 index 805a87d47b57..000000000000 --- a/canvas/source/java/perftest/manifest +++ /dev/null @@ -1 +0,0 @@ -RegistrationClassName: PerfTest diff --git a/canvas/source/java/win/WindowAdapter.java b/canvas/source/java/win/WindowAdapter.java deleted file mode 100644 index 6cfe54db5991..000000000000 --- a/canvas/source/java/win/WindowAdapter.java +++ /dev/null @@ -1,199 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// UNO -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.uno.AnyConverter; -import com.sun.star.lang.XInitialization; -import com.sun.star.lib.uno.helper.WeakBase; - -// OOo AWT -import com.sun.star.awt.*; - -// system-dependent stuff -import sun.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Win32): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(Win32): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - // create the embedded frame - if( os.startsWith("Windows") ) - frame = new sun.awt.windows.WEmbeddedFrame( windowHandle ); - else - throw new com.sun.star.uno.RuntimeException(); - - -// frame = new javax.swing.JFrame( "Test window" ); - -// // resize it according to the given bounds -// frame.setBounds( boundRect ); -// frame.setVisible( true ); - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(Win32): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/java/x11/WindowAdapter.java b/canvas/source/java/x11/WindowAdapter.java deleted file mode 100644 index 555f6c8ca1b8..000000000000 --- a/canvas/source/java/x11/WindowAdapter.java +++ /dev/null @@ -1,197 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -import com.sun.star.awt.*; - - -public class WindowAdapter -// defacto implementing the interface, but not deriving from it, since -// we're no real XInterface here -// implements com.sun.star.awt.XWindow -{ - // the frame object we're generating. TODO: Remove public access. - public java.awt.Frame frame; - private boolean fullscreen; - - public WindowAdapter( int windowHandle, - boolean _fullscreen ) - { - CanvasUtils.printLog( "WindowAdapter(X11): constructor called" ); - fullscreen = false; - - if( _fullscreen ) - { - // create a normal Java frame, and set it into fullscreen mode - frame = new javax.swing.JFrame( "Presentation" ); - frame.setUndecorated( true ); - frame.setVisible( true ); - - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): entering fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame ); - fullscreen = true; - } - else - { - CanvasUtils.printLog( "WindowAdapter(X11): fullscreen not supported" ); - } - - graphics.dispose(); - } - else - { - // we're initialized with the operating system window handle - // as the parameter. We then generate a dummy Java frame with - // that window as the parent, to fake a root window for the - // Java implementation. - - // now, we're getting slightly system dependent here. - String os = (String) System.getProperty("os.name"); - - System.err.println("WindowAdapter created"); - - // create the embedded frame - if( os.startsWith("Linux") ) - { - // create a java frame from that - // TODO: Maybe that's the reason why we crash on Linux 1.5beta - // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame - - // TODO - //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); // Crashes 1.5, because class is unknown - //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile, because class is not in 1.4. - CanvasUtils.printLog( "WindowAdapter(X11): no frame created for now" ); - frame = null; // disabled for now - } - else - { - throw new com.sun.star.uno.RuntimeException(); - } - } - } - - //---------------------------------------------------------------------------------- - - public void dispose() - { - if( fullscreen ) - { - java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics(); - if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() ) - { - CanvasUtils.printLog( "WindowAdapter(X11): leaving fullscreen mode" ); - graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null ); - } - graphics.dispose(); - } - - if( frame != null ) - frame.dispose(); - } - - //---------------------------------------------------------------------------------- - - // - // XWindow interface - // ================= - // - public void setPosSize( int X, int Y, int Width, int Height, short Flags ) - { - frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) ); - } - - public com.sun.star.awt.Rectangle getPosSize( ) - { - java.awt.Rectangle bounds = frame.getBounds(); - - return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); - } - - public void setVisible( boolean visible ) - { - frame.setVisible( visible ); - } - - public void setEnable( boolean enable ) - { - frame.setEnabled( enable ); - } - - public void setFocus() - { - } - - public void addWindowListener( XWindowListener xListener ) - { - } - - public void removeWindowListener( XWindowListener xListener ) - { - } - - public void addFocusListener( XFocusListener xListener ) - { - } - - public void removeFocusListener( XFocusListener xListener ) - { - } - - public void addKeyListener( XKeyListener xListener ) - { - } - - public void removeKeyListener( XKeyListener xListener ) - { - } - - public void addMouseListener( XMouseListener xListener ) - { - } - - public void removeMouseListener( XMouseListener xListener ) - { - } - - public void addMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void removeMouseMotionListener( XMouseMotionListener xListener ) - { - } - - public void addPaintListener( XPaintListener xListener ) - { - } - - public void removePaintListener( XPaintListener xListener ) - { - } -} diff --git a/canvas/source/null/exports.map b/canvas/source/null/exports.map deleted file mode 100644 index 4101b0d761a9..000000000000 --- a/canvas/source/null/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -CAN_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/canvas/source/null/makefile.mk b/canvas/source/null/makefile.mk index 98bf2c5c9b71..07971ef8153e 100644 --- a/canvas/source/null/makefile.mk +++ b/canvas/source/null/makefile.mk @@ -60,7 +60,7 @@ SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp diff --git a/canvas/source/null/null_spritecanvas.hxx b/canvas/source/null/null_spritecanvas.hxx index 662897a3df10..136e09a291db 100644 --- a/canvas/source/null/null_spritecanvas.hxx +++ b/canvas/source/null/null_spritecanvas.hxx @@ -38,7 +38,7 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <cppuhelper/compbase8.hxx> #include <comphelper/uno3.hxx> @@ -57,7 +57,7 @@ namespace nullcanvas typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::rendering::XSpriteCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::rendering::XBufferController, ::com::sun::star::awt::XWindowListener, ::com::sun::star::beans::XPropertySet, diff --git a/canvas/source/simplecanvas/exports.map b/canvas/source/simplecanvas/exports.map deleted file mode 100644 index 4101b0d761a9..000000000000 --- a/canvas/source/simplecanvas/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -CAN_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/canvas/source/simplecanvas/makefile.mk b/canvas/source/simplecanvas/makefile.mk index dc99c0a9bbc9..4d5a7e7bb3a1 100644 --- a/canvas/source/simplecanvas/makefile.mk +++ b/canvas/source/simplecanvas/makefile.mk @@ -52,7 +52,7 @@ SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx index 7ce8d02038b9..ad833cc3ca40 100644..100755 --- a/canvas/source/tools/canvastools.cxx +++ b/canvas/source/tools/canvastools.cxx @@ -991,6 +991,54 @@ namespace canvas return aPolyPoly; } + int calcGradientStepCount( ::basegfx::B2DHomMatrix& rTotalTransform, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState, + const rendering::Texture& texture, + int nColorSteps ) + { + // calculate overall texture transformation (directly from + // texture to device space). + ::basegfx::B2DHomMatrix aMatrix; + + rTotalTransform.identity(); + ::basegfx::unotools::homMatrixFromAffineMatrix( rTotalTransform, + texture.AffineTransform ); + ::canvas::tools::mergeViewAndRenderTransform(aMatrix, + viewState, + renderState); + rTotalTransform *= aMatrix; // prepend total view/render transformation + + // determine size of gradient in device coordinate system + // (to e.g. determine sensible number of gradient steps) + ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 ); + ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 ); + ::basegfx::B2DPoint aRightTop( 1.0, 0.0 ); + ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 ); + + aLeftTop *= rTotalTransform; + aLeftBottom *= rTotalTransform; + aRightTop *= rTotalTransform; + aRightBottom*= rTotalTransform; + + // longest line in gradient bound rect + const int nGradientSize( + static_cast<int>( + ::std::max( + ::basegfx::B2DVector(aRightBottom-aLeftTop).getLength(), + ::basegfx::B2DVector(aRightTop-aLeftBottom).getLength() ) + 1.0 ) ); + + // typical number for pixel of the same color (strip size) + const int nStripSize( nGradientSize < 50 ? 2 : 4 ); + + // use at least three steps, and at utmost the number of color + // steps + return ::std::max( 3, + ::std::min( + nGradientSize / nStripSize, + nColorSteps ) ); + } + } // namespace tools } // namespace canvas diff --git a/canvas/source/tools/image.cxx b/canvas/source/tools/image.cxx index 2b7d38abc8ea..b6183e463e99 100644 --- a/canvas/source/tools/image.cxx +++ b/canvas/source/tools/image.cxx @@ -1512,7 +1512,7 @@ void Image::fillGradientImpl( const ParametricPolyPolygon::Values& rValues, typedef color_generator_adaptor<color_type> color_generator_type; unsigned int dwNumSteps = static_cast<unsigned int>(rBounds.getWidth()); color_generator_type colors(color1,color2,dwNumSteps); - colors.set_linear(rValues.meType != ParametricPolyPolygon::GRADIENT_AXIAL); + colors.set_linear(true); // color = f(x,y) gradient_polymorphic_wrapper<agg::gradient_x> gf_x; diff --git a/canvas/source/tools/parametricpolypolygon.cxx b/canvas/source/tools/parametricpolypolygon.cxx index db449f6c15f8..368f04a572e3 100644 --- a/canvas/source/tools/parametricpolypolygon.cxx +++ b/canvas/source/tools/parametricpolypolygon.cxx @@ -50,68 +50,126 @@ using namespace ::com::sun::star; namespace canvas { - ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient( - const uno::Reference< rendering::XGraphicDevice >& rDevice, - const uno::Sequence< uno::Sequence< double > >& colors, - const uno::Sequence< double >& stops ) + uno::Sequence<rtl::OUString> ParametricPolyPolygon::getAvailableServiceNames() { - // TODO(P2): hold gradient brush statically, and only setup - // the colors - return new ParametricPolyPolygon( rDevice, GRADIENT_LINEAR, colors, stops ); + uno::Sequence<rtl::OUString> aRet(3); + aRet[0] = rtl::OUString::createFromAscii("LinearGradient"); + aRet[1] = rtl::OUString::createFromAscii("EllipticalGradient"); + aRet[2] = rtl::OUString::createFromAscii("RectangularGradient"); + + return aRet; + } + + ParametricPolyPolygon* ParametricPolyPolygon::create( + const uno::Reference< rendering::XGraphicDevice >& rDevice, + const ::rtl::OUString& rServiceName, + const uno::Sequence< uno::Any >& rArgs ) + { + uno::Sequence< uno::Sequence< double > > colorSequence(2); + uno::Sequence< double > colorStops(2); + double fAspectRatio=1.0; + + // defaults + uno::Sequence< rendering::RGBColor > rgbColors(1); + rgbColors[0] = rendering::RGBColor(0,0,0); + colorSequence[0] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors); + rgbColors[0] = rendering::RGBColor(1,1,1); + colorSequence[1] = rDevice->getDeviceColorSpace()->convertFromRGB(rgbColors); + colorStops[0] = 0; + colorStops[1] = 1; + + // extract args + for( sal_Int32 i=0; i<rArgs.getLength(); ++i ) + { + beans::PropertyValue aProp; + if( (rArgs[i] >>= aProp) ) + { + if( aProp.Name.equalsAscii("Colors") ) + { + aProp.Value >>= colorSequence; + } + else if( aProp.Name.equalsAscii("Stops") ) + { + aProp.Value >>= colorStops; + } + else if( aProp.Name.equalsAscii("AspectRatio") ) + { + aProp.Value >>= fAspectRatio; + } + } + } + + if( rServiceName.equalsAscii("LinearGradient") ) + { + return createLinearHorizontalGradient(rDevice, colorSequence, colorStops); + } + else if( rServiceName.equalsAscii("EllipticalGradient") ) + { + return createEllipticalGradient(rDevice, colorSequence, colorStops, fAspectRatio); + } + else if( rServiceName.equalsAscii("RectangularGradient") ) + { + return createRectangularGradient(rDevice, colorSequence, colorStops, fAspectRatio); + } + else if( rServiceName.equalsAscii("VerticalLineHatch") ) + { + // TODO: NYI + } + else if( rServiceName.equalsAscii("OrthogonalLinesHatch") ) + { + // TODO: NYI + } + else if( rServiceName.equalsAscii("ThreeCrossingLinesHatch") ) + { + // TODO: NYI + } + else if( rServiceName.equalsAscii("FourCrossingLinesHatch") ) + { + // TODO: NYI + } + + return NULL; } - ParametricPolyPolygon* ParametricPolyPolygon::createAxialHorizontalGradient( + ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice, const uno::Sequence< uno::Sequence< double > >& colors, const uno::Sequence< double >& stops ) { // TODO(P2): hold gradient brush statically, and only setup // the colors - return new ParametricPolyPolygon( rDevice, GRADIENT_AXIAL, colors, stops ); - } - - namespace - { - double calcAspectRatio( const geometry::RealRectangle2D& rBoundRect ) - { - const double nWidth( rBoundRect.X2 - rBoundRect.X1 ); - const double nHeight( rBoundRect.Y2 - rBoundRect.Y1 ); - - return ::basegfx::fTools::equalZero( nHeight ) ? 1.0 : fabs( nWidth / nHeight ); - } + return new ParametricPolyPolygon( rDevice, GRADIENT_LINEAR, colors, stops ); } ParametricPolyPolygon* ParametricPolyPolygon::createEllipticalGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice, const uno::Sequence< uno::Sequence< double > >& colors, const uno::Sequence< double >& stops, - const geometry::RealRectangle2D& boundRect ) + double fAspectRatio ) { // TODO(P2): hold gradient polygon statically, and only setup // the colors return new ParametricPolyPolygon( rDevice, ::basegfx::tools::createPolygonFromCircle( - ::basegfx::B2DPoint( 0.5, 0.5), 0.5 ), + ::basegfx::B2DPoint(0,0), 1 ), GRADIENT_ELLIPTICAL, - colors, stops, - calcAspectRatio( boundRect ) ); + colors, stops, fAspectRatio ); } ParametricPolyPolygon* ParametricPolyPolygon::createRectangularGradient( const uno::Reference< rendering::XGraphicDevice >& rDevice, const uno::Sequence< uno::Sequence< double > >& colors, const uno::Sequence< double >& stops, - const geometry::RealRectangle2D& boundRect ) + double fAspectRatio ) { // TODO(P2): hold gradient polygon statically, and only setup // the colors return new ParametricPolyPolygon( rDevice, ::basegfx::tools::createPolygonFromRect( - ::basegfx::B2DRectangle( 0.0, 0.0, 1.0, 1.0 ) ), + ::basegfx::B2DRectangle( -1, -1, 1, 1 ) ), GRADIENT_RECTANGULAR, - colors, stops, - calcAspectRatio( boundRect ) ); + colors, stops, fAspectRatio ); } void SAL_CALL ParametricPolyPolygon::disposing() diff --git a/canvas/source/tools/verifyinput.cxx b/canvas/source/tools/verifyinput.cxx index c2ee4ed968a0..42ab1c7aee19 100644 --- a/canvas/source/tools/verifyinput.cxx +++ b/canvas/source/tools/verifyinput.cxx @@ -426,7 +426,7 @@ namespace canvas #endif } - if( texture.RepeatModeX < rendering::TexturingMode::CLAMP || + if( texture.RepeatModeX < rendering::TexturingMode::NONE || texture.RepeatModeX > rendering::TexturingMode::REPEAT ) { #if OSL_DEBUG_LEVEL > 0 @@ -442,7 +442,7 @@ namespace canvas #endif } - if( texture.RepeatModeY < rendering::TexturingMode::CLAMP || + if( texture.RepeatModeY < rendering::TexturingMode::NONE || texture.RepeatModeY > rendering::TexturingMode::REPEAT ) { #if OSL_DEBUG_LEVEL > 0 diff --git a/canvas/source/vcl/canvas.hxx b/canvas/source/vcl/canvas.hxx index f7667d8f2c19..adda8d8eea40 100644 --- a/canvas/source/vcl/canvas.hxx +++ b/canvas/source/vcl/canvas.hxx @@ -38,7 +38,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase7.hxx> #include <comphelper/uno3.hxx> @@ -60,7 +59,7 @@ namespace vclcanvas typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::util::XUpdatable, ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base; diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index f82ce1344a5c..a83b260d52d5 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -1387,7 +1387,7 @@ namespace vclcanvas const ::Size& rSz, const GraphicAttr& rAttr ) const { - ENSURE_OR_RETURN( rGrf, + ENSURE_OR_RETURN_FALSE( rGrf, "Invalid Graphic" ); if( !mpOutDev ) diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx index 11350c0b4f9f..023ceb2b5005 100644..100755 --- a/canvas/source/vcl/canvashelper_texturefill.cxx +++ b/canvas/source/vcl/canvashelper_texturefill.cxx @@ -54,6 +54,8 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dlinegeometry.hxx> #include <basegfx/tools/tools.hxx> +#include <basegfx/tools/lerp.hxx> +#include <basegfx/tools/keystoplerp.hxx> #include <basegfx/tools/canvastools.hxx> #include <basegfx/numeric/ftools.hxx> @@ -62,6 +64,9 @@ #include <canvas/canvastools.hxx> #include <canvas/parametricpolypolygon.hxx> +#include <boost/bind.hpp> +#include <boost/tuple/tuple.hpp> + #include "spritecanvas.hxx" #include "canvashelper.hxx" #include "impltools.hxx" @@ -115,17 +120,13 @@ namespace vclcanvas Since most of the code for linear and axial gradients are the same, we've a unified method here */ - void fillGeneralLinearGradient( OutputDevice& rOutDev, - const ::basegfx::B2DHomMatrix& rTextureTransform, - const ::Rectangle& rBounds, - int nStepCount, - const ::Color& rColor1, - const ::Color& rColor2, - bool bFillNonOverlapping, - bool bAxialGradient ) + void fillLinearGradient( OutputDevice& rOutDev, + const ::basegfx::B2DHomMatrix& rTextureTransform, + const ::Rectangle& rBounds, + unsigned int nStepCount, + const ::canvas::ParametricPolyPolygon::Values& rValues, + const std::vector< ::Color >& rColors ) { - (void)bFillNonOverlapping; - // determine general position of gradient in relation to // the bound rect // ===================================================== @@ -204,36 +205,26 @@ namespace vclcanvas // iteratively render all other strips // ----------------------------------- - // ensure that nStepCount is odd, to have a well-defined - // middle index for axial gradients. - if( bAxialGradient && !(nStepCount % 2) ) + // ensure that nStepCount matches color stop parity, to + // have a well-defined middle color e.g. for axial + // gradients. + if( (rColors.size() % 2) != (nStepCount % 2) ) ++nStepCount; - const int nStepCountHalved( nStepCount / 2 ); + basegfx::tools::KeyStopLerp aLerper(rValues.maStops); // only iterate nStepCount-1 steps, as the last strip is // explicitely painted below - for( int i=0; i<nStepCount-1; ++i ) + for( unsigned int i=0; i<nStepCount-1; ++i ) { - // lerp color - if( bAxialGradient ) - { - // axial gradient has a triangle-like interpolation function - const int iPrime( i<=nStepCountHalved ? i : nStepCount-i-1); + std::ptrdiff_t nIndex; + double fAlpha; + boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(double(i)/nStepCount); - rOutDev.SetFillColor( - Color( (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetRed() + iPrime*rColor2.GetRed())/nStepCountHalved), - (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetGreen() + iPrime*rColor2.GetGreen())/nStepCountHalved), - (UINT8)(((nStepCountHalved - iPrime)*rColor1.GetBlue() + iPrime*rColor2.GetBlue())/nStepCountHalved) ) ); - } - else - { - // linear gradient has a plain lerp between start and end color - rOutDev.SetFillColor( - Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) ); - } + rOutDev.SetFillColor( + Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) )); // copy right egde of polygon to left edge (and also // copy the closing point) @@ -280,59 +271,18 @@ namespace vclcanvas aTempPoly[3] = ::Point( ::basegfx::fround( rPoint4.getX() ), ::basegfx::fround( rPoint4.getY() ) ); - if( bAxialGradient ) - rOutDev.SetFillColor( rColor1 ); - else - rOutDev.SetFillColor( rColor2 ); + rOutDev.SetFillColor( rColors.back() ); rOutDev.DrawPolygon( aTempPoly ); } - - inline void fillLinearGradient( OutputDevice& rOutDev, - const ::Color& rColor1, - const ::Color& rColor2, - const ::basegfx::B2DHomMatrix& rTextureTransform, - const ::Rectangle& rBounds, - int nStepCount, - bool bFillNonOverlapping ) - { - fillGeneralLinearGradient( rOutDev, - rTextureTransform, - rBounds, - nStepCount, - rColor1, - rColor2, - bFillNonOverlapping, - false ); - } - - inline void fillAxialGradient( OutputDevice& rOutDev, - const ::Color& rColor1, - const ::Color& rColor2, - const ::basegfx::B2DHomMatrix& rTextureTransform, - const ::Rectangle& rBounds, - int nStepCount, - bool bFillNonOverlapping ) - { - fillGeneralLinearGradient( rOutDev, - rTextureTransform, - rBounds, - nStepCount, - rColor1, - rColor2, - bFillNonOverlapping, - true ); - } - void fillPolygonalGradient( OutputDevice& rOutDev, - const ::canvas::ParametricPolyPolygon::Values& rValues, - const ::Color& rColor1, - const ::Color& rColor2, const ::basegfx::B2DHomMatrix& rTextureTransform, const ::Rectangle& rBounds, - int nStepCount, - bool bFillNonOverlapping ) + unsigned int nStepCount, + bool bFillNonOverlapping, + const ::canvas::ParametricPolyPolygon::Values& rValues, + const std::vector< ::Color >& rColors ) { const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly ); @@ -366,9 +316,6 @@ namespace vclcanvas // apply scaling (possibly anisotrophic) to inner polygon // ------------------------------------------------------ - // move center of scaling to origin - aInnerPolygonTransformMatrix.translate( -0.5, -0.5 ); - // scale inner polygon according to aspect ratio: for // wider-than-tall bounds (nAspectRatio > 1.0), the inner // polygon, representing the gradient focus, must have @@ -393,9 +340,6 @@ namespace vclcanvas aInnerPolygonTransformMatrix.scale( 0.0, 0.0 ); } - // move origin back to former center of polygon - aInnerPolygonTransformMatrix.translate( 0.5, 0.5 ); - // and finally, add texture transform to it. aInnerPolygonTransformMatrix *= rTextureTransform; @@ -403,8 +347,8 @@ namespace vclcanvas aInnerPoly.transform( aInnerPolygonTransformMatrix ); - const sal_Int32 nNumPoints( aOuterPoly.count() ); - ::Polygon aTempPoly( static_cast<USHORT>(nNumPoints+1) ); + const sal_uInt32 nNumPoints( aOuterPoly.count() ); + ::Polygon aTempPoly( static_cast<USHORT>(nNumPoints+1) ); // increase number of steps by one: polygonal gradients have // the outermost polygon rendered in rColor2, and the @@ -422,37 +366,42 @@ namespace vclcanvas // color). ++nStepCount; + basegfx::tools::KeyStopLerp aLerper(rValues.maStops); + if( !bFillNonOverlapping ) { // fill background - rOutDev.SetFillColor( rColor1 ); + rOutDev.SetFillColor( rColors.front() ); rOutDev.DrawRect( rBounds ); // render polygon // ============== - for( int i=1,p; i<nStepCount; ++i ) + for( unsigned int i=1,p; i<nStepCount; ++i ) { + const double fT( i/double(nStepCount) ); + + std::ptrdiff_t nIndex; + double fAlpha; + boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT); + // lerp color rOutDev.SetFillColor( - Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) ); + Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) )); // scale and render polygon, by interpolating between // outer and inner polygon. - // calc interpolation parameter in [0,1] range - const double nT( (nStepCount-i)/double(nStepCount) ); - for( p=0; p<nNumPoints; ++p ) { const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) ); const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) ); aTempPoly[(USHORT)p] = ::Point( - basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ), - basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) ); + basegfx::fround( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ), + basegfx::fround( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) ); } // close polygon explicitely @@ -486,13 +435,19 @@ namespace vclcanvas aTempPolyPoly.Insert( aTempPoly ); aTempPolyPoly.Insert( aTempPoly2 ); - for( int i=0,p; i<nStepCount; ++i ) + for( unsigned int i=0,p; i<nStepCount; ++i ) { + const double fT( (i+1)/double(nStepCount) ); + + std::ptrdiff_t nIndex; + double fAlpha; + boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT); + // lerp color rOutDev.SetFillColor( - Color( (UINT8)(((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount), - (UINT8)(((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount) ) ); + Color( (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha)), + (UINT8)(basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha)) )); #if defined(VERBOSE) && OSL_DEBUG_LEVEL > 0 if( i && !(i % 10) ) @@ -503,17 +458,14 @@ namespace vclcanvas // calculate the inner polygon, which is actually the // start of the _next_ color strip. Thus, i+1 - // calc interpolation parameter in [0,1] range - const double nT( (nStepCount-i-1)/double(nStepCount) ); - for( p=0; p<nNumPoints; ++p ) { const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) ); const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) ); aTempPoly[(USHORT)p] = ::Point( - basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ), - basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) ); + basegfx::fround( fT*rInnerPoint.getX() + (1-fT)*rOuterPoint.getX() ), + basegfx::fround( fT*rInnerPoint.getY() + (1-fT)*rOuterPoint.getY() ) ); } // close polygon explicitely @@ -546,46 +498,33 @@ namespace vclcanvas void doGradientFill( OutputDevice& rOutDev, const ::canvas::ParametricPolyPolygon::Values& rValues, - const ::Color& rColor1, - const ::Color& rColor2, + const std::vector< ::Color >& rColors, const ::basegfx::B2DHomMatrix& rTextureTransform, const ::Rectangle& rBounds, - int nStepCount, + unsigned int nStepCount, bool bFillNonOverlapping ) { switch( rValues.meType ) { case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR: fillLinearGradient( rOutDev, - rColor1, - rColor2, rTextureTransform, rBounds, nStepCount, - bFillNonOverlapping ); - break; - - case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL: - fillAxialGradient( rOutDev, - rColor1, - rColor2, - rTextureTransform, - rBounds, - nStepCount, - bFillNonOverlapping ); + rValues, + rColors ); break; case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL: // FALLTHROUGH intended case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR: fillPolygonalGradient( rOutDev, - rValues, - rColor1, - rColor2, rTextureTransform, rBounds, nStepCount, - bFillNonOverlapping ); + bFillNonOverlapping, + rValues, + rColors ); break; default: @@ -594,11 +533,19 @@ namespace vclcanvas } } + int numColorSteps( const ::Color& rColor1, const ::Color& rColor2 ) + { + return ::std::max( + labs( rColor1.GetRed() - rColor2.GetRed() ), + ::std::max( + labs( rColor1.GetGreen() - rColor2.GetGreen() ), + labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ); + } + bool gradientFill( OutputDevice& rOutDev, OutputDevice* p2ndOutDev, const ::canvas::ParametricPolyPolygon::Values& rValues, - const ::Color& rColor1, - const ::Color& rColor2, + const std::vector< ::Color >& rColors, const PolyPolygon& rPoly, const rendering::ViewState& viewState, const rendering::RenderState& renderState, @@ -612,65 +559,27 @@ namespace vclcanvas // deadlocks, canvashelper calls this method with locked own // mutex. - // calculate overall texture transformation (directly from - // texture to device space). - ::basegfx::B2DHomMatrix aMatrix; - ::basegfx::B2DHomMatrix aTextureTransform; - - ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform, - texture.AffineTransform ); - ::canvas::tools::mergeViewAndRenderTransform(aMatrix, - viewState, - renderState); - aTextureTransform *= aMatrix; // prepend total view/render transformation - - // determine maximal bound rect of gradient-filled polygon - const ::Rectangle aPolygonDeviceRectOrig( - rPoly.GetBoundRect() ); - - // determine size of gradient in device coordinate system - // (to e.g. determine sensible number of gradient steps) - ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 ); - ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 ); - ::basegfx::B2DPoint aRightTop( 1.0, 0.0 ); - ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 ); - - aLeftTop *= aTextureTransform; - aLeftBottom *= aTextureTransform; - aRightTop *= aTextureTransform; - aRightBottom*= aTextureTransform; - - // calc step size // -------------- - const int nColorSteps( - ::std::max( - labs( rColor1.GetRed() - rColor2.GetRed() ), - ::std::max( - labs( rColor1.GetGreen() - rColor2.GetGreen() ), - labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ) ); - - // longest line in gradient bound rect - const int nGradientSize( - static_cast<int>( - ::std::max( - ::basegfx::B2DVector(aRightBottom-aLeftTop).getLength(), - ::basegfx::B2DVector(aRightTop-aLeftBottom).getLength() ) + 1.0 ) ); - - // typical number for pixel of the same color (strip size) - const int nStripSize( nGradientSize < 50 ? 2 : 4 ); - - // use at least three steps, and at utmost the number of color - // steps - const int nStepCount( - ::std::max( - 3, - ::std::min( - nGradientSize / nStripSize, - nColorSteps ) ) ); + int nColorSteps = 0; + for( size_t i=0; i<rColors.size()-1; ++i ) + nColorSteps += numColorSteps(rColors[i],rColors[i+1]); + + ::basegfx::B2DHomMatrix aTotalTransform; + const int nStepCount= + ::canvas::tools::calcGradientStepCount(aTotalTransform, + viewState, + renderState, + texture, + nColorSteps); rOutDev.SetLineColor(); + // determine maximal bound rect of texture-filled + // polygon + const ::Rectangle aPolygonDeviceRectOrig( + rPoly.GetBoundRect() ); + if( tools::isRectangle( rPoly ) ) { // use optimized output path @@ -687,9 +596,8 @@ namespace vclcanvas rOutDev.IntersectClipRegion( aPolygonDeviceRectOrig ); doGradientFill( rOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, false ); @@ -701,9 +609,8 @@ namespace vclcanvas p2ndOutDev->IntersectClipRegion( aPolygonDeviceRectOrig ); doGradientFill( *p2ndOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, false ); @@ -720,9 +627,8 @@ namespace vclcanvas doGradientFill( rOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, false ); @@ -734,9 +640,8 @@ namespace vclcanvas p2ndOutDev->SetClipRegion( aPolyClipRegion ); doGradientFill( *p2ndOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, false ); @@ -750,9 +655,8 @@ namespace vclcanvas rOutDev.SetRasterOp( ROP_XOR ); doGradientFill( rOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, true ); @@ -762,9 +666,8 @@ namespace vclcanvas rOutDev.SetRasterOp( ROP_XOR ); doGradientFill( rOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, true ); @@ -776,9 +679,8 @@ namespace vclcanvas p2ndOutDev->SetRasterOp( ROP_XOR ); doGradientFill( *p2ndOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, true ); @@ -788,9 +690,8 @@ namespace vclcanvas p2ndOutDev->SetRasterOp( ROP_XOR ); doGradientFill( *p2ndOutDev, rValues, - rColor1, - rColor2, - aTextureTransform, + rColors, + aTotalTransform, aPolygonDeviceRectOrig, nStepCount, true ); @@ -852,33 +753,41 @@ namespace vclcanvas ::canvas::ParametricPolyPolygon* pGradient = dynamic_cast< ::canvas::ParametricPolyPolygon* >( textures[0].Gradient.get() ); - if( pGradient ) + if( pGradient && pGradient->getValues().maColors.getLength() ) { // copy state from Gradient polypoly locally // (given object might change!) const ::canvas::ParametricPolyPolygon::Values& rValues( pGradient->getValues() ); - // TODO: use all the colors and place them on given positions/stops - const ::Color aColor1( - ::vcl::unotools::stdColorSpaceSequenceToColor( - rValues.maColors [0] ) ); - const ::Color aColor2( - ::vcl::unotools::stdColorSpaceSequenceToColor( - rValues.maColors [rValues.maColors.getLength () - 1] ) ); - - // TODO(E1): Return value - // TODO(F1): FillRule - gradientFill( mpOutDev->getOutDev(), - mp2ndOutDev.get() ? &mp2ndOutDev->getOutDev() : (OutputDevice*)NULL, - rValues, - aColor1, - aColor2, - aPolyPoly, - viewState, - renderState, - textures[0], - nTransparency ); + if( rValues.maColors.getLength() < 2 ) + { + rendering::RenderState aTempState=renderState; + aTempState.DeviceColor = rValues.maColors[0]; + fillPolyPolygon(pCanvas, xPolyPolygon, viewState, aTempState); + } + else + { + std::vector< ::Color > aColors(rValues.maColors.getLength()); + std::transform(&rValues.maColors[0], + &rValues.maColors[0]+rValues.maColors.getLength(), + aColors.begin(), + boost::bind( + &vcl::unotools::stdColorSpaceSequenceToColor, + _1)); + + // TODO(E1): Return value + // TODO(F1): FillRule + gradientFill( mpOutDev->getOutDev(), + mp2ndOutDev.get() ? &mp2ndOutDev->getOutDev() : (OutputDevice*)NULL, + rValues, + aColors, + aPolyPoly, + viewState, + renderState, + textures[0], + nTransparency ); + } } else { @@ -889,10 +798,6 @@ namespace vclcanvas } else if( textures[0].Bitmap.is() ) { -// OSL_ENSURE( textures[0].RepeatModeX == rendering::TexturingMode::REPEAT && -// textures[0].RepeatModeY == rendering::TexturingMode::REPEAT, -// "CanvasHelper::fillTexturedPolyPolygon(): VCL canvas cannot currently clamp textures." ); - const geometry::IntegerSize2D aBmpSize( textures[0].Bitmap->getSize() ); ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 && @@ -967,23 +872,6 @@ namespace vclcanvas aLocalState ); } } - else if ( textures[0].RepeatModeX == rendering::TexturingMode::CLAMP && - textures[0].RepeatModeY == rendering::TexturingMode::CLAMP ) - { - rendering::RenderState aLocalState( renderState ); - ::canvas::tools::appendToRenderState(aLocalState, - aTextureTransform); - ::basegfx::B2DHomMatrix aScaleCorrection; - aScaleCorrection.scale( 1.0/aBmpSize.Width, - 1.0/aBmpSize.Height ); - ::canvas::tools::appendToRenderState(aLocalState, - aScaleCorrection); - - return drawBitmap( pCanvas, - textures[0].Bitmap, - viewState, - aLocalState ); - } else { // No easy mapping to drawBitmap() - calculate @@ -1117,15 +1005,21 @@ namespace vclcanvas aSingleTextureRect, aPureTotalTransform ); - const ::Point aPt( ::vcl::unotools::pointFromB2DPoint( - aSingleDeviceTextureRect.getMinimum() ) ); + const ::Point aPtRepeat( ::vcl::unotools::pointFromB2DPoint( + aSingleDeviceTextureRect.getMinimum() ) ); const ::Size aSz( ::basegfx::fround( aScale.getX() * aBmpSize.Width ), ::basegfx::fround( aScale.getY() * aBmpSize.Height ) ); const ::Size aIntegerNextTileX( ::vcl::unotools::sizeFromB2DSize(aNextTileX) ); const ::Size aIntegerNextTileY( ::vcl::unotools::sizeFromB2DSize(aNextTileY) ); - const sal_Int32 nTilesX( nX2 - nX1 ); - const sal_Int32 nTilesY( nY2 - nY1 ); + const ::Point aPt( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? + ::basegfx::fround( aOutputPos.getX() ) : aPtRepeat.X(), + textures[0].RepeatModeY == rendering::TexturingMode::NONE ? + ::basegfx::fround( aOutputPos.getY() ) : aPtRepeat.Y() ); + const sal_Int32 nTilesX( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? + 1 : nX2 - nX1 ); + const sal_Int32 nTilesY( textures[0].RepeatModeX == rendering::TexturingMode::NONE ? + 1 : nY2 - nY1 ); OutputDevice& rOutDev( mpOutDev->getOutDev() ); @@ -1206,20 +1100,9 @@ namespace vclcanvas aPolyPoly.Translate( ::Point( -aPolygonDeviceRect.Left(), -aPolygonDeviceRect.Top() ) ); - aVDev.SetRasterOp( ROP_XOR ); - textureFill( aVDev, - *pGrfObj, - aOutPos, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - aVDev.SetFillColor( COL_BLACK ); - aVDev.SetRasterOp( ROP_0 ); - aVDev.DrawPolyPolygon( aPolyPoly ); - aVDev.SetRasterOp( ROP_XOR ); + const Region aPolyClipRegion( aPolyPoly ); + + aVDev.SetClipRegion( aPolyClipRegion ); textureFill( aVDev, *pGrfObj, aOutPos, @@ -1251,7 +1134,6 @@ namespace vclcanvas aOutputBmpEx ); } else -#if defined(QUARTZ) // TODO: other ports should avoid the XOR-trick too (implementation vs. interface!) { const Region aPolyClipRegion( aPolyPoly ); @@ -1287,66 +1169,6 @@ namespace vclcanvas r2ndOutDev.Pop(); } } -#else // TODO: remove once doing the XOR-trick in the canvas-layer becomes redundant - { - // output via repeated XORing - rOutDev.Push( PUSH_RASTEROP ); - rOutDev.SetRasterOp( ROP_XOR ); - textureFill( rOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - rOutDev.SetFillColor( COL_BLACK ); - rOutDev.SetRasterOp( ROP_0 ); - rOutDev.DrawPolyPolygon( aPolyPoly ); - rOutDev.SetRasterOp( ROP_XOR ); - textureFill( rOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - rOutDev.Pop(); - - if( mp2ndOutDev ) - { - OutputDevice& r2ndOutDev( mp2ndOutDev->getOutDev() ); - r2ndOutDev.Push( PUSH_RASTEROP ); - r2ndOutDev.SetRasterOp( ROP_XOR ); - textureFill( r2ndOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - r2ndOutDev.SetFillColor( COL_BLACK ); - r2ndOutDev.SetRasterOp( ROP_0 ); - r2ndOutDev.DrawPolyPolygon( aPolyPoly ); - r2ndOutDev.SetRasterOp( ROP_XOR ); - textureFill( r2ndOutDev, - *pGrfObj, - aPt, - aIntegerNextTileX, - aIntegerNextTileY, - nTilesX, - nTilesY, - aSz, - aGrfAttr ); - r2ndOutDev.Pop(); - } - } -#endif // complex-clipping vs. XOR-trick } } } diff --git a/canvas/source/vcl/exports.map b/canvas/source/vcl/exports.map deleted file mode 100644 index 4101b0d761a9..000000000000 --- a/canvas/source/vcl/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -CAN_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/canvas/source/vcl/makefile.mk b/canvas/source/vcl/makefile.mk index 21eed478123a..be2fc69894a4 100644 --- a/canvas/source/vcl/makefile.mk +++ b/canvas/source/vcl/makefile.mk @@ -75,7 +75,7 @@ SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map DEF1NAME=$(SHL1TARGET) DEF1EXPORTFILE=exports.dxp diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx index a5d4a6fe1e10..db4b05ddb9b2 100644 --- a/canvas/source/vcl/spritecanvas.hxx +++ b/canvas/source/vcl/spritecanvas.hxx @@ -39,7 +39,6 @@ #include <com/sun/star/rendering/XIntegerBitmap.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XBufferController.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <cppuhelper/compbase9.hxx> #include <comphelper/uno3.hxx> @@ -62,7 +61,7 @@ namespace vclcanvas typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, ::com::sun::star::rendering::XIntegerBitmap, ::com::sun::star::rendering::XGraphicDevice, - ::com::sun::star::rendering::XParametricPolyPolygon2DFactory, + ::com::sun::star::lang::XMultiServiceFactory, ::com::sun::star::rendering::XBufferController, ::com::sun::star::awt::XWindowListener, ::com::sun::star::util::XUpdatable, diff --git a/comphelper/inc/comphelper/namedvaluecollection.hxx b/comphelper/inc/comphelper/namedvaluecollection.hxx index 81aed9171408..72cd0e7cdfbe 100644 --- a/comphelper/inc/comphelper/namedvaluecollection.hxx +++ b/comphelper/inc/comphelper/namedvaluecollection.hxx @@ -61,6 +61,8 @@ namespace comphelper NamedValueCollection( const NamedValueCollection& _rCopySource ); + NamedValueCollection& operator=( const NamedValueCollection& i_rCopySource ); + /** constructs a collection @param _rElements the wrapped elements of the collection. The <code>Any</code> might contain a sequence of @@ -104,6 +106,11 @@ namespace comphelper impl_assign( _rArguments ); } + inline void clear() + { + impl_assign( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() ); + } + /// returns the number of elements in the collection size_t size() const; diff --git a/comphelper/qa/makefile.mk b/comphelper/qa/makefile.mk index 6e715675bb03..0360d308529e 100644 --- a/comphelper/qa/makefile.mk +++ b/comphelper/qa/makefile.mk @@ -33,6 +33,8 @@ ENABLE_EXCEPTIONS := TRUE .INCLUDE: settings.mk +CFLAGSCXX += $(CPPUNIT_CFLAGS) + DLLPRE = # no leading "lib" on .so files INCPRE += $(MISC)$/$(TARGET)$/inc diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx index 570a85122c96..8bab7fa3d7c7 100644 --- a/comphelper/source/misc/namedvaluecollection.cxx +++ b/comphelper/source/misc/namedvaluecollection.cxx @@ -85,7 +85,14 @@ namespace comphelper NamedValueCollection::NamedValueCollection( const NamedValueCollection& _rCopySource ) :m_pImpl( new NamedValueCollection_Impl ) { - m_pImpl->aValues = _rCopySource.m_pImpl->aValues; + *this = _rCopySource; + } + + //-------------------------------------------------------------------- + NamedValueCollection& NamedValueCollection::operator=( const NamedValueCollection& i_rCopySource ) + { + m_pImpl->aValues = i_rCopySource.m_pImpl->aValues; + return *this; } //-------------------------------------------------------------------- diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 58892b73233c..1423cd42ed93 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -41,7 +41,6 @@ #include <cppcanvas/canvas.hxx> #include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/TexturingMode.hpp> -#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/geometry/RealPoint2D.hpp> #include <com/sun/star/rendering/ViewState.hpp> @@ -52,6 +51,7 @@ #include <com/sun/star/rendering/PathCapType.hpp> #include <com/sun/star/rendering/PathJoinType.hpp> #include <basegfx/tools/canvastools.hxx> +#include <basegfx/tools/gradienttools.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> @@ -591,13 +591,12 @@ namespace cppcanvas // discernible difference should be visible. nSteps > 64 ) { - uno::Reference< rendering::XParametricPolyPolygon2DFactory > xFactory( + uno::Reference< lang::XMultiServiceFactory> xFactory( rParms.mrCanvas->getUNOCanvas()->getDevice()->getParametricPolyPolygonFactory() ); if( xFactory.is() ) { - ::basegfx::B2DHomMatrix aTextureTransformation; - rendering::Texture aTexture; + rendering::Texture aTexture; aTexture.RepeatModeX = rendering::TexturingMode::CLAMP; aTexture.RepeatModeY = rendering::TexturingMode::CLAMP; @@ -632,240 +631,118 @@ namespace cppcanvas uno::Sequence< uno::Sequence < double > > aColors(2); uno::Sequence< double > aStops(2); - aStops[0] = 0.0; - aStops[1] = 1.0; + if( rGradient.GetStyle() == GRADIENT_AXIAL ) + { + aStops.realloc(3); + aColors.realloc(3); - aColors[0] = aStartColor; - aColors[1] = aEndColor; + aStops[0] = 0.0; + aStops[1] = 0.5; + aStops[2] = 1.0; + aColors[0] = aEndColor; + aColors[1] = aStartColor; + aColors[2] = aEndColor; + } + else + { + aStops[0] = 0.0; + aStops[1] = 1.0; - // Setup texture transformation - // ---------------------------- + aColors[0] = aStartColor; + aColors[1] = aEndColor; + } const ::basegfx::B2DRectangle aBounds( ::basegfx::tools::getRange(aDevicePoly) ); + const ::basegfx::B2DVector aOffset( + rGradient.GetOfsX() / 100.0, + rGradient.GetOfsY() / 100.0); + double fRotation( rGradient.GetAngle() * M_PI / 1800.0 ); + const double fBorder( rGradient.GetBorder() / 100.0 ); - // setup rotation angle. VCL rotates - // counter-clockwise, while canvas transformation - // rotates clockwise - double nRotation( -rGradient.GetAngle() * M_PI / 1800.0 ); + basegfx::B2DHomMatrix aRot90; + aRot90.rotate(M_PI_2); + basegfx::ODFGradientInfo aGradInfo; + rtl::OUString aGradientService; switch( rGradient.GetStyle() ) { case GRADIENT_LINEAR: - // FALLTHROUGH intended + basegfx::tools::createLinearODFGradientInfo(aGradInfo, + aBounds, + nSteps, + fBorder, + fRotation); + // map odf to svg gradient orientation - x + // instead of y direction + aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aRot90; + aGradientService = rtl::OUString::createFromAscii("LinearGradient"); + break; + case GRADIENT_AXIAL: { - // standard orientation for VCL linear - // gradient is vertical, thus, rotate 90 - // degrees - nRotation += M_PI/2.0; - - const double nBorder( - ::basegfx::pruneScaleValue( - (1.0 - rGradient.GetBorder() / 100.0) ) ); - - // shrink texture, to account for border - // (only in x direction, linear gradient - // is constant in y direction, anyway) - aTextureTransformation.scale( nBorder, - 1.0 ); - - // linear gradients don't respect offsets - // (they are implicitely assumed to be - // 50%). linear gradients don't have - // border on both sides, only on the - // startColor side, axial gradients have - // border on both sides. As both gradients - // are invariant in y direction: leave y - // offset alone. - double nOffsetX( rGradient.GetBorder() / 200.0 ); - - // determine type of gradient (and necessary - // transformation matrix, should it be emulated by a - // generic gradient) - switch( rGradient.GetStyle() ) - { - case GRADIENT_LINEAR: - nOffsetX = rGradient.GetBorder() / 100.0; - aTexture.Gradient = xFactory->createLinearHorizontalGradient( aColors, - aStops ); - break; - - case GRADIENT_AXIAL: - // vcl considers center color as start color - ::std::swap(aColors[0],aColors[1]); - aTexture.Gradient = xFactory->createAxialHorizontalGradient( aColors, - aStops ); - break; - - default: // other cases can't happen - break; - } - - // apply border offset values - aTextureTransformation.translate( nOffsetX, - 0.0 ); - - // rotate texture according to gradient rotation - aTextureTransformation.translate( -0.5, -0.5 ); - aTextureTransformation.rotate( nRotation ); - - // to let the first strip of a rotated - // gradient start at the _edge_ of the - // bound rect (and not, due to rotation, - // slightly inside), slightly enlarge the - // gradient: - // - // y/2 sin(alpha) + x/2 cos(alpha) - // - // (values to change are not actual - // gradient scales, but original bound - // rect dimensions. Since we still want - // the border setting to apply after that, - // we multiply with that as above for - // nScaleX) - const double nScale( - ::basegfx::pruneScaleValue( - fabs( aBounds.getHeight()*sin(nRotation) ) + - fabs( aBounds.getWidth()*cos(nRotation) ))); - - // scale and translate back origin to center of - // primitive - aTextureTransformation = basegfx::tools::createScaleTranslateB2DHomMatrix( - nScale, nScale, 0.5*aBounds.getWidth(), 0.5*aBounds.getHeight()) - * aTextureTransformation; + basegfx::tools::createLinearODFGradientInfo(aGradInfo, + aBounds, + nSteps, + fBorder, + fRotation); + // map odf to svg gradient orientation - x + // instead of y direction + aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aRot90; + + // map odf axial gradient to 3-stop linear + // gradient - shift left by 0.5 + basegfx::B2DHomMatrix aShift; + aShift.translate(-0.5,0); + aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aShift; + + aGradientService = rtl::OUString::createFromAscii("LinearGradient"); + break; } - break; case GRADIENT_RADIAL: - // FALLTHROUGH intended - case GRADIENT_ELLIPTICAL: - // FALLTHROUGH intended - case GRADIENT_SQUARE: - // FALLTHROUGH intended - case GRADIENT_RECT: - { - // determine scale factors for the gradient (must - // be scaled up from [0,1]x[0,1] rect to object - // bounds). Will potentially changed in switch - // statement below. - // Respect border value, while doing so, the VCL - // gradient's border will effectively shrink the - // resulting gradient. - double nScaleX( aBounds.getWidth() * (1.0 - rGradient.GetBorder() / 100.0) ); - double nScaleY( aBounds.getHeight()* (1.0 - rGradient.GetBorder() / 100.0) ); - - // determine offset values. Since the border is - // divided half-by-half to both sides of the - // gradient, divide translation offset by an - // additional 2. Also respect offset here, but - // since VCL gradients have their center at [0,0] - // for zero offset, but canvas gradients have - // their top, left edge aligned with the - // primitive, and offset of 50% effectively must - // yield zero shift. Both values will potentially - // be adapted in switch statement below. - double nOffsetX( aBounds.getWidth() * - (2.0 * rGradient.GetOfsX() - 100.0 + rGradient.GetBorder()) / 200.0 ); - double nOffsetY( aBounds.getHeight() * - (2.0 * rGradient.GetOfsY() - 100.0 + rGradient.GetBorder()) / 200.0 ); - - // determine type of gradient (and necessary - // transformation matrix, should it be emulated by a - // generic gradient) - switch( rGradient.GetStyle() ) - { - case GRADIENT_RADIAL: - { - // create isotrophic scaling - if( nScaleX > nScaleY ) - { - nOffsetY -= (nScaleX - nScaleY) * 0.5; - nScaleY = nScaleX; - } - else - { - nOffsetX -= (nScaleY - nScaleX) * 0.5; - nScaleX = nScaleY; - } - - // enlarge gradient to match bound rect diagonal - aTextureTransformation.translate( -0.5, -0.5 ); - const double nScale( hypot(aBounds.getWidth(), aBounds.getHeight()) / nScaleX ); - aTextureTransformation.scale( nScale, nScale ); - aTextureTransformation.translate( 0.5, 0.5 ); - - aTexture.Gradient = xFactory->createEllipticalGradient( aColors, - aStops, - geometry::RealRectangle2D(0.0,0.0, - 1.0,1.0) ); - } - break; - - case GRADIENT_ELLIPTICAL: - { - // enlarge gradient slightly - aTextureTransformation.translate( -0.5, -0.5 ); - const double nSqrt2( sqrt(2.0) ); - aTextureTransformation.scale( nSqrt2,nSqrt2 ); - aTextureTransformation.translate( 0.5, 0.5 ); - - aTexture.Gradient = xFactory->createEllipticalGradient( - aColors, - aStops, - ::basegfx::unotools::rectangle2DFromB2DRectangle( - aBounds )); - } - break; - - case GRADIENT_SQUARE: - // create isotrophic scaling - if( nScaleX > nScaleY ) - { - nOffsetY -= (nScaleX - nScaleY) * 0.5; - nScaleY = nScaleX; - } - else - { - nOffsetX -= (nScaleY - nScaleX) * 0.5; - nScaleX = nScaleY; - } - - aTexture.Gradient = xFactory->createRectangularGradient( aColors, - aStops, - geometry::RealRectangle2D(0.0,0.0, - 1.0,1.0) ); - break; - - case GRADIENT_RECT: - aTexture.Gradient = xFactory->createRectangularGradient( - aColors, - aStops, - ::basegfx::unotools::rectangle2DFromB2DRectangle( - aBounds ) ); - break; - - default: // other cases can't happen - break; - } - - nScaleX = ::basegfx::pruneScaleValue( nScaleX ); - nScaleY = ::basegfx::pruneScaleValue( nScaleY ); + basegfx::tools::createRadialODFGradientInfo(aGradInfo, + aBounds, + aOffset, + nSteps, + fBorder); + aGradientService = rtl::OUString::createFromAscii("EllipticalGradient"); + break; - aTextureTransformation.scale( nScaleX, nScaleY ); + case GRADIENT_ELLIPTICAL: + basegfx::tools::createEllipticalODFGradientInfo(aGradInfo, + aBounds, + aOffset, + nSteps, + fBorder, + fRotation); + aGradientService = rtl::OUString::createFromAscii("EllipticalGradient"); + break; - // rotate texture according to gradient rotation - aTextureTransformation = basegfx::tools::createRotateAroundPoint(0.5*nScaleX, 0.5*nScaleY, nRotation) - * aTextureTransformation; + case GRADIENT_SQUARE: + basegfx::tools::createSquareODFGradientInfo(aGradInfo, + aBounds, + aOffset, + nSteps, + fBorder, + fRotation); + aGradientService = rtl::OUString::createFromAscii("RectangularGradient"); + break; - aTextureTransformation.translate( nOffsetX, nOffsetY ); - } - break; + case GRADIENT_RECT: + basegfx::tools::createRectangularODFGradientInfo(aGradInfo, + aBounds, + aOffset, + nSteps, + fBorder, + fRotation); + aGradientService = rtl::OUString::createFromAscii("RectangularGradient"); + break; default: ENSURE_OR_THROW( false, - "ImplRenderer::createGradientAction(): Unexpected gradient type" ); + "ImplRenderer::createGradientAction(): Unexpected gradient type" ); break; } @@ -876,31 +753,49 @@ namespace cppcanvas // gradient will always display at the origin, and // not within the polygon bound (which might be // miles away from the origin). - aTextureTransformation.translate( aBounds.getMinX(), - aBounds.getMinY() ); - + aGradInfo.maTextureTransform.translate( aBounds.getMinX(), + aBounds.getMinY() ); ::basegfx::unotools::affineMatrixFromHomMatrix( aTexture.AffineTransform, - aTextureTransformation ); + aGradInfo.maTextureTransform ); + + uno::Sequence<uno::Any> args(3); + beans::PropertyValue aProp; + aProp.Name = rtl::OUString::createFromAscii("Colors"); + aProp.Value <<= aColors; + args[0] <<= aProp; + aProp.Name = rtl::OUString::createFromAscii("Stops"); + aProp.Value <<= aStops; + args[1] <<= aProp; + aProp.Name = rtl::OUString::createFromAscii("AspectRatio"); + aProp.Value <<= aGradInfo.mfAspectRatio; + args[2] <<= aProp; + + aTexture.Gradient.set( + xFactory->createInstanceWithArguments(aGradientService, + args), + uno::UNO_QUERY); + if( aTexture.Gradient.is() ) + { + ActionSharedPtr pPolyAction( + internal::PolyPolyActionFactory::createPolyPolyAction( + aDevicePoly, + rParms.mrCanvas, + getState( rParms.mrStates ), + aTexture ) ); - ActionSharedPtr pPolyAction( - internal::PolyPolyActionFactory::createPolyPolyAction( - aDevicePoly, - rParms.mrCanvas, - getState( rParms.mrStates ), - aTexture ) ); + if( pPolyAction ) + { + maActions.push_back( + MtfAction( + pPolyAction, + rParms.mrCurrActionIndex ) ); - if( pPolyAction ) - { - maActions.push_back( - MtfAction( - pPolyAction, - rParms.mrCurrActionIndex ) ); + rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1; + } - rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1; + // done, using native gradients + return; } - - // done, using native gradients - return; } } @@ -1880,8 +1775,8 @@ namespace cppcanvas } else { - aTexture.RepeatModeX = rendering::TexturingMode::CLAMP; - aTexture.RepeatModeY = rendering::TexturingMode::CLAMP; + aTexture.RepeatModeX = rendering::TexturingMode::NONE; + aTexture.RepeatModeY = rendering::TexturingMode::NONE; } ::PolyPolygon aPath; @@ -2874,7 +2769,7 @@ namespace cppcanvas aSubset.mnSubsetEnd = ::std::min( aRangeBegin->mpAction->getActionCount(), nEndIndex - aRangeBegin->mnOrigIndex ); - ENSURE_OR_RETURN( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, + ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, "ImplRenderer::forSubsetRange(): Invalid indices" ); rFunctor( *aRangeBegin, aSubset ); @@ -2890,7 +2785,7 @@ namespace cppcanvas nStartIndex - aRangeBegin->mnOrigIndex ); aSubset.mnSubsetEnd = aRangeBegin->mpAction->getActionCount(); - ENSURE_OR_RETURN( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, + ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, "ImplRenderer::forSubsetRange(): Invalid indices" ); rFunctor( *aRangeBegin, aSubset ); @@ -2919,7 +2814,7 @@ namespace cppcanvas aSubset.mnSubsetBegin = 0; aSubset.mnSubsetEnd = nEndIndex - aRangeEnd->mnOrigIndex; - ENSURE_OR_RETURN( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, + ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0, "ImplRenderer::forSubsetRange(): Invalid indices" ); rFunctor( *aRangeEnd, aSubset ); @@ -2934,10 +2829,10 @@ namespace cppcanvas ActionVector::const_iterator& o_rRangeBegin, ActionVector::const_iterator& o_rRangeEnd ) const { - ENSURE_OR_RETURN( io_rStartIndex<=io_rEndIndex, + ENSURE_OR_RETURN_FALSE( io_rStartIndex<=io_rEndIndex, "ImplRenderer::getSubsetIndices(): invalid action range" ); - ENSURE_OR_RETURN( !maActions.empty(), + ENSURE_OR_RETURN_FALSE( !maActions.empty(), "ImplRenderer::getSubsetIndices(): no actions to render" ); const sal_Int32 nMinActionIndex( maActions.front().mnOrigIndex ); diff --git a/dtrans/source/generic/exports.map b/dtrans/source/generic/exports.map deleted file mode 100644 index 28449cc0f4a8..000000000000 --- a/dtrans/source/generic/exports.map +++ /dev/null @@ -1,9 +0,0 @@ -DTRANS_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; - diff --git a/dtrans/source/generic/makefile.mk b/dtrans/source/generic/makefile.mk index c1afa848d7ed..e015400c32d9 100644 --- a/dtrans/source/generic/makefile.mk +++ b/dtrans/source/generic/makefile.mk @@ -46,7 +46,7 @@ SLOFILES= \ SHL1TARGET= dtrans -SHL1VERSIONMAP= exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1STDLIBS= \ $(SALLIB) \ diff --git a/dtrans/util/exports.map b/dtrans/util/exports.map deleted file mode 100644 index 7c56baa9bd73..000000000000 --- a/dtrans/util/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/dtrans/util/makefile.mk b/dtrans/util/makefile.mk index 921f4458b43c..0443c131ccb6 100644 --- a/dtrans/util/makefile.mk +++ b/dtrans/util/makefile.mk @@ -64,7 +64,7 @@ SHL1IMPLIB=i$(SHL1TARGET) SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) DEF1EXPORTFILE= exports.dxp -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map .IF "$(GUI)"=="WNT" diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index 36c6300b9fdc..8599ec75c634 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -64,9 +64,10 @@ Language Identifier Constants and Strings http://msdn2.microsoft.com/en-us/library/ms776294.aspx - Lists for 2003, XP and Vista, overview with URLs pointing to regional settings: - NLS information page - http://www.microsoft.com/globaldev/nlsweb/default.mspx + Hey, yet another list, maybe this one will not move around? It seems to be + quite complete.. + Language Identifier Constants and Strings (Windows) + http://msdn.microsoft.com/en-us/library/dd318693(VS.85).aspx List of supported locale identifiers in Word http://support.microsoft.com/default.aspx?scid=KB;en-us;q221435 @@ -500,5 +501,16 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_ARABIC_SUDAN 0xA001 /* makeLangID( 0x28, getPrimaryLanguage( LANGUAGE_ARABIC_SAUDI_ARABIA)) */ #define LANGUAGE_USER_ANCIENT_GREEK 0x0649 #define LANGUAGE_USER_ASTURIAN 0x064A +#define LANGUAGE_USER_LATGALIAN 0x064B +#define LANGUAGE_USER_MAORE 0x064C +#define LANGUAGE_USER_BUSHI 0x064D +#define LANGUAGE_USER_TAHITIAN 0x064E +#define LANGUAGE_USER_MALAGASY_PLATEAU 0x064F +#define LANGUAGE_USER_PAPIAMENTU_ARUBA 0x8079 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_PAPIAMENTU)) */ +#define LANGUAGE_USER_SARDINIAN_CAMPIDANESE 0x0650 +#define LANGUAGE_USER_SARDINIAN_GALLURESE 0x0651 +#define LANGUAGE_USER_SARDINIAN_LOGUDORESE 0x0652 +#define LANGUAGE_USER_SARDINIAN_SASSARESE 0x0653 +#define LANGUAGE_USER_BAFIA 0x0654 #endif /* INCLUDED_I18NPOOL_LANG_H */ diff --git a/i18npool/source/breakiterator/data/dict.map b/i18npool/source/breakiterator/data/dict.map index 271ba8b2b83c..ebd4f9185d1f 100644 --- a/i18npool/source/breakiterator/data/dict.map +++ b/i18npool/source/breakiterator/data/dict.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; getDataArea; diff --git a/i18npool/source/breakiterator/data/dict_word.txt b/i18npool/source/breakiterator/data/dict_word.txt index 367a82db9e6f..f69f038e7f7e 100644 --- a/i18npool/source/breakiterator/data/dict_word.txt +++ b/i18npool/source/breakiterator/data/dict_word.txt @@ -35,7 +35,7 @@ $ALetter = [\u0002 [:Alphabetic:] [:name= COMMERCIAL AT:] [:name= HEBREW PUNCT $MidLetter = [[:name = APOSTROPHE:] [:name = GRAVE ACCENT:] \u0084 [:name = SOFT HYPHEN:] [:name = MIDDLE DOT:] [:name = GREEK TONOS:] [:name= FULL STOP:] [:name = HEBREW PUNCTUATION GERSHAYIM:] [:name = DOUBLE VERTICAL LINE:] [:name = LEFT SINGLE QUOTATION MARK:] [:name = RIGHT SINGLE QUOTATION MARK:] [:name = HYPHENATION POINT:] [:name = PRIME:] - [:name = HYPHEN-MINUS:] [:name = EN DASH:] [:name = EM DASH:] ]; + [:name = HYPHEN-MINUS:] ]; $SufixLetter = [:name= FULL STOP:]; diff --git a/i18npool/source/breakiterator/data/dict_word_prepostdash.txt b/i18npool/source/breakiterator/data/dict_word_prepostdash.txt index 1bf94451fae2..0a60cc5d4924 100644 --- a/i18npool/source/breakiterator/data/dict_word_prepostdash.txt +++ b/i18npool/source/breakiterator/data/dict_word_prepostdash.txt @@ -27,7 +27,7 @@ $Hangul = [:Script = HANGUL:]; # list of dashes or hyphens that should be accepted as part of the word if a single one of these # pre- or postfixes a word. E.g. in German: "Arbeits-" or "-nehmer" where that hyphen needs to # be part of the word in order to have it properly spell checked etc. -$PrePostDashHyphen = [ [:name = HYPHEN-MINUS:] [:name = EN DASH:] [:name = EM DASH:] ]; +$PrePostDashHyphen = [ [:name = HYPHEN-MINUS:] ]; $ALetter = [\u0002 [:Alphabetic:] [:name= COMMERCIAL AT:] [:name= HEBREW PUNCTUATION GERESH:] @@ -41,7 +41,7 @@ $ALetter = [\u0002 [:Alphabetic:] [:name= COMMERCIAL AT:] [:name= HEBREW PUNCT $MidLetter = [[:name = APOSTROPHE:] [:name = GRAVE ACCENT:] \u0084 [:name = SOFT HYPHEN:] [:name = MIDDLE DOT:] [:name = GREEK TONOS:] [:name= FULL STOP:] [:name = HEBREW PUNCTUATION GERSHAYIM:] [:name = DOUBLE VERTICAL LINE:] [:name = LEFT SINGLE QUOTATION MARK:] [:name = RIGHT SINGLE QUOTATION MARK:] [:name = HYPHENATION POINT:] [:name = PRIME:] - [:name = HYPHEN-MINUS:] [:name = EN DASH:] [:name = EM DASH:] ]; + [:name = HYPHEN-MINUS:] ]; $SufixLetter = [:name= FULL STOP:]; diff --git a/i18npool/source/collator/data/collator_data.map b/i18npool/source/collator/data/collator_data.map index 09f298912ee9..412635f19eed 100644 --- a/i18npool/source/collator/data/collator_data.map +++ b/i18npool/source/collator/data/collator_data.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; get_zh_charset; diff --git a/i18npool/source/indexentry/data/index_data.map b/i18npool/source/indexentry/data/index_data.map index b9add8b3a6f8..30d03853d6ad 100644 --- a/i18npool/source/indexentry/data/index_data.map +++ b/i18npool/source/indexentry/data/index_data.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; get_indexdata_ko_dict; diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index 6ba1ad1b8151..28c86d39673e 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -349,6 +349,7 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_YORUBA, "yo", "NG" }, { LANGUAGE_SOMALI, "so", "SO" }, { LANGUAGE_PAPIAMENTU, "pap", "AN" }, + { LANGUAGE_USER_PAPIAMENTU_ARUBA, "pap", "AW" }, { LANGUAGE_ENGLISH_SINGAPORE, "en", "SG" }, { LANGUAGE_YIDDISH, "yi", "IL" }, // new: old was "ji" { LANGUAGE_YIDDISH, "ji", "IL" }, // old: new is "yi" @@ -401,7 +402,11 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_KURDISH_SYRIA, "ku", "SY" }, { LANGUAGE_USER_KURDISH_IRAQ, "ku", "IQ" }, { LANGUAGE_USER_KURDISH_IRAN, "ku", "IR" }, - { LANGUAGE_USER_SARDINIAN, "sc", "IT" }, + { LANGUAGE_USER_SARDINIAN, "sc", "IT" }, // macrolanguage code + { LANGUAGE_USER_SARDINIAN_CAMPIDANESE, "sro", "IT" }, + { LANGUAGE_USER_SARDINIAN_GALLURESE, "sdn", "IT" }, + { LANGUAGE_USER_SARDINIAN_LOGUDORESE, "src", "IT" }, + { LANGUAGE_USER_SARDINIAN_SASSARESE, "sdc", "IT" }, { LANGUAGE_BRETON_FRANCE, "br", "FR" }, { LANGUAGE_OBSOLETE_USER_BRETON, "br", "FR" }, { LANGUAGE_KALAALLISUT_GREENLAND, "kl", "GL" }, @@ -445,6 +450,12 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_USER_SHUSWAP, "shs", "CA" }, { LANGUAGE_USER_ANCIENT_GREEK, "grc", "GR" }, { LANGUAGE_USER_ASTURIAN, "ast", "ES" }, + { LANGUAGE_USER_LATGALIAN, "ltg", "LV" }, + { LANGUAGE_USER_MAORE, "swb", "YT" }, + { LANGUAGE_USER_BUSHI, "buc", "YT" }, + { LANGUAGE_USER_TAHITIAN, "ty", "PF" }, + { LANGUAGE_USER_MALAGASY_PLATEAU, "plt", "MG" }, + { LANGUAGE_USER_BAFIA, "ksf", "CM" }, { LANGUAGE_NONE, "zxx", "" }, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information { LANGUAGE_DONTKNOW, "", "" } // marks end of table }; diff --git a/i18npool/source/isolang/langid.pl b/i18npool/source/isolang/langid.pl index 629f08901a7d..06883279345b 100755 --- a/i18npool/source/isolang/langid.pl +++ b/i18npool/source/isolang/langid.pl @@ -390,7 +390,7 @@ sub main() '^\s*completelangiso\s*[= ](.{2,3}(-..)?)*' . $langcoun . '', "$SRC_ROOT", "solenv", "inc/postset.mk", # needs a duplicated pair of backslashes to produce a literal \\ - ('^\s*completelangiso\s*=', '^\s+' . $langcoun . '\s*\\\\*$')); + ('^\s*completelangiso\s*=', '^\s*' . $langcoun . '\s*\\\\*$')); } } return 0; diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 081d6164e75b..4204b3636fcb 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -654,7 +654,9 @@ void LCFormatNode::generateCode (const OFileWriter &of) const OUString aPar1( RTL_CONSTASCII_USTRINGPARAM( "0)" )); OUString aPar2( RTL_CONSTASCII_USTRINGPARAM( "-)" )); OUString aPar3( RTL_CONSTASCII_USTRINGPARAM( " )" )); - if (aCode.indexOf( aPar1 ) > 0 || aCode.indexOf( aPar2 ) > 0 || aCode.indexOf( aPar3 ) > 0) + OUString aPar4( RTL_CONSTASCII_USTRINGPARAM( "])" )); + if (aCode.indexOf( aPar1 ) > 0 || aCode.indexOf( aPar2 ) > 0 || + aCode.indexOf( aPar3 ) > 0 || aCode.indexOf( aPar4 ) > 0) fprintf( stderr, "Warning: FormatCode formatindex=\"%d\" for currency uses parentheses for negative amounts, which probably is not correct for locales not based on en_US.\n", formatindex); } break; diff --git a/i18npool/source/localedata/data/en_CA.xml b/i18npool/source/localedata/data/en_CA.xml index 31d24643b44a..121de11814a7 100644 --- a/i18npool/source/localedata/data/en_CA.xml +++ b/i18npool/source/localedata/data/en_CA.xml @@ -13,14 +13,14 @@ </LC_INFO> <LC_CTYPE> <Separators> - <DateSeparator>/</DateSeparator> + <DateSeparator>-</DateSeparator> <ThousandSeparator>,</ThousandSeparator> <DecimalSeparator>.</DecimalSeparator> <TimeSeparator>:</TimeSeparator> <Time100SecSeparator>.</Time100SecSeparator> <ListSeparator>;</ListSeparator> <LongDateDayOfWeekSeparator>, </LongDateDayOfWeekSeparator> - <LongDateDaySeparator>,</LongDateDaySeparator> + <LongDateDaySeparator>, </LongDateDaySeparator> <LongDateMonthSeparator> </LongDateMonthSeparator> <LongDateYearSeparator> </LongDateYearSeparator> </Separators> @@ -84,16 +84,16 @@ <FormatCode>[$$-1009]#,##0.--;[RED]-[$$-1009]#,##0.--</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18"> - <FormatCode>DD/MM/YY</FormatCode> + <FormatCode>YY-M-D</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey9" default="true" type="long" usage="DATE" formatindex="19"> <FormatCode>MMMM D, YYYY</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey8" default="true" type="medium" usage="DATE" formatindex="20"> - <FormatCode>DD/MM/YY</FormatCode> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="20"> + <FormatCode>YY-MM-DD</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="21"> - <FormatCode>DD/MM/YYYY</FormatCode> + <FormatElement msgid="DateFormatskey7" default="true" type="medium" usage="DATE" formatindex="21"> + <FormatCode>YYYY-MM-DD</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey10" default="false" type="long" usage="DATE" formatindex="22"> <FormatCode>MMM D, YY</FormatCode> @@ -114,7 +114,7 @@ <FormatCode>NN, MMM D, YY</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="28"> - <FormatCode>NN DD/MMM YY</FormatCode> + <FormatCode>NN DD-MMM YY</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey14" default="false" type="long" usage="DATE" formatindex="29"> <FormatCode>NN, MMMM D, YYYY</FormatCode> @@ -134,10 +134,10 @@ <DefaultName>ISO 8601</DefaultName> </FormatElement> <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="34"> - <FormatCode>MM/YY</FormatCode> + <FormatCode>YY-MM</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="35"> - <FormatCode>DD/MMM</FormatCode> + <FormatCode>MMM DD</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="36"> <FormatCode>MMMM</FormatCode> @@ -170,10 +170,10 @@ <FormatCode>[HH]:MM:SS.00</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> - <FormatCode>DD/MM/YY HH:MM</FormatCode> + <FormatCode>YYYY-MM-DD HH:MM</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> - <FormatCode>DD/MM/YYYY HH:MM:SS</FormatCode> + <FormatCode>YYYY-MM-DD HH:MM:SS</FormatCode> </FormatElement> </LC_FORMAT> <LC_COLLATION ref="en_US" /> diff --git a/i18npool/source/localedata/data/fr_CA.xml b/i18npool/source/localedata/data/fr_CA.xml index fcc99570bae9..c5976c73e741 100644 --- a/i18npool/source/localedata/data/fr_CA.xml +++ b/i18npool/source/localedata/data/fr_CA.xml @@ -87,15 +87,15 @@ <FormatCode># ##0,-- [$$-C0C];[RED]-# ##0,-- [$$-C0C]</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18"> - <FormatCode>AA-MM-JJ</FormatCode> + <FormatCode>AA-M-J</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey9" default="true" type="long" usage="DATE" formatindex="19"> <FormatCode>J MMMM AAAA</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey8" default="true" type="medium" usage="DATE" formatindex="20"> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="20"> <FormatCode>AA-MM-JJ</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="21"> + <FormatElement msgid="DateFormatskey7" default="true" type="medium" usage="DATE" formatindex="21"> <FormatCode>AAAA-MM-JJ</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey10" default="false" type="long" usage="DATE" formatindex="22"> @@ -173,7 +173,7 @@ <FormatCode>[HH]:MM:SS,00</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> - <FormatCode>AA-MM-JJ HH:MM</FormatCode> + <FormatCode>AAAA-MM-JJ HH:MM</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> <FormatCode>AAAA-MM-JJ HH:MM:SS</FormatCode> diff --git a/i18npool/source/localedata/data/hsb_DE.xml b/i18npool/source/localedata/data/hsb_DE.xml new file mode 100644 index 000000000000..6513dad5f57e --- /dev/null +++ b/i18npool/source/localedata/data/hsb_DE.xml @@ -0,0 +1,350 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE Locale SYSTEM 'locale.dtd'> +<Locale versionDTD="2.0.3" allowUpdateFromCLDR="no" version="1.0"> + <LC_INFO> + <Language> + <LangID>hsb</LangID> + <DefaultName>Sorbian, Upper</DefaultName> + </Language> + <Country> + <CountryID>DE</CountryID> + <DefaultName>Germany</DefaultName> + </Country> + </LC_INFO> + <LC_CTYPE unoid="generic"> + <Separators> + <DateSeparator>.</DateSeparator> + <ThousandSeparator>.</ThousandSeparator> + <DecimalSeparator>,</DecimalSeparator> + <TimeSeparator>:</TimeSeparator> + <Time100SecSeparator>,</Time100SecSeparator> + <ListSeparator>;</ListSeparator> + <LongDateDayOfWeekSeparator>, </LongDateDayOfWeekSeparator> + <LongDateDaySeparator>. </LongDateDaySeparator> + <LongDateMonthSeparator> </LongDateMonthSeparator> + <LongDateYearSeparator> </LongDateYearSeparator> + </Separators> + <Markers> + <QuotationStart>‚</QuotationStart> + <QuotationEnd>‘</QuotationEnd> + <DoubleQuotationStart>„</DoubleQuotationStart> + <DoubleQuotationEnd>“</DoubleQuotationEnd> + </Markers> + <TimeAM>dopołdnja</TimeAM> + <TimePM>popołdnju</TimePM> + <MeasurementSystem>metric</MeasurementSystem> + </LC_CTYPE> + <LC_FORMAT replaceFrom="[CURRENCY]" replaceTo="[$€-042E]"> + <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> + <FormatCode>Standard</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1"> + <FormatCode>0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2"> + <FormatCode>0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3"> + <FormatCode>#.##0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4"> + <FormatCode>#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5"> + <FormatCode>#.###,00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6"> + <FormatCode>0,00E+000</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7"> + <FormatCode>0,00E+00</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8"> + <FormatCode>0%</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9"> + <FormatCode>0,00%</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY" formatindex="12"> + <FormatCode>[CURRENCY]#.##0;-[CURRENCY]#.##0</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY" formatindex="13"> + <FormatCode>[CURRENCY]#.##0,00;-[CURRENCY]#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY" formatindex="14"> + <FormatCode>[CURRENCY]#.##0;[RED]-[CURRENCY]#.##0</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY" formatindex="15"> + <FormatCode>[CURRENCY]#.##0,00;[RED]-[CURRENCY]#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY" formatindex="16"> + <FormatCode>CCC#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17"> + <FormatCode>[CURRENCY]#.##0,--;[RED]-[CURRENCY]#.##0,--</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey11" default="true" type="short" usage="DATE" formatindex="18"> + <FormatCode>D.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey14" default="true" type="long" usage="DATE" formatindex="19"> + <FormatCode>NNNNDD, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey6" default="true" type="medium" usage="DATE" formatindex="20"> + <FormatCode>DD.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="21"> + <FormatCode>DD.MM.YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="22"> + <FormatCode>D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="23"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey21" default="false" type="long" usage="DATE" formatindex="24"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="25"> + <FormatCode>D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey22" default="false" type="long" usage="DATE" formatindex="26"> + <FormatCode>D, MMMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey10" default="false" type="medium" usage="DATE" formatindex="27"> + <FormatCode>NN, DD.MMM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey18" default="false" type="long" usage="DATE" formatindex="28"> + <FormatCode>NN, D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey19" default="false" type="long" usage="DATE" formatindex="29"> + <FormatCode>NN, D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey20" default="false" type="long" usage="DATE" formatindex="30"> + <FormatCode>NNNND, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey12" default="false" type="short" usage="DATE" formatindex="31"> + <FormatCode>MM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="32"> + <FormatCode>YY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="33"> + <FormatCode>YYYY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey1" default="false" type="medium" usage="DATE" formatindex="34"> + <FormatCode>MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="35"> + <FormatCode>MMM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="36"> + <FormatCode>MMMM</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="37"> + <FormatCode>QQ YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey9" default="false" type="medium" usage="DATE" formatindex="38"> + <FormatCode>WW</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey1" default="false" type="short" usage="TIME" formatindex="39"> + <FormatCode>HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey2" default="false" type="medium" usage="TIME" formatindex="40"> + <FormatCode>HH:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey3" default="true" type="short" usage="TIME" formatindex="41"> + <FormatCode>HH:MM AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey4" default="true" type="medium" usage="TIME" formatindex="42"> + <FormatCode>HH:MM:SS AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey5" default="false" type="medium" usage="TIME" formatindex="43"> + <FormatCode>[HH]:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey6" default="false" type="short" usage="TIME" formatindex="44"> + <FormatCode>MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey7" default="false" type="medium" usage="TIME" formatindex="45"> + <FormatCode>[HH]:MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> + <FormatCode>DD.MM.YY HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> + <FormatCode>DD.MM.YYYY HH:MM:SS AM/PM</FormatCode> + </FormatElement> + </LC_FORMAT> + <LC_COLLATION> + <Collator default="true" unoid="alphanumeric"/> + <CollationOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </CollationOptions> + </LC_COLLATION> + <LC_SEARCH> + <SearchOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </SearchOptions> + </LC_SEARCH> + <LC_INDEX> + <IndexKey unoid="alphanumeric" default="true" phonetic="false">A-C Č Ć D {Dź} E F-H {Ch} I-K Ł L-N Ń O Ó P {Př} Q R S Š T {Tř} U-Z Ž</IndexKey> + <UnicodeScript>0</UnicodeScript> + <UnicodeScript>1</UnicodeScript> + <UnicodeScript>2</UnicodeScript> + <FollowPageWord>sć.</FollowPageWord> + <FollowPageWord>sć.sć.</FollowPageWord> + </LC_INDEX> + <LC_CALENDAR> + <Calendar unoid="gregorian" default="true"> + <DaysOfWeek> + <Day> + <DayID>sun</DayID> + <DefaultAbbrvName>nje</DefaultAbbrvName> + <DefaultFullName>njedźela</DefaultFullName> + </Day> + <Day> + <DayID>mon</DayID> + <DefaultAbbrvName>pón</DefaultAbbrvName> + <DefaultFullName>póndźela</DefaultFullName> + </Day> + <Day> + <DayID>tue</DayID> + <DefaultAbbrvName>wut</DefaultAbbrvName> + <DefaultFullName>wutora</DefaultFullName> + </Day> + <Day> + <DayID>wed</DayID> + <DefaultAbbrvName>srj</DefaultAbbrvName> + <DefaultFullName>srjeda</DefaultFullName> + </Day> + <Day> + <DayID>thu</DayID> + <DefaultAbbrvName>štw</DefaultAbbrvName> + <DefaultFullName>štwórtk</DefaultFullName> + </Day> + <Day> + <DayID>fri</DayID> + <DefaultAbbrvName>pja</DefaultAbbrvName> + <DefaultFullName>pjatk</DefaultFullName> + </Day> + <Day> + <DayID>sat</DayID> + <DefaultAbbrvName>sob</DefaultAbbrvName> + <DefaultFullName>sobota</DefaultFullName> + </Day> + </DaysOfWeek> + <MonthsOfYear> + <Month> + <MonthID>jan</MonthID> + <DefaultAbbrvName>jan</DefaultAbbrvName> + <DefaultFullName>januar</DefaultFullName> + </Month> + <Month> + <MonthID>feb</MonthID> + <DefaultAbbrvName>feb</DefaultAbbrvName> + <DefaultFullName>februar</DefaultFullName> + </Month> + <Month> + <MonthID>mar</MonthID> + <DefaultAbbrvName>měrc</DefaultAbbrvName> + <DefaultFullName>měrc</DefaultFullName> + </Month> + <Month> + <MonthID>apr</MonthID> + <DefaultAbbrvName>apr</DefaultAbbrvName> + <DefaultFullName>apryl</DefaultFullName> + </Month> + <Month> + <MonthID>may</MonthID> + <DefaultAbbrvName>meja</DefaultAbbrvName> + <DefaultFullName>meja</DefaultFullName> + </Month> + <Month> + <MonthID>jun</MonthID> + <DefaultAbbrvName>jun</DefaultAbbrvName> + <DefaultFullName>junij</DefaultFullName> + </Month> + <Month> + <MonthID>jul</MonthID> + <DefaultAbbrvName>jul</DefaultAbbrvName> + <DefaultFullName>julij</DefaultFullName> + </Month> + <Month> + <MonthID>aug</MonthID> + <DefaultAbbrvName>awg</DefaultAbbrvName> + <DefaultFullName>awgust</DefaultFullName> + </Month> + <Month> + <MonthID>sep</MonthID> + <DefaultAbbrvName>sep</DefaultAbbrvName> + <DefaultFullName>september</DefaultFullName> + </Month> + <Month> + <MonthID>oct</MonthID> + <DefaultAbbrvName>okt</DefaultAbbrvName> + <DefaultFullName>oktober</DefaultFullName> + </Month> + <Month> + <MonthID>nov</MonthID> + <DefaultAbbrvName>now</DefaultAbbrvName> + <DefaultFullName>nowember</DefaultFullName> + </Month> + <Month> + <MonthID>dec</MonthID> + <DefaultAbbrvName>dec</DefaultAbbrvName> + <DefaultFullName>december</DefaultFullName> + </Month> + </MonthsOfYear> + <Eras> + <Era> + <EraID>bc</EraID> + <DefaultAbbrvName>př. Chr.</DefaultAbbrvName> + <DefaultFullName>před Chrystusom</DefaultFullName> + </Era> + <Era> + <EraID>ad</EraID> + <DefaultAbbrvName>po Chr.</DefaultAbbrvName> + <DefaultFullName>po Chrystusu</DefaultFullName> + </Era> + </Eras> + <StartDayOfWeek> + <DayID>mon</DayID> + </StartDayOfWeek> + <MinimalDaysInFirstWeek>4</MinimalDaysInFirstWeek> + </Calendar> + </LC_CALENDAR> + <LC_CURRENCY> + <Currency default="true" usedInCompatibleFormatCodes="true"> + <CurrencyID>EUR</CurrencyID> + <CurrencySymbol>€</CurrencySymbol> + <BankSymbol>EUR</BankSymbol> + <CurrencyName>Euro</CurrencyName> + <DecimalPlaces>2</DecimalPlaces> + </Currency> + </LC_CURRENCY> + <LC_TRANSLITERATION> + <Transliteration unoid="LOWERCASE_UPPERCASE"/> + <Transliteration unoid="UPPERCASE_LOWERCASE"/> + <Transliteration unoid="IGNORE_CASE"/> + </LC_TRANSLITERATION> + <LC_MISC> + <ReservedWords> + <trueWord>prawje</trueWord> + <falseWord>wopak</falseWord> + <quarter1Word>prěni kwartal</quarter1Word> + <quarter2Word>druhi kwartal</quarter2Word> + <quarter3Word>třeći kwartal</quarter3Word> + <quarter4Word>štwórty kwartal</quarter4Word> + <aboveWord>horjeka</aboveWord> + <belowWord>deleka</belowWord> + <quarter1Abbreviation>K1</quarter1Abbreviation> + <quarter2Abbreviation>K2</quarter2Abbreviation> + <quarter3Abbreviation>K3</quarter3Abbreviation> + <quarter4Abbreviation>K4</quarter4Abbreviation> + </ReservedWords> + </LC_MISC> + <LC_NumberingLevel ref="en_US"/> + <LC_OutLineNumberingLevel ref="en_US"/> +</Locale> +<!--Version 1.0 --> diff --git a/i18npool/source/localedata/data/locale.dtd b/i18npool/source/localedata/data/locale.dtd index b9ee78f69e79..d47d4ad26edc 100644 --- a/i18npool/source/localedata/data/locale.dtd +++ b/i18npool/source/localedata/data/locale.dtd @@ -19,14 +19,17 @@ A second possiblity is: - - temporarily change the DOCTYPE of your file to read (all on one line) - <!DOCTYPE Locale SYSTEM "http://svn.services.openoffice.org/ooo/trunk/i18npool/source/localedata/data/locale.dtd"> + - temporarily (!) change the DOCTYPE of your file to read (all on one line) + <!DOCTYPE Locale SYSTEM "http://hg.services.openoffice.org/DEV300/raw-file/tip/i18npool/source/localedata/data/locale.dtd"> - upload it to the form available at http://www.validome.org/ - This will validate the file against the HEAD revision of locale.dtd, for - other revisions you'll have to specify the corresponding tags or cws branch - instead of trunk. + This will validate the file against the HEAD revision of locale.dtd on the + DEV300 development code line, for other revisions you'll have to specify + the corresponding tags or cws branch instead. For example, to validate + against a modified locale.dtd in CWS locales33 you would use + + <!DOCTYPE Locale SYSTEM "http://hg.services.openoffice.org/cws/locales33/raw-file/tip/i18npool/source/localedata/data/locale.dtd"> Please test locale data files either in a non-product (!) build, which @@ -56,16 +59,22 @@ <!ENTITY % UNOModule 'unoid CDATA #IMPLIED'> + <!ENTITY % MessageID 'msgid CDATA #REQUIRED'> + <!ENTITY % RefLocale 'ref CDATA #IMPLIED'> +<!-- Where given, an element can be inherited from another locale, e.g. + ref="en_US" --> + <!ENTITY % LIBModule 'module CDATA #IMPLIED'> -<!-- The locale referred to for the sub categories --> +<!-- The locale referred to for the sub categories, implementation detail. --> <!ENTITY % replaceFrom 'replaceFrom CDATA #IMPLIED'> <!ENTITY % replaceTo 'replaceTo CDATA #IMPLIED'> +<!-- See below for the LC_FORMAT element. --> <!ELEMENT DefaultName (#PCDATA)> @@ -84,28 +93,35 @@ --> <!ATTLIST Locale allowUpdateFromCLDR (yes|no) #REQUIRED> <!-- Whether some data elements may be (automatically) updated from the Common - Locale Data Repository, see http://www.unicode.org/cldr/ + Locale Data Repository, see http://cldr.unicode.org/ + Note: This mechanism currently (2010-02-21) is outdated. --> <!ATTLIST Locale version CDATA #REQUIRED> <!-- Valid number, may designate versioned data --> + <!ELEMENT LC_INFO (Language, Country, Platform?, Variant?)> <!ELEMENT Language (LangID, DefaultName) > <!ELEMENT LangID (#PCDATA) > -<!-- LangID must be valid two or three letter language identifier defined by ISO-639 - Use ISO 639-1 two letter code where available, else ISO 639-2 three letter code. +<!-- LangID must be a valid two or three letter language identifier defined by + ISO 639. Use ISO 639-1 two letter code where available, else ISO 639-2 or + 639-3 three letter code. --> <!ELEMENT Country (CountryID, DefaultName) > <!ELEMENT CountryID (#PCDATA) > -<!-- CountryID must be valid two letter country identifier defined by ISO-3166 --> +<!-- CountryID must be a valid two letter country identifier defined by ISO 3166. --> <!ELEMENT Platform (PlatformID) > <!ELEMENT PlatformID (#PCDATA) > -<!-- can be generic|unix|win32|macos --> +<!-- Unused, deprecated, can be generic|unix|win32|macos, best Platform element + be absent. +--> <!ELEMENT Variant (#PCDATA) > +<!-- Reserved for future use, currently unused. --> + <!-- The LC_FORMAT element contains number format codes and may actually appear twice (with the second ocurrence named LC_FORMAT_1). One section is @@ -122,18 +138,22 @@ --> <!ELEMENT LC_FORMAT (FormatElement*) > +<!-- All FormatElement elements must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_FORMAT %RefLocale;> <!ATTLIST LC_FORMAT %replaceFrom;> -<!-- Define placeholder for currency code --> +<!-- Define placeholder for currency code, usually "[CURRENCY]" --> <!ATTLIST LC_FORMAT %replaceTo;> -<!-- Currency code to be used to replace the placeholder --> +<!-- Currency code to be used to replace the placeholder, e.g. "[$R-1C09]". + Note: The brackets and the leading $ character are mandatory, the + hyphen-minus separates the currency symbol from the hexagesimal MS-LCID, + letters contained in the LCID have to be in upper case, leading zeros are + to be omitted. LCIDs are defined in i18npool/inc/i18npool/lang.h +--> <!ELEMENT LC_FORMAT_1 (FormatElement*) > <!ATTLIST LC_FORMAT_1 %RefLocale;> <!ATTLIST LC_FORMAT_1 %replaceFrom;> -<!-- Define placeholder for currency code --> <!ATTLIST LC_FORMAT_1 %replaceTo;> -<!-- Currency code to be used to replace the placeholder --> <!ELEMENT FormatElement ( FormatCode, DefaultName?)> <!ATTLIST FormatElement %MessageID;> @@ -234,34 +254,54 @@ <!ELEMENT FormatCode (#PCDATA)> +<!-- The LC_CALENDAR element defines calendars used with a locale. --> <!ELEMENT LC_CALENDAR (Calendar* ) > +<!-- At least one Calendar element must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_CALENDAR %RefLocale;> + <!ELEMENT Calendar (DaysOfWeek, MonthsOfYear, Eras, StartDayOfWeek, MinimalDaysInFirstWeek) > <!ATTLIST Calendar %UNOModule;> -<!-- the unoid of a gregorian calendar MUST be lower case "gregorian" --> +<!-- The unoid of a gregorian calendar MUST be lower case "gregorian", + calendars MUST match the names defined in the OASIS OpenDocument Format + (ODF) 1.2 or later specification. The implementation name registered with + the OOo service resgistry MUST match, e.g. + com.sun.star.i18n.Calendar_gregorian +--> <!ATTLIST Calendar default (true|false) #REQUIRED > +<!-- Exactly one Calendar element has to be the default calendar. --> + <!ELEMENT DaysOfWeek (Day*)> +<!-- All Day elements of a Calendar must be given if the RefLocale mechanism is not used! --> <!ATTLIST DaysOfWeek %RefLocale;> -<!-- Sequence of days is important, MUST start with Sunday --> +<!-- Sequence of days is important, MUST start with Sunday. --> <!ELEMENT Day (DayID, DefaultAbbrvName, DefaultFullName)> <!ELEMENT DayID (#PCDATA)> -<!-- DayID is preferably the lower case abbreviated English name like sun for Sunday --> +<!-- Preferably the lower case abbreviated English name like sun for Sunday. --> <!ELEMENT DefaultAbbrvName (#PCDATA)> +<!-- The abbreviated day name, e.g. Sun for Sunday. --> <!ELEMENT DefaultFullName (#PCDATA)> +<!-- The full day name, e.g. Sunday for Sunday. --> + <!ELEMENT MonthsOfYear (Month*)> +<!-- All Month elements of a Calendar must be given if the RefLocale mechanism is not used! --> <!ATTLIST MonthsOfYear %RefLocale;> +<!-- Sequence of months is important, MUST start with the first month of a + year, e.g. January in a Gregorian calendar. + --> <!ELEMENT Month (MonthID, DefaultAbbrvName, DefaultFullName)> <!ELEMENT MonthID (#PCDATA)> -<!-- preferably the lower case abbreviated English name like jan for January --> +<!-- Preferably the lower case abbreviated English name like jan for January. --> + <!ELEMENT Eras (Era*)> -<!-- The eras MUST be in chronological order, e.g. first BC then AC --> +<!-- All Era elements of a Calendar must be given if the RefLocale mechanism is not used! --> <!ATTLIST Eras %RefLocale;> +<!-- The eras MUST be in chronological order, e.g. first BC then AC. --> <!ELEMENT Era (EraID, DefaultAbbrvName, DefaultFullName)> <!ELEMENT EraID (#PCDATA)> <!-- If a calendar has special eras (like zh_TW ROC or ja_JP Gengou calendar) and a date before those eras is undefined, a leading (first) dummy era with EraID="Dummy" has to be defined to enable the number formatter to - fall back to a gregorian calendar for those date values if the XCalendar + fall back to a Gregorian calendar for those date values if the XCalendar implementation returns an era value of 0. --> @@ -276,10 +316,14 @@ is in the new year. --> + +<!-- The LC_CURRENCY element defines currencies used with a locale. --> <!ELEMENT LC_CURRENCY (Currency* ) > +<!-- At least one Currency element must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_CURRENCY %RefLocale;> <!ELEMENT Currency (CurrencyID, CurrencySymbol, BankSymbol, CurrencyName, DecimalPlaces)> <!ATTLIST Currency default (true|false) #REQUIRED > +<!-- Exactly one Currency element has to be the default currency. --> <!ATTLIST Currency usedInCompatibleFormatCodes (true|false) #REQUIRED > <!-- If this currency is the one used in compatible number format codes with <member>FormatElement::formatIndex</member> values in the range 12..17. @@ -296,35 +340,49 @@ 'usedInCompatibleFormatCodes' must both be "false". --> <!ELEMENT CurrencyID (#PCDATA)> +<!-- The ISO 4217 three letter currency code, e.g. USD or EUR. --> <!ELEMENT CurrencySymbol (#PCDATA)> +<!-- The currency symbol, e.g. $ or €. --> <!ELEMENT BankSymbol (#PCDATA)> +<!-- The ISO 4217 three letter currency code, e.g. USD or EUR. --> <!ELEMENT CurrencyName (#PCDATA)> +<!-- The native currency name, e.g. Dollar or Euro. --> <!ELEMENT DecimalPlaces (#PCDATA)> +<!-- Number of decimal places used with the currency, usually 2 or 0, e.g. 2 + for cents. +--> + <!ELEMENT LC_CTYPE (Separators?, Markers?, TimeAM?, TimePM?, MeasurementSystem?)> +<!-- All elements must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_CTYPE %RefLocale;> <!ATTLIST LC_CTYPE %UNOModule;> + <!ELEMENT Separators (DateSeparator, ThousandSeparator, DecimalSeparator, TimeSeparator, Time100SecSeparator, ListSeparator, LongDateDayOfWeekSeparator, LongDateDaySeparator, LongDateMonthSeparator, LongDateYearSeparator)> -<!ELEMENT Markers (QuotationStart, QuotationEnd, DoubleQuotationStart, DoubleQuotationEnd)> <!ELEMENT DateSeparator (#PCDATA)> <!ELEMENT ThousandSeparator (#PCDATA)> <!ELEMENT DecimalSeparator (#PCDATA)> <!ELEMENT TimeSeparator (#PCDATA)> <!ELEMENT Time100SecSeparator (#PCDATA)> -<!ELEMENT TimeAM (#PCDATA)> -<!ELEMENT TimePM (#PCDATA)> <!ELEMENT ListSeparator (#PCDATA)> +<!ELEMENT LongDateDayOfWeekSeparator (#PCDATA)> +<!ELEMENT LongDateDaySeparator (#PCDATA)> +<!ELEMENT LongDateMonthSeparator (#PCDATA)> +<!ELEMENT LongDateYearSeparator (#PCDATA)> + +<!ELEMENT Markers (QuotationStart, QuotationEnd, DoubleQuotationStart, DoubleQuotationEnd)> <!ELEMENT QuotationStart (#PCDATA)> <!ELEMENT QuotationEnd (#PCDATA)> <!ELEMENT DoubleQuotationStart (#PCDATA)> <!ELEMENT DoubleQuotationEnd (#PCDATA)> + +<!ELEMENT TimeAM (#PCDATA)> +<!ELEMENT TimePM (#PCDATA)> <!ELEMENT MeasurementSystem (#PCDATA)> -<!ELEMENT LongDateDayOfWeekSeparator (#PCDATA)> -<!ELEMENT LongDateDaySeparator (#PCDATA)> -<!ELEMENT LongDateMonthSeparator (#PCDATA)> -<!ELEMENT LongDateYearSeparator (#PCDATA)> + <!ELEMENT LC_COLLATION (Collator*, CollationOptions?)> +<!-- All elements must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_COLLATION %RefLocale;> <!-- Optional ICU tailoring. @@ -345,13 +403,21 @@ <!ELEMENT CollationOptions (TransliterationModules+)> <!ELEMENT TransliterationModules (#PCDATA)> + <!ELEMENT LC_SEARCH (SearchOptions?)> +<!-- All elements must be given if the RefLocale mechanism is not used! --> <!ATTLIST LC_SEARCH %RefLocale;> <!ELEMENT SearchOptions (TransliterationModules+)> + <!ELEMENT LC_INDEX (IndexKey*, UnicodeScript*, FollowPageWord*)> <!ATTLIST LC_INDEX %RefLocale;> + <!-- + The IndexKey element is optional, but should be given if the locale + requires a specific sort order in Writer's index tables or entries are to + be combined under keys. + Index key for the algorithm and language, like >A-Z< for English => A, B, C, ..., Y, Z. The letters specify under which key an entry goes and the order the keys are sorted. Keys may be reordered or letters inserted to @@ -391,16 +457,22 @@ <!ATTLIST IndexKey %LIBModule;> <!ATTLIST IndexKey default (true|false) #REQUIRED > <!ATTLIST IndexKey phonetic (true|false) #REQUIRED > + <!-- The Unicode script types are those of offapi/com/sun/star/i18n/UnicodeScript.idl, they define the code range for the language. --> <!ELEMENT UnicodeScript (#PCDATA)> + <!-- The FollowPageWord entries were originally hard-coded in ../../indexentry/indexentrysupplier.cxx, most locales used the English ``p.'' and ``pp.'', valid data should be provided by native speakers. + These words or abbreviations are used in the Writer's index table. The + first FollowPageWord element is the abbreviation for "page" (p.), the + second FollowPageWord element the abbreviation for "page and following + pages" (pp.). --> <!ELEMENT FollowPageWord (#PCDATA)> diff --git a/i18npool/source/localedata/data/localedata_en.map b/i18npool/source/localedata/data/localedata_en.map index 10e5a998c932..ab13f033745c 100644 --- a/i18npool/source/localedata/data/localedata_en.map +++ b/i18npool/source/localedata/data/localedata_en.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; getAllCalendars_en_AU; diff --git a/i18npool/source/localedata/data/localedata_es.map b/i18npool/source/localedata/data/localedata_es.map index edcdd4e153e3..7743539232a6 100644 --- a/i18npool/source/localedata/data/localedata_es.map +++ b/i18npool/source/localedata/data/localedata_es.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; getAllCalendars_es_AR; diff --git a/i18npool/source/localedata/data/localedata_euro.map b/i18npool/source/localedata/data/localedata_euro.map index 1a28eb537bd5..130a3c5a249f 100644 --- a/i18npool/source/localedata/data/localedata_euro.map +++ b/i18npool/source/localedata/data/localedata_euro.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; getAllCalendars_ast_ES; @@ -32,6 +32,7 @@ getAllCalendars_fy_NL; getAllCalendars_ga_IE; getAllCalendars_gsc_FR; getAllCalendars_hr_HR; +getAllCalendars_hsb_DE; getAllCalendars_is_IS; getAllCalendars_it_CH; getAllCalendars_it_IT; @@ -39,6 +40,7 @@ getAllCalendars_ka_GE; getAllCalendars_kl_GL; getAllCalendars_la_VA; getAllCalendars_lb_LU; +getAllCalendars_ltg_LV; getAllCalendars_lt_LT; getAllCalendars_lv_LV; getAllCalendars_mk_MK; @@ -99,6 +101,7 @@ getAllCurrencies_fy_NL; getAllCurrencies_ga_IE; getAllCurrencies_gsc_FR; getAllCurrencies_hr_HR; +getAllCurrencies_hsb_DE; getAllCurrencies_is_IS; getAllCurrencies_it_CH; getAllCurrencies_it_IT; @@ -106,6 +109,7 @@ getAllCurrencies_ka_GE; getAllCurrencies_kl_GL; getAllCurrencies_la_VA; getAllCurrencies_lb_LU; +getAllCurrencies_ltg_LV; getAllCurrencies_lt_LT; getAllCurrencies_lv_LV; getAllCurrencies_mk_MK; @@ -166,6 +170,7 @@ getAllFormats0_fy_NL; getAllFormats0_ga_IE; getAllFormats0_gsc_FR; getAllFormats0_hr_HR; +getAllFormats0_hsb_DE; getAllFormats0_is_IS; getAllFormats0_it_CH; getAllFormats0_it_IT; @@ -173,6 +178,7 @@ getAllFormats0_ka_GE; getAllFormats0_kl_GL; getAllFormats0_la_VA; getAllFormats0_lb_LU; +getAllFormats0_ltg_LV; getAllFormats0_lt_LT; getAllFormats0_lv_LV; getAllFormats0_mk_MK; @@ -233,6 +239,7 @@ getBreakIteratorRules_fy_NL; getBreakIteratorRules_ga_IE; getBreakIteratorRules_gsc_FR; getBreakIteratorRules_hr_HR; +getBreakIteratorRules_hsb_DE; getBreakIteratorRules_is_IS; getBreakIteratorRules_it_CH; getBreakIteratorRules_it_IT; @@ -240,6 +247,7 @@ getBreakIteratorRules_ka_GE; getBreakIteratorRules_kl_GL; getBreakIteratorRules_la_VA; getBreakIteratorRules_lb_LU; +getBreakIteratorRules_ltg_LV; getBreakIteratorRules_lt_LT; getBreakIteratorRules_lv_LV; getBreakIteratorRules_mk_MK; @@ -300,6 +308,7 @@ getCollationOptions_fy_NL; getCollationOptions_ga_IE; getCollationOptions_gsc_FR; getCollationOptions_hr_HR; +getCollationOptions_hsb_DE; getCollationOptions_is_IS; getCollationOptions_it_CH; getCollationOptions_it_IT; @@ -307,6 +316,7 @@ getCollationOptions_ka_GE; getCollationOptions_kl_GL; getCollationOptions_la_VA; getCollationOptions_lb_LU; +getCollationOptions_ltg_LV; getCollationOptions_lt_LT; getCollationOptions_lv_LV; getCollationOptions_mk_MK; @@ -367,6 +377,7 @@ getCollatorImplementation_fy_NL; getCollatorImplementation_ga_IE; getCollatorImplementation_gsc_FR; getCollatorImplementation_hr_HR; +getCollatorImplementation_hsb_DE; getCollatorImplementation_is_IS; getCollatorImplementation_it_CH; getCollatorImplementation_it_IT; @@ -374,6 +385,7 @@ getCollatorImplementation_ka_GE; getCollatorImplementation_kl_GL; getCollatorImplementation_la_VA; getCollatorImplementation_lb_LU; +getCollatorImplementation_ltg_LV; getCollatorImplementation_lt_LT; getCollatorImplementation_lv_LV; getCollatorImplementation_mk_MK; @@ -434,6 +446,7 @@ getContinuousNumberingLevels_fy_NL; getContinuousNumberingLevels_ga_IE; getContinuousNumberingLevels_gsc_FR; getContinuousNumberingLevels_hr_HR; +getContinuousNumberingLevels_hsb_DE; getContinuousNumberingLevels_is_IS; getContinuousNumberingLevels_it_CH; getContinuousNumberingLevels_it_IT; @@ -441,6 +454,7 @@ getContinuousNumberingLevels_ka_GE; getContinuousNumberingLevels_kl_GL; getContinuousNumberingLevels_la_VA; getContinuousNumberingLevels_lb_LU; +getContinuousNumberingLevels_ltg_LV; getContinuousNumberingLevels_lt_LT; getContinuousNumberingLevels_lv_LV; getContinuousNumberingLevels_mk_MK; @@ -501,6 +515,7 @@ getFollowPageWords_fy_NL; getFollowPageWords_ga_IE; getFollowPageWords_gsc_FR; getFollowPageWords_hr_HR; +getFollowPageWords_hsb_DE; getFollowPageWords_is_IS; getFollowPageWords_it_CH; getFollowPageWords_it_IT; @@ -508,6 +523,7 @@ getFollowPageWords_ka_GE; getFollowPageWords_kl_GL; getFollowPageWords_la_VA; getFollowPageWords_lb_LU; +getFollowPageWords_ltg_LV; getFollowPageWords_lt_LT; getFollowPageWords_lv_LV; getFollowPageWords_mk_MK; @@ -568,6 +584,7 @@ getForbiddenCharacters_fy_NL; getForbiddenCharacters_ga_IE; getForbiddenCharacters_gsc_FR; getForbiddenCharacters_hr_HR; +getForbiddenCharacters_hsb_DE; getForbiddenCharacters_is_IS; getForbiddenCharacters_it_CH; getForbiddenCharacters_it_IT; @@ -575,6 +592,7 @@ getForbiddenCharacters_ka_GE; getForbiddenCharacters_kl_GL; getForbiddenCharacters_la_VA; getForbiddenCharacters_lb_LU; +getForbiddenCharacters_ltg_LV; getForbiddenCharacters_lt_LT; getForbiddenCharacters_lv_LV; getForbiddenCharacters_mk_MK; @@ -635,6 +653,7 @@ getIndexAlgorithm_fy_NL; getIndexAlgorithm_ga_IE; getIndexAlgorithm_gsc_FR; getIndexAlgorithm_hr_HR; +getIndexAlgorithm_hsb_DE; getIndexAlgorithm_is_IS; getIndexAlgorithm_it_CH; getIndexAlgorithm_it_IT; @@ -642,6 +661,7 @@ getIndexAlgorithm_ka_GE; getIndexAlgorithm_kl_GL; getIndexAlgorithm_la_VA; getIndexAlgorithm_lb_LU; +getIndexAlgorithm_ltg_LV; getIndexAlgorithm_lt_LT; getIndexAlgorithm_lv_LV; getIndexAlgorithm_mk_MK; @@ -702,6 +722,7 @@ getLCInfo_fy_NL; getLCInfo_ga_IE; getLCInfo_gsc_FR; getLCInfo_hr_HR; +getLCInfo_hsb_DE; getLCInfo_is_IS; getLCInfo_it_CH; getLCInfo_it_IT; @@ -709,6 +730,7 @@ getLCInfo_ka_GE; getLCInfo_kl_GL; getLCInfo_la_VA; getLCInfo_lb_LU; +getLCInfo_ltg_LV; getLCInfo_lt_LT; getLCInfo_lv_LV; getLCInfo_mk_MK; @@ -769,6 +791,7 @@ getLocaleItem_fy_NL; getLocaleItem_ga_IE; getLocaleItem_gsc_FR; getLocaleItem_hr_HR; +getLocaleItem_hsb_DE; getLocaleItem_is_IS; getLocaleItem_it_CH; getLocaleItem_it_IT; @@ -776,6 +799,7 @@ getLocaleItem_ka_GE; getLocaleItem_kl_GL; getLocaleItem_la_VA; getLocaleItem_lb_LU; +getLocaleItem_ltg_LV; getLocaleItem_lt_LT; getLocaleItem_lv_LV; getLocaleItem_mk_MK; @@ -836,6 +860,7 @@ getOutlineNumberingLevels_fy_NL; getOutlineNumberingLevels_ga_IE; getOutlineNumberingLevels_gsc_FR; getOutlineNumberingLevels_hr_HR; +getOutlineNumberingLevels_hsb_DE; getOutlineNumberingLevels_is_IS; getOutlineNumberingLevels_it_CH; getOutlineNumberingLevels_it_IT; @@ -843,6 +868,7 @@ getOutlineNumberingLevels_ka_GE; getOutlineNumberingLevels_kl_GL; getOutlineNumberingLevels_la_VA; getOutlineNumberingLevels_lb_LU; +getOutlineNumberingLevels_ltg_LV; getOutlineNumberingLevels_lt_LT; getOutlineNumberingLevels_lv_LV; getOutlineNumberingLevels_mk_MK; @@ -903,6 +929,7 @@ getReservedWords_fy_NL; getReservedWords_ga_IE; getReservedWords_gsc_FR; getReservedWords_hr_HR; +getReservedWords_hsb_DE; getReservedWords_is_IS; getReservedWords_it_CH; getReservedWords_it_IT; @@ -910,6 +937,7 @@ getReservedWords_ka_GE; getReservedWords_kl_GL; getReservedWords_la_VA; getReservedWords_lb_LU; +getReservedWords_ltg_LV; getReservedWords_lt_LT; getReservedWords_lv_LV; getReservedWords_mk_MK; @@ -970,6 +998,7 @@ getSearchOptions_fy_NL; getSearchOptions_ga_IE; getSearchOptions_gsc_FR; getSearchOptions_hr_HR; +getSearchOptions_hsb_DE; getSearchOptions_is_IS; getSearchOptions_it_CH; getSearchOptions_it_IT; @@ -977,6 +1006,7 @@ getSearchOptions_ka_GE; getSearchOptions_kl_GL; getSearchOptions_la_VA; getSearchOptions_lb_LU; +getSearchOptions_ltg_LV; getSearchOptions_lt_LT; getSearchOptions_lv_LV; getSearchOptions_mk_MK; @@ -1037,6 +1067,7 @@ getTransliterations_fy_NL; getTransliterations_ga_IE; getTransliterations_gsc_FR; getTransliterations_hr_HR; +getTransliterations_hsb_DE; getTransliterations_is_IS; getTransliterations_it_CH; getTransliterations_it_IT; @@ -1044,6 +1075,7 @@ getTransliterations_ka_GE; getTransliterations_kl_GL; getTransliterations_la_VA; getTransliterations_lb_LU; +getTransliterations_ltg_LV; getTransliterations_lt_LT; getTransliterations_lv_LV; getTransliterations_mk_MK; @@ -1104,6 +1136,7 @@ getUnicodeScripts_fy_NL; getUnicodeScripts_ga_IE; getUnicodeScripts_gsc_FR; getUnicodeScripts_hr_HR; +getUnicodeScripts_hsb_DE; getUnicodeScripts_is_IS; getUnicodeScripts_it_CH; getUnicodeScripts_it_IT; @@ -1111,6 +1144,7 @@ getUnicodeScripts_ka_GE; getUnicodeScripts_kl_GL; getUnicodeScripts_la_VA; getUnicodeScripts_lb_LU; +getUnicodeScripts_ltg_LV; getUnicodeScripts_lt_LT; getUnicodeScripts_lv_LV; getUnicodeScripts_mk_MK; diff --git a/i18npool/source/localedata/data/localedata_others.map b/i18npool/source/localedata/data/localedata_others.map index a8212624e8e8..fd9e13cfb779 100644 --- a/i18npool/source/localedata/data/localedata_others.map +++ b/i18npool/source/localedata/data/localedata_others.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: getAllCalendars_af_NA; getAllCalendars_af_ZA; @@ -48,6 +48,7 @@ getAllCalendars_nso_ZA; getAllCalendars_om_ET; getAllCalendars_or_IN; getAllCalendars_pa_IN; +getAllCalendars_plt_MG; getAllCalendars_rw_RW; getAllCalendars_sg_CF; getAllCalendars_shs_CA; @@ -123,6 +124,7 @@ getAllCurrencies_nso_ZA; getAllCurrencies_om_ET; getAllCurrencies_or_IN; getAllCurrencies_pa_IN; +getAllCurrencies_plt_MG; getAllCurrencies_rw_RW; getAllCurrencies_sg_CF; getAllCurrencies_shs_CA; @@ -198,6 +200,7 @@ getAllFormats0_nso_ZA; getAllFormats0_om_ET; getAllFormats0_or_IN; getAllFormats0_pa_IN; +getAllFormats0_plt_MG; getAllFormats0_rw_RW; getAllFormats0_sg_CF; getAllFormats0_shs_CA; @@ -273,6 +276,7 @@ getBreakIteratorRules_nso_ZA; getBreakIteratorRules_om_ET; getBreakIteratorRules_or_IN; getBreakIteratorRules_pa_IN; +getBreakIteratorRules_plt_MG; getBreakIteratorRules_rw_RW; getBreakIteratorRules_sg_CF; getBreakIteratorRules_shs_CA; @@ -348,6 +352,7 @@ getCollationOptions_nso_ZA; getCollationOptions_om_ET; getCollationOptions_or_IN; getCollationOptions_pa_IN; +getCollationOptions_plt_MG; getCollationOptions_rw_RW; getCollationOptions_sg_CF; getCollationOptions_shs_CA; @@ -423,6 +428,7 @@ getCollatorImplementation_nso_ZA; getCollatorImplementation_om_ET; getCollatorImplementation_or_IN; getCollatorImplementation_pa_IN; +getCollatorImplementation_plt_MG; getCollatorImplementation_rw_RW; getCollatorImplementation_sg_CF; getCollatorImplementation_shs_CA; @@ -498,6 +504,7 @@ getContinuousNumberingLevels_nso_ZA; getContinuousNumberingLevels_om_ET; getContinuousNumberingLevels_or_IN; getContinuousNumberingLevels_pa_IN; +getContinuousNumberingLevels_plt_MG; getContinuousNumberingLevels_rw_RW; getContinuousNumberingLevels_sg_CF; getContinuousNumberingLevels_shs_CA; @@ -573,6 +580,7 @@ getFollowPageWords_nso_ZA; getFollowPageWords_om_ET; getFollowPageWords_or_IN; getFollowPageWords_pa_IN; +getFollowPageWords_plt_MG; getFollowPageWords_rw_RW; getFollowPageWords_sg_CF; getFollowPageWords_shs_CA; @@ -648,6 +656,7 @@ getForbiddenCharacters_nso_ZA; getForbiddenCharacters_om_ET; getForbiddenCharacters_or_IN; getForbiddenCharacters_pa_IN; +getForbiddenCharacters_plt_MG; getForbiddenCharacters_rw_RW; getForbiddenCharacters_sg_CF; getForbiddenCharacters_shs_CA; @@ -723,6 +732,7 @@ getIndexAlgorithm_nso_ZA; getIndexAlgorithm_om_ET; getIndexAlgorithm_or_IN; getIndexAlgorithm_pa_IN; +getIndexAlgorithm_plt_MG; getIndexAlgorithm_rw_RW; getIndexAlgorithm_sg_CF; getIndexAlgorithm_shs_CA; @@ -798,6 +808,7 @@ getLCInfo_nso_ZA; getLCInfo_om_ET; getLCInfo_or_IN; getLCInfo_pa_IN; +getLCInfo_plt_MG; getLCInfo_rw_RW; getLCInfo_sg_CF; getLCInfo_shs_CA; @@ -873,6 +884,7 @@ getLocaleItem_nso_ZA; getLocaleItem_om_ET; getLocaleItem_or_IN; getLocaleItem_pa_IN; +getLocaleItem_plt_MG; getLocaleItem_rw_RW; getLocaleItem_sg_CF; getLocaleItem_shs_CA; @@ -948,6 +960,7 @@ getOutlineNumberingLevels_nso_ZA; getOutlineNumberingLevels_om_ET; getOutlineNumberingLevels_or_IN; getOutlineNumberingLevels_pa_IN; +getOutlineNumberingLevels_plt_MG; getOutlineNumberingLevels_rw_RW; getOutlineNumberingLevels_sg_CF; getOutlineNumberingLevels_shs_CA; @@ -1023,6 +1036,7 @@ getReservedWords_nso_ZA; getReservedWords_om_ET; getReservedWords_or_IN; getReservedWords_pa_IN; +getReservedWords_plt_MG; getReservedWords_rw_RW; getReservedWords_sg_CF; getReservedWords_shs_CA; @@ -1098,6 +1112,7 @@ getSearchOptions_nso_ZA; getSearchOptions_om_ET; getSearchOptions_or_IN; getSearchOptions_pa_IN; +getSearchOptions_plt_MG; getSearchOptions_rw_RW; getSearchOptions_sg_CF; getSearchOptions_shs_CA; @@ -1173,6 +1188,7 @@ getTransliterations_nso_ZA; getTransliterations_om_ET; getTransliterations_or_IN; getTransliterations_pa_IN; +getTransliterations_plt_MG; getTransliterations_rw_RW; getTransliterations_sg_CF; getTransliterations_shs_CA; @@ -1248,6 +1264,7 @@ getUnicodeScripts_nso_ZA; getUnicodeScripts_om_ET; getUnicodeScripts_or_IN; getUnicodeScripts_pa_IN; +getUnicodeScripts_plt_MG; getUnicodeScripts_rw_RW; getUnicodeScripts_sg_CF; getUnicodeScripts_shs_CA; diff --git a/i18npool/source/localedata/data/ltg_LV.xml b/i18npool/source/localedata/data/ltg_LV.xml new file mode 100644 index 000000000000..c41c38c86b9c --- /dev/null +++ b/i18npool/source/localedata/data/ltg_LV.xml @@ -0,0 +1,350 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE Locale SYSTEM 'locale.dtd'> +<Locale versionDTD="2.0.3" allowUpdateFromCLDR="no" version="1.0"> + <LC_INFO> + <Language> + <LangID>ltg</LangID> + <DefaultName>Latgalian</DefaultName> + </Language> + <Country> + <CountryID>LV</CountryID> + <DefaultName>Latvia</DefaultName> + </Country> + </LC_INFO> + <LC_CTYPE unoid="generic"> + <Separators> + <DateSeparator>.</DateSeparator> + <ThousandSeparator> </ThousandSeparator> + <DecimalSeparator>,</DecimalSeparator> + <TimeSeparator>:</TimeSeparator> + <Time100SecSeparator>,</Time100SecSeparator> + <ListSeparator>;</ListSeparator> + <LongDateDayOfWeekSeparator>, </LongDateDayOfWeekSeparator> + <LongDateDaySeparator>, </LongDateDaySeparator> + <LongDateMonthSeparator> </LongDateMonthSeparator> + <LongDateYearSeparator> </LongDateYearSeparator> + </Separators> + <Markers> + <QuotationStart>‘</QuotationStart> + <QuotationEnd>’</QuotationEnd> + <DoubleQuotationStart>“</DoubleQuotationStart> + <DoubleQuotationEnd>”</DoubleQuotationEnd> + </Markers> + <TimeAM>AM</TimeAM> + <TimePM>PM</TimePM> + <MeasurementSystem>metric</MeasurementSystem> + </LC_CTYPE> + <LC_FORMAT> + <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> + <FormatCode>General</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1"> + <FormatCode>0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2"> + <FormatCode>0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3"> + <FormatCode># ##0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4"> + <FormatCode># ##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5"> + <FormatCode># ###,00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6"> + <FormatCode>0,00E+00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7"> + <FormatCode>0,00E+000</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8"> + <FormatCode>0%</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9"> + <FormatCode>0,00%</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY" formatindex="12"> + <FormatCode># ##0[$Ls-64B];-# ##0[$Ls-64B]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY" formatindex="13"> + <FormatCode># ##0,00[$Ls-64B];-# ##0,00[$Ls-64B]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY" formatindex="14"> + <FormatCode># ##0[$Ls-64B];[RED]-# ##0[$Ls-64B]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY" formatindex="15"> + <FormatCode># ##0,00[$Ls-64B];[RED]-# ##0,00[$Ls-64B]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY" formatindex="16"> + <FormatCode># ##0,00 CCC</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17"> + <FormatCode># ##0,--[$Ls-64B];[RED]-# ##0,--[$Ls-64B]</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey11" default="true" type="short" usage="DATE" formatindex="18"> + <FormatCode>D.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey14" default="true" type="long" usage="DATE" formatindex="19"> + <FormatCode>NNNNDD, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey6" default="true" type="medium" usage="DATE" formatindex="20"> + <FormatCode>DD.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="21"> + <FormatCode>DD.MM.YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="22"> + <FormatCode>D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="23"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey21" default="false" type="long" usage="DATE" formatindex="24"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="25"> + <FormatCode>D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey22" default="false" type="long" usage="DATE" formatindex="26"> + <FormatCode>D, MMMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey10" default="false" type="medium" usage="DATE" formatindex="27"> + <FormatCode>NN, DD.MMM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey18" default="false" type="long" usage="DATE" formatindex="28"> + <FormatCode>NN, D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey19" default="false" type="long" usage="DATE" formatindex="29"> + <FormatCode>NN, D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey20" default="false" type="long" usage="DATE" formatindex="30"> + <FormatCode>NNNND, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey12" default="false" type="short" usage="DATE" formatindex="31"> + <FormatCode>MM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="32"> + <FormatCode>YY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="33"> + <FormatCode>YYYY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey1" default="false" type="medium" usage="DATE" formatindex="34"> + <FormatCode>MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="35"> + <FormatCode>MMM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="36"> + <FormatCode>MMMM</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="37"> + <FormatCode>QQ YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey9" default="false" type="medium" usage="DATE" formatindex="38"> + <FormatCode>WW</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey1" default="false" type="short" usage="TIME" formatindex="39"> + <FormatCode>HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey2" default="false" type="medium" usage="TIME" formatindex="40"> + <FormatCode>HH:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey3" default="true" type="short" usage="TIME" formatindex="41"> + <FormatCode>HH:MM AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey4" default="true" type="medium" usage="TIME" formatindex="42"> + <FormatCode>HH:MM:SS AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey5" default="false" type="medium" usage="TIME" formatindex="43"> + <FormatCode>[HH]:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey6" default="false" type="short" usage="TIME" formatindex="44"> + <FormatCode>MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey7" default="false" type="medium" usage="TIME" formatindex="45"> + <FormatCode>[HH]:MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> + <FormatCode>DD.MM.YY HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> + <FormatCode>DD.MM.YYYY HH:MM:SS AM/PM</FormatCode> + </FormatElement> + </LC_FORMAT> + <LC_COLLATION> + <Collator default="true" unoid="alphanumeric"/> + <CollationOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </CollationOptions> + </LC_COLLATION> + <LC_SEARCH> + <SearchOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </SearchOptions> + </LC_SEARCH> + <LC_INDEX> + <IndexKey phonetic="false" default="true" unoid="alphanumeric">A-Ž</IndexKey> + <UnicodeScript>0</UnicodeScript> + <UnicodeScript>1</UnicodeScript> + <UnicodeScript>2</UnicodeScript> + <FollowPageWord>lpp.</FollowPageWord> + <FollowPageWord>lpp.</FollowPageWord> + </LC_INDEX> + <LC_CALENDAR> + <Calendar unoid="gregorian" default="true"> + <DaysOfWeek> + <Day> + <DayID>sun</DayID> + <DefaultAbbrvName>Sv</DefaultAbbrvName> + <DefaultFullName>svātdīne</DefaultFullName> + </Day> + <Day> + <DayID>mon</DayID> + <DefaultAbbrvName>P</DefaultAbbrvName> + <DefaultFullName>pyrmūdīne</DefaultFullName> + </Day> + <Day> + <DayID>tue</DayID> + <DefaultAbbrvName>Ū</DefaultAbbrvName> + <DefaultFullName>ūtardīne</DefaultFullName> + </Day> + <Day> + <DayID>wed</DayID> + <DefaultAbbrvName>T</DefaultAbbrvName> + <DefaultFullName>trešdīne</DefaultFullName> + </Day> + <Day> + <DayID>thu</DayID> + <DefaultAbbrvName>C</DefaultAbbrvName> + <DefaultFullName>catūrtdīne</DefaultFullName> + </Day> + <Day> + <DayID>fri</DayID> + <DefaultAbbrvName>Pk</DefaultAbbrvName> + <DefaultFullName>pīktdīne</DefaultFullName> + </Day> + <Day> + <DayID>sat</DayID> + <DefaultAbbrvName>S</DefaultAbbrvName> + <DefaultFullName>sastdīne</DefaultFullName> + </Day> + </DaysOfWeek> + <MonthsOfYear> + <Month> + <MonthID>jan</MonthID> + <DefaultAbbrvName>Jan</DefaultAbbrvName> + <DefaultFullName>janvars</DefaultFullName> + </Month> + <Month> + <MonthID>feb</MonthID> + <DefaultAbbrvName>Peb</DefaultAbbrvName> + <DefaultFullName>pebraļs</DefaultFullName> + </Month> + <Month> + <MonthID>mar</MonthID> + <DefaultAbbrvName>Mar</DefaultAbbrvName> + <DefaultFullName>marts</DefaultFullName> + </Month> + <Month> + <MonthID>apr</MonthID> + <DefaultAbbrvName>Apr</DefaultAbbrvName> + <DefaultFullName>apreļs</DefaultFullName> + </Month> + <Month> + <MonthID>may</MonthID> + <DefaultAbbrvName>Maj</DefaultAbbrvName> + <DefaultFullName>majs</DefaultFullName> + </Month> + <Month> + <MonthID>jun</MonthID> + <DefaultAbbrvName>Juņ</DefaultAbbrvName> + <DefaultFullName>juņs</DefaultFullName> + </Month> + <Month> + <MonthID>jul</MonthID> + <DefaultAbbrvName>Juļ</DefaultAbbrvName> + <DefaultFullName>juļs</DefaultFullName> + </Month> + <Month> + <MonthID>aug</MonthID> + <DefaultAbbrvName>Aug</DefaultAbbrvName> + <DefaultFullName>augusts</DefaultFullName> + </Month> + <Month> + <MonthID>sep</MonthID> + <DefaultAbbrvName>Seņ</DefaultAbbrvName> + <DefaultFullName>seņtebris</DefaultFullName> + </Month> + <Month> + <MonthID>oct</MonthID> + <DefaultAbbrvName>Okt</DefaultAbbrvName> + <DefaultFullName>oktebris</DefaultFullName> + </Month> + <Month> + <MonthID>nov</MonthID> + <DefaultAbbrvName>Noj</DefaultAbbrvName> + <DefaultFullName>nojabris</DefaultFullName> + </Month> + <Month> + <MonthID>dec</MonthID> + <DefaultAbbrvName>Dek</DefaultAbbrvName> + <DefaultFullName>dekabris</DefaultFullName> + </Month> + </MonthsOfYear> + <Eras> + <Era> + <EraID>bc</EraID> + <DefaultAbbrvName>p.k.</DefaultAbbrvName> + <DefaultFullName>pyrms Kristus</DefaultFullName> + </Era> + <Era> + <EraID>ad</EraID> + <DefaultAbbrvName>AD</DefaultAbbrvName> + <DefaultFullName>pec Kristus</DefaultFullName> + </Era> + </Eras> + <StartDayOfWeek> + <DayID>mon</DayID> + </StartDayOfWeek> + <MinimalDaysInFirstWeek>1</MinimalDaysInFirstWeek> + </Calendar> + </LC_CALENDAR> + <LC_CURRENCY> + <Currency default="true" usedInCompatibleFormatCodes="true"> + <CurrencyID>LVL</CurrencyID> + <CurrencySymbol>Ls</CurrencySymbol> + <BankSymbol>LVL</BankSymbol> + <CurrencyName>Lats</CurrencyName> + <DecimalPlaces>2</DecimalPlaces> + </Currency> + </LC_CURRENCY> + <LC_TRANSLITERATION> + <Transliteration unoid="LOWERCASE_UPPERCASE"/> + <Transliteration unoid="UPPERCASE_LOWERCASE"/> + <Transliteration unoid="IGNORE_CASE"/> + </LC_TRANSLITERATION> + <LC_MISC> + <ReservedWords> + <trueWord>patīss</trueWord> + <falseWord>oploms</falseWord> + <quarter1Word>1. catūrksnis</quarter1Word> + <quarter2Word>2. catūrksnis</quarter2Word> + <quarter3Word>3. catūrksnis</quarter3Word> + <quarter4Word>4. catūrksnis</quarter4Word> + <aboveWord>viers</aboveWord> + <belowWord>zam</belowWord> + <quarter1Abbreviation>C1</quarter1Abbreviation> + <quarter2Abbreviation>C2</quarter2Abbreviation> + <quarter3Abbreviation>C3</quarter3Abbreviation> + <quarter4Abbreviation>C4</quarter4Abbreviation> + </ReservedWords> + </LC_MISC> + <LC_NumberingLevel ref="lv_LV"/> + <LC_OutLineNumberingLevel ref="lv_LV"/> +</Locale> +<!--Version 1.0 --> diff --git a/i18npool/source/localedata/data/lv_LV.xml b/i18npool/source/localedata/data/lv_LV.xml index e29a06eaf274..27bb0f13e409 100644 --- a/i18npool/source/localedata/data/lv_LV.xml +++ b/i18npool/source/localedata/data/lv_LV.xml @@ -1,462 +1,415 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Locale SYSTEM 'locale.dtd'> <Locale versionDTD="2.0.3" allowUpdateFromCLDR="no" version="1.2"> -<LC_INFO> -<Language> -<LangID>lv</LangID> -<DefaultName>Latvian</DefaultName> -</Language> -<Country> -<CountryID>LV</CountryID> -<DefaultName>Latvia</DefaultName> -</Country> -<Platform> -<PlatformID>generic</PlatformID> -</Platform> -</LC_INFO> -<LC_CTYPE unoid="generic"> -<Separators> -<DateSeparator>.</DateSeparator> -<ThousandSeparator> </ThousandSeparator> -<DecimalSeparator>,</DecimalSeparator> -<TimeSeparator>:</TimeSeparator> -<Time100SecSeparator>,</Time100SecSeparator> -<ListSeparator>;</ListSeparator> -<LongDateDayOfWeekSeparator></LongDateDayOfWeekSeparator> -<LongDateDaySeparator> </LongDateDaySeparator> -<LongDateMonthSeparator> </LongDateMonthSeparator> -<LongDateYearSeparator> g.</LongDateYearSeparator> -</Separators> -<Markers> -<QuotationStart>‘</QuotationStart> -<QuotationEnd>’</QuotationEnd> -<DoubleQuotationStart>“</DoubleQuotationStart> -<DoubleQuotationEnd>”</DoubleQuotationEnd> -</Markers> -<TimeAM>AM</TimeAM> -<TimePM>PM</TimePM> -<MeasurementSystem>Metric</MeasurementSystem> -</LC_CTYPE> -<LC_FORMAT> -<FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18"> -<FormatCode>D.M.YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="28"> -<FormatCode>NN DD MMM YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="34"> -<FormatCode>MM.YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="35"> -<FormatCode>MMM DD</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="36"> -<FormatCode>MMMM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey6" default="false" type="medium" usage="DATE" formatindex="37"> -<FormatCode>QQ YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="21"> -<FormatCode>DD.MM.YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey8" default="true" type="medium" usage="DATE" formatindex="20"> -<FormatCode>DD.MM.YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey9" default="true" type="long" usage="DATE" formatindex="19"> -<FormatCode>DD. NNNNMMMM, YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey10" default="false" type="long" usage="DATE" formatindex="22"> -<FormatCode>D. MMM, YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey11" default="false" type="long" usage="DATE" formatindex="23"> -<FormatCode>D. MMM, YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey12" default="false" type="long" usage="DATE" formatindex="25"> -<FormatCode>D. MMMM, YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey13" default="false" type="long" usage="DATE" formatindex="27"> -<FormatCode>NN, D. MMMM, YY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey14" default="false" type="long" usage="DATE" formatindex="29"> -<FormatCode>NN, D. MMMM, YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="30"> -<FormatCode>NNNNMMMM D, YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="24"> -<FormatCode>D. MMM. YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="26"> -<FormatCode>D. MMMM YYYY</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey18" default="false" type="short" usage="DATE" formatindex="31"> -<FormatCode>DD-MM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey19" default="false" type="medium" usage="DATE" formatindex="32"> -<FormatCode>YY-MM-DD</FormatCode> -<DefaultName>ISO 8601</DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey20" default="false" type="medium" usage="DATE" formatindex="33"> -<FormatCode>YYYY-MM-DD</FormatCode> -<DefaultName>ISO 8601</DefaultName> -</FormatElement> -<FormatElement msgid="DateFormatskey21" default="false" type="medium" usage="DATE" formatindex="38"> -<FormatCode>WW</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey1" default="true" type="short" usage="TIME" formatindex="39"> -<FormatCode>HH:MM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey2" default="true" type="medium" usage="TIME" formatindex="40"> -<FormatCode>HH:MM:SS</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey3" default="false" type="short" usage="TIME" formatindex="41"> -<FormatCode>HH:MM AM/PM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey4" default="false" type="medium" usage="TIME" formatindex="42"> -<FormatCode>HH:MM:SS AM/PM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey5" default="false" type="medium" usage="TIME" formatindex="43"> -<FormatCode>[HH]:MM:SS</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey6" default="false" type="short" usage="TIME" formatindex="44"> -<FormatCode>MM:SS,00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="TimeFormatskey7" default="false" type="medium" usage="TIME" formatindex="45"> -<FormatCode>[HH]:MM:SS,00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> -<FormatCode>DD.MM.YY HH:MM</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> -<FormatCode>DD.MM.YYYY HH:MM:SS</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> -<FormatCode>Standard</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1"> -<FormatCode>0</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2"> -<FormatCode>0,00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3"> -<FormatCode># ##0</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4"> -<FormatCode># ##0,00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5"> -<FormatCode># ###,00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY" formatindex="12"> -<FormatCode># ##0[$Ls-426];-# ##0[$Ls-426]</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY" formatindex="13"> -<FormatCode># ##0,00[$Ls-426];-# ##0,00[$Ls-426]</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY" formatindex="14"> -<FormatCode># ##0[$Ls-426];[RED]-# ##0[$Ls-426]</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY" formatindex="15"> -<FormatCode># ##0,00[$Ls-426];[RED]-# ##0,00[$Ls-426]</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY" formatindex="16"> -<FormatCode># ##0,00 CCC</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17"> -<FormatCode># ##0,--[$Ls-426];[RED]-# ##0,--[$Ls-426]</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8"> -<FormatCode>0%</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9"> -<FormatCode>0,00%</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6"> -<FormatCode>0,00E+000</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -<FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7"> -<FormatCode>0,00E+00</FormatCode> -<DefaultName></DefaultName> -</FormatElement> -</LC_FORMAT> -<LC_COLLATION> -<Collator unoid="alphanumeric" default="true"/> -<CollationOptions> -<TransliterationModules>IGNORE_CASE</TransliterationModules> -</CollationOptions> -</LC_COLLATION> -<LC_SEARCH> -<SearchOptions> -<TransliterationModules>IGNORE_CASE</TransliterationModules> -</SearchOptions> -</LC_SEARCH> -<LC_INDEX> -<IndexKey unoid="alphanumeric" default="true" phonetic="false">A-Y Č Ģ Ķ Ļ Ņ Š Ž</IndexKey> -<UnicodeScript>0</UnicodeScript> -<UnicodeScript>1</UnicodeScript> -<UnicodeScript>2</UnicodeScript> -<FollowPageWord>p.</FollowPageWord> -<FollowPageWord>pp.</FollowPageWord> -</LC_INDEX> -<LC_CALENDAR> -<Calendar unoid="gregorian" default="true"> -<DaysOfWeek> -<Day> -<DayID>sun</DayID> -<DefaultAbbrvName>Sv</DefaultAbbrvName> -<DefaultFullName>svētdiena</DefaultFullName> -</Day> -<Day> -<DayID>mon</DayID> -<DefaultAbbrvName>P</DefaultAbbrvName> -<DefaultFullName>pirmdiena</DefaultFullName> -</Day> -<Day> -<DayID>tue</DayID> -<DefaultAbbrvName>O</DefaultAbbrvName> -<DefaultFullName>otrdiena</DefaultFullName> -</Day> -<Day> -<DayID>wed</DayID> -<DefaultAbbrvName>T</DefaultAbbrvName> -<DefaultFullName>trešdiena</DefaultFullName> -</Day> -<Day> -<DayID>thu</DayID> -<DefaultAbbrvName>C</DefaultAbbrvName> -<DefaultFullName>ceturtdiena</DefaultFullName> -</Day> -<Day> -<DayID>fri</DayID> -<DefaultAbbrvName>Pk</DefaultAbbrvName> -<DefaultFullName>piektdiena</DefaultFullName> -</Day> -<Day> -<DayID>sat</DayID> -<DefaultAbbrvName>S</DefaultAbbrvName> -<DefaultFullName>sestdiena</DefaultFullName> -</Day> -</DaysOfWeek> -<MonthsOfYear> -<Month> -<MonthID>jan</MonthID> -<DefaultAbbrvName>jan</DefaultAbbrvName> -<DefaultFullName>janvāris</DefaultFullName> -</Month> -<Month> -<MonthID>feb</MonthID> -<DefaultAbbrvName>feb</DefaultAbbrvName> -<DefaultFullName>februāris</DefaultFullName> -</Month> -<Month> -<MonthID>mar</MonthID> -<DefaultAbbrvName>mar</DefaultAbbrvName> -<DefaultFullName>marts</DefaultFullName> -</Month> -<Month> -<MonthID>apr</MonthID> -<DefaultAbbrvName>apr</DefaultAbbrvName> -<DefaultFullName>aprīlis</DefaultFullName> -</Month> -<Month> -<MonthID>may</MonthID> -<DefaultAbbrvName>mai</DefaultAbbrvName> -<DefaultFullName>maijs</DefaultFullName> -</Month> -<Month> -<MonthID>jun</MonthID> -<DefaultAbbrvName>jūn</DefaultAbbrvName> -<DefaultFullName>jūnijs</DefaultFullName> -</Month> -<Month> -<MonthID>jul</MonthID> -<DefaultAbbrvName>jūl</DefaultAbbrvName> -<DefaultFullName>jūlijs</DefaultFullName> -</Month> -<Month> -<MonthID>aug</MonthID> -<DefaultAbbrvName>aug</DefaultAbbrvName> -<DefaultFullName>augusts</DefaultFullName> -</Month> -<Month> -<MonthID>sep</MonthID> -<DefaultAbbrvName>sep</DefaultAbbrvName> -<DefaultFullName>septembris</DefaultFullName> -</Month> -<Month> -<MonthID>oct</MonthID> -<DefaultAbbrvName>okt</DefaultAbbrvName> -<DefaultFullName>oktobris</DefaultFullName> -</Month> -<Month> -<MonthID>nov</MonthID> -<DefaultAbbrvName>nov</DefaultAbbrvName> -<DefaultFullName>novembris</DefaultFullName> -</Month> -<Month> -<MonthID>dec</MonthID> -<DefaultAbbrvName>dec</DefaultAbbrvName> -<DefaultFullName>decembris</DefaultFullName> -</Month> -</MonthsOfYear> -<Eras> -<Era> -<EraID>bc</EraID> -<DefaultAbbrvName>pmē</DefaultAbbrvName> -<DefaultFullName>pirms mūsu ēras</DefaultFullName> -</Era> -<Era> -<EraID>ad</EraID> -<DefaultAbbrvName>mē</DefaultAbbrvName> -<DefaultFullName>mūsu ērā</DefaultFullName> -</Era> -</Eras> -<StartDayOfWeek> -<DayID>mon</DayID> -</StartDayOfWeek> -<MinimalDaysInFirstWeek>1</MinimalDaysInFirstWeek> -</Calendar> -</LC_CALENDAR> -<LC_CURRENCY> -<Currency default="true" usedInCompatibleFormatCodes="true"> -<CurrencyID>LVL</CurrencyID> -<CurrencySymbol>Ls</CurrencySymbol> -<BankSymbol>LVL</BankSymbol> -<CurrencyName>Lats</CurrencyName> -<DecimalPlaces>2</DecimalPlaces> -</Currency> -</LC_CURRENCY> -<LC_TRANSLITERATION> -<Transliteration unoid="UPPERCASE_LOWERCASE"/> -<Transliteration unoid="IGNORE_CASE"/> -<Transliteration unoid="LOWERCASE_UPPERCASE" /> -</LC_TRANSLITERATION> -<LC_MISC> -<ReservedWords> -<trueWord>patiess</trueWord> -<falseWord>aplams</falseWord> -<quarter1Word>1. ceturksnis</quarter1Word> -<quarter2Word>2. ceturksnis</quarter2Word> -<quarter3Word>3. ceturksnis</quarter3Word> -<quarter4Word>4. ceturksnis</quarter4Word> -<aboveWord>augstāk</aboveWord> -<belowWord>zemāk</belowWord> -<quarter1Abbreviation>C1</quarter1Abbreviation> -<quarter2Abbreviation>C2</quarter2Abbreviation> -<quarter3Abbreviation>C3</quarter3Abbreviation> -<quarter4Abbreviation>C4</quarter4Abbreviation> -</ReservedWords> -</LC_MISC> -<LC_NumberingLevel> -<NumberingLevel Prefix=" " NumType="4" Suffix=")" /> -<NumberingLevel Prefix=" " NumType="4" Suffix="." /> -<NumberingLevel Prefix="(" NumType="4" Suffix="." /> -<NumberingLevel Prefix=" " NumType="2" Suffix="." /> -<NumberingLevel Prefix=" " NumType="0" Suffix=")" /> -<NumberingLevel Prefix=" " NumType="1" Suffix=")" /> -<NumberingLevel Prefix="(" NumType="1" Suffix=")" /> -<NumberingLevel Prefix=" " NumType="3" Suffix="." /> -</LC_NumberingLevel> -<LC_OutLineNumberingLevel> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="1" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix="(" NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix="." BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="1" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="1" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="2" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="3" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="4" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -<OutlineStyle> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="27A2" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="E006" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=")" BulletChar="E004" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> -<OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> -</OutlineStyle> -</LC_OutLineNumberingLevel> + <LC_INFO> + <Language> + <LangID>lv</LangID> + <DefaultName>Latvian</DefaultName> + </Language> + <Country> + <CountryID>LV</CountryID> + <DefaultName>Latvia</DefaultName> + </Country> + </LC_INFO> + <LC_CTYPE unoid="generic"> + <Separators> + <DateSeparator>.</DateSeparator> + <ThousandSeparator> </ThousandSeparator> + <DecimalSeparator>,</DecimalSeparator> + <TimeSeparator>:</TimeSeparator> + <Time100SecSeparator>,</Time100SecSeparator> + <ListSeparator>;</ListSeparator> + <LongDateDayOfWeekSeparator></LongDateDayOfWeekSeparator> + <LongDateDaySeparator> </LongDateDaySeparator> + <LongDateMonthSeparator> </LongDateMonthSeparator> + <LongDateYearSeparator> g.</LongDateYearSeparator> + </Separators> + <Markers> + <QuotationStart>‘</QuotationStart> + <QuotationEnd>’</QuotationEnd> + <DoubleQuotationStart>“</DoubleQuotationStart> + <DoubleQuotationEnd>”</DoubleQuotationEnd> + </Markers> + <TimeAM>AM</TimeAM> + <TimePM>PM</TimePM> + <MeasurementSystem>metric</MeasurementSystem> + </LC_CTYPE> + <LC_FORMAT> + <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> + <FormatCode>Standard</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1"> + <FormatCode>0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2"> + <FormatCode>0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3"> + <FormatCode># ##0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4"> + <FormatCode># ##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5"> + <FormatCode># ###,00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6"> + <FormatCode>0,00E+000</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7"> + <FormatCode>0,00E+00</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8"> + <FormatCode>0%</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9"> + <FormatCode>0,00%</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY" formatindex="12"> + <FormatCode># ##0[$Ls-426];-# ##0[$Ls-426]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY" formatindex="13"> + <FormatCode># ##0,00[$Ls-426];-# ##0,00[$Ls-426]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY" formatindex="14"> + <FormatCode># ##0[$Ls-426];[RED]-# ##0[$Ls-426]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY" formatindex="15"> + <FormatCode># ##0,00[$Ls-426];[RED]-# ##0,00[$Ls-426]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY" formatindex="16"> + <FormatCode># ##0,00 CCC</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17"> + <FormatCode># ##0,--[$Ls-426];[RED]-# ##0,--[$Ls-426]</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18"> + <FormatCode>D.M.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey9" default="true" type="long" usage="DATE" formatindex="19"> + <FormatCode>DD. NNNNMMMM, YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey8" default="true" type="medium" usage="DATE" formatindex="20"> + <FormatCode>DD.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="21"> + <FormatCode>DD.MM.YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey10" default="false" type="long" usage="DATE" formatindex="22"> + <FormatCode>D. MMM, YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey11" default="false" type="long" usage="DATE" formatindex="23"> + <FormatCode>D. MMM, YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="24"> + <FormatCode>D. MMM. YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey12" default="false" type="long" usage="DATE" formatindex="25"> + <FormatCode>D. MMMM, YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="26"> + <FormatCode>D. MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey13" default="false" type="long" usage="DATE" formatindex="27"> + <FormatCode>NN, D. MMMM, YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="28"> + <FormatCode>NN DD MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey14" default="false" type="long" usage="DATE" formatindex="29"> + <FormatCode>NN, D. MMMM, YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="30"> + <FormatCode>NNNNMMMM D, YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey18" default="false" type="short" usage="DATE" formatindex="31"> + <FormatCode>DD-MM</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey19" default="false" type="medium" usage="DATE" formatindex="32"> + <FormatCode>YY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey20" default="false" type="medium" usage="DATE" formatindex="33"> + <FormatCode>YYYY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="34"> + <FormatCode>MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="35"> + <FormatCode>MMM DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="36"> + <FormatCode>MMMM</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey6" default="false" type="medium" usage="DATE" formatindex="37"> + <FormatCode>QQ YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey21" default="false" type="medium" usage="DATE" formatindex="38"> + <FormatCode>WW</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey1" default="true" type="short" usage="TIME" formatindex="39"> + <FormatCode>HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey2" default="true" type="medium" usage="TIME" formatindex="40"> + <FormatCode>HH:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey3" default="false" type="short" usage="TIME" formatindex="41"> + <FormatCode>HH:MM AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey4" default="false" type="medium" usage="TIME" formatindex="42"> + <FormatCode>HH:MM:SS AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey5" default="false" type="medium" usage="TIME" formatindex="43"> + <FormatCode>[HH]:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey6" default="false" type="short" usage="TIME" formatindex="44"> + <FormatCode>MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey7" default="false" type="medium" usage="TIME" formatindex="45"> + <FormatCode>[HH]:MM:SS,00</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> + <FormatCode>DD.MM.YY HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> + <FormatCode>DD.MM.YYYY HH:MM:SS</FormatCode> + </FormatElement> + </LC_FORMAT> + <LC_COLLATION> + <Collator unoid="alphanumeric" default="true"/> + <CollationOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </CollationOptions> + </LC_COLLATION> + <LC_SEARCH> + <SearchOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </SearchOptions> + </LC_SEARCH> + <LC_INDEX> + <IndexKey unoid="alphanumeric" default="true" phonetic="false">A-Y Č Ģ Ķ Ļ Ņ Š Ž</IndexKey> + <UnicodeScript>0</UnicodeScript> + <UnicodeScript>1</UnicodeScript> + <UnicodeScript>2</UnicodeScript> + <FollowPageWord>p.</FollowPageWord> + <FollowPageWord>pp.</FollowPageWord> + </LC_INDEX> + <LC_CALENDAR> + <Calendar unoid="gregorian" default="true"> + <DaysOfWeek> + <Day> + <DayID>sun</DayID> + <DefaultAbbrvName>Sv</DefaultAbbrvName> + <DefaultFullName>svētdiena</DefaultFullName> + </Day> + <Day> + <DayID>mon</DayID> + <DefaultAbbrvName>P</DefaultAbbrvName> + <DefaultFullName>pirmdiena</DefaultFullName> + </Day> + <Day> + <DayID>tue</DayID> + <DefaultAbbrvName>O</DefaultAbbrvName> + <DefaultFullName>otrdiena</DefaultFullName> + </Day> + <Day> + <DayID>wed</DayID> + <DefaultAbbrvName>T</DefaultAbbrvName> + <DefaultFullName>trešdiena</DefaultFullName> + </Day> + <Day> + <DayID>thu</DayID> + <DefaultAbbrvName>C</DefaultAbbrvName> + <DefaultFullName>ceturtdiena</DefaultFullName> + </Day> + <Day> + <DayID>fri</DayID> + <DefaultAbbrvName>Pk</DefaultAbbrvName> + <DefaultFullName>piektdiena</DefaultFullName> + </Day> + <Day> + <DayID>sat</DayID> + <DefaultAbbrvName>S</DefaultAbbrvName> + <DefaultFullName>sestdiena</DefaultFullName> + </Day> + </DaysOfWeek> + <MonthsOfYear> + <Month> + <MonthID>jan</MonthID> + <DefaultAbbrvName>jan</DefaultAbbrvName> + <DefaultFullName>janvāris</DefaultFullName> + </Month> + <Month> + <MonthID>feb</MonthID> + <DefaultAbbrvName>feb</DefaultAbbrvName> + <DefaultFullName>februāris</DefaultFullName> + </Month> + <Month> + <MonthID>mar</MonthID> + <DefaultAbbrvName>mar</DefaultAbbrvName> + <DefaultFullName>marts</DefaultFullName> + </Month> + <Month> + <MonthID>apr</MonthID> + <DefaultAbbrvName>apr</DefaultAbbrvName> + <DefaultFullName>aprīlis</DefaultFullName> + </Month> + <Month> + <MonthID>may</MonthID> + <DefaultAbbrvName>mai</DefaultAbbrvName> + <DefaultFullName>maijs</DefaultFullName> + </Month> + <Month> + <MonthID>jun</MonthID> + <DefaultAbbrvName>jūn</DefaultAbbrvName> + <DefaultFullName>jūnijs</DefaultFullName> + </Month> + <Month> + <MonthID>jul</MonthID> + <DefaultAbbrvName>jūl</DefaultAbbrvName> + <DefaultFullName>jūlijs</DefaultFullName> + </Month> + <Month> + <MonthID>aug</MonthID> + <DefaultAbbrvName>aug</DefaultAbbrvName> + <DefaultFullName>augusts</DefaultFullName> + </Month> + <Month> + <MonthID>sep</MonthID> + <DefaultAbbrvName>sep</DefaultAbbrvName> + <DefaultFullName>septembris</DefaultFullName> + </Month> + <Month> + <MonthID>oct</MonthID> + <DefaultAbbrvName>okt</DefaultAbbrvName> + <DefaultFullName>oktobris</DefaultFullName> + </Month> + <Month> + <MonthID>nov</MonthID> + <DefaultAbbrvName>nov</DefaultAbbrvName> + <DefaultFullName>novembris</DefaultFullName> + </Month> + <Month> + <MonthID>dec</MonthID> + <DefaultAbbrvName>dec</DefaultAbbrvName> + <DefaultFullName>decembris</DefaultFullName> + </Month> + </MonthsOfYear> + <Eras> + <Era> + <EraID>bc</EraID> + <DefaultAbbrvName>pmē</DefaultAbbrvName> + <DefaultFullName>pirms mūsu ēras</DefaultFullName> + </Era> + <Era> + <EraID>ad</EraID> + <DefaultAbbrvName>mē</DefaultAbbrvName> + <DefaultFullName>mūsu ērā</DefaultFullName> + </Era> + </Eras> + <StartDayOfWeek> + <DayID>mon</DayID> + </StartDayOfWeek> + <MinimalDaysInFirstWeek>1</MinimalDaysInFirstWeek> + </Calendar> + </LC_CALENDAR> + <LC_CURRENCY> + <Currency default="true" usedInCompatibleFormatCodes="true"> + <CurrencyID>LVL</CurrencyID> + <CurrencySymbol>Ls</CurrencySymbol> + <BankSymbol>LVL</BankSymbol> + <CurrencyName>Lats</CurrencyName> + <DecimalPlaces>2</DecimalPlaces> + </Currency> + </LC_CURRENCY> + <LC_TRANSLITERATION> + <Transliteration unoid="UPPERCASE_LOWERCASE"/> + <Transliteration unoid="IGNORE_CASE"/> + <Transliteration unoid="LOWERCASE_UPPERCASE" /> + </LC_TRANSLITERATION> + <LC_MISC> + <ReservedWords> + <trueWord>patiess</trueWord> + <falseWord>aplams</falseWord> + <quarter1Word>1. ceturksnis</quarter1Word> + <quarter2Word>2. ceturksnis</quarter2Word> + <quarter3Word>3. ceturksnis</quarter3Word> + <quarter4Word>4. ceturksnis</quarter4Word> + <aboveWord>augstāk</aboveWord> + <belowWord>zemāk</belowWord> + <quarter1Abbreviation>C1</quarter1Abbreviation> + <quarter2Abbreviation>C2</quarter2Abbreviation> + <quarter3Abbreviation>C3</quarter3Abbreviation> + <quarter4Abbreviation>C4</quarter4Abbreviation> + </ReservedWords> + </LC_MISC> + <LC_NumberingLevel> + <NumberingLevel Prefix=" " NumType="4" Suffix=")" /> + <NumberingLevel Prefix=" " NumType="4" Suffix="." /> + <NumberingLevel Prefix="(" NumType="4" Suffix="." /> + <NumberingLevel Prefix=" " NumType="2" Suffix="." /> + <NumberingLevel Prefix=" " NumType="0" Suffix=")" /> + <NumberingLevel Prefix=" " NumType="1" Suffix=")" /> + <NumberingLevel Prefix="(" NumType="1" Suffix=")" /> + <NumberingLevel Prefix=" " NumType="3" Suffix="." /> + </LC_NumberingLevel> + <LC_OutLineNumberingLevel> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="1" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix="(" NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix="." BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="1" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="1" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="2" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="3" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " BulletChar="0020" BulletFontName="" ParentNumbering="4" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + <OutlineStyle> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="27A2" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="0" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="E006" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="50" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=")" BulletChar="E004" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="100" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="150" SymbolTextDistance="50" FirstLineOffset="0" /> + <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0" /> + </OutlineStyle> + </LC_OutLineNumberingLevel> </Locale> diff --git a/i18npool/source/localedata/data/makefile.mk b/i18npool/source/localedata/data/makefile.mk index fe31d176f682..2591b70fb63d 100644 --- a/i18npool/source/localedata/data/makefile.mk +++ b/i18npool/source/localedata/data/makefile.mk @@ -151,6 +151,7 @@ MY_MISC_CXXFILES = \ $(MISC)$/localedata_hi_IN.cxx \ $(MISC)$/localedata_hil_PH.cxx \ $(MISC)$/localedata_hr_HR.cxx \ + $(MISC)$/localedata_hsb_DE.cxx \ $(MISC)$/localedata_hu_HU.cxx \ $(MISC)$/localedata_hy_AM.cxx \ $(MISC)$/localedata_ia.cxx \ @@ -173,6 +174,7 @@ MY_MISC_CXXFILES = \ $(MISC)$/localedata_ln_CD.cxx \ $(MISC)$/localedata_lo_LA.cxx \ $(MISC)$/localedata_lt_LT.cxx \ + $(MISC)$/localedata_ltg_LV.cxx \ $(MISC)$/localedata_lv_LV.cxx \ $(MISC)$/localedata_mk_MK.cxx \ $(MISC)$/localedata_ml_IN.cxx \ @@ -194,6 +196,7 @@ MY_MISC_CXXFILES = \ $(MISC)$/localedata_or_IN.cxx \ $(MISC)$/localedata_pa_IN.cxx \ $(MISC)$/localedata_pl_PL.cxx \ + $(MISC)$/localedata_plt_MG.cxx \ $(MISC)$/localedata_pt_BR.cxx \ $(MISC)$/localedata_pt_PT.cxx \ $(MISC)$/localedata_ro_RO.cxx \ @@ -353,6 +356,7 @@ SHL3OBJS= \ $(SLO)$/localedata_ga_IE.obj \ $(SLO)$/localedata_gsc_FR.obj \ $(SLO)$/localedata_hr_HR.obj \ + $(SLO)$/localedata_hsb_DE.obj \ $(SLO)$/localedata_is_IS.obj \ $(SLO)$/localedata_it_CH.obj \ $(SLO)$/localedata_it_IT.obj \ @@ -361,6 +365,7 @@ SHL3OBJS= \ $(SLO)$/localedata_la_VA.obj \ $(SLO)$/localedata_lb_LU.obj \ $(SLO)$/localedata_lt_LT.obj \ + $(SLO)$/localedata_ltg_LV.obj \ $(SLO)$/localedata_lv_LV.obj \ $(SLO)$/localedata_mk_MK.obj \ $(SLO)$/localedata_mt_MT.obj \ @@ -455,6 +460,7 @@ SHL4OBJS= \ $(SLO)$/localedata_om_ET.obj \ $(SLO)$/localedata_or_IN.obj \ $(SLO)$/localedata_pa_IN.obj \ + $(SLO)$/localedata_plt_MG.obj \ $(SLO)$/localedata_rw_RW.obj \ $(SLO)$/localedata_sg_CF.obj \ $(SLO)$/localedata_shs_CA.obj \ diff --git a/i18npool/source/localedata/data/plt_MG.xml b/i18npool/source/localedata/data/plt_MG.xml new file mode 100644 index 000000000000..63906044f6e3 --- /dev/null +++ b/i18npool/source/localedata/data/plt_MG.xml @@ -0,0 +1,358 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE Locale SYSTEM 'locale.dtd'> +<Locale versionDTD="2.0.3" allowUpdateFromCLDR="no" version="1.0"> + <LC_INFO> + <Language> + <LangID>plt</LangID> + <DefaultName>Malagasy, Plateau</DefaultName> + </Language> + <Country> + <CountryID>MG</CountryID> + <DefaultName>Madagascar</DefaultName> + </Country> + </LC_INFO> + <LC_CTYPE unoid="generic"> + <Separators> + <DateSeparator>.</DateSeparator> + <ThousandSeparator>.</ThousandSeparator> + <DecimalSeparator>,</DecimalSeparator> + <TimeSeparator>:</TimeSeparator> + <Time100SecSeparator>.</Time100SecSeparator> + <ListSeparator>;</ListSeparator> + <LongDateDayOfWeekSeparator>, </LongDateDayOfWeekSeparator> + <LongDateDaySeparator>, </LongDateDaySeparator> + <LongDateMonthSeparator> </LongDateMonthSeparator> + <LongDateYearSeparator> </LongDateYearSeparator> + </Separators> + <Markers> + <QuotationStart>“</QuotationStart> + <QuotationEnd>”</QuotationEnd> + <DoubleQuotationStart>‘</DoubleQuotationStart> + <DoubleQuotationEnd>’</DoubleQuotationEnd> + </Markers> + <TimeAM>AM</TimeAM> + <TimePM>PM</TimePM> + <MeasurementSystem>metric</MeasurementSystem> + </LC_CTYPE> + <LC_FORMAT replaceFrom="[CURRENCY]" replaceTo="[$Ar.-64F]"> + <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0"> + <FormatCode>General</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1"> + <FormatCode>0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2"> + <FormatCode>0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3"> + <FormatCode>#.##0</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4"> + <FormatCode>#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5"> + <FormatCode>#.###,00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6"> + <FormatCode>0,00E+00</FormatCode> + </FormatElement> + <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7"> + <FormatCode>0,00E+000</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8"> + <FormatCode>0%</FormatCode> + </FormatElement> + <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9"> + <FormatCode>0,00%</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY" formatindex="12"> + <FormatCode>#.##0 [CURRENCY];- #.##0 [CURRENCY]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY" formatindex="13"> + <FormatCode>#.##0,00 [CURRENCY];- #.##0,00 [CURRENCY]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY" formatindex="14"> + <FormatCode>#.##0 [CURRENCY];[RED]- #.##0 [CURRENCY]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY" formatindex="15"> + <FormatCode>#.##0,00 [CURRENCY];[RED]- #.##0,00 [CURRENCY]</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY" formatindex="16"> + <FormatCode>CCC#.##0,00</FormatCode> + </FormatElement> + <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17"> + <FormatCode>#.##0,-- [CURRENCY];[RED]- #.##0,-- [CURRENCY]</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey11" default="true" type="short" usage="DATE" formatindex="18"> + <FormatCode>D.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey14" default="true" type="long" usage="DATE" formatindex="19"> + <FormatCode>NNNNDD, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey6" default="true" type="medium" usage="DATE" formatindex="20"> + <FormatCode>DD.MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="21"> + <FormatCode>DD.MM.YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="22"> + <FormatCode>D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="23"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey21" default="false" type="long" usage="DATE" formatindex="24"> + <FormatCode>D, MMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="25"> + <FormatCode>D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey22" default="false" type="long" usage="DATE" formatindex="26"> + <FormatCode>D, MMMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey10" default="false" type="medium" usage="DATE" formatindex="27"> + <FormatCode>NN, DD.MMM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey18" default="false" type="long" usage="DATE" formatindex="28"> + <FormatCode>NN, D, MMM YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey19" default="false" type="long" usage="DATE" formatindex="29"> + <FormatCode>NN, D, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey20" default="false" type="long" usage="DATE" formatindex="30"> + <FormatCode>NNNND, MMMM YYYY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey12" default="false" type="short" usage="DATE" formatindex="31"> + <FormatCode>MM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="32"> + <FormatCode>YY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="33"> + <FormatCode>YYYY-MM-DD</FormatCode> + <DefaultName>ISO 8601</DefaultName> + </FormatElement> + <FormatElement msgid="DateFormatskey1" default="false" type="medium" usage="DATE" formatindex="34"> + <FormatCode>MM.YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="35"> + <FormatCode>MMM.DD</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="36"> + <FormatCode>MMMM</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="37"> + <FormatCode>QQ YY</FormatCode> + </FormatElement> + <FormatElement msgid="DateFormatskey9" default="false" type="medium" usage="DATE" formatindex="38"> + <FormatCode>WW</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey1" default="false" type="short" usage="TIME" formatindex="39"> + <FormatCode>HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey2" default="false" type="medium" usage="TIME" formatindex="40"> + <FormatCode>HH:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey3" default="true" type="short" usage="TIME" formatindex="41"> + <FormatCode>HH:MM AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey4" default="true" type="medium" usage="TIME" formatindex="42"> + <FormatCode>HH:MM:SS AM/PM</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey5" default="false" type="medium" usage="TIME" formatindex="43"> + <FormatCode>[HH]:MM:SS</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey6" default="false" type="short" usage="TIME" formatindex="44"> + <FormatCode>MM:SS.00</FormatCode> + </FormatElement> + <FormatElement msgid="TimeFormatskey7" default="false" type="medium" usage="TIME" formatindex="45"> + <FormatCode>[HH]:MM:SS.00</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> + <FormatCode>DD.MM.YY HH:MM</FormatCode> + </FormatElement> + <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> + <FormatCode>DD.MM.YYYY HH:MM:SS AM/PM</FormatCode> + </FormatElement> + </LC_FORMAT> + <LC_COLLATION> + <Collator default="true" unoid="alphanumeric"/> + <CollationOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </CollationOptions> + </LC_COLLATION> + <LC_SEARCH> + <SearchOptions> + <TransliterationModules>IGNORE_CASE</TransliterationModules> + </SearchOptions> + </LC_SEARCH> + <LC_INDEX> + <IndexKey phonetic="false" default="true" unoid="alphanumeric">A-Z</IndexKey> + <UnicodeScript>0</UnicodeScript> + <UnicodeScript>1</UnicodeScript> + <FollowPageWord>p</FollowPageWord> + <FollowPageWord>pp</FollowPageWord> + </LC_INDEX> + <LC_CALENDAR> + <Calendar unoid="gregorian" default="true"> + <DaysOfWeek> + <Day> + <DayID>sun</DayID> + <DefaultAbbrvName>Alah</DefaultAbbrvName> + <DefaultFullName>Alahady</DefaultFullName> + </Day> + <Day> + <DayID>mon</DayID> + <DefaultAbbrvName>Alat</DefaultAbbrvName> + <DefaultFullName>Alatsinainy</DefaultFullName> + </Day> + <Day> + <DayID>tue</DayID> + <DefaultAbbrvName>Tal</DefaultAbbrvName> + <DefaultFullName>Talata</DefaultFullName> + </Day> + <Day> + <DayID>wed</DayID> + <DefaultAbbrvName>Alar</DefaultAbbrvName> + <DefaultFullName>Alarobia</DefaultFullName> + </Day> + <Day> + <DayID>thu</DayID> + <DefaultAbbrvName>Alak</DefaultAbbrvName> + <DefaultFullName>Alakamisy</DefaultFullName> + </Day> + <Day> + <DayID>fri</DayID> + <DefaultAbbrvName>Zom</DefaultAbbrvName> + <DefaultFullName>Zoma</DefaultFullName> + </Day> + <Day> + <DayID>sat</DayID> + <DefaultAbbrvName>Asab</DefaultAbbrvName> + <DefaultFullName>Asabotsy</DefaultFullName> + </Day> + </DaysOfWeek> + <MonthsOfYear> + <Month> + <MonthID>jan</MonthID> + <DefaultAbbrvName>Jan</DefaultAbbrvName> + <DefaultFullName>Janoary</DefaultFullName> + </Month> + <Month> + <MonthID>feb</MonthID> + <DefaultAbbrvName>Feb</DefaultAbbrvName> + <DefaultFullName>Febroary</DefaultFullName> + </Month> + <Month> + <MonthID>mar</MonthID> + <DefaultAbbrvName>Mar</DefaultAbbrvName> + <DefaultFullName>Marsa</DefaultFullName> + </Month> + <Month> + <MonthID>apr</MonthID> + <DefaultAbbrvName>Apr</DefaultAbbrvName> + <DefaultFullName>Aprily</DefaultFullName> + </Month> + <Month> + <MonthID>may</MonthID> + <DefaultAbbrvName>May</DefaultAbbrvName> + <DefaultFullName>May</DefaultFullName> + </Month> + <Month> + <MonthID>jun</MonthID> + <DefaultAbbrvName>Jon</DefaultAbbrvName> + <DefaultFullName>Jona</DefaultFullName> + </Month> + <Month> + <MonthID>jul</MonthID> + <DefaultAbbrvName>Jol</DefaultAbbrvName> + <DefaultFullName>Jolay</DefaultFullName> + </Month> + <Month> + <MonthID>aug</MonthID> + <DefaultAbbrvName>Aog</DefaultAbbrvName> + <DefaultFullName>Aogosta</DefaultFullName> + </Month> + <Month> + <MonthID>sep</MonthID> + <DefaultAbbrvName>Sep</DefaultAbbrvName> + <DefaultFullName>Septambra</DefaultFullName> + </Month> + <Month> + <MonthID>oct</MonthID> + <DefaultAbbrvName>Okt</DefaultAbbrvName> + <DefaultFullName>Oktobra</DefaultFullName> + </Month> + <Month> + <MonthID>nov</MonthID> + <DefaultAbbrvName>Nov</DefaultAbbrvName> + <DefaultFullName>Novambra</DefaultFullName> + </Month> + <Month> + <MonthID>dec</MonthID> + <DefaultAbbrvName>Des</DefaultAbbrvName> + <DefaultFullName>Desambra</DefaultFullName> + </Month> + </MonthsOfYear> + <Eras> + <Era> + <EraID>bc</EraID> + <DefaultAbbrvName>BC</DefaultAbbrvName> + <DefaultFullName>BC</DefaultFullName> + </Era> + <Era> + <EraID>ad</EraID> + <DefaultAbbrvName>AD</DefaultAbbrvName> + <DefaultFullName>Anno Domini</DefaultFullName> + </Era> + </Eras> + <StartDayOfWeek> + <DayID>mon</DayID> + </StartDayOfWeek> + <MinimalDaysInFirstWeek>1</MinimalDaysInFirstWeek> + </Calendar> + </LC_CALENDAR> + <LC_CURRENCY> + <Currency default="true" usedInCompatibleFormatCodes="true"> + <CurrencyID>MGA</CurrencyID> + <CurrencySymbol>Ar.</CurrencySymbol> + <BankSymbol>MGA</BankSymbol> + <CurrencyName>Ariary</CurrencyName> + <DecimalPlaces>2</DecimalPlaces> + </Currency> + </LC_CURRENCY> + <LC_TRANSLITERATION> + <Transliteration unoid="LOWERCASE_UPPERCASE"/> + <Transliteration unoid="UPPERCASE_LOWERCASE"/> + <Transliteration unoid="IGNORE_CASE"/> + </LC_TRANSLITERATION> + <LC_MISC> + <ReservedWords> + <trueWord>Marina</trueWord> + <falseWord>Diso</falseWord> + <quarter1Word>Quarter 1</quarter1Word> + <quarter2Word>Quarter 2</quarter2Word> + <quarter3Word>Quarter 3</quarter3Word> + <quarter4Word>Quarter 4</quarter4Word> + <aboveWord>Ambony</aboveWord> + <belowWord>Ambany</belowWord> + <quarter1Abbreviation>Q1</quarter1Abbreviation> + <quarter2Abbreviation>Q2</quarter2Abbreviation> + <quarter3Abbreviation>Q3</quarter3Abbreviation> + <quarter4Abbreviation>Q4</quarter4Abbreviation> + </ReservedWords> + </LC_MISC> + <LC_NumberingLevel> + <NumberingLevel NumType="4" Prefix=" " Suffix=")"/> + <NumberingLevel NumType="4" Prefix=" " Suffix="."/> + <NumberingLevel NumType="4" Prefix="(" Suffix=")"/> + <NumberingLevel NumType="2" Prefix=" " Suffix="."/> + <NumberingLevel NumType="0" Prefix=" " Suffix=")"/> + <NumberingLevel NumType="1" Prefix=" " Suffix=")"/> + <NumberingLevel NumType="1" Prefix="(" Suffix=")"/> + <NumberingLevel NumType="3" Prefix=" " Suffix="."/> + </LC_NumberingLevel> + <LC_OutLineNumberingLevel ref="en_US"/> +</Locale> +<!--Version 1.0 --> diff --git a/i18npool/source/localedata/data/ro_RO.xml b/i18npool/source/localedata/data/ro_RO.xml index ed92d9243cb6..c03ebd990f88 100644 --- a/i18npool/source/localedata/data/ro_RO.xml +++ b/i18npool/source/localedata/data/ro_RO.xml @@ -223,10 +223,11 @@ <LC_COLLATION ref="en_US"/> <LC_SEARCH ref="en_US"/> <LC_INDEX> - <IndexKey unoid="alphanumeric" default="true" phonetic="false">A Ă Â B-I Î J-S Ş T Ţ U-Z</IndexKey> + <IndexKey unoid="alphanumeric" default="true" phonetic="false">A Ă Â B-I Î J-S Ș Ş T Ț Ţ U-Z</IndexKey> <UnicodeScript>0</UnicodeScript> <UnicodeScript>1</UnicodeScript> <UnicodeScript>2</UnicodeScript> + <UnicodeScript>3</UnicodeScript> <FollowPageWord>p.</FollowPageWord> <FollowPageWord>pp.</FollowPageWord> </LC_INDEX> diff --git a/i18npool/source/localedata/data/shs_CA.xml b/i18npool/source/localedata/data/shs_CA.xml index 4060d002bbe2..c7e46fa3453d 100644 --- a/i18npool/source/localedata/data/shs_CA.xml +++ b/i18npool/source/localedata/data/shs_CA.xml @@ -13,7 +13,7 @@ </LC_INFO> <LC_CTYPE> <Separators> - <DateSeparator>/</DateSeparator> + <DateSeparator>-</DateSeparator> <ThousandSeparator>,</ThousandSeparator> <DecimalSeparator>.</DecimalSeparator> <TimeSeparator>:</TimeSeparator> @@ -84,16 +84,16 @@ <FormatCode>[CURRENCY]#,##0.--;[RED]-[CURRENCY]#,##0.--</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18"> - <FormatCode>M/D/YY</FormatCode> + <FormatCode>YY-M-D</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey9" default="true" type="long" usage="DATE" formatindex="19"> <FormatCode>NNNNMMMM DD, YYYY</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey8" default="true" type="medium" usage="DATE" formatindex="20"> - <FormatCode>MM/DD/YY</FormatCode> + <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="20"> + <FormatCode>YY-MM-DD</FormatCode> </FormatElement> - <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="21"> - <FormatCode>MM/DD/YYYY</FormatCode> + <FormatElement msgid="DateFormatskey7" default="true" type="medium" usage="DATE" formatindex="21"> + <FormatCode>YYYY-MM-DD</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey10" default="false" type="long" usage="DATE" formatindex="22"> <FormatCode>MMM D, YY</FormatCode> @@ -114,7 +114,7 @@ <FormatCode>NN, MMM D, YY</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="28"> - <FormatCode>NN DD/MMM YY</FormatCode> + <FormatCode>NN DD-MMM YY</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey14" default="false" type="long" usage="DATE" formatindex="29"> <FormatCode>NN, MMMM D, YYYY</FormatCode> @@ -134,7 +134,7 @@ <DefaultName>ISO 8601</DefaultName> </FormatElement> <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="34"> - <FormatCode>MM/YY</FormatCode> + <FormatCode>YY-MM</FormatCode> </FormatElement> <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="35"> <FormatCode>MMM DD</FormatCode> @@ -170,10 +170,10 @@ <FormatCode>[HH]:MM:SS.00</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey1" default="true" type="medium" usage="DATE_TIME" formatindex="46"> - <FormatCode>MM/DD/YY HH:MM AM/PM</FormatCode> + <FormatCode>YYYY-MM-DD HH:MM</FormatCode> </FormatElement> <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47"> - <FormatCode>MM/DD/YYYY HH:MM:SS</FormatCode> + <FormatCode>YYYY-MM-DD HH:MM:SS</FormatCode> </FormatElement> </LC_FORMAT> <LC_COLLATION> diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index eeb9955c35bc..920a63fe149a 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -167,6 +167,8 @@ static const struct { { "mt_MT", lcl_DATA_EURO }, { "sc_IT", lcl_DATA_EURO }, { "ast_ES", lcl_DATA_EURO }, + { "ltg_LV", lcl_DATA_EURO }, + { "hsb_DE", lcl_DATA_EURO }, { "ja_JP", lcl_DATA_OTHERS }, { "ko_KR", lcl_DATA_OTHERS }, @@ -245,6 +247,7 @@ static const struct { { "ar_OM", lcl_DATA_OTHERS }, { "ug_CN", lcl_DATA_OTHERS }, { "om_ET", lcl_DATA_OTHERS }, + { "plt_MG", lcl_DATA_OTHERS }, }; static const sal_Unicode under = sal_Unicode('_'); diff --git a/i18npool/source/search/i18nsearch.map b/i18npool/source/search/i18nsearch.map deleted file mode 100644 index 02fe32ac5839..000000000000 --- a/i18npool/source/search/i18nsearch.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { -global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - -local: - *; -}; diff --git a/i18npool/source/search/makefile.mk b/i18npool/source/search/makefile.mk index 0a0d804c5c06..aed976edd896 100644 --- a/i18npool/source/search/makefile.mk +++ b/i18npool/source/search/makefile.mk @@ -68,7 +68,7 @@ SHL1STDLIBS= \ $(I18NREGEXPLIB) SHL1DEPN= makefile.mk -SHL1VERSIONMAP= i18nsearch.map +SHL1VERSIONMAP= $(SOLARENV)/src/component.map SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) diff --git a/i18npool/source/textconversion/data/stc_char.dic b/i18npool/source/textconversion/data/stc_char.dic index 27560f3bc34f..32c2b3c66502 100644 --- a/i18npool/source/textconversion/data/stc_char.dic +++ b/i18npool/source/textconversion/data/stc_char.dic @@ -59,11 +59,11 @@ 丰:丰豐 临:臨 丸:丸汍 -为:為 +为:為爲 丽:麗 举:舉 乃:乃迺 -么:么麼 +么:么麼麽 义:義 乌:烏 乐:樂 @@ -76,15 +76,17 @@ 了:了暸瞭 争:爭 亍:亍豖 +于:於 亏:虧 云:云雲 井:井丼 亘:亙 亚:亞 -产:產 +产:產産 亩:畝 亲:親 亵:褻 +亸:嚲 亿:億 仂:仂扐 仄:仄庂 @@ -99,7 +101,7 @@ 们:們 价:價价 仿:仿倣髣 -众:眾 +众:眾衆 优:優优 伙:伙夥 会:會 @@ -107,11 +109,12 @@ 伞:傘 伟:偉 传:傳 +伣:俔 伤:傷 伥:倀 伦:倫 伧:傖 -伪:偽 +伪:偽僞 伫:佇 佑:佑祐 体:體体 @@ -136,6 +139,7 @@ 俨:儼 俩:倆 俪:儷 +俫:倈 俭:儉 修:修脩 俯:俯頫 @@ -188,7 +192,7 @@ 凛:凜 几:几幾 凤:鳳 -凫:鳧 +凫:鳧鳬 凭:憑 凯:凱 凶:凶兇 @@ -196,7 +200,7 @@ 击:擊 凿:鑿 刍:芻 -划:划劃 +划:划劃畫 刘:劉 则:則 刚:剛 @@ -204,6 +208,7 @@ 删:刪 刨:刨鉋鑤 别:別彆 +刬:剗 刭:剄 刮:刮颳 制:制製 @@ -232,6 +237,7 @@ 勋:勛勳 勖:勗勖 勤:勤懃 +勚:勩 匀:勻 匡:匡劻 匦:匭 @@ -262,7 +268,8 @@ 压:壓 厌:厭 厍:厙 -厕:廁 +厐:龎 +厕:廁厠 厘:釐厘 厢:廂 厣:厴 @@ -271,6 +278,7 @@ 厩:廄 厮:廝 县:縣 +叁:叄 参:參 双:雙 发:發髮醱 @@ -287,14 +295,16 @@ 吃:吃喫 合:合閤 吊:弔吊 +同:衕 后:后後 向:向嚮曏 吓:嚇 吕:呂 吗:嗎 +吣:唚 吨:噸吨 听:聽听 -启:啟 +启:啟啓 吴:吳 呆:呆獃騃 呐:吶 @@ -315,6 +325,8 @@ 咛:嚀 咯:咯詻 咱:咱偺 +咝:噝 +咤:吒 咸:咸鹹 咽:咽嚥 哄:哄鬨 @@ -333,7 +345,9 @@ 唇:唇脣 唉:唉欸 唛:嘜 +唝:嗊 唠:嘮 +唡:啢 唢:嗩 唤:喚 啕:啕咷 @@ -342,6 +356,7 @@ 啬:嗇 啭:囀 啮:齧嚙囓 +啴:嘽 啸:嘯 喂:喂餵 喧:喧諠 @@ -374,6 +389,7 @@ 圹:壙 场:場 址:址阯 +坂:阪 坏:壞坏 坑:坑阬 块:塊 @@ -385,17 +401,21 @@ 坟:墳 坠:墜 垄:壟 +垅:壠 垆:壚 垒:壘 垦:墾 垩:堊 垫:墊 垭:埡 +垱:壋 垲:塏 +垴:堖 埘:塒 埙:壎塤 埚:堝 堇:堇菫 +埯:垵 堑:塹 堕:墮 堤:堤隄 @@ -403,11 +423,12 @@ 墙:牆墻 壮:壯 声:聲 -壳:殼 +壳:殼殻 壶:壺 +壸:壼 处:處 备:備 -复:復複复 +复:復複复覆 够:夠 夫:夫伕 夭:夭殀 @@ -418,7 +439,7 @@ 奁:奩 奂:奐 奋:奮 -奖:獎 +奖:獎奬 奥:奧 奶:奶嬭 奸:奸姦 @@ -428,9 +449,10 @@ 妙:妙玅 妩:嫵 妪:嫗 -妫:媯 +妫:媯嬀 姗:姍 姜:姜薑 +姹:奼 娄:婁 娅:婭 娆:嬈 @@ -480,6 +502,7 @@ 尽:盡儘 局:局侷跼挶 层:層 +屃:屓 屉:屜 届:屆 属:屬 @@ -491,12 +514,13 @@ 岖:嶇 岗:崗 岘:峴 +岙:嶴 岚:嵐 岛:島 岩:岩巖嵒 岭:嶺岭 岳:岳嶽 -岽:崠 +岽:崠崬 岿:巋 峄:嶧 峡:峽 @@ -561,11 +585,13 @@ 强:強彊 归:歸 当:當儅噹 -录:錄 +录:錄録 +彝:彞 彗:彗篲 彦:彥 彩:彩綵 彻:徹 +征:徵 径:徑 徇:徇侚 徊:徊佪 @@ -600,7 +626,7 @@ 恼:惱 恽:惲 悦:悅 -悫:愨 +悫:愨慤 悬:懸 悭:慳 悯:憫 @@ -630,6 +656,7 @@ 战:戰 戚:戚慼 戬:戩 +戯:戱 户:戶 扁:扁稨 扉:屝扉 @@ -669,6 +696,7 @@ 拨:撥 择:擇 挂:掛挂 +挜:掗 挚:摯 挛:攣 挝:撾 @@ -680,6 +708,7 @@ 挣:掙 挤:擠 挥:揮 +挦:撏 挽:挽輓 捂:捂摀 捆:捆梱綑 @@ -701,6 +730,7 @@ 掼:摜 插:插扱 揽:攬 +揾:搵 揿:撳 搀:攙 搁:擱 @@ -745,9 +775,11 @@ 旷:曠 昂:昂卬 昆:昆崑 +旸:暘 昙:曇 昵:暱昵 昼:晝 +昽:曨 显:顯 晋:晉 晒:曬晒 @@ -788,6 +820,7 @@ 枢:樞 枣:棗 枥:櫪 +枧:梘 枨:棖 枪:槍鎗 枫:楓 @@ -824,6 +857,9 @@ 桩:樁 梁:梁樑 梦:夢 +梼:檮 +梾:棶 +梿:槤 检:檢 棂:櫺欞 棋:棋碁 @@ -837,10 +873,12 @@ 椭:橢 楼:樓 榄:欖 +榅:榲 榇:櫬 榈:櫚 榉:櫸 榨:搾榨 +槚:檟 槛:檻 槟:檳 槠:櫧 @@ -896,7 +934,7 @@ 沥:瀝 沦:淪 沧:滄 -沩:溈 +沩:溈潙 沪:滬 沾:沾霑 泄:泄洩 @@ -925,6 +963,7 @@ 浍:澮 济:濟 浏:瀏 +浐:滻 浑:渾 浒:滸 浓:濃 @@ -970,7 +1009,7 @@ 滗:潷 滚:滾 滞:滯 -滟:灩 +滟:灩灧 滠:灄 满:滿 滢:瀅 @@ -979,9 +1018,11 @@ 滦:灤 滨:濱 滩:灘 +滪:澦 漓:漓灕 演:演縯 漾:漾瀁 +漤:灠 潆:瀠 潇:瀟 潋:瀲 @@ -996,6 +1037,7 @@ 灭:滅 灯:燈 灵:靈 +灶:竈 灾:災 灿:燦 炀:煬 @@ -1032,12 +1074,13 @@ 爱:愛 爷:爺 牍:牘 -牦:犛 +牦:犛氂 牵:牽 牺:犧 犊:犢 状:狀 犷:獷 +犸:獁 犹:猶 狈:狽 狞:獰 @@ -1059,14 +1102,17 @@ 献:獻 獭:獺 玑:璣 +玚:瑒 玛:瑪 玮:瑋 环:環鐶 现:現 +玱:瑲 玺:璽 珏:玨 珐:琺 珑:瓏 +珰:璫 珲:琿 球:球毬 琅:琅瑯 @@ -1091,6 +1137,8 @@ 疟:瘧 疠:癘 疡:瘍 +疬:癧 +疭:瘲 疮:瘡 疯:瘋 疱:皰 @@ -1099,6 +1147,7 @@ 痈:廱癰 痉:痙 痒:癢痒 +痖:瘂 痨:癆 痪:瘓 痫:癇 @@ -1107,7 +1156,7 @@ 痹:痺痹 瘅:癉 瘗:瘞 -瘘:瘺 +瘘:瘺瘻 瘪:癟 瘫:癱 瘾:癮 @@ -1125,14 +1174,18 @@ 盖:蓋 盗:盜 盘:槃盤 +眍:瞘 眦:眥 眯:瞇眯 眺:眺覜 +眬:矓 +着:著 睁:睜 睐:睞 睑:瞼 睾:睪睾 睿:睿叡 +瞆:瞶 瞒:瞞 瞩:矚 矫:矯 @@ -1145,15 +1198,18 @@ 砗:硨 砚:硯 砧:砧碪 +砜:碸 砺:礪 砻:礱 砾:礫 础:礎 +硁:硜 硕:碩 硖:硤 硗:磽 +硙:磑 确:確确 -硷:鹼 +硷:鹼礆 碍:礙 碛:磧 碜:磣 @@ -1164,6 +1220,8 @@ 礼:禮 祆:祆祅 祛:祛袪 +祃:禡 +祎:禕 祢:禰 祯:禎 祷:禱 @@ -1180,6 +1238,8 @@ 积:積 称:稱 秽:穢 +秾:穠 +稆:穭 税:稅 稣:穌 稳:穩 @@ -1187,13 +1247,14 @@ 穷:窮 窃:竊 窍:竅 +窎:窵 窑:窯 窜:竄 窝:窩 窥:窺 窦:竇 窭:窶 -竖:豎 +竖:豎竪 竞:競 端:端耑 笃:篤 @@ -1210,9 +1271,11 @@ 策:策筴 筚:篳 筛:篩 +筜:簹 筝:箏 筱:筱篠 筹:籌 +筼:篔 签:簽籤 简:簡 箅:箄箅 @@ -1246,6 +1309,7 @@ 紧:緊 累:累櫐纍 絷:縶 +纟:糹 纠:糾 纡:紆 红:紅 @@ -1260,20 +1324,24 @@ 纫:紉 纬:緯 纭:紜 +纮:紘 纯:純 纰:紕 纱:紗 纲:綱 纳:納 +纴:紝 纵:縱 纶:綸 纷:紛 纸:紙 纹:紋 纺:紡 +纻:紵 +纼:紖 纽:紐 纾:紓 -线:線 +线:線綫 绀:紺 绁:紲 绂:紱 @@ -1294,44 +1362,50 @@ 绑:綁 绒:絨 结:結 +绔:絝 绕:繞 +绖:絰 绗:絎 绘:繪 给:給 绚:絢 绛:絳 络:絡 -绝:絕 +绝:絕絶 绞:絞 统:統 绠:綆 绡:綃 绢:絹 -绣:繡 +绣:繡綉 +绤:綌 绥:綏 -绦:絛縚 +绦:絛縚縧 继:繼 绨:綈 绩:績勣 绪:緒 绫:綾 +绬:緓 续:續 绮:綺 绯:緋 绰:綽 +绱:緔鞝 绲:緄 绳:繩 维:維 绵:綿 绶:綬 -绷:繃 +绷:繃綳 绸:綢 +绹:綯 绺:綹 绻:綣 综:綜 绽:綻 绾:綰 -绿:綠 +绿:綠緑 缀:綴 缁:緇 缂:緙 @@ -1342,6 +1416,7 @@ 缇:緹 缈:緲 缉:緝 +缊:縕 缋:繢 缌:緦 缍:綞 @@ -1360,6 +1435,7 @@ 缛:縟 缜:縝 缝:縫 +缞:縗 缟:縞 缠:纏 缡:縭 @@ -1377,7 +1453,7 @@ 缭:繚 缮:繕 缯:繒 -缰:韁 +缰:韁繮 缱:繾 缲:繰 缳:繯 @@ -1400,6 +1476,7 @@ 耀:耀燿 考:考攷 耗:耗秏 +耢:耮 耧:耬 耸:聳 耻:恥 @@ -1426,6 +1503,7 @@ 胜:勝胜 胡:胡鬍楜衚 胧:朧矓 +胨:腖 胪:臚 胫:脛 胭:胭臙 @@ -1452,6 +1530,7 @@ 膑:臏 膘:膘臕 膻:羶膻 +臜:臢 致:致緻 舄:舄潟 舆:輿 @@ -1478,6 +1557,7 @@ 苍:蒼 苎:苧 苏:蘇甦囌 +苧:薴 苟:苟茍 苹:蘋苹 茂:茂楙 @@ -1490,6 +1570,7 @@ 茧:繭茧 荆:荊 荐:荐薦 +荙:薘 荚:莢 荛:蕘 荜:蓽 @@ -1506,8 +1587,9 @@ 荩:藎 荪:蓀 荫:蔭 -荬:藚 +荬:藚蕒 荭:葒 +荮:葤 药:藥葯 莅:蒞 莓:莓苺 @@ -1520,7 +1602,7 @@ 莸:蕕 莹:瑩 莺:鶯 -莼:蓴 +莼:蓴蒓 菱:菱蔆 萝:蘿 萤:螢 @@ -1542,10 +1624,12 @@ 蓥:鎣 蓦:驀 蔑:蔑衊 +蔂:虆 蔷:薔 蔹:蘞 蔺:藺 蔼:藹 +蕰:薀 蕲:蘄 蕴:蘊 薮:藪 @@ -1553,7 +1637,7 @@ 藉:藉耤 藓:蘚 藤:藤籐 -蘖:蘗 +蘖:蘗櫱 虏:虜 虑:慮 虚:虛 @@ -1590,8 +1674,11 @@ 蝼:螻 蝾:蠑 蟮:蟺 +螀:螿 +螨:蟎 蠢:蠢惷 蠼:蠷蠼 +蟏:蠨 衅:釁舋 衔:銜啣 补:補 @@ -1601,14 +1688,17 @@ 袄:襖 袅:裊嬝嫋 袖:袖褎 +袆:褘 袜:襪 袭:襲 +袯:襏 装:裝 裆:襠 +裈:褌 裢:褳 裣:襝 裤:褲 -裥:襉 +裥:襉襇 裸:裸祼 褛:褸 褴:襤 @@ -1625,6 +1715,7 @@ 觊:覬 觋:覡 觌:覿 +觍:覥 觎:覦 觏:覯 觐:覲 @@ -1633,8 +1724,10 @@ 觞:觴 触:觸触 觯:觶 +訚:誾 誉:譽 誊:謄 +讠:訁 计:計 订:訂 讣:訃 @@ -1646,10 +1739,12 @@ 让:讓 讪:訕 讫:訖 +讬:託 训:訓 议:議 讯:訊 记:記 +讱:訒 讲:講 讳:諱 讴:謳 @@ -1659,6 +1754,7 @@ 许:許 讹:訛 论:論 +讻:訩 讼:訟 讽:諷 设:設 @@ -1670,6 +1766,7 @@ 评:評 诅:詛 识:識 +诇:詗 诈:詐 诉:訴 诊:診 @@ -1678,6 +1775,7 @@ 词:詞 诎:詘 诏:詔 +诐:詖 译:譯 诒:詒 诓:誆 @@ -1703,6 +1801,7 @@ 诧:詫 诨:諢 诩:詡 +诪:譸 诫:誡 诬:誣 语:語 @@ -1712,7 +1811,7 @@ 诱:誘 诲:誨 诳:誑 -说:說 +说:說説 诵:誦 诶:誒 请:請 @@ -1753,11 +1852,12 @@ 谛:諦 谜:謎 谝:諞 +谞:諝 谟:謨 谠:讜 谡:謖 谢:謝 -谣:謠 +谣:謠謡 谤:謗 谥:謚 谦:謙 @@ -1765,7 +1865,7 @@ 谨:謹 谩:謾 谪:謫 -谫:譾 +谫:譾謭 谬:謬 谭:譚 谮:譖 @@ -1780,9 +1880,11 @@ 谷:谷穀 豆:豆荳 豚:豚魨 +豮:豶 贝:貝 贞:貞 负:負 +贠:貟 贡:貢 财:財 责:責 @@ -1817,7 +1919,7 @@ 赀:貲 赁:賃 赂:賂 -赃:贓 +赃:贓贜 资:資 赅:賅 赆:贐 @@ -1827,25 +1929,30 @@ 赊:賒 赋:賦 赌:賭 -赍:齎 +赍:齎賫 赎:贖 赏:賞 赐:賜 +赑:贔 +赒:賙 赓:賡 赔:賠 赕:賧 赖:賴 +赗:賵 赘:贅 赙:賻 赚:賺 赛:賽 赜:賾 -赝:贗 +赝:贗贋 赞:贊讚 +赟:贇 赠:贈 赡:贍 赢:贏 赣:贛 +赪:赬 赵:趙 赶:趕赶 趋:趨 @@ -1856,6 +1963,7 @@ 跖:跖蹠 跞:躒 践:踐 +跶:躂 跷:蹺 跸:蹕 跹:躚 @@ -1876,17 +1984,20 @@ 轧:軋 轨:軌 轩:軒 +轪:軑 轫:軔 转:轉 轭:軛 轮:輪 软:軟 轰:轟 +轱:軲 轲:軻 轳:轤 轴:軸 轵:軹 轶:軼 +轷:軤 轸:軫 轹:轢 轺:軺 @@ -1895,6 +2006,7 @@ 载:載 轾:輊 轿:轎 +辀:輈 辁:輇 辂:輅 较:較 @@ -1906,11 +2018,13 @@ 辉:輝 辊:輥 辋:輞 +辌:輬 辍:輟 辎:輜 辏:輳 辐:輻 辑:輯 +辒:轀 输:輸 辔:轡 辕:轅 @@ -1966,20 +2080,23 @@ 郦:酈 郧:鄖 郸:鄲 +酂:酇 酝:醞 酬:酬詶 +酦:醱 酱:醬 酸:酸痠 酽:釅 酾:釃 酿:釀 -采:釆采採 +采:釆采採埰 释:釋 里:里浬裡裏 野:野埜 鉴:鑒鋻鑑 銮:鑾 錾:鏨 +钅:釒 钆:釓 钇:釔 针:針鍼 @@ -1988,16 +2105,21 @@ 钋:釙 钌:釕 钍:釷 -钎:釬 +钎:釬釺 钏:釧 钐:釤 +钑:鈒 钒:釩 钓:釣 钔:鍆 钕:釹 +钖:鍚 钗:釵 +钘:鈃 钙:鈣 +钚:鈈 钛:鈦 +钜:鉅 钝:鈍 钞:鈔 钟:鐘鍾 @@ -2010,7 +2132,7 @@ 钦:欽 钧:鈞 钨:鎢 -钩:鉤 +钩:鈎鉤 钪:鈧 钫:鈁 钬:鈥 @@ -2022,8 +2144,9 @@ 钲:鉦 钳:鉗拑 钴:鈷 -钵:缽 +钵:缽鉢 钶:鈳 +钷:鉕 钸:鈽 钹:鈸 钺:鉞戉 @@ -2039,6 +2162,7 @@ 铄:鑠 铅:鉛 铆:鉚 +铇:鉋 铈:鈰 铉:鉉 铊:鉈 @@ -2046,16 +2170,22 @@ 铌:鈮 铍:鈹 铎:鐸 +铏:鉶 铐:銬 铑:銠 铒:鉺 +铓:鋩 +铔:錏 铕:銪 铖:鋮 铗:鋏 +铘:鋣 铙:鐃 +铚:銍 铛:鐺 铜:銅 铝:鋁 +铞:銱 铟:銦 铠:鎧 铡:鍘 @@ -2063,6 +2193,7 @@ 铣:銑鐉 铤:鋌 铥:銩 +铦:銛 铧:鏵 铨:銓 铩:鎩 @@ -2083,6 +2214,7 @@ 铸:鑄 铹:鐒 铺:鋪舖 +铻:鋙 铼:錸 铽:鋱 链:鏈 @@ -2090,6 +2222,7 @@ 销:銷 锁:鎖 锂:鋰 +锃:鋥 锄:鋤 锅:鍋 锆:鋯 @@ -2099,7 +2232,10 @@ 锊:鋝 锋:鋒 锌:鋅 -锐:銳 +锍:鋶 +锎:鐦 +锏:鐧 +锐:銳鋭 锑:銻 锒:鋃 锓:鋟 @@ -2107,18 +2243,26 @@ 锕:錒 锖:錆 锗:鍺 +锘:鍩 错:錯 锚:錨 锛:錛 +锜:錡 +锝:鍀 锞:錁 锟:錕 +锠:錩 锡:錫 锢:錮 锣:鑼 锤:錘鎚 锥:錐 锦:錦 +锧:鑕 +锨:杴鍁 锩:錈 +锪:鍃 +锫:錇 锬:錟 锭:錠 键:鍵 @@ -2126,6 +2270,7 @@ 锰:錳 锱:錙 锲:鍥 +锳:鍈 锴:鍇 锵:鏘 锶:鍶 @@ -2134,52 +2279,70 @@ 锹:鍬 锻:鍛 锼:鎪 +锽:鍠 锾:鍰 +锿:鎄 镀:鍍 镁:鎂 镂:鏤 +镃:鎡 镄:鐨 +镅:鎇 镆:鏌 镇:鎮 +镈:鎛 镉:鎘 镊:鑷 -镌:鐫 +镋:鎲 +镌:鐫鎸 镍:鎳 +镎:鎿 镏:鎦 镐:鎬 镑:鎊 镒:鎰 镓:鎵 镔:鑌 +镕:鎔 镖:鏢 镗:鏜 镘:鏝 镙:鏍 +镚:鏰 镛:鏞 镜:鏡 镝:鏑 镞:鏃 镟:鏇 +镠:鏐 镡:鐔 +镢:鐝钁 镣:鐐 镤:鏷 +镥:鑥 镦:鐓 镧:鑭 镨:鐠 +镩:鑹 镪:鏹 镫:鐙 镬:鑊 镭:鐳 +镮:鐶 镯:鐲 镰:鐮鎌 镱:鐿 +镲:鑔 镳:鑣 +镴:鑞 +镵:鑱 镶:鑲瓖 长:長 门:門 闩:閂 闪:閃 闫:閆 +闬:閈 闭:閉 问:問 闯:闖 @@ -2198,13 +2361,15 @@ 闼:闥 闽:閩 闾:閭 +闿:闓 阀:閥 阁:閣 阂:閡 阃:閫 阄:鬮 -阅:閱 +阅:閱閲 阆:閬 +阇:闍 阈:閾 阉:閹 阊:閶 @@ -2216,12 +2381,15 @@ 阐:闡 阑:闌 阒:闃 +阓:闠 阔:闊 阕:闋 阖:闔 阗:闐 +阘:闒 阙:闕 阚:闞 +阛:闤 队:隊 阳:陽暘 阴:陰 @@ -2253,15 +2421,18 @@ 霁:霽 霉:霉黴 霓:霓蜺 +霡:霢 霭:靄 靓:靚 静:靜 面:面麵 靥:靨 鞑:韃 +鞒:鞽 鞯:韉 韦:韋 韧:韌 +韨:韍 韩:韓 韪:韙 韫:韞 @@ -2289,19 +2460,23 @@ 颈:頸 颉:頡 颊:頰 +颋:頲 颌:頜 颍:潁 +颎:熲 颏:頦 颐:頤 频:頻 -颓:頹隤穨 +颓:頹隤穨頽 颔:頷 +颕:頴 颖:穎 颗:顆 题:題 +颙:顒 颚:顎 颛:顓 -颜:顏 +颜:顏顔 额:額 颞:顳 颟:顢 @@ -2309,19 +2484,29 @@ 颡:顙 颢:顥 颤:顫 +颥:顬 颦:顰 颧:顴 风:風 +飏:颺 +飐:颭 飑:颮 飒:颯 飓:颶 +飔:颸 飕:颼 +飖:颻 +飗:飀 飘:飄 飙:飆 +飚:飈 飞:飛 飨:饗 餍:饜 +饣:飠 +饤:飣 饥:飢饑 +饦:飥 饧:餳 饨:飩 饩:餼 @@ -2338,29 +2523,41 @@ 饵:餌 饶:饒 饷:餉饟 +饹:餎 饺:餃 +饻:餏 饼:餅 饽:餑 +饾:餖 饿:餓 +馀:余 馁:餒 +馂:餕 +馃:餜 馄:餛 馅:餡 馆:館 +馇:餷 馈:饋餽 馊:餿 馋:饞 +馌:饁 馍:饃糢 +馎:餺 馏:餾 馐:饈 馑:饉 馒:饅 +馓:饊 馔:饌 +馕:饢 马:馬 驭:馭 驮:馱 驯:馴 驰:馳 驱:驅 +驲:馹 驳:駁駮 驴:驢 驵:駔 @@ -2376,23 +2573,30 @@ 驿:驛 骀:駘 骁:驍 -骂:罵 +骂:罵駡 +骃:駰 骄:驕 骅:驊 骆:駱 骇:駭 骈:駢 +骉:驫 骊:驪 骋:騁 验:驗 +骍:騂 +骎:駸 骏:駿 骐:騏 骑:騎 骒:騍 骓:騅 +骔:騌 +骕:驌 骖:驂 骗:騙 骘:騭 +骙:騤 骚:騷 骛:騖 骜:驁 @@ -2405,6 +2609,7 @@ 骣:驏 骤:驟 骥:驥 +骦:驦 骧:驤 髅:髏 髋:髖 @@ -2414,23 +2619,37 @@ 魇:魘 魉:魎 鱼:魚 +鱽:魛 鱿:魷 +鲀:魨 鲁:魯 鲂:魴 -鲇:鯰 +鲃:䰾 +鲄:魺 +鲅:鮁 +鲆:鮃 +鲇:鯰鮎 鲈:鱸 +鲉:鮋 +鲊:鮓 鲋:鮒 +鲌:鮊 鲍:鮑 鲎:鱟 +鲏:鮍 鲐:鮐 鲑:鮭 鲒:鮚 鲔:鮪 鲕:鮞 +鲖:鮦 +鲗:鰂 +鲘:鮜 +鲙:鱠 鲚:鱭 鲛:鮫 鲜:鮮 -鲞:鯗 +鲞:鯗鮝 鲟:鱘 鲠:鯁 鲡:鱺 @@ -2442,64 +2661,92 @@ 鲧:鯀 鲨:鯊 鲩:鯇 +鲪:鮶 鲫:鯽 +鲬:鯒 鲭:鯖 鲮:鯪 +鲯:鯕 鲰:鯫 鲱:鯡 鲲:鯤 鲳:鯧 +鲴:鯝 鲵:鯢 鲷:鯛 鲸:鯨 +鲹:鰺 +鲺:鯴 鲻:鯔 +鲼:鱝 鲽:鰈 +鲾:鰏 +鲿:鱨 +鳀:鯷 +鳁:鰮 鳃:鰓 -鳄:鱷 +鳄:鱷鰐 鳅:鰍 鳆:鰒 鳇:鰉 +鳊:鯿 +鳋:鰠 鳌:鰲鼇 鳍:鰭 鳎:鰨 鳏:鰥 鳐:鰩 +鳑:鰟 +鳒:鰜 鳓:鰳 鳔:鰾 鳕:鱈 鳖:鱉 鳗:鰻 +鳘:鰵 +鳙:鱅 +鳚:䲁 +鳛:鰼 鳜:鱖 鳝:鱔 鳞:鱗 鳟:鱒 鳢:鱧 +鳣:鱣 鸟:鳥 鸠:鳩 -鸡:雞 +鸡:雞鷄 鸢:鳶 鸣:鳴 +鸤:鳲 鸥:鷗 鸦:鴉 +鸧:鶬 鸨:鴇 鸩:鴆酖 鸪:鴣 鸫:鶇 鸬:鸕 鸭:鴨 +鸮:鴞 鸯:鴦 +鸰:鴒 鸱:鴟 鸲:鴝 鸳:鴛 +鸴:鷽 鸵:鴕 鸶:鷥 鸷:鷙 鸸:鴯 鸹:鴰 鸺:鵂 +鸻:鴴 +鸼:鵃 鸽:鴿 鸾:鸞 鸿:鴻 +鹀:鵐 鹁:鵓 鹂:鸝 鹃:鵑 @@ -2510,18 +2757,33 @@ 鹈:鵜 鹉:鵡 鹊:鵲 +鹋:鶓 鹌:鵪 +鹍:鵾 鹎:鵯 鹏:鵬 +鹐:鵮 鹑:鶉 +鹒:鶊 +鹓:鵷 +鹔:鷫 鹕:鶘 +鹖:鶡 鹗:鶚 鹘:鶻 -鹚:鶿 +鹙:鶖 +鹚:鶿鷀 +鹛:鶥 鹜:鶩 +鹝:鷊 鹞:鷂 +鹟:鶲 +鹠:鶹 +鹡:鶺 +鹢:鷁 鹣:鶼 鹤:鶴 +鹥:鷖 鹦:鸚 鹧:鷓 鹨:鷚 @@ -2530,24 +2792,32 @@ 鹫:鷲 鹬:鷸 鹭:鷺 +鹯:鸇 鹰:鷹 +鹱:鸌 +鹲:鸏 鹳:鸛 +鹴:鸘 鹾:鹺 麦:麥 麸:麩 麻:麻痲痳 黄:黃 黉:黌 +黡:黶 黩:黷 黪:黲 黾:黽 鼋:黿 鼍:鼉 +鼗:鞀 鼹:鼴 齐:齊 齑:齏 齿:齒 龀:齔 +龁:齕 +龂:齗 龃:齟 龄:齡 龅:齙 diff --git a/i18npool/source/textconversion/data/stc_word.dic b/i18npool/source/textconversion/data/stc_word.dic index 314c6223cc70..4ae42366888d 100644 --- a/i18npool/source/textconversion/data/stc_word.dic +++ b/i18npool/source/textconversion/data/stc_word.dic @@ -1147,3 +1147,4 @@ 音频文件<音頻檔 模拟信号<類比信號 驱动程序<驅動程式 +什么<甚麼 diff --git a/i18npool/source/textconversion/data/textconv_dict.map b/i18npool/source/textconversion/data/textconv_dict.map index 03f9073c5d86..afd873b6f38e 100644 --- a/i18npool/source/textconversion/data/textconv_dict.map +++ b/i18npool/source/textconversion/data/textconv_dict.map @@ -1,4 +1,4 @@ -OOO_1.1 { +UDK_3_0_0 { global: GetVersionInfo; getHangul2HanjaData; diff --git a/i18npool/util/i18npool.map b/i18npool/util/i18npool.map deleted file mode 100644 index 02fe32ac5839..000000000000 --- a/i18npool/util/i18npool.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { -global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - -local: - *; -}; diff --git a/i18npool/util/makefile.mk b/i18npool/util/makefile.mk index 5bf520eaad4d..d9b87d19e6ca 100644 --- a/i18npool/util/makefile.mk +++ b/i18npool/util/makefile.mk @@ -60,7 +60,7 @@ SHL1IMPLIB= i$(SHL1TARGET) SHL1DEPN= makefile.mk \ $(SLB)/i18nisolang$(ISOLANG_MAJOR)$(COMID).lib -SHL1VERSIONMAP=$(PRJNAME).map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME=$(SHL1TARGET) diff --git a/l10ntools/inc/wrdtrans.hxx b/l10ntools/inc/wrdtrans.hxx deleted file mode 100644 index b0b65526a2a2..000000000000 --- a/l10ntools/inc/wrdtrans.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ -/* - -// OBSOLETE // - -#ifndef TX3_WRDTRANS_HXX -#define TX3_WRDTRANS_HXX - -// USED - // Base Classes - // Components -class WordTransTree; -class WordTrans_ErrorList; - // Parameters -#include <tools/string.hxx> - -class WordTransformer -{ - public: - enum E_Error - { - OK = 0, - ERROR_NO_WORDLIST, - ERROR_HOTKEY, - ERROR_OUTPUTSTRING_TOO_LONG, - OTHER_ERROR - }; - - // LIFECYCLE - WordTransformer(); - ~WordTransformer(); - BOOL LoadWordlist( /// @return False, if file could not be read, or there is already a wordlist loaded. - const ByteString & i_sWordlist_Filepath, - CharSet i_nWorkingCharSet = RTL_TEXTENCODING_MS_1252, - CharSet i_nFileCharSet = RTL_TEXTENCODING_MS_1252 ); - - // OPERATIONS - USHORT Transform( /// @return The number of errors during transforming. - ByteString & io_sText); - - // INQUIRY - USHORT NrOfErrors() const; - E_Error GetError( - USHORT i_nNr, /// [0 .. NrOfErrors()-1], other values return an empty error. - ByteString * o_pErrorText = 0) const; /// If o_pErrorText != 0, the String is filled with the description of the error. - - private: - // SERVICE FUNCTION - void CreateError(); - - // DATA - WordTransTree * dpTransformer; - WordTrans_ErrorList * - dpErrors; -}; - - - -#endif - - -*/ diff --git a/l10ntools/java/receditor/java/transex3/model/SdfString.java b/l10ntools/java/receditor/java/transex3/model/SdfString.java index 7419aeb5578b..7eec2151b7c3 100644 --- a/l10ntools/java/receditor/java/transex3/model/SdfString.java +++ b/l10ntools/java/receditor/java/transex3/model/SdfString.java @@ -97,32 +97,7 @@ public class SdfString { public void setModuleName(String modulename) { this.modulename = modulename; } - /* - public String getRealFileName(){ - //String srcroot = "U:\\cws01\\l10ncleanup\\SRC680\\src.m213";//java.lang.System.getProperty( "SOLARSRC"); - //String isWindows = "4nt";//java.lang.System.getProperty( "USE_SHELL"); - String srcroot = java.lang.System.getProperty( "SOLARSRC" ); - String isWindows = java.lang.System.getProperty( "USE_SHELL" ); - //System.out.println("srcroot="+srcroot+" isWindows="+isWindows ); - //if( true ) return; - //String relpath = sourceString.getFileId().substring( sourceString.getFileId().lastIndexOf("\\") - // , sourceString.getFileId().length() ); - String filename; - if( isWindows != null && isWindows.compareTo( "4nt") == 0 ) - { - filename = srcroot + "\\" + //sourceString.getProject() + "\\" + - sourceString.getFileId() +".recommand"; - } - else - { - String filepart = sourceString.getFileId(); - filepart = filepart.replaceAll( "\\\\" , "/" ); - filename = srcroot + "/" + //sourceString.getProject() + "//" + - filepart +".recommand"; - } - return filename; - }*/ public String getRealFileName(){ String filepart = sourceString.getFileId(); filepart = filepart.replaceAll( "\\\\" , "_" ); diff --git a/l10ntools/scripts/fast_merge.pl b/l10ntools/scripts/fast_merge.pl index e2980fafddda..5dc63cf95d79 100644 --- a/l10ntools/scripts/fast_merge.pl +++ b/l10ntools/scripts/fast_merge.pl @@ -45,12 +45,8 @@ my $last_localize_file; my $first_run = "1"; my $sdf_filename; my $merge_dir; -my $WIN; my $state = "none"; -if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) { $WIN = 'TRUE'; } -else { $WIN = ''; } - $SIG{INT} = 'inthandler'; $SIG{QUIT} = 'quithandler'; @@ -67,7 +63,6 @@ struct ( sdf_obj => parse_options(); my $lock_file = $merge_dir."/lock.mk"; -$lock_file =~ s/\//\\/g , if ( $WIN ) ; acquire_lock(); read_sdf_file_names(); init(); @@ -247,10 +242,9 @@ sub make_paths { my $localizeFile = $merge_dir."\\".$current[ 0 ]->module."\\".$current[ 0 ]->file; my $path = getDir( $localizeFile ); - if ( !$WIN ) { $path =~ s/\\/\//g; } + $path =~ s/\\/\//g; - $localizeFile = $path."\\localize.sdf"; - if ( !$WIN ) { $localizeFile =~ s/\\/\//g; } + $localizeFile = $path."/localize.sdf"; return ( $path , $localizeFile ); } diff --git a/l10ntools/scripts/localize.pl b/l10ntools/scripts/localize.pl index 8b6a8231ebce..82ef331a63d5 100755 --- a/l10ntools/scripts/localize.pl +++ b/l10ntools/scripts/localize.pl @@ -70,14 +70,12 @@ my $no_gsicheck = ''; my $mode = ''; my $bVerbose = "0"; my $srcpath = ''; -my $WIN; my $languages; #my %sl_modules; # Contains all modules where en-US and de is source language my $use_default_date = '0'; my $force_ooo_module = '0'; my %is_ooo_module; my %is_so_module; -my $DELIMITER; # ( leftpart ) ( rightpart ) # prj file dummy type gid lid helpid pform width lang text helptext qhelptext title timestamp @@ -91,23 +89,14 @@ my @sdfparticles; parse_options(); check_modules_scm(); -if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) { - $WIN = 'TRUE'; - $DELIMITER = "\\"; -} - else { - $WIN = ''; - $DELIMITER = "/"; -} - my $binpath = ''; if( defined $ENV{UPDMINOREXT} ) { - $binpath = $ENV{SOLARVER}.$DELIMITER.$ENV{INPATH}.$DELIMITER."bin".$ENV{UPDMINOREXT}.$DELIMITER ; + $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin".$ENV{UPDMINOREXT}."/" ; } else { - $binpath = $ENV{SOLARVER}.$DELIMITER.$ENV{INPATH}.$DELIMITER."bin".$DELIMITER ; + $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin/" ; } #%sl_modules = fetch_sourcelanguage_dirlist(); @@ -187,9 +176,8 @@ sub splitfile{ exit( -1 ); } my $src_root = $ENV{SRC_ROOT}; - #print $WIN eq "TRUE" ? $src_root."\\l10n_so\n" : $src_root."/l10n_so\n"; - my $so_l10n_path = $WIN eq "TRUE" ? $src_root."\\l10n_so\\source" : $src_root."/l10n_so/source"; - my $ooo_l10n_path = $WIN eq "TRUE" ? $src_root."\\l10n\\source" : $src_root."/l10n/source"; + my $so_l10n_path = $src_root."/l10n_so/source"; + my $ooo_l10n_path = $src_root."/l10n/source"; #print "$so_l10n_path\n"; #print "$ooo_l10n_path\n"; @@ -286,7 +274,7 @@ sub write_sdf my @sdf_file; # mkdir!!!! - my $current_l10n_file = $WIN eq "TRUE" ? $l10n_file."\\$lang\\localize.sdf" : $l10n_file."/$lang/localize.sdf"; + my $current_l10n_file = $l10n_file."/$lang/localize.sdf"; print "Writing '$current_l10n_file'\n"; if( open DESTFILE , "< $current_l10n_file" ){ @@ -430,17 +418,17 @@ sub add_paths { my $langhash_ref = shift; my $root_dir = $ENV{ SRC_ROOT }; - my $ooo_l10n_dir = "$root_dir"."$DELIMITER"."l10n"."$DELIMITER"."source"; - my $so_l10n_dir = "$root_dir"."$DELIMITER"."l10n_so"."$DELIMITER"."source"; + my $ooo_l10n_dir = "$root_dir/l10n/source"; + my $so_l10n_dir = "$root_dir/l10n_so/source"; if( -e $ooo_l10n_dir ) { foreach my $lang ( keys( %{ $langhash_ref } ) ) { - my $loc_file = "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf"; + my $loc_file = "$ooo_l10n_dir/$lang/localize.sdf"; if( -e $loc_file ) { - push @sdfparticles , "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf"; + push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf"; } else { print "WARNING: $loc_file not found ....\n"; } } @@ -450,10 +438,10 @@ sub add_paths { foreach my $lang ( keys( %{ $langhash_ref } ) ) { - my $loc_file = "$so_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf"; + my $loc_file = "$so_l10n_dir/$lang/localize.sdf"; if( -e $loc_file ) { - push @sdfparticles , "$ooo_l10n_dir"."$DELIMITER"."$lang"."$DELIMITER"."localize.sdf"; + push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf"; } else { #print "WARNING: $loc_file not found ....\n"; } @@ -530,10 +518,6 @@ sub collectfiles{ } #foreach } # if } # if -# if ( !$bVerbose ){ -# if ( $WIN eq "TRUE" ) { $args .= " > $my_localize_log"; } -# else { $args .= " >& $my_localize_log"; } -# } if ( $bVerbose ) { print STDOUT $command.$args."\n"; } my $rc = system( $command.$args ); diff --git a/l10ntools/scripts/localize_old.pl b/l10ntools/scripts/localize_old.pl index fe63ba9a93de..d6b66d6bb535 100755 --- a/l10ntools/scripts/localize_old.pl +++ b/l10ntools/scripts/localize_old.pl @@ -63,7 +63,6 @@ my $outputfile = ''; my $mode = ''; my $bVerbose="0"; my $srcpath = ''; -my $WIN; my $languages; #my %sl_modules; # Contains all modules where en-US and de is source language my $use_default_date = '0'; @@ -78,13 +77,6 @@ my $default_date = "2002-02-02 02:02:02"; #### main #### parse_options(); -if ( defined $ENV{USE_SHELL} && $ENV{USE_SHELL} eq '4nt' ) { - $WIN = 'TRUE'; -} - else { - $WIN = ''; -} - #%sl_modules = fetch_sourcelanguage_dirlist(); @@ -136,13 +128,11 @@ sub splitfile{ next if( $prj eq "binfilter" ); # Don't merge strings into binfilter module chomp( $line ); $currentFile = $srcpath . '\\' . $prj . '\\' . $file; - if ( $WIN ) { $currentFile =~ s/\//\\/g; } - else { $currentFile =~ s/\\/\//g; } + $currentFile =~ s/\\/\//g; $cur_sdffile = $currentFile; #if( $cur_sdffile =~ /\.$file_types[\s]*$/ ){ - if( $WIN ) { $cur_sdffile =~ s/\\[^\\]*\.$file_types[\s]*$/\\localize.sdf/; } - else { $cur_sdffile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; } + $cur_sdffile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; #} # Set default date @@ -182,41 +172,6 @@ sub splitfile{ } ######################################################### -#sub fetch_sourcelanguage_dirlist -#{ -# -# my $working_path = getcwd(); -# my %sl_dirlist; -# -# chdir $srcpath; -# my @all_dirs = csh_glob( "*" ); -# -# foreach my $file ( @all_dirs ) -# { -# if( -d $file ) -# { -# my $module = $file; -# $file .= "/prj/l10n"; -# $file =~ s/\//\\/ , if( $WIN ) ; -# -# if( -f $file ) # Test file <module>/prj/l10n -# { -# $sl_dirlist{ $module } = 1; -# if( $bVerbose eq "1" ) { print STDOUT "$module: de and en-US source language detected\n"; } -# } -# } -# } -# -# chdir $working_path; -# -# return %sl_dirlist; -#} - -#sub has_two_sourcelanguages -#{ -# my $module = shift; -# return defined $sl_modules{ $module } ; -#} sub writesdf{ my $lastFile = shift; @@ -225,8 +180,7 @@ sub writesdf{ my %index=(); if( $localizeFile =~ /\.$file_types[\s]*$/ ){ - if( $WIN ) { $localizeFile =~ s/\\[^\\]*\.$file_types[\s]*$/\\localize.sdf/; } - else { $localizeFile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; } + $localizeFile =~ s/\/[^\/]*\.$file_types[\s]*$/\/localize.sdf/; }else { print STDERR "Strange filetype found '$localizeFile'\n"; return; @@ -471,10 +425,6 @@ sub collectfiles{ } #foreach } # if } # if -# if ( !$bVerbose ){ -# if ( $WIN eq "TRUE" ) { $args .= " > $my_localize_log"; } -# else { $args .= " >& $my_localize_log"; } -# } if ( $bVerbose ) { print STDOUT $command.$args."\n"; } my $rc = system( $command.$args ); diff --git a/l10ntools/source/help/makefile.mk b/l10ntools/source/help/makefile.mk index 50351913fe55..b66077501a8d 100644 --- a/l10ntools/source/help/makefile.mk +++ b/l10ntools/source/help/makefile.mk @@ -101,7 +101,7 @@ JAVACLASSFILES = \ $(CLASSDIR)$/$(PACKAGE)$/HelpFileDocument.class .IF "$(SYSTEM_LUCENE)" == "YES" -CLASSPATH!:=$(CLASSPATH)$(PATH_SEPERATOR)$(LUCENE_CORE_JAR)$(PATH_SEPERATOR)$(LUCENE_ANALYZERS_JAR) +EXTRAJARFILES += $(LUCENE_CORE_JAR) $(LUCENE_ANALYZERS_JAR) .ELSE JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar .ENDIF diff --git a/l10ntools/source/wrdtrans.cxx b/l10ntools/source/wrdtrans.cxx deleted file mode 100644 index 10d6f472640f..000000000000 --- a/l10ntools/source/wrdtrans.cxx +++ /dev/null @@ -1,245 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_l10ntools.hxx" - -/* -#include "wrdtrans.hxx" - - -// NOT FULLY DECLARED SERVICES -#include <vector> -#include <vos/macros.hxx> - - -#include <tools/stream.hxx> -#include "wtratree.hxx" - -#include <tools/string.hxx> -*/ -//************** Declaration WordTrans_ErrorList ******************// -/* -typedef NAMESPACE_STD(vector)<ByteString> Stl_ByteStringList; - -class WordTrans_ErrorList -{ - public: - // OPERATIONS - void AddError( - WordTransformer::E_Error - i_eType, - const char * i_sErrorDescription ); - void Clear(); /// Empties the list. - - // INQUIRY - USHORT NrOfErrors() const; - WordTransformer::E_Error - GetError( - USHORT i_nNr, /// [0 .. NrOfErrors()-1], other values return an empty error. - ByteString * o_pErrorText ) const; /// If o_pErrorText != 0, the String is filled with the description of the error. - private: - // DATA - Stl_ByteStringList aErrors; -}; - -*/ - -//************** Implementation WordTransformer ******************// - -/* -WordTransformer::WordTransformer() - : dpTransformer(0), - dpErrors(new WordTrans_ErrorList) -{ -} - -WordTransformer::~WordTransformer() -{ - if (dpTransformer != 0) - delete dpTransformer; - delete dpErrors; -} - -BOOL -WordTransformer::LoadWordlist( const ByteString & i_sWordlist_Filepath, - CharSet i_nWorkingCharSet, - CharSet i_nFileCharSet ) -{ - if (dpTransformer != 0) - return FALSE; - - SvFileStream aFile(String(i_sWordlist_Filepath,RTL_TEXTENCODING_ASCII_US),STREAM_STD_READ); - if (! aFile.IsOpen()) - return FALSE; - aFile.SetStreamCharSet( i_nFileCharSet ) ; -// aFile.SetTargetCharSet( i_nWorkingCharSet ); - - dpTransformer = new WordTransTree; - - ByteString sTrans; - while ( aFile.ReadLine(sTrans) ) - { - dpTransformer->AddWordPair(sTrans.GetToken(0,';'),sTrans.GetToken(1,';')); - } - - aFile.Close(); - return TRUE; -} - -USHORT -WordTransformer::Transform(ByteString & io_sText) -{ - // Initialization and precondition testing: - dpErrors->Clear(); - if (dpTransformer == 0) - { - dpErrors->AddError(ERROR_NO_WORDLIST,"Error: No wordlist was loaded."); - return dpErrors->NrOfErrors(); - } - else if (io_sText.Len() > 63 * 1024) - { - dpErrors->AddError(ERROR_OUTPUTSTRING_TOO_LONG,"Error: Inputstring was too long (bigger than 63 KB)."); - return dpErrors->NrOfErrors(); - } - else if (io_sText.Len() == 0) - { - return 0; - } - - // Transform: - dpTransformer->InitTransformation( - io_sText.GetBuffer(), - io_sText.Len() ); - - for ( ; !dpTransformer->TextEndReached(); ) - { - if (dpTransformer->TransformNextToken() != WordTransTree::OK) - { - CreateError(); - } - } - io_sText = dpTransformer->Output(); - return dpErrors->NrOfErrors(); -} - -USHORT -WordTransformer::NrOfErrors() const -{ - return dpErrors->NrOfErrors(); -} - -WordTransformer::E_Error -WordTransformer::GetError( USHORT i_nNr, - ByteString * o_pErrorText) const -{ - return dpErrors->GetError(i_nNr,o_pErrorText); -} - -void -WordTransformer::CreateError() -{ - ByteString sErr; - - switch (dpTransformer->CurResult()) - { - case WordTransTree::OK: - break; - case WordTransTree::HOTKEY_LOST: - sErr = ByteString("Error: By replacement of string "); - sErr += dpTransformer->CurReplacedString(); - sErr += " by "; - sErr += dpTransformer->CurReplacingString(); - sErr += "the hotkey at char '"; - sErr += dpTransformer->CurHotkey(); - sErr += "' was lost."; - dpErrors->AddError( ERROR_HOTKEY,sErr.GetBufferAccess()); - sErr.ReleaseBufferAccess(); - break; - case WordTransTree::OUTPUT_OVERFLOW: - dpErrors->AddError(ERROR_OUTPUTSTRING_TOO_LONG,"Error: Output buffer overflow."); - break; - default: - dpErrors->AddError(OTHER_ERROR,"Error: Unknown error."); - } -} -*/ -//************** Implementation WordTrans_ErrorList ******************// -/* -void -WordTrans_ErrorList::AddError( WordTransformer::E_Error i_eType, - const char * i_sErrorDescription ) -{ - ByteString sErrorType = "xxx"; - char * pErrorChars = sErrorType.GetBufferAccess(); - pErrorChars[0] = char(i_eType / 100 + '0'); - pErrorChars[1] = char( (i_eType % 100) / 10 + '0'); - pErrorChars[2] = char(i_eType % 10 + '0'); - sErrorType += i_sErrorDescription; - - aErrors.push_back(sErrorType); - sErrorType.ReleaseBufferAccess(); -} - -void -WordTrans_ErrorList::Clear() -{ - aErrors.erase(aErrors.begin(),aErrors.end()); -} - -USHORT -WordTrans_ErrorList::NrOfErrors() const -{ - return aErrors.size(); -} - -WordTransformer::E_Error -WordTrans_ErrorList::GetError( USHORT i_nNr, - ByteString * o_pErrorText ) const -{ - if ( i_nNr < aErrors.size() ) - { - const ByteString & rError = aErrors[i_nNr]; - const char * pErrorChars = rError.GetBuffer(); - - USHORT nError = USHORT( (pErrorChars[0] - '0') ) * 100 - + (pErrorChars[1] - '0') * 10 - + pErrorChars[2] - '0'; - - if (o_pErrorText != 0) - *o_pErrorText = pErrorChars+3; - - return WordTransformer::E_Error(nError); - } - else - { - if (o_pErrorText != 0) - *o_pErrorText = ""; - return WordTransformer::OK; - } -} -*/ diff --git a/o3tl/inc/o3tl/vector_pool.hxx b/o3tl/inc/o3tl/vector_pool.hxx new file mode 100644 index 000000000000..19fc3d6d74c4 --- /dev/null +++ b/o3tl/inc/o3tl/vector_pool.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * 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: lazy_update.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 INCLUDED_O3TL_VECTOR_POOL_HXX +#define INCLUDED_O3TL_VECTOR_POOL_HXX + +#include <sal/types.h> +#include <vector> + +namespace o3tl +{ + namespace detail + { + template<typename ValueType, class Container> class simple_pool_impl : + public Container + { + typedef typename Container::value_type value_type; + std::ptrdiff_t mnFirstFreeIndex; + + public: + simple_pool_impl() : + mnFirstFreeIndex(-1) + {} + + std::ptrdiff_t alloc() + { + return store(ValueType()); + } + + std::ptrdiff_t store(const ValueType& rCopy) + { + if( mnFirstFreeIndex != -1 ) + { + std::ptrdiff_t nIdx=mnFirstFreeIndex; + mnFirstFreeIndex = this->at(mnFirstFreeIndex).nextFree; + this->at(nIdx).value = rCopy; + this->at(nIdx).nextFree = -1; + + return nIdx; + } + else + { + push_back(value_type(rCopy)); + return this->size()-1; + } + } + + void free( std::ptrdiff_t nIdx ) + { + this->at(nIdx).nextFree = mnFirstFreeIndex; + mnFirstFreeIndex = nIdx; + } + + const ValueType& get( std::ptrdiff_t nIdx ) const + { + return this->operator[](nIdx).value; + } + ValueType& get( std::ptrdiff_t nIdx ) + { + return this->operator[](nIdx).value; + } + }; + + template< typename ValueType > struct struct_from_value + { + struct type + { + type() : + value(), + nextFree(-1) + {} + explicit type( const ValueType& val ) : + value(val), + nextFree(-1) + {} + + ValueType value; + std::ptrdiff_t nextFree; + }; + }; + } + + /** Simple vector-based memory pool allocator + + This template can be used to provide simple pooled memory + allocation from a container class that adheres to the stl + random access container concept. Note that alloc/free works + with _indices_ into the container! + + @example + <pre> +vector_pool<type> myPool; +int nIdx=myPool.alloc(); +myPool[nIdx] = myVal; + ... do stuff ... +myPool.free(nIdx); + </pre> + */ + template<typename ValueType> struct vector_pool : + public detail::simple_pool_impl<ValueType, + std::vector<typename detail::struct_from_value<ValueType>::type > > + {}; +} + +#endif /* INCLUDED_O3TL_VECTOR_POOL_HXX */ diff --git a/o3tl/prj/build.lst b/o3tl/prj/build.lst index 98293257e4bd..2606d1df8586 100644 --- a/o3tl/prj/build.lst +++ b/o3tl/prj/build.lst @@ -1,4 +1,4 @@ -ot o3tl : sal testshl2 BOOST:boost NULL +ot o3tl : sal CPPUNIT:cppunit BOOST:boost NULL ot o3tl usr1 - all ot_mkout NULL ot o3tl\inc get - all ot_inc NULL ot o3tl\prj get - all ot_prj NULL diff --git a/o3tl/qa/export.map b/o3tl/qa/export.map index 709047ae63e5..3308588ef6f8 100644 --- a/o3tl/qa/export.map +++ b/o3tl/qa/export.map @@ -25,9 +25,9 @@ # #************************************************************************* -UDK_3.1 { +UDK_3_0_0 { global: - registerAllTestFunction; + cppunitTestPlugIn; local: *; diff --git a/o3tl/qa/makefile.mk b/o3tl/qa/makefile.mk index 7effe534bbee..3475aeeca9bb 100644 --- a/o3tl/qa/makefile.mk +++ b/o3tl/qa/makefile.mk @@ -35,6 +35,9 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) + .IF "$(L10N_framework)"=="" # --- Common ---------------------------------------------------------- @@ -42,18 +45,19 @@ ENABLE_EXCEPTIONS=TRUE SHL1OBJS= \ $(SLO)$/cow_wrapper_clients.obj \ $(SLO)$/test-cow_wrapper.obj \ + $(SLO)$/test-vector_pool.obj \ $(SLO)$/test-heap_ptr.obj \ $(SLO)$/test-range.obj SHL1TARGET= tests SHL1STDLIBS= $(SALLIB) \ - $(TESTSHL2LIB)\ $(CPPUNITLIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) SHL1VERSIONMAP = export.map +SHL1RPATH = NONE # END ------------------------------------------------------------------ @@ -65,16 +69,9 @@ SLOFILES=$(SHL1OBJS) .ENDIF # L10N_framework .INCLUDE : target.mk -.INCLUDE : _cppunit.mk # --- Enable test execution in normal build ------------------------ .IF "$(L10N_framework)"=="" -unittest : $(SHL1TARGETN) - @echo ---------------------------------------------------------- - @echo - start unit test on library $(SHL1TARGETN) - @echo ---------------------------------------------------------- - $(TESTSHL2) -sf $(mktmp ) $(SHL1TARGETN) - -ALLTAR : unittest +.INCLUDE : _cppunit.mk .ENDIF # L10N_framework diff --git a/o3tl/qa/test-cow_wrapper.cxx b/o3tl/qa/test-cow_wrapper.cxx index eebbb633f82b..84d615fca3db 100644 --- a/o3tl/qa/test-cow_wrapper.cxx +++ b/o3tl/qa/test-cow_wrapper.cxx @@ -1,6 +1,9 @@ // autogenerated file with codegen.pl -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" #include "cow_wrapper_clients.hxx" @@ -119,15 +122,6 @@ public: }; // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(cow_wrapper_test, "cow_wrapper_test"); - - -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -void RegisterAdditionalFunctions(FktRegFuncPtr ) -{ -} -// NOADDITIONAL; +CPPUNIT_TEST_SUITE_REGISTRATION(cow_wrapper_test); +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/o3tl/qa/test-heap_ptr.cxx b/o3tl/qa/test-heap_ptr.cxx index 44dc2083947a..fe2f78eec8af 100644 --- a/o3tl/qa/test-heap_ptr.cxx +++ b/o3tl/qa/test-heap_ptr.cxx @@ -25,7 +25,9 @@ * ************************************************************************/ -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <o3tl/heap_ptr.hxx> @@ -160,4 +162,4 @@ class heap_ptr_test : public CppUnit::TestFixture }; // class heap_ptr_test // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(heap_ptr_test, "o3tltests"); +CPPUNIT_TEST_SUITE_REGISTRATION(heap_ptr_test); diff --git a/o3tl/qa/test-range.cxx b/o3tl/qa/test-range.cxx index 9ead908675b9..31cf2aec7c10 100644 --- a/o3tl/qa/test-range.cxx +++ b/o3tl/qa/test-range.cxx @@ -25,8 +25,9 @@ * ************************************************************************/ - -#include <testshl/simpleheader.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" #include <o3tl/range.hxx> #include <vector> @@ -230,4 +231,4 @@ public: }; // class range_test // ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(range_test, "o3tltests"); +CPPUNIT_TEST_SUITE_REGISTRATION(range_test); diff --git a/o3tl/qa/test-vector_pool.cxx b/o3tl/qa/test-vector_pool.cxx new file mode 100644 index 000000000000..4efaebdd3414 --- /dev/null +++ b/o3tl/qa/test-vector_pool.cxx @@ -0,0 +1,69 @@ +// autogenerated file with codegen.pl + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include <o3tl/vector_pool.hxx> + +using namespace ::o3tl; + +class vector_pool_test : public CppUnit::TestFixture +{ +public: + void testPoolBasics() + { + vector_pool<int> aPool; + + std::ptrdiff_t nIdx1 = aPool.alloc(); + std::ptrdiff_t nIdx2 = aPool.alloc(); + std::ptrdiff_t nIdx3 = aPool.alloc(); + + CPPUNIT_ASSERT_MESSAGE("allocator idx order 1", nIdx1 < nIdx2 ); + CPPUNIT_ASSERT_MESSAGE("allocator idx order 2", nIdx2 < nIdx3 ); + + aPool.free(nIdx2); + aPool.free(nIdx3); + + nIdx2 = aPool.alloc(); + nIdx3 = aPool.alloc(); + + CPPUNIT_ASSERT_MESSAGE("allocator idx order 1 after fragmentation", nIdx1 < nIdx3 ); + CPPUNIT_ASSERT_MESSAGE("allocator idx order 2 after fragmentation", nIdx3 < nIdx2 ); + } + + void testPoolValueSemantics() + { + vector_pool<int> aPool; + + std::ptrdiff_t nIdx1 = aPool.store(0); + CPPUNIT_ASSERT_MESSAGE("allocator value semantics 1", aPool.get(nIdx1) == 0 ); + + std::ptrdiff_t nIdx2 = aPool.store(1); + CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2", aPool.get(nIdx2) == 1 ); + + std::ptrdiff_t nIdx3 = aPool.store(2); + CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3", aPool.get(nIdx3) == 2 ); + + aPool.free(nIdx2); + aPool.free(nIdx3); + + nIdx2 = aPool.store(1); + CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2 after fragmentation", aPool.get(nIdx2) == 1 ); + + nIdx3 = aPool.store(2); + CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3 after fragmentation", aPool.get(nIdx3) == 2 ); + } + + // Change the following lines only, if you add, remove or rename + // member functions of the current class, + // because these macros are need by auto register mechanism. + + CPPUNIT_TEST_SUITE(vector_pool_test); + CPPUNIT_TEST(testPoolBasics); + CPPUNIT_TEST(testPoolValueSemantics); + CPPUNIT_TEST_SUITE_END(); +}; + +// ----------------------------------------------------------------------------- +CPPUNIT_TEST_SUITE_REGISTRATION(vector_pool_test); diff --git a/padmin/source/fontentry.cxx b/padmin/source/fontentry.cxx index 608a240b9866..f67d2c0d18d6 100644 --- a/padmin/source/fontentry.cxx +++ b/padmin/source/fontentry.cxx @@ -555,7 +555,7 @@ IMPL_LINK( FontImportDialog, RefreshTimeoutHdl, void*, EMPTYARG ) std::list< String > aFiles; m_aNewFonts.clear(); OUString aDirectory( m_aFromDirEdt.GetText() ); - FindFiles( aDirectory, aFiles, String( RTL_CONSTASCII_USTRINGPARAM( "PFA;PFB;TTF;TTC" ) ), m_aSubDirsBox.IsChecked() ); + FindFiles( aDirectory, aFiles, String( RTL_CONSTASCII_USTRINGPARAM( "PFA;PFB;TTF;TTC;OTF" ) ), m_aSubDirsBox.IsChecked() ); OString aDir( OUStringToOString( aDirectory, aEncoding ) ); aDir += "/"; while( aFiles.begin() != aFiles.end() ) diff --git a/rsc/source/parser/erscerr.cxx b/rsc/source/parser/erscerr.cxx index 11aaf9cce85f..158aea21b6e3 100644 --- a/rsc/source/parser/erscerr.cxx +++ b/rsc/source/parser/erscerr.cxx @@ -200,7 +200,7 @@ void RscError::WriteError( const ERRTYPE& rError, const char * pMessage ) case ERR_NOINPUT: StdLstErr( "Input file was not specified.\n"); case ERR_USAGE: - StdLstOut( "Copyright (C) 1990-92 STAR DIVISION GmbH\n" ); + StdLstOut( "Copyright (C) 2000, 2010 Oracle and/or its affiliates.\n" ); { char buf[40]; diff --git a/rsc/source/parser/makefile.mk b/rsc/source/parser/makefile.mk index 1254bee932f6..a46c60aae213 100644 --- a/rsc/source/parser/makefile.mk +++ b/rsc/source/parser/makefile.mk @@ -45,17 +45,6 @@ ENABLE_EXCEPTIONS=true YACCTARGET= $(INCCOM)$/yyrscyacc.cxx YACCFILES= rscyacc.y -CXXFILES= rscpar.cxx \ - rscyacc.cxx \ - rsclex.cxx \ - erscerr.cxx \ - rsckey.cxx \ - rscinit.cxx \ - rscibas.cxx \ - rscdb.cxx \ - rscicpx.cxx \ - parser.cxx - OBJFILES= $(OBJ)$/rscpar.obj \ $(OBJ)$/rscyacc.obj \ $(OBJ)$/rsclex.obj \ diff --git a/rsc/source/parser/parser.cxx b/rsc/source/parser/parser.cxx deleted file mode 100644 index 1ba974a4778d..000000000000 --- a/rsc/source/parser/parser.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <string.h> -#include <ctype.h> - -#include <tools/solar.h> -#define RSC_COMPILER - -#include <rscall.h> -#include <rsctools.hxx> -#include <rschash.hxx> -#include <rsckey.hxx> -#include <rsctree.hxx> -#include <rscerror.h> -#include <rscdef.hxx> - -#include <rsctop.hxx> -#include <rscmgr.hxx> -#include <rscconst.hxx> -#include <rscarray.hxx> -#include <rscclass.hxx> -#include <rsccont.hxx> -#include <rscrange.hxx> -#include <rscflag.hxx> -#include <rscstr.hxx> - -#include <rscdb.hxx> -#include <rscpar.hxx> - diff --git a/rsc/source/parser/parser.hxx b/rsc/source/parser/parser.hxx deleted file mode 100644 index 274b720b1e2d..000000000000 --- a/rsc/source/parser/parser.hxx +++ /dev/null @@ -1,26 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ diff --git a/rsc/source/prj/gui.cxx b/rsc/source/prj/gui.cxx index 0ff0549d161f..67d86a8b35cf 100644 --- a/rsc/source/prj/gui.cxx +++ b/rsc/source/prj/gui.cxx @@ -30,6 +30,7 @@ #include <stdlib.h> #include <stdio.h> +#include <sal/main.h> #include <rscrsc.hxx> #include <rscdb.hxx> @@ -68,15 +69,7 @@ RscVerbosity lcl_determineVerbosity( int argc, char ** argv ) return RscVerbosityNormal; } -#if defined( UNX ) || ( defined( OS2 ) && ( defined( CSET ) || defined ( GCC ))) || defined (WTC) || defined(ICC) || defined(__MINGW32__) -int main ( int argc, char ** argv) { -#else -#if defined( MTW ) -int main ( int argc, char const ** argv) { -#else -int cdecl main ( int argc, char ** argv) { -#endif -#endif +SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { #ifndef UNX #ifdef CSET atexit( ExitProgram ); diff --git a/rsc/source/prj/start.cxx b/rsc/source/prj/start.cxx index b36614cec8c4..a2841dd9765b 100644 --- a/rsc/source/prj/start.cxx +++ b/rsc/source/prj/start.cxx @@ -54,6 +54,7 @@ #endif // UNX #include <rsctools.hxx> #include <rscerror.h> +#include <sal/main.h> #include <tools/fsys.hxx> /*************** C O D E ************************************************/ @@ -176,7 +177,7 @@ static BOOL CallPrePro( const ByteString& rPrePro, #if ((defined OS2 || defined WNT) && (defined TCPP || defined tcpp)) || defined UNX || defined OS2 nExit = spawnvp( P_WAIT, rPrePro.GetBuffer(), (char* const*)pCmdL->GetBlock() ); #elif defined CSET - nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), char **) (const char**)pCmdL->GetBlock() ); + nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (const char**)pCmdL->GetBlock() ); #elif defined WTC nExit = spawnvp( P_WAIT, (char*)rPrePro.GetBuffer(), (const char* const*)pCmdL->GetBlock() ); #elif defined MTW @@ -322,14 +323,8 @@ static BOOL CallRsc2( ByteString aRsc2Name, |* Letzte Aenderung MM 05.09.91 |* *************************************************************************/ -#if defined UNX || (defined OS2 && (defined CSET || defined GCC )) || defined WTC || defined MTW || defined ICC || defined(__MINGW32__) -int main ( int argc, char ** argv) -{ -#else -int cdecl main ( int argc, char ** argv) +SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { -#endif - BOOL bPrePro = TRUE; BOOL bResFile = TRUE; BOOL bHelp = FALSE; diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index ddc585ae38a4..92d53700aa86 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -700,6 +700,8 @@ inline void SaxWriterHelper::clearBuffer() throw( SAXException ) m_Sequence.realloc(nCurrentPos); nCurrentPos = writeSequence(); m_Sequence.realloc(SEQUENCESIZE); + // Be sure to update the array pointer after the reallocation. + mp_Sequence = m_Sequence.getArray(); } } diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 84941bee8e37..a43c7e52a353 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -31,6 +31,7 @@ #include <boost/scoped_ptr.hpp> #include <osl/diagnose.h> +#include <rtl/ustrbuf.hxx> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/xml/sax/XFastContextHandler.hpp> @@ -41,8 +42,9 @@ #include <string.h> -using ::rtl::OUString; using ::rtl::OString; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; using namespace ::std; using namespace ::osl; using namespace ::cppu; @@ -51,8 +53,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::xml::sax; //using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; -namespace sax_fastparser -{ + +namespace sax_fastparser { // -------------------------------------------------------------------- @@ -111,30 +113,35 @@ private: // the implementation part //--------------------------------------------- -extern "C" +extern "C" { + +static void call_callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts) { - static void call_callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts) - { - FastSaxParser::callbackStartElement(userData,name,atts); - } - static void call_callbackEndElement(void *userData, const XML_Char *name) - { - FastSaxParser::callbackEndElement(userData,name); - } - static void call_callbackCharacters( void *userData , const XML_Char *s , int nLen ) - { - FastSaxParser::callbackCharacters(userData,s,nLen); - } - static int call_callbackExternalEntityRef(XML_Parser parser, - const XML_Char *openEntityNames, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId) - { - return FastSaxParser::callbackExternalEntityRef(parser,openEntityNames,base,systemId,publicId); - } + FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData ); + pFastParser->callbackStartElement( name, atts ); +} + +static void call_callbackEndElement(void *userData, const XML_Char *name) +{ + FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData ); + pFastParser->callbackEndElement( name ); +} + +static void call_callbackCharacters( void *userData , const XML_Char *s , int nLen ) +{ + FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( userData ); + pFastParser->callbackCharacters( s, nLen ); } +static int call_callbackExternalEntityRef( XML_Parser parser, + const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId ) +{ + FastSaxParser* pFastParser = reinterpret_cast< FastSaxParser* >( XML_GetUserData( parser ) ); + return pFastParser->callbackExternalEntityRef( parser, openEntityNames, base, systemId, publicId ); +} + +} // extern "C" + // -------------------------------------------------------------------- // FastLocatorImpl implementation // -------------------------------------------------------------------- @@ -172,15 +179,13 @@ OUString SAL_CALL FastLocatorImpl::getSystemId(void) throw (RuntimeException) // FastSaxParser implementation // -------------------------------------------------------------------- -FastSaxParser::FastSaxParser( ) +FastSaxParser::FastSaxParser() { mxDocumentLocator.set( new FastLocatorImpl( this ) ); // performance-Improvment. Reference is needed when calling the startTag callback. // Handing out the same object with every call is allowed (see sax-specification) mxAttributes.set( new FastAttributeList( mxTokenHandler ) ); - - mbExceptionWasThrown = sal_False; } // -------------------------------------------------------------------- @@ -419,34 +424,27 @@ void FastSaxParser::parseStream( const InputSource& maStructSource) throw (SAXEx struct Entity entity; entity.maStructSource = maStructSource; - if( ! entity.maStructSource.aInputStream.is() ) - { - throw SAXException( OUString::createFromAscii( "No input source" ), Reference< XInterface > () , Any() ); - } + if( !entity.maStructSource.aInputStream.is() ) + throw SAXException( OUString( RTL_CONSTASCII_USTRINGPARAM( "No input source" ) ), Reference< XInterface >(), Any() ); entity.maConverter.setInputStream( entity.maStructSource.aInputStream ); if( entity.maStructSource.sEncoding.getLength() ) - { - entity.maConverter.setEncoding( OUStringToOString( entity.maStructSource.sEncoding , RTL_TEXTENCODING_ASCII_US ) ); - } + entity.maConverter.setEncoding( OUStringToOString( entity.maStructSource.sEncoding, RTL_TEXTENCODING_ASCII_US ) ); // create parser with proper encoding entity.mpParser = XML_ParserCreate( 0 ); - if( ! entity.mpParser ) - { - throw SAXException( OUString::createFromAscii( "Couldn't create parser" ), Reference< XInterface > (), Any() ); - } + if( !entity.mpParser ) + throw SAXException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Couldn't create parser" ) ), Reference< XInterface >(), Any() ); // set all necessary C-Callbacks - XML_SetUserData( entity.mpParser , this ); - XML_SetElementHandler( entity.mpParser , - call_callbackStartElement , - call_callbackEndElement ); - XML_SetCharacterDataHandler( entity.mpParser , call_callbackCharacters ); - XML_SetExternalEntityRefHandler( entity.mpParser, - call_callbackExternalEntityRef); + XML_SetUserData( entity.mpParser, this ); + XML_SetElementHandler( entity.mpParser, call_callbackStartElement, call_callbackEndElement ); + XML_SetCharacterDataHandler( entity.mpParser, call_callbackCharacters ); + XML_SetExternalEntityRefHandler( entity.mpParser, call_callbackExternalEntityRef ); + // maSavedException used to transport exceptions through C callbacks maSavedException.clear(); + pushEntity( entity ); try { @@ -569,112 +567,71 @@ Sequence< OUString > FastSaxParser::getSupportedServiceNames(void) throw (Runtim * Helper functions and classes * *-------------------------------------------*/ -OUString getErrorMessage( XML_Error xmlE, OUString sSystemId , sal_Int32 nLine ) -{ - OUString Message; - if( XML_ERROR_NONE == xmlE ) { - Message = OUString::createFromAscii( "No" ); - } - else if( XML_ERROR_NO_MEMORY == xmlE ) { - Message = OUString::createFromAscii( "no memory" ); - } - else if( XML_ERROR_SYNTAX == xmlE ) { - Message = OUString::createFromAscii( "syntax" ); - } - else if( XML_ERROR_NO_ELEMENTS == xmlE ) { - Message = OUString::createFromAscii( "no elements" ); - } - else if( XML_ERROR_INVALID_TOKEN == xmlE ) { - Message = OUString::createFromAscii( "invalid token" ); - } - else if( XML_ERROR_UNCLOSED_TOKEN == xmlE ) { - Message = OUString::createFromAscii( "unclosed token" ); - } - else if( XML_ERROR_PARTIAL_CHAR == xmlE ) { - Message = OUString::createFromAscii( "partial char" ); - } - else if( XML_ERROR_TAG_MISMATCH == xmlE ) { - Message = OUString::createFromAscii( "tag mismatch" ); - } - else if( XML_ERROR_DUPLICATE_ATTRIBUTE == xmlE ) { - Message = OUString::createFromAscii( "duplicate attribute" ); - } - else if( XML_ERROR_JUNK_AFTER_DOC_ELEMENT == xmlE ) { - Message = OUString::createFromAscii( "junk after doc element" ); - } - else if( XML_ERROR_PARAM_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "parameter entity reference" ); - } - else if( XML_ERROR_UNDEFINED_ENTITY == xmlE ) { - Message = OUString::createFromAscii( "undefined entity" ); - } - else if( XML_ERROR_RECURSIVE_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "recursive entity reference" ); - } - else if( XML_ERROR_ASYNC_ENTITY == xmlE ) { - Message = OUString::createFromAscii( "async entity" ); - } - else if( XML_ERROR_BAD_CHAR_REF == xmlE ) { - Message = OUString::createFromAscii( "bad char reference" ); - } - else if( XML_ERROR_BINARY_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "binary entity reference" ); - } - else if( XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "attribute external entity reference" ); - } - else if( XML_ERROR_MISPLACED_XML_PI == xmlE ) { - Message = OUString::createFromAscii( "misplaced xml processing instruction" ); - } - else if( XML_ERROR_UNKNOWN_ENCODING == xmlE ) { - Message = OUString::createFromAscii( "unknown encoding" ); - } - else if( XML_ERROR_INCORRECT_ENCODING == xmlE ) { - Message = OUString::createFromAscii( "incorrect encoding" ); - } - else if( XML_ERROR_UNCLOSED_CDATA_SECTION == xmlE ) { - Message = OUString::createFromAscii( "unclosed cdata section" ); - } - else if( XML_ERROR_EXTERNAL_ENTITY_HANDLING == xmlE ) { - Message = OUString::createFromAscii( "external entity reference" ); - } - else if( XML_ERROR_NOT_STANDALONE == xmlE ) { - Message = OUString::createFromAscii( "not standalone" ); - } - OUString str = OUString::createFromAscii( "[" ); - str += sSystemId; - str += OUString::createFromAscii( " line " ); - str += OUString::valueOf( nLine ); - str += OUString::createFromAscii( "]: " ); - str += Message; - str += OUString::createFromAscii( "error" ); +namespace { - return str; +OUString lclGetErrorMessage( XML_Error xmlE, const OUString& sSystemId, sal_Int32 nLine ) +{ + const sal_Char* pMessage = ""; + switch( xmlE ) + { + case XML_ERROR_NONE: pMessage = "No"; break; + case XML_ERROR_NO_MEMORY: pMessage = "no memory"; break; + case XML_ERROR_SYNTAX: pMessage = "syntax"; break; + case XML_ERROR_NO_ELEMENTS: pMessage = "no elements"; break; + case XML_ERROR_INVALID_TOKEN: pMessage = "invalid token"; break; + case XML_ERROR_UNCLOSED_TOKEN: pMessage = "unclosed token"; break; + case XML_ERROR_PARTIAL_CHAR: pMessage = "partial char"; break; + case XML_ERROR_TAG_MISMATCH: pMessage = "tag mismatch"; break; + case XML_ERROR_DUPLICATE_ATTRIBUTE: pMessage = "duplicate attribute"; break; + case XML_ERROR_JUNK_AFTER_DOC_ELEMENT: pMessage = "junk after doc element"; break; + case XML_ERROR_PARAM_ENTITY_REF: pMessage = "parameter entity reference"; break; + case XML_ERROR_UNDEFINED_ENTITY: pMessage = "undefined entity"; break; + case XML_ERROR_RECURSIVE_ENTITY_REF: pMessage = "recursive entity reference"; break; + case XML_ERROR_ASYNC_ENTITY: pMessage = "async entity"; break; + case XML_ERROR_BAD_CHAR_REF: pMessage = "bad char reference"; break; + case XML_ERROR_BINARY_ENTITY_REF: pMessage = "binary entity reference"; break; + case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: pMessage = "attribute external entity reference"; break; + case XML_ERROR_MISPLACED_XML_PI: pMessage = "misplaced xml processing instruction"; break; + case XML_ERROR_UNKNOWN_ENCODING: pMessage = "unknown encoding"; break; + case XML_ERROR_INCORRECT_ENCODING: pMessage = "incorrect encoding"; break; + case XML_ERROR_UNCLOSED_CDATA_SECTION: pMessage = "unclosed cdata section"; break; + case XML_ERROR_EXTERNAL_ENTITY_HANDLING: pMessage = "external entity reference"; break; + case XML_ERROR_NOT_STANDALONE: pMessage = "not standalone"; break; + default:; + } + + OUStringBuffer aBuffer( sal_Unicode( '[' ) ); + aBuffer.append( sSystemId ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " line " ) ); + aBuffer.append( nLine ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "]: " ) ); + aBuffer.appendAscii( pMessage ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " error" ) ); + return aBuffer.makeStringAndClear(); } +} // namespace // starts parsing with actual parser ! -void FastSaxParser::parse( ) +void FastSaxParser::parse() { - const int nBufSize = 16*1024; + const int BUFFER_SIZE = 16 * 1024; + Sequence< sal_Int8 > seqOut( BUFFER_SIZE ); - int nRead = nBufSize; - Sequence< sal_Int8 > seqOut(nBufSize); - - while( nRead ) + int nRead = 0; + do { - nRead = getEntity().maConverter.readAndConvert( seqOut, nBufSize ); - - if( ! nRead ) + nRead = getEntity().maConverter.readAndConvert( seqOut, BUFFER_SIZE ); + if( nRead <= 0 ) { - XML_Parse( getEntity().mpParser, ( const char * ) seqOut.getArray(), 0 , 1 ); + XML_Parse( getEntity().mpParser, (const char*) seqOut.getConstArray(), 0, 1 ); break; } - sal_Bool bContinue = ( XML_Parse( getEntity().mpParser, (const char *) seqOut.getArray(), nRead, 0 ) != 0 ); - - if( !bContinue || mbExceptionWasThrown ) + bool bContinue = XML_Parse( getEntity().mpParser, (const char*) seqOut.getConstArray(), nRead, 0 ) != 0; + // callbacks used inside XML_Parse may have caught an exception + if( !bContinue || maSavedException.hasValue() ) { // Error during parsing ! XML_Error xmlE = XML_GetErrorCode( getEntity().mpParser ); @@ -682,26 +639,25 @@ void FastSaxParser::parse( ) sal_Int32 nLine = mxDocumentLocator->getLineNumber(); SAXParseException aExcept( - getErrorMessage(xmlE , sSystemId, nLine) , + lclGetErrorMessage( xmlE, sSystemId, nLine ), Reference< XInterface >(), - Any( &maSavedException , getCppuType( &maSavedException) ), + Any( &maSavedException, getCppuType( &maSavedException ) ), mxDocumentLocator->getPublicId(), mxDocumentLocator->getSystemId(), mxDocumentLocator->getLineNumber(), mxDocumentLocator->getColumnNumber() - ); + ); + // error handler is set, it may throw the exception if( mxErrorHandler.is() ) - { - // error handler is set, so the handler may throw the maSavedException mxErrorHandler->fatalError( Any( aExcept ) ); - } - // Error handler has not thrown an maSavedException, but parsing cannot go on, - // so an maSavedException MUST be thrown. + // error handler has not thrown, but parsing cannot go on, the + // exception MUST be thrown throw aExcept; } } + while( nRead > 0 ); } //------------------------------------------ @@ -721,25 +677,23 @@ struct AttributeData } // namespace -void FastSaxParser::callbackStartElement( void *pvThis, const XML_Char *pwName, const XML_Char **awAttributes ) +void FastSaxParser::callbackStartElement( const XML_Char* pwName, const XML_Char** awAttributes ) { - FastSaxParser *pThis = (FastSaxParser*)pvThis; - Reference< XFastContextHandler > xParentContext; - if( !pThis->maContextStack.empty() ) + if( !maContextStack.empty() ) { - xParentContext = pThis->maContextStack.top()->mxContext; + xParentContext = maContextStack.top()->mxContext; if( !xParentContext.is() ) { // we ignore current elements, so no processing needed - pThis->pushContext(); + pushContext(); return; } } - pThis->pushContext(); + pushContext(); - pThis->mxAttributes->clear(); + mxAttributes->clear(); // create attribute map and process namespace instructions int i = 0; @@ -747,108 +701,100 @@ void FastSaxParser::callbackStartElement( void *pvThis, const XML_Char *pwName, const XML_Char *pName; const XML_Char *pPrefix; - /* #158414# Each element may define new namespaces, also for attribues. - First, process all namespace attributes and cache other attributes in a - vector. Second, process the attributes after namespaces have been - initialized. */ - ::std::vector< AttributeData > aAttribs; - - // #158414# first: get namespaces - for( ; awAttributes[i]; i += 2 ) + try { - OSL_ASSERT( awAttributes[i+1] ); + /* #158414# Each element may define new namespaces, also for attribues. + First, process all namespace attributes and cache other attributes in a + vector. Second, process the attributes after namespaces have been + initialized. */ + ::std::vector< AttributeData > aAttribs; - pThis->splitName( awAttributes[i], pPrefix, nPrefixLen, pName, nNameLen ); - if( nPrefixLen ) + // #158414# first: get namespaces + for( ; awAttributes[i]; i += 2 ) { - if( (nPrefixLen == 5) && (strncmp( pPrefix, "xmlns", 5 ) == 0) ) + OSL_ASSERT( awAttributes[i+1] ); + + splitName( awAttributes[i], pPrefix, nPrefixLen, pName, nNameLen ); + if( nPrefixLen ) { - pThis->DefineNamespace( OString( pName, nNameLen ), awAttributes[i+1] ); + if( (nPrefixLen == 5) && (strncmp( pPrefix, "xmlns", 5 ) == 0) ) + { + DefineNamespace( OString( pName, nNameLen ), awAttributes[i+1] ); + } + else + { + aAttribs.resize( aAttribs.size() + 1 ); + aAttribs.back().maPrefix = OString( pPrefix, nPrefixLen ); + aAttribs.back().maName = OString( pName, nNameLen ); + aAttribs.back().maValue = OString( awAttributes[i+1] ); + } } else { - aAttribs.resize( aAttribs.size() + 1 ); - aAttribs.back().maPrefix = OString( pPrefix, nPrefixLen ); - aAttribs.back().maName = OString( pName, nNameLen ); - aAttribs.back().maValue = OString( awAttributes[i+1] ); + if( (nNameLen == 5) && (strcmp( pName, "xmlns" ) == 0) ) + { + // namespace of the element found + maContextStack.top()->maNamespace = OUString( awAttributes[i+1], strlen( awAttributes[i+1] ), RTL_TEXTENCODING_UTF8 ); + } + else + { + aAttribs.resize( aAttribs.size() + 1 ); + aAttribs.back().maName = OString( pName, nNameLen ); + aAttribs.back().maValue = OString( awAttributes[i+1] ); + } } } - else + + // #158414# second: fill attribute list with other attributes + for( ::std::vector< AttributeData >::const_iterator aIt = aAttribs.begin(), aEnd = aAttribs.end(); aIt != aEnd; ++aIt ) { - if( (nNameLen == 5) && (strcmp( pName, "xmlns" ) == 0) ) + if( aIt->maPrefix.getLength() > 0 ) { - // namespace of the element found - pThis->maContextStack.top()->maNamespace = OUString( awAttributes[i+1], strlen( awAttributes[i+1] ), RTL_TEXTENCODING_UTF8 ); + sal_Int32 nAttributeToken = GetTokenWithPrefix( aIt->maPrefix, aIt->maName ); + if( nAttributeToken != FastToken::DONTKNOW ) + mxAttributes->add( nAttributeToken, aIt->maValue ); + else + mxAttributes->addUnknown( GetNamespaceURL( aIt->maPrefix ), aIt->maName, aIt->maValue ); } else { - aAttribs.resize( aAttribs.size() + 1 ); - aAttribs.back().maName = OString( pName, nNameLen ); - aAttribs.back().maValue = OString( awAttributes[i+1] ); + sal_Int32 nAttributeToken = GetToken( aIt->maName ); + if( nAttributeToken != FastToken::DONTKNOW ) + mxAttributes->add( nAttributeToken, aIt->maValue ); + else + mxAttributes->addUnknown( aIt->maName, aIt->maValue ); } } - } - // #158414# second: fill attribute list with other attributes - for( ::std::vector< AttributeData >::const_iterator aIt = aAttribs.begin(), aEnd = aAttribs.end(); aIt != aEnd; ++aIt ) - { - if( aIt->maPrefix.getLength() ) - { - const sal_Int32 nAttributeToken = pThis->GetTokenWithPrefix( aIt->maPrefix, aIt->maName ); - if( nAttributeToken != FastToken::DONTKNOW ) - pThis->mxAttributes->add( nAttributeToken, aIt->maValue ); - else - pThis->mxAttributes->addUnknown( pThis->GetNamespaceURL( aIt->maPrefix ), aIt->maName, aIt->maValue ); - } + sal_Int32 nElementToken; + splitName( pwName, pPrefix, nPrefixLen, pName, nNameLen ); + if( nPrefixLen > 0 ) + nElementToken = GetTokenWithPrefix( pPrefix, nPrefixLen, pName, nNameLen ); + else if( maContextStack.top()->maNamespace.getLength() > 0 ) + nElementToken = GetTokenWithNamespaceURL( maContextStack.top()->maNamespace, pName, nNameLen ); else - { - const sal_Int32 nAttributeToken = pThis->GetToken( aIt->maName ); - if( nAttributeToken != FastToken::DONTKNOW ) - pThis->mxAttributes->add( nAttributeToken, aIt->maValue ); - else - pThis->mxAttributes->addUnknown( aIt->maName, aIt->maValue ); - } - } + nElementToken = GetToken( pName ); + maContextStack.top()->mnElementToken = nElementToken; - sal_Int32 nElementToken; - pThis->splitName( pwName, pPrefix, nPrefixLen, pName, nNameLen ); - if( nPrefixLen ) - { - nElementToken = pThis->GetTokenWithPrefix( pPrefix, nPrefixLen, pName, nNameLen ); - } - else if( pThis->maContextStack.top()->maNamespace.getLength() ) - { - nElementToken = pThis->GetTokenWithNamespaceURL( pThis->maContextStack.top()->maNamespace, pName, nNameLen ); - } - else - { - nElementToken = pThis->GetToken( pName ); - } - pThis->maContextStack.top()->mnElementToken = nElementToken; - - try - { - Reference< XFastAttributeList > xAttr( pThis->mxAttributes.get() ); + Reference< XFastAttributeList > xAttr( mxAttributes.get() ); Reference< XFastContextHandler > xContext; if( nElementToken == FastToken::DONTKNOW ) { - if( nPrefixLen ) - { - pThis->maContextStack.top()->maNamespace = pThis->GetNamespaceURL( pPrefix, nPrefixLen ); - } + if( nPrefixLen > 0 ) + maContextStack.top()->maNamespace = GetNamespaceURL( pPrefix, nPrefixLen ); - const OUString aNamespace( pThis->maContextStack.top()->maNamespace ); + const OUString aNamespace( maContextStack.top()->maNamespace ); const OUString aElementName( pPrefix, nPrefixLen, RTL_TEXTENCODING_UTF8 ); - pThis->maContextStack.top()->maElementName = aElementName; + maContextStack.top()->maElementName = aElementName; if( xParentContext.is() ) xContext = xParentContext->createUnknownChildContext( aNamespace, aElementName, xAttr ); else - xContext = pThis->mxDocumentHandler->createUnknownChildContext( aNamespace, aElementName, xAttr ); + xContext = mxDocumentHandler->createUnknownChildContext( aNamespace, aElementName, xAttr ); if( xContext.is() ) { - pThis->maContextStack.top()->mxContext = xContext; + maContextStack.top()->mxContext = xContext; xContext->startUnknownElement( aNamespace, aElementName, xAttr ); } } @@ -857,142 +803,125 @@ void FastSaxParser::callbackStartElement( void *pvThis, const XML_Char *pwName, if( xParentContext.is() ) xContext = xParentContext->createFastChildContext( nElementToken, xAttr ); else - xContext = pThis->mxDocumentHandler->createFastChildContext( nElementToken, xAttr ); + xContext = mxDocumentHandler->createFastChildContext( nElementToken, xAttr ); if( xContext.is() ) { - pThis->maContextStack.top()->mxContext = xContext; + maContextStack.top()->mxContext = xContext; xContext->startFastElement( nElementToken, xAttr ); } } } catch( Exception& e ) { - pThis->maSavedException <<= e; + maSavedException <<= e; } } -void FastSaxParser::callbackEndElement( void *pvThis , const XML_Char * ) +void FastSaxParser::callbackEndElement( const XML_Char* ) { - FastSaxParser *pThis = (FastSaxParser*)pvThis; - - if( !pThis->maContextStack.empty() ) + OSL_ENSURE( !maContextStack.empty(), "FastSaxParser::callbackEndElement - no context" ); + if( !maContextStack.empty() ) { - SaxContextImplPtr pContext( pThis->maContextStack.top() ); + SaxContextImplPtr pContext( maContextStack.top() ); const Reference< XFastContextHandler >& xContext( pContext->mxContext ); if( xContext.is() ) try { sal_Int32 nElementToken = pContext->mnElementToken; if( nElementToken != FastToken::DONTKNOW ) - { xContext->endFastElement( nElementToken ); - } else - { xContext->endUnknownElement( pContext->maNamespace, pContext->maElementName ); - } } catch( Exception& e ) { - pThis->maSavedException <<= e; + maSavedException <<= e; } - pThis->popContext(); - } - else - { - OSL_ENSURE( false, "no context on sax::FastSaxParser::callbackEndElement() ??? "); + popContext(); } } -void FastSaxParser::callbackCharacters( void *pvThis , const XML_Char *s , int nLen ) +void FastSaxParser::callbackCharacters( const XML_Char* s, int nLen ) { - FastSaxParser *pThis = (FastSaxParser*)pvThis; - - const Reference< XFastContextHandler >& xContext( pThis->maContextStack.top()->mxContext ); + const Reference< XFastContextHandler >& xContext( maContextStack.top()->mxContext ); if( xContext.is() ) try { xContext->characters( OUString( s, nLen, RTL_TEXTENCODING_UTF8 ) ); } catch( Exception& e ) { - pThis->maSavedException <<= e; + maSavedException <<= e; } } int FastSaxParser::callbackExternalEntityRef( XML_Parser parser, - const XML_Char *context, - const XML_Char * /*base*/, - const XML_Char *systemId, - const XML_Char *publicId) + const XML_Char *context, const XML_Char * /*base*/, const XML_Char *systemId, const XML_Char *publicId ) { bool bOK = true; InputSource source; - FastSaxParser *pImpl = ((FastSaxParser*)XML_GetUserData( parser )); struct Entity entity; - if( pImpl->mxEntityResolver.is() ) { - try - { - entity.maStructSource = pImpl->mxEntityResolver->resolveEntity( - OUString( publicId, strlen( publicId ), RTL_TEXTENCODING_UTF8 ) , - OUString( systemId, strlen( systemId ), RTL_TEXTENCODING_UTF8 ) ); - } - catch( SAXParseException & e ) - { - pImpl->maSavedException <<= e; - bOK = false; - } - catch( SAXException & e ) - { - pImpl->maSavedException <<= SAXParseException( - e.Message , e.Context , e.WrappedException , - pImpl->mxDocumentLocator->getPublicId(), - pImpl->mxDocumentLocator->getSystemId(), - pImpl->mxDocumentLocator->getLineNumber(), - pImpl->mxDocumentLocator->getColumnNumber() ); - bOK = false; - } + if( mxEntityResolver.is() ) try + { + entity.maStructSource = mxEntityResolver->resolveEntity( + OUString( publicId, strlen( publicId ), RTL_TEXTENCODING_UTF8 ) , + OUString( systemId, strlen( systemId ), RTL_TEXTENCODING_UTF8 ) ); + } + catch( SAXParseException & e ) + { + maSavedException <<= e; + bOK = false; + } + catch( SAXException & e ) + { + maSavedException <<= SAXParseException( + e.Message, e.Context, e.WrappedException, + mxDocumentLocator->getPublicId(), + mxDocumentLocator->getSystemId(), + mxDocumentLocator->getLineNumber(), + mxDocumentLocator->getColumnNumber() ); + bOK = false; } if( entity.maStructSource.aInputStream.is() ) { - entity.mpParser = XML_ExternalEntityParserCreate( parser , context, 0 ); + entity.mpParser = XML_ExternalEntityParserCreate( parser, context, 0 ); if( ! entity.mpParser ) { return false; } entity.maConverter.setInputStream( entity.maStructSource.aInputStream ); - pImpl->pushEntity( entity ); + pushEntity( entity ); try { - pImpl->parse(); + parse(); } catch( SAXParseException & e ) { - pImpl->maSavedException <<= e; + maSavedException <<= e; bOK = false; } catch( IOException &e ) { SAXException aEx; aEx.WrappedException <<= e; - pImpl->maSavedException <<= aEx; + maSavedException <<= aEx; bOK = false; } catch( RuntimeException &e ) { SAXException aEx; aEx.WrappedException <<= e; - pImpl->maSavedException <<= aEx; + maSavedException <<= aEx; bOK = false; } - pImpl->popEntity(); + popEntity(); XML_ParserFree( entity.mpParser ); } @@ -1000,4 +929,4 @@ int FastSaxParser::callbackExternalEntityRef( XML_Parser parser, return bOK; } -} +} // namespace sax_fastparser diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx index 236db124c99e..3d494a6d3c81 100644 --- a/sax/source/fastparser/fastparser.hxx +++ b/sax/source/fastparser/fastparser.hxx @@ -94,14 +94,12 @@ public: 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); -public: - // the C-Callbacks for the expat parser - void static callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts); - void static callbackEndElement(void *userData, const XML_Char *name); - void static callbackCharacters( void *userData , const XML_Char *s , int nLen ); - int static callbackExternalEntityRef( XML_Parser parser, const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); + // called by the C callbacks of the expat parser + void callbackStartElement( const XML_Char* name, const XML_Char** atts ); + void callbackEndElement( const XML_Char* name ); + void callbackCharacters( const XML_Char* s, int nLen ); + int callbackExternalEntityRef( XML_Parser parser, const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); -public: void pushEntity( const struct Entity &entity ) { vecEntity.push_back( entity ); } void popEntity() { vecEntity.pop_back( ); } struct Entity &getEntity() { return vecEntity.back(); } @@ -139,10 +137,9 @@ private: // External entity stack std::vector< struct Entity > vecEntity; - // Exception cannot be thrown through the C-XmlParser (possible resource leaks), - // therefor the maSavedException must be saved somewhere. + // Exceptions cannot be thrown through the C-XmlParser (possible resource leaks), + // therefore the exception must be saved somewhere. ::com::sun::star::uno::Any maSavedException; - sal_Bool mbExceptionWasThrown; ::com::sun::star::lang::Locale maLocale; diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 9bdd91f4b5e4..35bfba29c904 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -909,10 +909,10 @@ void Converter::convertDuration(::rtl::OUStringBuffer& rBuffer, rBuffer.append(static_cast<sal_Int32>(rDuration.Days)); rBuffer.append(sal_Unicode('D')); } - const sal_Int32 nHSecs(static_cast<sal_Int32>(rDuration.Seconds) - + static_cast<sal_Int32>(rDuration.HundredthSeconds)); + const sal_Int32 nMSecs(static_cast<sal_Int32>(rDuration.Seconds) + + static_cast<sal_Int32>(rDuration.MilliSeconds)); if (static_cast<sal_Int32>(rDuration.Hours) + - static_cast<sal_Int32>(rDuration.Minutes) + nHSecs) + static_cast<sal_Int32>(rDuration.Minutes) + nMSecs) { rBuffer.append(sal_Unicode('T')); // time separator if (rDuration.Hours) @@ -925,20 +925,37 @@ void Converter::convertDuration(::rtl::OUStringBuffer& rBuffer, rBuffer.append(static_cast<sal_Int32>(rDuration.Minutes)); rBuffer.append(sal_Unicode('M')); } - if (nHSecs) + if (nMSecs) { // seconds must not be omitted (i.e. ".42S" is not valid) rBuffer.append(static_cast<sal_Int32>(rDuration.Seconds)); - if (rDuration.HundredthSeconds) + if (rDuration.MilliSeconds) { rBuffer.append(sal_Unicode('.')); - const sal_Int32 nHundredthSeconds( - rDuration.HundredthSeconds % 100); - if (nHundredthSeconds < 10) + const sal_Int32 nMilliSeconds(rDuration.MilliSeconds % 1000); + if (nMilliSeconds < 100) { rBuffer.append(sal_Unicode('0')); } - rBuffer.append(nHundredthSeconds); + if (nMilliSeconds < 10) + { + rBuffer.append(sal_Unicode('0')); + } + if (0 == (nMilliSeconds % 10)) + { + if (0 == (nMilliSeconds % 100)) + { + rBuffer.append(nMilliSeconds / 100); + } + else + { + rBuffer.append(nMilliSeconds / 10); + } + } + else + { + rBuffer.append(nMilliSeconds); + } } rBuffer.append(sal_Unicode('S')); } @@ -959,8 +976,9 @@ readUnsignedNumber(const ::rtl::OUString & rString, { bool bOverflow(false); sal_Int32 nTemp(0); + sal_Int32 nPos(io_rnPos); - for (sal_Int32 nPos = io_rnPos; (nPos < rString.getLength()); ++nPos) + while (nPos < rString.getLength()) { const sal_Unicode c = rString[nPos]; if ((sal_Unicode('0') <= c) && (c <= sal_Unicode('9'))) @@ -974,25 +992,20 @@ readUnsignedNumber(const ::rtl::OUString & rString, } else { - if (io_rnPos != nPos) // read something? - { - io_rnPos = nPos; - if (bOverflow) - { - return R_OVERFLOW; - } - else - { - o_rNumber = nTemp; - return R_SUCCESS; - } - } - else break; + break; } + ++nPos; + } + + if (io_rnPos == nPos) // read something? + { + o_rNumber = -1; + return R_NOTHING; } - o_rNumber = -1; - return R_NOTHING; + io_rnPos = nPos; + o_rNumber = nTemp; + return (bOverflow) ? R_OVERFLOW : R_SUCCESS; } static bool @@ -1069,7 +1082,7 @@ bool Converter::convertDuration(util::Duration& rDuration, sal_Int32 nHours(0); sal_Int32 nMinutes(0); sal_Int32 nSeconds(0); - sal_Int32 nHundredthSeconds(0); + sal_Int32 nMilliSeconds(0); bTimePart = readDurationT(string, nPos); bSuccess = (R_SUCCESS == readUnsignedNumber(string, nPos, nTemp)); @@ -1123,30 +1136,39 @@ bool Converter::convertDuration(util::Duration& rDuration, nTemp = -1; const sal_Int32 nStart(nPos); bSuccess = - (R_SUCCESS == readUnsignedNumber(string, nPos, nTemp)); + (R_NOTHING != readUnsignedNumber(string, nPos, nTemp)); if ((nPos < string.getLength()) && bSuccess) { - if (sal_Unicode('S') == string[nPos]) + if (-1 != nTemp) { - ++nPos; - if (-1 != nTemp) + nTemp = -1; + const sal_Int32 nDigits = nPos - nStart; + OSL_ENSURE(nDigits > 0, "bad code monkey"); + const sal_Unicode cZero('0'); + nMilliSeconds = 100 * (string[nStart] - cZero); + if (nDigits >= 2) { - nTemp = -1; - const sal_Int32 nDigits = nPos - nStart; - OSL_ENSURE(nDigits > 0, "bad code monkey"); - nHundredthSeconds = 10 * - (string[nStart] - sal_Unicode('0')); - if (nDigits >= 2) + nMilliSeconds += 10 * + (string[nStart+1] - cZero); + if (nDigits >= 3) { - nHundredthSeconds += - (string[nStart+1] - sal_Unicode('0')); + nMilliSeconds += (string[nStart+2] - cZero); } } + + if (sal_Unicode('S') == string[nPos]) + { + ++nPos; + } else { bSuccess = false; } } + else + { + bSuccess = false; + } } } else @@ -1182,14 +1204,14 @@ bool Converter::convertDuration(util::Duration& rDuration, if (bSuccess) { - rDuration.Negative = bIsNegativeDuration; - rDuration.Years = static_cast<sal_Int16>(nYears); - rDuration.Months = static_cast<sal_Int16>(nMonths); - rDuration.Days = static_cast<sal_Int16>(nDays); - rDuration.Hours = static_cast<sal_Int16>(nHours); - rDuration.Minutes = static_cast<sal_Int16>(nMinutes); - rDuration.Seconds = static_cast<sal_Int16>(nSeconds); - rDuration.HundredthSeconds = static_cast<sal_Int16>(nHundredthSeconds); + rDuration.Negative = bIsNegativeDuration; + rDuration.Years = static_cast<sal_Int16>(nYears); + rDuration.Months = static_cast<sal_Int16>(nMonths); + rDuration.Days = static_cast<sal_Int16>(nDays); + rDuration.Hours = static_cast<sal_Int16>(nHours); + rDuration.Minutes = static_cast<sal_Int16>(nMinutes); + rDuration.Seconds = static_cast<sal_Int16>(nSeconds); + rDuration.MilliSeconds = static_cast<sal_Int16>(nMilliSeconds); } return bSuccess; @@ -1202,24 +1224,26 @@ struct Test { return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days && a.Hours == b.Hours && a.Minutes == b.Minutes && a.Seconds == b.Seconds - && a.HundredthSeconds == b.HundredthSeconds + && a.MilliSeconds == b.MilliSeconds && a.Negative == b.Negative; } - static void doTest(util::Duration const & rid, const char * pis) + static void doTest(util::Duration const & rid, char const*const pis, + char const*const i_pos = 0) { - bool bSuccess(false); - ::rtl::OUStringBuffer buf; - Converter::convertDuration(buf, rid); - ::rtl::OUString os(buf.makeStringAndClear()); - OSL_TRACE(::rtl::OUStringToOString(os.getStr(), RTL_TEXTENCODING_UTF8)); - OSL_ASSERT(os.equalsAscii(pis)); + char const*const pos((i_pos) ? i_pos : pis); util::Duration od; - bSuccess = Converter::convertDuration(od, os); - OSL_TRACE("%d %dY %dM %dD %dH %dM %dS %dH", + ::rtl::OUString is(::rtl::OUString::createFromAscii(pis)); + bool bSuccess = Converter::convertDuration(od, is); + OSL_TRACE("%d %dY %dM %dD %dH %dM %dS %dm", od.Negative, od.Years, od.Months, od.Days, - od.Hours, od.Minutes, od.Seconds, od.HundredthSeconds); + od.Hours, od.Minutes, od.Seconds, od.MilliSeconds); OSL_ASSERT(bSuccess); OSL_ASSERT(eqDuration(rid, od)); + ::rtl::OUStringBuffer buf; + Converter::convertDuration(buf, od); + OSL_TRACE( + ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8)); + OSL_ASSERT(buf.makeStringAndClear().equalsAscii(pos)); } static void doTestF(const char * pis) { @@ -1228,7 +1252,7 @@ struct Test { ::rtl::OUString::createFromAscii(pis)); OSL_TRACE("%d %dY %dM %dD %dH %dM %dS %dH", od.Negative, od.Years, od.Months, od.Days, - od.Hours, od.Minutes, od.Seconds, od.HundredthSeconds); + od.Hours, od.Minutes, od.Seconds, od.MilliSeconds); OSL_ASSERT(!bSuccess); } Test() { @@ -1239,24 +1263,27 @@ struct Test { doTest( util::Duration(false, 0, 0, 0, 52, 0, 0, 0), "PT52H" ); doTest( util::Duration(false, 0, 0, 0, 0, 717, 0, 0), "PT717M" ); doTest( util::Duration(false, 0, 0, 0, 0, 0, 121, 0), "PT121S" ); - doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 19), "PT0.19S" ); - doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 9), "PT0.09S" ); + doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 190), "PT0.19S" ); + doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 90), "PT0.09S" ); + doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 9), "PT0.009S" ); + doTest( util::Duration(false, 0, 0, 0, 0, 0, 9, 999), + "PT9.999999999999999999999999999999S", "PT9.999S" ); doTest( util::Duration(true , 0, 0, 9999, 0, 0, 0, 0), "-P9999D" ); - doTest( util::Duration(true , 7, 6, 5, 4, 3, 2, 1), + doTest( util::Duration(true , 7, 6, 5, 4, 3, 2, 10), "-P7Y6M5DT4H3M2.01S" ); doTest( util::Duration(false, 0, 6, 0, 0, 3, 0, 0), "P6MT3M" ); doTest( util::Duration(false, 0, 0, 0, 0, 0, 0, 0), "P0D" ); - doTestF("1Y1M"); - doTestF("P-1Y1M"); - doTestF("P1M1Y"); - doTestF("PT1Y"); - doTestF("P1Y1M1M"); - doTestF("P1YT1MT1M"); - doTestF("P1YT"); - doTestF("P99999999999Y"); - doTestF("PT.1S"); - doTestF("PT5M.134S"); - doTestF("PT1.S"); + doTestF("1Y1M"); // invalid: no ^P + doTestF("P-1Y1M"); // invalid: - after P + doTestF("P1M1Y"); // invalid: Y after M + doTestF("PT1Y"); // invalid: Y after T + doTestF("P1Y1M1M"); // invalid: M twice, no T + doTestF("P1YT1MT1M"); // invalid: T twice + doTestF("P1YT"); // invalid: T but no H,M,S + doTestF("P99999999999Y"); // cannot parse so many Ys + doTestF("PT.1S"); // invalid: no 0 preceding . + doTestF("PT5M.134S"); // invalid: no 0 preceding . + doTestF("PT1.S"); // invalid: no digit following . OSL_TRACE("\nSAX CONVERTER TEST END\n"); } }; @@ -1285,6 +1312,15 @@ void Converter::convertDateTime( const sal_Unicode zero('0'); const sal_Unicode tee ('T'); + if (i_rDateTime.Year < 1000) { + i_rBuffer.append(zero); + } + if (i_rDateTime.Year < 100) { + i_rBuffer.append(zero); + } + if (i_rDateTime.Year < 10) { + i_rBuffer.append(zero); + } i_rBuffer.append( static_cast<sal_Int32>(i_rDateTime.Year) ).append(dash); if( i_rDateTime.Month < 10 ) { i_rBuffer.append(zero); @@ -1352,6 +1388,46 @@ bool Converter::convertDateTime( util::DateTime& rDateTime, } } +static bool +readDateTimeComponent(const ::rtl::OUString & rString, + sal_Int32 & io_rnPos, sal_Int32 & o_rnTarget, + const sal_Int32 nMinLength, const bool bExactLength) +{ + const sal_Int32 nOldPos(io_rnPos); + sal_Int32 nTemp(0); + if (R_SUCCESS != readUnsignedNumber(rString, io_rnPos, nTemp)) + { + return false; + } + const sal_Int32 nTokenLength(io_rnPos - nOldPos); + if ((nTokenLength < nMinLength) || + (bExactLength && (nTokenLength > nMinLength))) + { + return false; // bad length + } + o_rnTarget = nTemp; + return true; +} + +static bool lcl_isLeapYear(const sal_uInt32 nYear) +{ + return ((nYear % 4) == 0) + && !(((nYear % 100) == 0) || ((nYear % 400) == 0)); +} + +static sal_uInt16 +lcl_MaxDaysPerMonth(const sal_Int32 nMonth, const sal_Int32 nYear) +{ + static sal_uInt16 s_MaxDaysPerMonth[12] = + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + OSL_ASSERT(0 < nMonth && nMonth <= 12); + if ((2 == nMonth) && lcl_isLeapYear(nYear)) + { + return 29; + } + return s_MaxDaysPerMonth[nMonth - 1]; +} + /** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */ bool Converter::convertDateOrDateTime( util::Date & rDate, util::DateTime & rDateTime, @@ -1359,97 +1435,233 @@ bool Converter::convertDateOrDateTime( { bool bSuccess = true; - rtl::OUString aDateStr, aTimeStr, sDoubleStr; - sal_Int32 nPos = rString.indexOf( (sal_Unicode) 'T' ); - sal_Int32 nPos2 = rString.indexOf( (sal_Unicode) ',' ); - if (nPos2 < 0) - nPos2 = rString.indexOf( (sal_Unicode) '.' ); - if ( nPos >= 0 ) + const ::rtl::OUString string = rString.trim().toAsciiUpperCase(); + sal_Int32 nPos(0); + bool bNegative(false); + if ((string.getLength() > nPos) && (sal_Unicode('-') == string[nPos])) { - aDateStr = rString.copy( 0, nPos ); - if ( nPos2 >= 0 ) - { - aTimeStr = rString.copy( nPos + 1, nPos2 - nPos - 1 ); - sDoubleStr = OUString(RTL_CONSTASCII_USTRINGPARAM("0.")); - sDoubleStr += rString.copy( nPos2 + 1 ); - } - else - { - aTimeStr = rString.copy(nPos + 1); - sDoubleStr = OUString(RTL_CONSTASCII_USTRINGPARAM("0.0")); - } + ++nPos; + bNegative = true; } - else - aDateStr = rString; // no separator: only date part - sal_Int32 nYear = 1899; - sal_Int32 nMonth = 12; - sal_Int32 nDay = 30; - sal_Int32 nHour = 0; - sal_Int32 nMin = 0; - sal_Int32 nSec = 0; + sal_Int32 nYear(0); + { + bSuccess = readDateTimeComponent(string, nPos, nYear, 4, false); + bSuccess &= (0 < nYear); + bSuccess &= (nPos < string.getLength()); // not last token + } + if (bSuccess && (sal_Unicode('-') != string[nPos])) // separator + { + bSuccess = false; + } + if (bSuccess) + { + ++nPos; + } - const sal_Unicode* pStr = aDateStr.getStr(); - sal_Int32 nDateTokens = 1; - while ( *pStr ) + sal_Int32 nMonth(0); + if (bSuccess) { - if ( *pStr == '-' ) - nDateTokens++; - pStr++; + bSuccess = readDateTimeComponent(string, nPos, nMonth, 2, true); + bSuccess &= (0 < nMonth) && (nMonth <= 12); + bSuccess &= (nPos < string.getLength()); // not last token } - if ( nDateTokens > 3 || aDateStr.getLength() == 0 ) + if (bSuccess && (sal_Unicode('-') != string[nPos])) // separator + { bSuccess = false; - else + } + if (bSuccess) + { + ++nPos; + } + + sal_Int32 nDay(0); + if (bSuccess) + { + bSuccess = readDateTimeComponent(string, nPos, nDay, 2, true); + bSuccess &= (0 < nDay) && (nDay <= lcl_MaxDaysPerMonth(nMonth, nYear)); + } + + bool bHaveTime(false); + if (bSuccess && (nPos < string.getLength())) { - sal_Int32 n = 0; - if ( !convertNumber( nYear, aDateStr.getToken( 0, '-', n ), 0, 9999 ) ) + if (sal_Unicode('T') == string[nPos]) // time separator + { + bHaveTime = true; + ++nPos; + } + } + + sal_Int32 nHours(0); + sal_Int32 nMinutes(0); + sal_Int32 nSeconds(0); + sal_Int32 nMilliSeconds(0); + if (bSuccess && bHaveTime) + { + { + bSuccess = readDateTimeComponent(string, nPos, nHours, 2, true); + bSuccess &= (0 <= nHours) && (nHours <= 24); + bSuccess &= (nPos < string.getLength()); // not last token + } + if (bSuccess && (sal_Unicode(':') != string[nPos])) // separator + { bSuccess = false; - if ( nDateTokens >= 2 ) - if ( !convertNumber( nMonth, aDateStr.getToken( 0, '-', n ), 0, 12 ) ) - bSuccess = false; - if ( nDateTokens >= 3 ) - if ( !convertNumber( nDay, aDateStr.getToken( 0, '-', n ), 0, 31 ) ) + } + if (bSuccess) + { + ++nPos; + } + + if (bSuccess) + { + bSuccess = readDateTimeComponent(string, nPos, nMinutes, 2, true); + bSuccess &= (0 <= nMinutes) && (nMinutes < 60); + bSuccess &= (nPos < string.getLength()); // not last token + } + if (bSuccess && (sal_Unicode(':') != string[nPos])) // separator + { + bSuccess = false; + } + if (bSuccess) + { + ++nPos; + } + + if (bSuccess) + { + bSuccess = readDateTimeComponent(string, nPos, nSeconds, 2, true); + bSuccess &= (0 <= nSeconds) && (nSeconds < 60); + } + if (bSuccess && (nPos < string.getLength()) && + (sal_Unicode('.') == string[nPos])) // fraction separator + { + ++nPos; + const sal_Int32 nStart(nPos); + sal_Int32 nTemp(0); + if (R_NOTHING == readUnsignedNumber(string, nPos, nTemp)) + { bSuccess = false; + } + if (bSuccess) + { + // cannot use nTemp because of possible leading zeros + // and possible overflow => read digits directly + const sal_Int32 nDigits(nPos - nStart); + OSL_ENSURE(nDigits > 0, "bad code monkey"); + const sal_Unicode cZero('0'); + nMilliSeconds = 100 * (string[nStart] - cZero); + if (nDigits >= 2) + { + nMilliSeconds += 10 * (string[nStart+1] - cZero); + if (nDigits >= 3) + { + nMilliSeconds += (string[nStart+2] - cZero); + } + } + } + } + + if (bSuccess && (nHours == 24)) + { + if (!((0 == nMinutes) && (0 == nSeconds) && (0 == nMilliSeconds))) + { + bSuccess = false; // only 24:00:00 is valid + } +#if 0 + else + { + nHours = 0; // normalize 24:00:00 to 00:00:00 of next day + lcl_addDay(bNegative, nYear, nMonth, nDay, 1); + } +#endif + } } - if ( aTimeStr.getLength() > 0 ) // time is optional + bool bHaveTimezone(false); + bool bHaveTimezonePlus(false); + bool bHaveTimezoneMinus(false); + if (bSuccess && (nPos < string.getLength())) { - pStr = aTimeStr.getStr(); - sal_Int32 nTimeTokens = 1; - while ( *pStr ) + const sal_Unicode c(string[nPos]); + if (sal_Unicode('+') == c) { - if ( *pStr == ':' ) - nTimeTokens++; - pStr++; + bHaveTimezone = true; + bHaveTimezonePlus = true; + ++nPos; + } + else if (sal_Unicode('-') == c) + { + bHaveTimezone = true; + bHaveTimezoneMinus = true; + ++nPos; + } + else if (sal_Unicode('Z') == c) + { + bHaveTimezone = true; + ++nPos; } - if ( nTimeTokens > 3 ) - bSuccess = false; else { - sal_Int32 n = 0; - if ( !convertNumber( nHour, aTimeStr.getToken( 0, ':', n ), 0, 23 ) ) - bSuccess = false; - if ( nTimeTokens >= 2 ) - if ( !convertNumber( nMin, aTimeStr.getToken( 0, ':', n ), 0, 59 ) ) - bSuccess = false; - if ( nTimeTokens >= 3 ) - if ( !convertNumber( nSec, aTimeStr.getToken( 0, ':', n ), 0, 59 ) ) - bSuccess = false; + bSuccess = false; + } + } + sal_Int32 nTimezoneHours(0); + sal_Int32 nTimezoneMinutes(0); + if (bSuccess && (bHaveTimezonePlus || bHaveTimezoneMinus)) + { + bSuccess = readDateTimeComponent( + string, nPos, nTimezoneHours, 2, true); + bSuccess &= (0 <= nTimezoneHours) && (nTimezoneHours <= 14); + bSuccess &= (nPos < string.getLength()); // not last token + if (bSuccess && (sal_Unicode(':') != string[nPos])) // separator + { + bSuccess = false; + } + if (bSuccess) + { + ++nPos; + } + if (bSuccess) + { + bSuccess = readDateTimeComponent( + string, nPos, nTimezoneMinutes, 2, true); + bSuccess &= (0 <= nTimezoneMinutes) && (nTimezoneMinutes < 60); + } + if (bSuccess && (nTimezoneHours == 14)) + { + if (0 != nTimezoneMinutes) + { + bSuccess = false; // only +-14:00 is valid + } } } + bSuccess &= (nPos == string.getLength()); // trailing junk? + + if (bSuccess && bHaveTimezone) + { + // util::DateTime does not support timezones! +#if 0 + // do not add timezone, just strip it (as suggested by er) + lcl_addTimezone(bNegative, nYear, nMonth, nDay, nHours, nMinutes, + !bHaveTimezoneMinus, nTimezoneHours, nTimezoneMinutes); +#endif + } + if (bSuccess) { - if ( aTimeStr.getLength() > 0 ) // time is optional + if (bHaveTime) // time is optional { + // util::DateTime does not support negative years! rDateTime.Year = static_cast<sal_uInt16>(nYear); rDateTime.Month = static_cast<sal_uInt16>(nMonth); rDateTime.Day = static_cast<sal_uInt16>(nDay); - rDateTime.Hours = static_cast<sal_uInt16>(nHour); - rDateTime.Minutes = static_cast<sal_uInt16>(nMin); - rDateTime.Seconds = static_cast<sal_uInt16>(nSec); + rDateTime.Hours = static_cast<sal_uInt16>(nHours); + rDateTime.Minutes = static_cast<sal_uInt16>(nMinutes); + rDateTime.Seconds = static_cast<sal_uInt16>(nSeconds); + // util::DateTime does not support 3 decimal digits of precision! rDateTime.HundredthSeconds = - static_cast<sal_uInt16>((sDoubleStr).toDouble() * 100); + static_cast<sal_uInt16>(nMilliSeconds / 10); rbDateTime = true; } else @@ -1463,6 +1675,100 @@ bool Converter::convertDateOrDateTime( return bSuccess; } +#if 0 +struct Test { + static bool eqDateTime(util::DateTime a, util::DateTime b) { + return a.Year == b.Year && a.Month == b.Month && a.Day == b.Day + && a.Hours == b.Hours && a.Minutes == b.Minutes + && a.Seconds == b.Seconds + && a.HundredthSeconds == b.HundredthSeconds; + } + static void doTest(util::DateTime const & rdt, char const*const pis, + char const*const i_pos = 0) + { + char const*const pos((i_pos) ? i_pos : pis); + ::rtl::OUString is(::rtl::OUString::createFromAscii(pis)); + util::DateTime odt; + bool bSuccess( Converter::convertDateTime(odt, is) ); + OSL_TRACE("Y:%d M:%d D:%d H:%d M:%d S:%d H:%d", + odt.Year, odt.Month, odt.Day, + odt.Hours, odt.Minutes, odt.Seconds, odt.HundredthSeconds); + OSL_ASSERT(bSuccess); + OSL_ASSERT(eqDateTime(rdt, odt)); + ::rtl::OUStringBuffer buf; + Converter::convertDateTime(buf, odt, true); + OSL_TRACE( + ::rtl::OUStringToOString(buf.getStr(), RTL_TEXTENCODING_UTF8)); + OSL_ASSERT(buf.makeStringAndClear().equalsAscii(pos)); + } + static void doTestF(const char * pis) + { + util::DateTime odt; + bool bSuccess = Converter::convertDateTime(odt, + ::rtl::OUString::createFromAscii(pis)); + OSL_TRACE("Y:%d M:%d D:%d H:%dH M:%d S:%d H:%d", + odt.Year, odt.Month, odt.Day, + odt.Hours, odt.Minutes, odt.Seconds, odt.HundredthSeconds); + OSL_ASSERT(!bSuccess); + } + Test() { + OSL_TRACE("\nSAX CONVERTER TEST BEGIN\n"); + doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1), "0001-01-01T00:00:00" ); + doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1), + "0001-01-01T00:00:00Z", "0001-01-01T00:00:00" ); +// doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1), "-0001-01-01T00:00:00" ); +// doTest( util::DateTime(0, 0, 0, 0, 1, 1, -1), "-0001-01-01T00:00:00Z" ); + doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1), + "0001-01-01T00:00:00-00:00", "0001-01-01T00:00:00" ); + doTest( util::DateTime(0, 0, 0, 0, 1, 1, 1), + "0001-01-01T00:00:00+00:00", "0001-01-01T00:00:00" ); + doTest( util::DateTime(0, 0, 0, 0, 2, 1, 1)/*(0, 0, 12, 0, 2, 1, 1)*/, + "0001-01-02T00:00:00-12:00", "0001-01-02T00:00:00" ); +// "0001-02-01T12:00:00" ); + doTest( util::DateTime(0, 0, 0, 0, 2, 1, 1)/*(0, 0, 12, 0, 1, 1, 1)*/, + "0001-01-02T00:00:00+12:00", "0001-01-02T00:00:00" ); +// "0001-01-01T12:00:00" ); + doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999), + "9999-12-31T23:59:59.99" ); + doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999), + "9999-12-31T23:59:59.99Z", "9999-12-31T23:59:59.99" ); + doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999), + "9999-12-31T23:59:59.9999999999999999999999999999999999999", + "9999-12-31T23:59:59.99" ); + doTest( util::DateTime(99, 59, 59, 23, 31, 12, 9999), + "9999-12-31T23:59:59.9999999999999999999999999999999999999Z", + "9999-12-31T23:59:59.99" ); + doTest( util::DateTime(0, 0, 0, 24, 1, 1, 333) + /*(0, 0, 0, 0, 2, 1, 333)*/, + "0333-01-01T24:00:00"/*, "0333-01-02T00:00:00"*/ ); + doTestF( "+0001-01-01T00:00:00" ); // invalid: ^+ + doTestF( "1-01-01T00:00:00" ); // invalid: < 4 Y + doTestF( "0001-1-01T00:00:00" ); // invalid: < 2 M + doTestF( "0001-01-1T00:00:00" ); // invalid: < 2 D + doTestF( "0001-01-01T0:00:00" ); // invalid: < 2 H + doTestF( "0001-01-01T00:0:00" ); // invalid: < 2 M + doTestF( "0001-01-01T00:00:0" ); // invalid: < 2 S + doTestF( "0001-01-01T00:00:00." ); // invalid: .$ + doTestF( "0001-01-01T00:00:00+1:00" ); // invalid: < 2 TZ H + doTestF( "0001-01-01T00:00:00+00:1" ); // invalid: < 2 TZ M + doTestF( "0001-13-01T00:00:00" ); // invalid: M > 12 + doTestF( "0001-01-32T00:00:00" ); // invalid: D > 31 + doTestF( "0001-01-01T25:00:00" ); // invalid: H > 24 + doTestF( "0001-01-01T00:60:00" ); // invalid: H > 59 + doTestF( "0001-01-01T00:00:60" ); // invalid: S > 59 + doTestF( "0001-01-01T24:01:00" ); // invalid: H=24, but M != 0 + doTestF( "0001-01-01T24:00:01" ); // invalid: H=24, but S != 0 + doTestF( "0001-01-01T24:00:00.1" ); // invalid: H=24, but H != 0 + doTestF( "0001-01-02T00:00:00+15:00" ); // invalid: TZ > +14:00 + doTestF( "0001-01-02T00:00:00+14:01" ); // invalid: TZ > +14:00 + doTestF( "0001-01-02T00:00:00-15:00" ); // invalid: TZ < -14:00 + doTestF( "0001-01-02T00:00:00-14:01" ); // invalid: TZ < -14:00 + OSL_TRACE("\nSAX CONVERTER TEST END\n"); + } +}; +static Test test; +#endif + /** gets the position of the first comma after npos in the string rStr. Commas inside '"' pairs are not matched */ sal_Int32 Converter::indexOfComma( const OUString& rStr, diff --git a/sot/source/sdstor/sdintern.hdb b/sot/source/sdstor/sdintern.hdb deleted file mode 100644 index 4dfbc69be013..000000000000 --- a/sot/source/sdstor/sdintern.hdb +++ /dev/null @@ -1,22 +0,0 @@ -write "/*************************************************************************" -write "* SDINTERN.HXX" -write "* __DATE__" -write "* (c) 1992-1995 STAR DIVISION" -write "*************************************************************************/" -write "#ifndef _SDINTERN_HXX" -write "#define _SDINTERN_HXX" -write "#ifndef _SOLAR_H" -write "#include <tools/solar.h>" -write "#endif" -write "#ifndef _STREAM_HXX" -write "#include <tools/stream.hxx>" -write "#endif" -file stg.hxx -file stgelem.hxx -file stgcache.hxx -file stgio.hxx -file stgstrms.hxx -file stgavl.hxx -file stgdir.hxx -write "#endif" - diff --git a/svl/inc/svl/smplhint.hxx b/svl/inc/svl/smplhint.hxx index baf3c85222b4..cf705b41c5ae 100644 --- a/svl/inc/svl/smplhint.hxx +++ b/svl/inc/svl/smplhint.hxx @@ -39,14 +39,14 @@ #define SFX_HINT_UPDATEDONE 0x00000020 #define SFX_HINT_DEINITIALIZING 0x00000040 #define SFX_HINT_MODECHANGED 0x00000080 -#define SFX_HINT_CANCELLABLE 0x00000100 -#define SFX_HINT_DATAAVAILABLE 0x00000200 -#define SFX_HINT_SAVECOMPLETED 0x00000400 -#define SFX_HINT_RELEASEREF 0x00000800 + // unused, formerly SFX_HINT_CANCELLABLE + // unused, formerly SFX_HINT_DATAAVAILABLE + // unused, formerly SFX_HINT_SAVECOMPLETED + // unused, formerly SFX_HINT_RELEASEREF #define SFX_HINT_COLORS_CHANGED 0x00001000 #define SFX_HINT_CTL_SETTINGS_CHANGED 0x00002000 #define SFX_HINT_ACCESSIBILITY_CHANGED 0x00004000 -#define SFX_HINT_VIEWCREATED 0x00008000 + // unused, formerly SFX_HINT_VIEWCREATED #define SFX_HINT_USER00 0x00010000 #define SFX_HINT_USER01 0x00020000 #define SFX_HINT_USER02 0x00040000 diff --git a/svl/qa/complex/ConfigItems/helper/exports.map b/svl/qa/complex/ConfigItems/helper/exports.map deleted file mode 100644 index 85610ad80888..000000000000 --- a/svl/qa/complex/ConfigItems/helper/exports.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - GetVersionInfo; - component_getImplementationEnvironment; - component_getFactory; - component_writeInfo; - - local: - *; -}; diff --git a/svl/qa/complex/ConfigItems/helper/makefile.mk b/svl/qa/complex/ConfigItems/helper/makefile.mk index 2c949da7b168..13ea12106792 100644 --- a/svl/qa/complex/ConfigItems/helper/makefile.mk +++ b/svl/qa/complex/ConfigItems/helper/makefile.mk @@ -65,7 +65,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -SHL1VERSIONMAP= exports.map +SHL1VERSIONMAP= $(SOLARENV)/src/component.map # --- Targets ------------------------------------------------------ diff --git a/svl/qa/makefile.mk b/svl/qa/makefile.mk index 4e107e31f924..7e8c7ee795cc 100644 --- a/svl/qa/makefile.mk +++ b/svl/qa/makefile.mk @@ -35,6 +35,8 @@ ENABLE_EXCEPTIONS = true .INCLUDE : settings.mk +CFLAGSCXX += $(CPPUNIT_CFLAGS) + # BEGIN ---------------------------------------------------------------- # auto generated Target:job by codegen.pl SHL1OBJS= \ diff --git a/svl/source/fsstor/exports.map b/svl/source/fsstor/exports.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/svl/source/fsstor/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/svl/source/fsstor/makefile.mk b/svl/source/fsstor/makefile.mk index 43515155d63d..dc91814772f9 100644 --- a/svl/source/fsstor/makefile.mk +++ b/svl/source/fsstor/makefile.mk @@ -56,7 +56,7 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(SALLIB) -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) diff --git a/svl/source/notify/makefile.mk b/svl/source/notify/makefile.mk index bfccd06de853..c2e6648907e5 100644 --- a/svl/source/notify/makefile.mk +++ b/svl/source/notify/makefile.mk @@ -42,7 +42,6 @@ SLOFILES = \ $(SLO)$/hint.obj \ $(SLO)$/lstner.obj \ $(SLO)$/isethint.obj \ - $(SLO)$/cancel.obj \ $(SLO)$/brdcst.obj \ $(SLO)$/listener.obj \ $(SLO)$/listenerbase.obj \ diff --git a/svl/source/passwordcontainer/exports.map b/svl/source/passwordcontainer/exports.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/svl/source/passwordcontainer/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/svl/source/passwordcontainer/makefile.mk b/svl/source/passwordcontainer/makefile.mk index 92a9993fd251..d9eb9615cf80 100644 --- a/svl/source/passwordcontainer/makefile.mk +++ b/svl/source/passwordcontainer/makefile.mk @@ -52,7 +52,7 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(SALLIB) -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) diff --git a/svtools/inc/svtools/grfmgr.hxx b/svtools/inc/svtools/grfmgr.hxx index 06f75394c8bb..3ed608c1525d 100644 --- a/svtools/inc/svtools/grfmgr.hxx +++ b/svtools/inc/svtools/grfmgr.hxx @@ -422,6 +422,11 @@ public: BOOL Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz, const GraphicAttr* pAttr = NULL, ULONG nFlags = GRFMGR_DRAW_STANDARD ); + BOOL DrawWithPDFHandling( OutputDevice& rOutDev, + const Point& rPt, const Size& rSz, + const GraphicAttr* pGrfAttr = NULL, + const ULONG nFlags = GRFMGR_DRAW_STANDARD ); + /** Draw the graphic repeatedly into the given output rectangle @param pOut diff --git a/svtools/prj/build.lst b/svtools/prj/build.lst index 4b2cd9f9b26b..15dbc36467d2 100644 --- a/svtools/prj/build.lst +++ b/svtools/prj/build.lst @@ -27,3 +27,4 @@ st svtools\util nmake - all st_util st_svtgraphic st st svtools\source\hatchwindow nmake - all st_hatchwin st_inc NULL st svtools\source\productregistration nmake - all st_prodreg st_util st_inc NULL st svtools\workben\unodialog nmake - all st_workben_udlg st_util NULL +st svtools\qa\unoapi nmake - all st_qa_unoapi NULL diff --git a/svtools/qa/unoapi/Test.java b/svtools/qa/unoapi/Test.java new file mode 100644 index 000000000000..8ae4af55ed61 --- /dev/null +++ b/svtools/qa/unoapi/Test.java @@ -0,0 +1,51 @@ +/************************************************************************* +* 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. +************************************************************************/ + +package org.openoffice.svtools.qa.unoapi; + +import org.openoffice.Runner; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +public final class Test { + @org.junit.Before public void setUp() throws Exception { + connection.setUp(); + } + + @org.junit.After public void tearDown() + throws InterruptedException, com.sun.star.uno.Exception + { + connection.tearDown(); + } + + @org.junit.Test public void test() { + assertTrue( + Runner.run( + "-sce", "svtools.sce", "-xcl", "knownissues.xcl", "-cs", + connection.getDescription())); + } + + private final OfficeConnection connection = new OfficeConnection(); +} diff --git a/svtools/qa/unoapi/makefile.mk b/svtools/qa/unoapi/makefile.mk index 2d75735d4b0d..e3afb77e637a 100644 --- a/svtools/qa/unoapi/makefile.mk +++ b/svtools/qa/unoapi/makefile.mk @@ -1,7 +1,6 @@ #************************************************************************* -# # 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 @@ -22,19 +21,28 @@ # version 3 along with OpenOffice.org. If not, see # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. -# -#************************************************************************* +#***********************************************************************/ -PRJ=..$/.. +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -PRJNAME=svtools -TARGET=qa_unoapi +PRJ = ../.. +PRJNAME = svtools +TARGET = qa_unoapi -.INCLUDE: settings.mk +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/svtools/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END +.INCLUDE: settings.mk .INCLUDE: target.mk +.INCLUDE: installationtest.mk -ALLTAR : UNOAPI_TEST +ALLTAR : javatest -UNOAPI_TEST: - +$(SOLARENV)$/bin$/checkapi -sce svtools.sce -xcl knownissues.xcl -tdoc $(PWD)$/testdocuments +.END diff --git a/svtools/source/contnr/templwin.cxx b/svtools/source/contnr/templwin.cxx index ab4bda64a652..47b5ab9aa4b9 100644 --- a/svtools/source/contnr/templwin.cxx +++ b/svtools/source/contnr/templwin.cxx @@ -1840,26 +1840,7 @@ sal_Bool SvtDocumentTemplateDialog::CanEnableEditBtn() const if ( pImpl->pWin->IsFileSelected() && aFolderURL.getLength() ) { ::rtl::OUString aFileTargetURL = pImpl->pWin->GetSelectedFile(); - ::rtl::OUString aFolderTargetURL; - - ::ucbhelper::Content aFolderContent; - Reference< XCommandEnvironment > xEnv; - if ( ::ucbhelper::Content::create( aFolderURL, xEnv, aFolderContent ) ) - try - { - ::rtl::OUString aTmpURL; - uno::Any aValue = aFolderContent.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TargetDirURL") ) ); - aValue >>= aTmpURL; - - uno::Reference< util::XOfficeInstallationDirectories > xOffInstDirs = pImpl->getOfficeInstDirs(); - if ( xOffInstDirs.is() ) - aFolderTargetURL = xOffInstDirs->makeAbsoluteURL( aTmpURL ); - } - catch( uno::Exception& ) - {} - - if ( aFolderTargetURL.getLength() && ::utl::UCBContentHelper::IsSubPath( aFolderTargetURL, aFileTargetURL ) ) - bEnable = sal_True; + bEnable = aFileTargetURL.getLength() > 0; } return bEnable; diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 8aadbb9028b0..02a578629039 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -66,7 +66,6 @@ #include <unotools/historyoptions.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> -#include <svl/cancel.hxx> #include <svl/itemset.hxx> #include "svl/urihelper.hxx" #include <unotools/pathoptions.hxx> diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 6647b9eee608..2849ddb71d10 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -854,7 +854,7 @@ void AssignmentPersistentData::Commit() m_aDatasource.SaveValue(); // create an interaction handler (may be needed for connecting) - const String sInteractionHandlerServiceName = String::CreateFromAscii("com.sun.star.sdb.InteractionHandler"); + const String sInteractionHandlerServiceName = String::CreateFromAscii("com.sun.star.task.InteractionHandler"); Reference< XInteractionHandler > xHandler; try { diff --git a/svtools/source/dialogs/wizardmachine.cxx b/svtools/source/dialogs/wizardmachine.cxx index bac18a2932dc..6a09f85036fd 100644 --- a/svtools/source/dialogs/wizardmachine.cxx +++ b/svtools/source/dialogs/wizardmachine.cxx @@ -90,7 +90,6 @@ namespace svt void OWizardPage::updateDialogTravelUI() { OWizardMachine* pWizardMachine = dynamic_cast< OWizardMachine* >( GetParent() ); - OSL_ENSURE( pWizardMachine, "OWizardPage::updateDialogTravelUI: where am I?" ); if ( pWizardMachine ) pWizardMachine->updateTravelUI(); } diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 53f4a3ed2515..221354cc6665 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -44,6 +44,10 @@ #include <unotools/cacheoptions.hxx> #include <svtools/grfmgr.hxx> +// --> OD 2010-01-04 #i105243# +#include <vcl/pdfextoutdevdata.hxx> +// <-- + // ----------- // - Defines - // ----------- @@ -738,6 +742,68 @@ BOOL GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz, return bRet; } +// --> OD 2010-01-04 #i105243# +BOOL GraphicObject::DrawWithPDFHandling( OutputDevice& rOutDev, + const Point& rPt, const Size& rSz, + const GraphicAttr* pGrfAttr, + const ULONG nFlags ) +{ + const GraphicAttr aGrfAttr( pGrfAttr ? *pGrfAttr : GetAttr() ); + + // Notify PDF writer about linked graphic (if any) + bool bWritingPdfLinkedGraphic( false ); + Point aPt( rPt ); + Size aSz( rSz ); + Rectangle aCropRect; + vcl::PDFExtOutDevData* pPDFExtOutDevData = + dynamic_cast<vcl::PDFExtOutDevData*>(rOutDev.GetExtOutDevData()); + if( pPDFExtOutDevData ) + { + // only delegate image handling to PDF, if no special treatment is necessary + if( GetGraphic().IsLink() && + rSz.Width() > 0L && + rSz.Height() > 0L && + !aGrfAttr.IsSpecialDrawMode() && + !aGrfAttr.IsMirrored() && + !aGrfAttr.IsRotated() && + !aGrfAttr.IsAdjusted() ) + { + bWritingPdfLinkedGraphic = true; + + if( aGrfAttr.IsCropped() ) + { + PolyPolygon aClipPolyPoly; + BOOL bRectClip; + const BOOL bCrop = ImplGetCropParams( &rOutDev, + aPt, aSz, + &aGrfAttr, + aClipPolyPoly, + bRectClip ); + if ( bCrop && bRectClip ) + { + aCropRect = aClipPolyPoly.GetBoundRect(); + } + } + + pPDFExtOutDevData->BeginGroup(); + } + } + + BOOL bRet = Draw( &rOutDev, rPt, rSz, &aGrfAttr, nFlags ); + + // Notify PDF writer about linked graphic (if any) + if( bWritingPdfLinkedGraphic ) + { + pPDFExtOutDevData->EndGroup( const_cast< Graphic& >(GetGraphic()), + aGrfAttr.GetTransparency(), + Rectangle( aPt, aSz ), + aCropRect ); + } + + return bRet; +} +// <-- + // ----------------------------------------------------------------------------- BOOL GraphicObject::DrawTiled( OutputDevice* pOut, const Rectangle& rArea, const Size& rSize, diff --git a/svtools/source/hatchwindow/exports.map b/svtools/source/hatchwindow/exports.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/svtools/source/hatchwindow/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/svtools/source/hatchwindow/makefile.mk b/svtools/source/hatchwindow/makefile.mk index c5a4dab09762..316e4ab1bfe2 100644 --- a/svtools/source/hatchwindow/makefile.mk +++ b/svtools/source/hatchwindow/makefile.mk @@ -55,7 +55,7 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(SALLIB) -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index e57c0d21d98a..391ad02e6aa1 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -73,33 +73,35 @@ struct SvtExtensionResIdMapping_Impl static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = { - { "awk", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, - { "bas", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, - { "bat", TRUE, STR_DESCRIPTION_BATCHFILE, IMG_APP }, + { "awk", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, + { "bas", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, + { "bat", TRUE, STR_DESCRIPTION_BATCHFILE, 0 }, { "bmk", FALSE, STR_DESCRIPTION_BOOKMARKFILE, 0 }, { "bmp", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_BITMAP }, - { "c", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "c", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "cfg", FALSE, STR_DESCRIPTION_CFGFILE, 0 }, - { "cmd", TRUE, STR_DESCRIPTION_BATCHFILE, IMG_APP }, - { "cob", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, - { "com", TRUE, STR_DESCRIPTION_APPLICATION, IMG_APP }, - { "cxx", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "cmd", TRUE, STR_DESCRIPTION_BATCHFILE, 0 }, + { "cob", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, + { "com", TRUE, STR_DESCRIPTION_APPLICATION, 0 }, + { "cxx", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "dbf", TRUE, STR_DESCRIPTION_DATABASE_TABLE, IMG_TABLE }, - { "def", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "def", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "dll", TRUE, STR_DESCRIPTION_SYSFILE, 0 }, - { "doc", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WORD }, + { "doc", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER }, + { "dot", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITERTEMPLATE }, + { "docx", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER }, { "dxf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_DXF }, - { "exe", TRUE, STR_DESCRIPTION_APPLICATION, IMG_APP }, + { "exe", TRUE, STR_DESCRIPTION_APPLICATION, 0 }, { "gif", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_GIF }, - { "h", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, - { "hlp", FALSE, STR_DESCRIPTION_HELP_DOC, IMG_HELP }, - { "hrc", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "h", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, + { "hlp", FALSE, STR_DESCRIPTION_HELP_DOC, 0 }, + { "hrc", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "htm", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML }, { "html", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML }, { "asp", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML }, - { "hxx", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "hxx", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "ini", FALSE, STR_DESCRIPTION_CFGFILE, 0 }, - { "java", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "java", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "jpeg", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG }, { "jpg", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_JPG }, { "lha", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, @@ -110,7 +112,7 @@ static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = { "lst", TRUE, STR_DESCRIPTION_LOGFILE, 0 }, { "met", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_MET }, { "mml", FALSE, STR_DESCRIPTION_MATHML_DOC, IMG_MATH }, - { "mod", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "mod", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "odb", FALSE, STR_DESCRIPTION_OO_DATABASE_DOC, IMG_OO_DATABASE_DOC }, { "odg", FALSE, STR_DESCRIPTION_OO_DRAW_DOC, IMG_OO_DRAW_DOC }, { "odf", FALSE, STR_DESCRIPTION_OO_MATH_DOC, IMG_OO_MATH_DOC }, @@ -122,31 +124,32 @@ static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = { "otp", FALSE, STR_DESCRIPTION_OO_IMPRESS_TEMPLATE, IMG_OO_IMPRESS_TEMPLATE }, { "ots", FALSE, STR_DESCRIPTION_OO_CALC_TEMPLATE, IMG_OO_CALC_TEMPLATE }, { "ott", FALSE, STR_DESCRIPTION_OO_WRITER_TEMPLATE, IMG_OO_WRITER_TEMPLATE }, - { "pas", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "pas", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "pcd", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD }, { "pct", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT }, { "pcx", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX }, - { "pl", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, + { "pl", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, { "png", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PNG }, { "rar", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, - { "sbl", FALSE, 0, IMG_MACROLIB }, + { "rtf", FALSE, STR_DESCRIPTION_WORD_DOC, IMG_WRITER }, + { "sbl", FALSE, 0, 0 }, { "sch", FALSE, 0, 0 }, { "sda", FALSE, STR_DESCRIPTION_SDRAW_DOC, IMG_DRAW }, { "sdb", FALSE, STR_DESCRIPTION_SDATABASE_DOC, IMG_DATABASE }, { "sdc", FALSE, STR_DESCRIPTION_SCALC_DOC, IMG_CALC }, { "sdd", FALSE, STR_DESCRIPTION_SIMPRESS_DOC, IMG_IMPRESS }, - { "sdp", FALSE, STR_DESCRIPTION_SIMPRESS_DOC, IMG_IMPRESSPACKED }, - { "sds", FALSE, STR_DESCRIPTION_SCHART_DOC, IMG_CHART }, + { "sdp", FALSE, STR_DESCRIPTION_SIMPRESS_DOC, 0 }, + { "sds", FALSE, STR_DESCRIPTION_SCHART_DOC, 0 }, { "sdw", FALSE, STR_DESCRIPTION_SWRITER_DOC, IMG_WRITER }, - { "sga", FALSE, 0, IMG_GALLERY }, + { "sga", FALSE, 0, 0 }, { "sgf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGF }, { "sgl", FALSE, STR_DESCRIPTION_GLOBALDOC, IMG_GLOBAL_DOC }, { "sgv", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SGV }, { "shtml", FALSE, STR_DESCRIPTION_HTMLFILE, IMG_HTML }, { "sim", FALSE, STR_DESCRIPTION_SIMAGE_DOC, IMG_SIM }, { "smf", FALSE, STR_DESCRIPTION_SMATH_DOC, IMG_MATH }, - { "src", TRUE, STR_DESCRIPTION_SOURCEFILE, IMG_TEXTFILE }, - { "svh", FALSE, STR_DESCRIPTION_HELP_DOC, IMG_SVHELP }, + { "src", TRUE, STR_DESCRIPTION_SOURCEFILE, 0 }, + { "svh", FALSE, STR_DESCRIPTION_HELP_DOC, 0 }, { "svm", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_SVM }, { "stc", FALSE, STR_DESCRIPTION_CALC_TEMPLATE, IMG_CALCTEMPLATE }, { "std", FALSE, STR_DESCRIPTION_DRAW_TEMPLATE, IMG_DRAWTEMPLATE }, @@ -157,27 +160,29 @@ static SvtExtensionResIdMapping_Impl __READONLY_DATA ExtensionMap_Impl[] = { "sxg", FALSE, STR_DESCRIPTION_SXGLOBAL_DOC, IMG_GLOBAL_DOC }, { "sxi", FALSE, STR_DESCRIPTION_SXIMPRESS_DOC, IMG_IMPRESS }, { "sxm", FALSE, STR_DESCRIPTION_SXMATH_DOC, IMG_MATH }, - { "sxs", FALSE, STR_DESCRIPTION_SXCHART_DOC, IMG_CHART }, + { "sxs", FALSE, STR_DESCRIPTION_SXCHART_DOC, 0 }, { "sxw", FALSE, STR_DESCRIPTION_SXWRITER_DOC, IMG_WRITER }, { "sys", TRUE, STR_DESCRIPTION_SYSFILE, 0 }, { "tif", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF }, { "tiff", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_TIFF }, { "txt", FALSE, STR_DESCRIPTION_TEXTFILE, IMG_TEXTFILE }, - { "url", FALSE, STR_DESCRIPTION_LINK, IMG_HTML }, + { "url", FALSE, STR_DESCRIPTION_LINK, 0 }, { "vor", FALSE, STR_DESCRIPTION_SOFFICE_TEMPLATE_DOC, IMG_WRITERTEMPLATE }, { "vxd", TRUE, STR_DESCRIPTION_SYSFILE, 0 }, { "wmf", TRUE, STR_DESCRIPTION_GRAPHIC_DOC, IMG_WMF }, - { "xls", FALSE, STR_DESCRIPTION_EXCEL_DOC, IMG_EXCEL }, - { "xlt", FALSE, STR_DESCRIPTION_EXCEL_TEMPLATE_DOC, IMG_EXCELTEMPLATE }, + { "xls", FALSE, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC }, + { "xlt", FALSE, STR_DESCRIPTION_EXCEL_TEMPLATE_DOC, IMG_CALCTEMPLATE }, + { "xlsx", FALSE, STR_DESCRIPTION_EXCEL_DOC, IMG_CALC }, { "uu", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, { "uue", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, { "z", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, { "zip", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, { "zoo", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, { "gz", TRUE, STR_DESCRIPTION_ARCHIVFILE, 0 }, - { "ppt", FALSE, STR_DESCRIPTION_POWERPOINT, IMG_POWERPOINT }, - { "pot", FALSE, STR_DESCRIPTION_POWERPOINT_TEMPLATE, IMG_POWERPOINTTEMPLATE }, - { "pps", FALSE, STR_DESCRIPTION_POWERPOINT_SHOW, IMG_POWERPOINT }, + { "ppt", FALSE, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS }, + { "pot", FALSE, STR_DESCRIPTION_POWERPOINT_TEMPLATE, IMG_IMPRESSTEMPLATE }, + { "pps", FALSE, STR_DESCRIPTION_POWERPOINT_SHOW, IMG_IMPRESS }, + { "pptx", FALSE, STR_DESCRIPTION_POWERPOINT, IMG_IMPRESS }, { "oxt", FALSE, STR_DESCRIPTION_EXTENSION, IMG_EXTENSION }, { 0, FALSE, 0, 0 } }; diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index 929276cfbdb5..39f9362e3940 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -307,6 +307,18 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE < "Asturian" ; LANGUAGE_USER_ASTURIAN ; > ; < "Sorbian, Upper" ; LANGUAGE_UPPER_SORBIAN_GERMANY ; > ; < "Sorbian, Lower" ; LANGUAGE_LOWER_SORBIAN_GERMANY ; > ; + < "Latgalian" ; LANGUAGE_USER_LATGALIAN ; > ; + < "Maore" ; LANGUAGE_USER_MAORE ; > ; + < "Bushi" ; LANGUAGE_USER_BUSHI ; > ; + < "Tahitian" ; LANGUAGE_USER_TAHITIAN ; > ; + < "Malagasy, Plateau" ; LANGUAGE_USER_MALAGASY_PLATEAU ; > ; + < "Papiamentu (Netherlands Antilles)" ; LANGUAGE_PAPIAMENTU ; > ; + < "Papiamento (Aruba)" ; LANGUAGE_USER_PAPIAMENTU_ARUBA ; > ; + < "Sardinian, Campidanese" ; LANGUAGE_USER_SARDINIAN_CAMPIDANESE ; > ; + < "Sardinian, Gallurese" ; LANGUAGE_USER_SARDINIAN_GALLURESE ; > ; + < "Sardinian, Logudorese" ; LANGUAGE_USER_SARDINIAN_LOGUDORESE ; > ; + < "Sardinian, Sassarese" ; LANGUAGE_USER_SARDINIAN_SASSARESE ; > ; + < "Bafia" ; LANGUAGE_USER_BAFIA ; > ; }; }; diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 4628c0d4b846..268533ebb8c8 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -42,6 +42,7 @@ #include <vos/mutex.hxx> #include <rtl/memory.h> #include <rtl/uuid.h> +#include <rtl/uri.hxx> #ifndef DEBUG_HXX #include <tools/debug.hxx> #endif @@ -154,6 +155,10 @@ SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjD } // ----------------------------------------------------------------------------- +// the reading of the parameter is done using the special service ::com::sun::star::datatransfer::MimeContentType, +// a similar approach should be implemented for creation of the mimetype string; +// for now the set of acceptable characters has to be hardcoded, in future it should be part of the service that creates the mimetype +const ::rtl::OUString aQuotedParamChars = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "()<>@,;:\\\"/[]?=!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. " ) ); static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescriptor& rObjDesc ) { @@ -177,8 +182,21 @@ static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescripto if( rObjDesc.maDisplayName.Len() ) { + // the display name might contain unacceptable characters, encode all of them + // this seems to be the only parameter currently that might contain such characters + sal_Bool pToAccept[128]; + for ( sal_Int32 nBInd = 0; nBInd < 128; nBInd++ ) + pToAccept[nBInd] = sal_False; + + for ( sal_Int32 nInd = 0; nInd < aQuotedParamChars.getLength(); nInd++ ) + { + sal_Unicode nChar = aQuotedParamChars.getStr()[nInd]; + if ( nChar < 128 ) + pToAccept[nChar] = sal_True; + } + aParams += ::rtl::OUString::createFromAscii( ";displayname=\"" ); - aParams += rObjDesc.maDisplayName; + aParams += ::rtl::Uri::encode( rObjDesc.maDisplayName, pToAccept, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); aParams += aChar; } @@ -248,7 +266,9 @@ static void ImplSetParameterString( TransferableObjectDescriptor& rObjDesc, cons if( xMimeType->hasParameter( aDisplayNameString ) ) { - rObjDesc.maDisplayName = xMimeType->getParameterValue( aDisplayNameString ); + // the display name might contain unacceptable characters, in this case they should be encoded + // this seems to be the only parameter currently that might contain such characters + rObjDesc.maDisplayName = ::rtl::Uri::decode( xMimeType->getParameterValue( aDisplayNameString ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); } if( xMimeType->hasParameter( aViewAspectString ) ) diff --git a/svtools/source/productregistration/exports.map b/svtools/source/productregistration/exports.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/svtools/source/productregistration/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/svtools/source/productregistration/makefile.mk b/svtools/source/productregistration/makefile.mk index 0b970b651059..a26e8feca753 100644 --- a/svtools/source/productregistration/makefile.mk +++ b/svtools/source/productregistration/makefile.mk @@ -59,7 +59,7 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(SALLIB) -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) diff --git a/svtools/workben/unodialog/makefile.mk b/svtools/workben/unodialog/makefile.mk index e9adb63d9b09..f18feffce5c3 100644 --- a/svtools/workben/unodialog/makefile.mk +++ b/svtools/workben/unodialog/makefile.mk @@ -56,7 +56,7 @@ SLOFILES= $(SLO)$/unodialogsample.obj \ # --- library ----------------------------------- SHL1TARGET=$(TARGET)$(DLLPOSTFIX) -SHL1VERSIONMAP=$(TARGET).map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1STDLIBS= \ $(CPPULIB) \ diff --git a/svtools/workben/unodialog/udlg.map b/svtools/workben/unodialog/udlg.map deleted file mode 100644 index 276f9673d067..000000000000 --- a/svtools/workben/unodialog/udlg.map +++ /dev/null @@ -1,8 +0,0 @@ -UDLG_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index b6d4fee27e00..d9adc182f4d7 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -195,6 +195,7 @@ namespace rtl { #define BASEPROPERTY_GRID_SELECTIONMODE 144 #define BASEPROPERTY_ENABLEVISIBLE 145 // sal_Bool #define BASEPROPERTY_REFERENCE_DEVICE 146 +#define BASEPROPERTY_HIGHCONTRASTMODE 147 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/prj/build.lst b/toolkit/prj/build.lst index 304d0e7c978f..126eea24c66c 100644 --- a/toolkit/prj/build.lst +++ b/toolkit/prj/build.lst @@ -11,3 +11,4 @@ ti toolkit\source\controls\grid nmake - all ti_grid NULL ti toolkit\source\layout\core nmake - all ti_layout_core NULL ti toolkit\source\layout\vcl nmake - all ti_layout_vcl NULL ti toolkit\util nmake - all ti_util ti_awt ti_controls ti_layout_core ti_helper ti_tree ti_grid ti_layout_vcl NULL +ti toolkit\qa\unoapi nmake - all ti_qa_unoapi NULL diff --git a/toolkit/qa/unoapi/Test.java b/toolkit/qa/unoapi/Test.java new file mode 100644 index 000000000000..f27d882314d2 --- /dev/null +++ b/toolkit/qa/unoapi/Test.java @@ -0,0 +1,51 @@ +/************************************************************************* +* 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. +************************************************************************/ + +package org.openoffice.toolkit.qa.unoapi; + +import org.openoffice.Runner; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +public final class Test { + @org.junit.Before public void setUp() throws Exception { + connection.setUp(); + } + + @org.junit.After public void tearDown() + throws InterruptedException, com.sun.star.uno.Exception + { + connection.tearDown(); + } + + @org.junit.Test public void test() { + assertTrue( + Runner.run( + "-sce", "toolkit.sce", "-xcl", "knownissues.xcl", "-tdoc", + "testdocuments", "-cs", connection.getDescription())); + } + + private final OfficeConnection connection = new OfficeConnection(); +} diff --git a/toolkit/qa/unoapi/knownissues.xcl b/toolkit/qa/unoapi/knownissues.xcl index ef954f00eeeb..6f57f37536a2 100644 --- a/toolkit/qa/unoapi/knownissues.xcl +++ b/toolkit/qa/unoapi/knownissues.xcl @@ -90,11 +90,6 @@ toolkit.AccessibleRadioButton toolkit.AccessibleToolBox # -> disabled in toolkit.sce -### i80788 ### -toolkit.Toolkit -toolkit.UnoControlDialog -# -> disabled in toolkit.sce - ### i86011 ### toolkit.UnoControlFileControl # -> disabled in toolkit.sce @@ -239,4 +234,9 @@ toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleComponent toolkit.UnoScrollBarControl::com::sun::star::awt::XScrollBar ### i94344 ### -toolkit.AccessibleTabPage::com::sun::star::accessibility::XAccessibleText
\ No newline at end of file +toolkit.AccessibleTabPage::com::sun::star::accessibility::XAccessibleText + +### i109643 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleValue +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleEventBroadcaster +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleSelection diff --git a/toolkit/qa/unoapi/makefile.mk b/toolkit/qa/unoapi/makefile.mk index a24f81d7c6ef..9517601c3917 100644 --- a/toolkit/qa/unoapi/makefile.mk +++ b/toolkit/qa/unoapi/makefile.mk @@ -1,7 +1,6 @@ #************************************************************************* -# # 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 @@ -22,22 +21,28 @@ # version 3 along with OpenOffice.org. If not, see # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. -# -#************************************************************************* +#***********************************************************************/ -PRJ=..$/.. +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -PRJNAME=toolkit -TARGET=qa_unoapi +PRJ = ../.. +PRJNAME = toolkit +TARGET = qa_unoapi -.INCLUDE: settings.mk +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/toolkit/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END +.INCLUDE: settings.mk .INCLUDE: target.mk +.INCLUDE: installationtest.mk -ALLTAR : UNOAPI_TEST +ALLTAR : javatest -UNOAPI_TEST: - +$(SOLARENV)$/bin$/checkapi -sce toolkit.sce -xcl knownissues.xcl -tdoc $(PWD)$/testdocuments - @echo ======================================================================= - @echo In case you noticed a failures of toolkit.AccessibleToolBoxItem make sure that the object bar is configured as text and not as icons - @echo ======================================================================= +.END diff --git a/toolkit/qa/unoapi/toolkit.sce b/toolkit/qa/unoapi/toolkit.sce index dad24165e2d2..1c8ad0c95181 100644 --- a/toolkit/qa/unoapi/toolkit.sce +++ b/toolkit/qa/unoapi/toolkit.sce @@ -17,8 +17,8 @@ -o toolkit.AccessibleScrollBar -o toolkit.AccessibleStatusBar -o toolkit.AccessibleStatusBarItem --o toolkit.AccessibleTabControl --o toolkit.AccessibleTabPage +#i109643 -o toolkit.AccessibleTabControl +#i109643 -o toolkit.AccessibleTabPage #i86287 -o toolkit.AccessibleToolBox #i88605 -o toolkit.AccessibleToolBoxItem -o toolkit.AccessibleWindow @@ -26,7 +26,7 @@ -o toolkit.MutableTreeNode -o toolkit.TabController -o toolkit.TabControllerModel -#i80788 -o toolkit.Toolkit +-o toolkit.Toolkit -o toolkit.UnoControlButton -o toolkit.UnoControlButtonModel -o toolkit.UnoControlCheckBox @@ -39,7 +39,7 @@ -o toolkit.UnoControlCurrencyFieldModel -o toolkit.UnoControlDateField -o toolkit.UnoControlDateFieldModel -#i80788 -o toolkit.UnoControlDialog +#allegedly was i80788, but still broken: -o toolkit.UnoControlDialog -o toolkit.UnoControlDialogModel -o toolkit.UnoControlEdit -o toolkit.UnoControlEditModel diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index 7a3b9ff5b2ec..175289d1ac84 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -490,10 +490,18 @@ void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHel getAccessibleRole() == accessibility::AccessibleRole::DIALOG ) ) // #i18891# rStateSet.AddState( accessibility::AccessibleStateType::ACTIVE ); + // #104290# MT: This way, a ComboBox doesn't get state FOCUSED. + // I also don't understand + // a) why WINDOW_FIRSTCHILD is used here (which btw is a border window in the case of a combo box) + // b) why HasFocus() is nout "enough" for a compound control + /* Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); if ( ( !pWindow->IsCompoundControl() && pWindow->HasFocus() ) || ( pWindow->IsCompoundControl() && pChild && pChild->HasFocus() ) ) rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED ); + */ + if ( pWindow->HasFocus() || ( pWindow->IsCompoundControl() && pWindow->HasChildPathFocus() ) ) + rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED ); if ( pWindow->IsWait() ) rStateSet.AddState( accessibility::AccessibleStateType::BUSY ); diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 045a46729961..248571819067 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -2163,6 +2163,10 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: aProp <<= (sal_Bool) mpImpl->isEnableVisible(); break; + case BASEPROPERTY_HIGHCONTRASTMODE: + aProp <<= (sal_Bool) GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode(); + break; + case BASEPROPERTY_TEXT: case BASEPROPERTY_LABEL: case BASEPROPERTY_TITLE: diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index dd22ea331830..7ede81d485d7 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -185,6 +185,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "HelpText", HELPTEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HelpURL", HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HideInactiveSelection", HIDEINACTIVESELECTION, bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "HighContrastMode", HIGHCONTRASTMODE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HScroll", HSCROLL, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HardLineBreaks", HARDLINEBREAKS, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ImageAlign", IMAGEALIGN, sal_Int16, BOUND, MAYBEDEFAULT), diff --git a/tools/bootstrp/command.cxx b/tools/bootstrp/command.cxx index 605965339b0e..2ab0cc8dc4a6 100644 --- a/tools/bootstrp/command.cxx +++ b/tools/bootstrp/command.cxx @@ -355,7 +355,7 @@ CCommand::CCommand( ByteString &rString ) { rString.SearchAndReplace( '\t', ' ' ); aCommand = rString.GetToken( 0, ' ' ); - aCommandLine = Search(); + aCommandLine = Search( "PATH" ); #ifndef UNX aCommandLine += " /c "; #else @@ -365,7 +365,7 @@ CCommand::CCommand( ByteString &rString ) ByteString sCmd( rString.GetToken( 0, ' ' )); ByteString sParam( rString.Copy( sCmd.Len())); - aCommandLine += Search( thePath, sCmd ); + aCommandLine += Search( "PATH", sCmd ); aCommandLine += sParam; ImplInit(); @@ -379,7 +379,7 @@ CCommand::CCommand( const char *pChar ) aString.SearchAndReplace( '\t', ' ' ); aCommand = aString.GetToken( 0, ' ' ); - aCommandLine = Search(); + aCommandLine = Search( "PATH" ); #ifndef UNX aCommandLine += " /c "; #else @@ -390,7 +390,7 @@ CCommand::CCommand( const char *pChar ) ByteString sCmd( rString.GetToken( 0, ' ' )); ByteString sParam( rString.Copy( sCmd.Len())); - aCommandLine += Search( thePath, sCmd ); + aCommandLine += Search( "PATH", sCmd ); aCommandLine += sParam; ImplInit(); diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx index 35968654b5cd..5c18793c9833 100644 --- a/tools/bootstrp/rscdep.cxx +++ b/tools/bootstrp/rscdep.cxx @@ -36,6 +36,7 @@ #include <string.h> #include "bootstrp/prj.hxx" +#include "sal/main.h" #include <tools/string.hxx> #include <tools/list.hxx> @@ -78,12 +79,7 @@ static int optopt = 0; static int opterr = 0; #endif - -int -#ifdef WNT -_cdecl -#endif -main( int argc, char **argv ) +SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) { int c; char aBuf[255]; diff --git a/tools/inc/bootstrp/command.hxx b/tools/inc/bootstrp/command.hxx index e0d8f1e39aeb..638beb6cce1f 100644 --- a/tools/inc/bootstrp/command.hxx +++ b/tools/inc/bootstrp/command.hxx @@ -92,8 +92,6 @@ public: void Print(); }; -static ByteString thePath( "PATH" ); - /** Declares and spawns a child process. The spawned programm could be a native executable or a schell script. */ @@ -127,7 +125,7 @@ public: @param sItem specifies the system shell @return the Location (when programm was found) */ - static ByteString Search( ByteString sEnv = thePath, + static ByteString Search( ByteString sEnv, ByteString sItem = COMMAND_SHELL ); /** Spawns the Process diff --git a/tools/inc/tools/debug.hxx b/tools/inc/tools/debug.hxx index e764ed2fc79a..b8aa1c8b59fe 100644 --- a/tools/inc/tools/debug.hxx +++ b/tools/inc/tools/debug.hxx @@ -125,19 +125,18 @@ struct DbgDataType #define DBG_FUNC_SAVEDATA 5 #define DBG_FUNC_SETPRINTMSGBOX 6 #define DBG_FUNC_SETPRINTWINDOW 7 -#define DBG_FUNC_SETPRINTSHELL 8 -#define DBG_FUNC_SETPRINTTESTTOOL 9 -#define DBG_FUNC_MEMTEST 10 -#define DBG_FUNC_XTORINFO 11 -#define DBG_FUNC_MEMINFO 12 -#define DBG_FUNC_COREDUMP 13 -#define DBG_FUNC_ALLERROROUT 14 -#define DBG_FUNC_SETTESTSOLARMUTEX 15 -#define DBG_FUNC_TESTSOLARMUTEX 16 -#define DBG_FUNC_PRINTFILE 17 -#define DBG_FUNC_GETPRINTMSGBOX 18 -#define DBG_FUNC_FILTERMESSAGE 19 // new for #i38967 -#define DBG_FUNC_UPDATEOSLHOOK 20 +#define DBG_FUNC_SETPRINTTESTTOOL 8 +#define DBG_FUNC_MEMTEST 9 +#define DBG_FUNC_XTORINFO 10 +#define DBG_FUNC_MEMINFO 11 +#define DBG_FUNC_COREDUMP 12 +#define DBG_FUNC_ALLERROROUT 13 +#define DBG_FUNC_SETTESTSOLARMUTEX 14 +#define DBG_FUNC_TESTSOLARMUTEX 15 +#define DBG_FUNC_PRINTFILE 16 +#define DBG_FUNC_GETPRINTMSGBOX 17 +#define DBG_FUNC_FILTERMESSAGE 18 // new for #i38967 +#define DBG_FUNC_UPDATEOSLHOOK 19 TOOLS_DLLPUBLIC void* DbgFunc( USHORT nAction, void* pData = NULL ); @@ -176,11 +175,6 @@ inline void DbgSetPrintWindow( DbgPrintLine pProc ) DbgFunc( DBG_FUNC_SETPRINTWINDOW, (void*)(long)pProc ); } -inline void DbgSetPrintShell( DbgPrintLine pProc ) -{ - DbgFunc( DBG_FUNC_SETPRINTSHELL, (void*)(long)pProc ); -} - inline void DbgSetPrintTestTool( DbgPrintLine pProc ) { DbgFunc( DBG_FUNC_SETPRINTTESTTOOL, (void*)(long)pProc ); @@ -344,6 +338,7 @@ void DbgPrintStackTree( void* p ); TOOLS_DLLPUBLIC void DbgOut( const sal_Char* pMsg, USHORT nOutType = DBG_OUT_TRACE, const sal_Char* pFile = NULL, USHORT nLine = 0 ); +TOOLS_DLLPUBLIC void DbgPrintShell(char const * message); TOOLS_DLLPUBLIC void DbgOutTypef( USHORT nOutType, const sal_Char* pFStr, ... ); TOOLS_DLLPUBLIC void DbgOutf( const sal_Char* pFStr, ... ); TOOLS_DLLPUBLIC void ImpDbgOutfBuf( sal_Char* pBuf, const sal_Char* pFStr, ... ); diff --git a/tools/inc/tools/diagnose_ex.h b/tools/inc/tools/diagnose_ex.h index 73b7bd9f96a5..fac739b32583 100644 --- a/tools/inc/tools/diagnose_ex.h +++ b/tools/inc/tools/diagnose_ex.h @@ -118,11 +118,28 @@ ifc ); } /** This macro asserts the given condition (in debug mode), and - returns false afterwards. + returns the given value afterwards. */ -#define ENSURE_OR_RETURN(c, m) if( !(c) ) { \ +#define ENSURE_OR_RETURN(c, m, r) if( !(c) ) { \ OSL_ENSURE(c, m); \ - return false; } + return r; } + +/** This macro asserts the given condition (in debug mode), and + returns false afterwards. + */ +#define ENSURE_OR_RETURN_FALSE(c, m) \ + ENSURE_OR_RETURN(c, m, false) + + +/** This macro asserts the given condition (in debug mode), and + returns afterwards, without return value "void". + */ +#define ENSURE_OR_RETURN_VOID( c, m ) \ + if( !(c) ) \ + { \ + OSL_ENSURE( c, m ); \ + return; \ + } diff --git a/canvas/source/java/SpriteBase.java b/tools/inc/tools/postextstl.h index 5f2ed3c57ecc..81a21e25c15b 100644 --- a/canvas/source/java/SpriteBase.java +++ b/tools/inc/tools/postextstl.h @@ -25,10 +25,12 @@ * ************************************************************************/ -// Canvas - -public interface SpriteBase -{ - // to be overridden - public SpriteRep getSpriteRep(); -} +#ifdef std_was_redefined_as_stlport +// put things back the way they were +# define std std_was_redefined_as_stlport +# undef _STLP_OUTERMOST_HEADER_ID +// force config to be re-read +# undef _STLP_NOTHROW_INHERENTLY +# undef _STLP_CONFIG_H +# include <stddef.h> +#endif diff --git a/tools/inc/tools/preextstl.h b/tools/inc/tools/preextstl.h new file mode 100644 index 000000000000..4d0418d01c57 --- /dev/null +++ b/tools/inc/tools/preextstl.h @@ -0,0 +1,64 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#if defined(ADAPT_EXT_STL) +# include <ostream> +# include <istream> +# include <fstream> +# include <iostream> +# include <vector> +# include <list> +# include <map> +# include <algorithm> +# if defined(std) +# define std_was_redefined_as_stlport std +# undef std +# define _STLP_OUTERMOST_HEADER_ID 0xdeadbeaf +# pragma GCC visibility push(default) +# include _STLP_NATIVE_HEADER(exception_defines.h) +# include _STLP_NATIVE_HEADER(limits) +# include _STLP_NATIVE_HEADER(memory) +# include _STLP_NATIVE_HEADER(exception) +# include _STLP_NATIVE_HEADER(iosfwd) +# include _STLP_NATIVE_HEADER(algorithm) +# include _STLP_NATIVE_HEADER(string) +# include _STLP_NATIVE_HEADER(streambuf) +# include _STLP_NATIVE_HEADER(ios) +# include _STLP_NATIVE_HEADER(locale) +# include _STLP_NATIVE_HEADER(stdexcept) +# include _STLP_NATIVE_HEADER(ostream) +# include _STLP_NATIVE_HEADER(istream) +# include _STLP_NATIVE_HEADER(iostream) +# include _STLP_NATIVE_HEADER(vector) +# include _STLP_NATIVE_HEADER(list) +# include _STLP_NATIVE_HEADER(map) +# pragma GCC visibility pop +# endif +#endif +//ext_std resolves to the std that external c++ libs, e.g. Graphite were built +//against regardless of whether that is stlport or system stl +namespace ext_std = std; diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx index c909ca3e37b0..8f13af8fd842 100644 --- a/tools/inc/tools/wintypes.hxx +++ b/tools/inc/tools/wintypes.hxx @@ -178,10 +178,11 @@ typedef sal_Int64 WinBits; #define WB_NOLABEL ((WinBits)0x02000000) #define WB_SORT ((WinBits)0x04000000) #define WB_DROPDOWN ((WinBits)0x08000000) +#define WB_HIDE ((WinBits)SAL_CONST_INT64(0x80000000)) #define WB_AUTOHSCROLL ((WinBits)SAL_CONST_INT64(0x10000000)) #define WB_DOCKABLE ((WinBits)SAL_CONST_INT64(0x20000000)) #define WB_AUTOVSCROLL ((WinBits)SAL_CONST_INT64(0x40000000)) -#define WB_HYPHENATION (((WinBits)SAL_CONST_INT64(0x80000000)) | WB_WORDBREAK) +#define WB_HYPHENATION (((WinBits)SAL_CONST_INT64(0x800000000)) | WB_WORDBREAK) #define WB_CHILDDLGCTRL ((WinBits)SAL_CONST_INT64(0x100000000000)) // system floating window @@ -193,7 +194,6 @@ typedef sal_Int64 WinBits; #define WB_DEFAULTWIN ((WinBits)SAL_CONST_INT64(0x4000000000)) #define WB_NEEDSFOCUS ((WinBits)SAL_CONST_INT64(0x1000000000)) -#define WB_HIDE ((WinBits)SAL_CONST_INT64(0x80000000)) #define WB_HSCROLL WB_HORZ #define WB_VSCROLL WB_VERT #define WB_TOPIMAGE WB_TOP @@ -205,6 +205,7 @@ typedef sal_Int64 WinBits; #define WB_SMALLSTYLE ((WinBits)0x04000000) #define WB_TOGGLE ((WinBits)SAL_CONST_INT64(0x1000000000)) #define WB_BEVELBUTTON ((WinBits)SAL_CONST_INT64(0x2000000000)) +#define WB_FLATBUTTON ((WinBits)SAL_CONST_INT64(0x4000000000)) // Window-Bits for FixedText #define WB_PATHELLIPSIS ((WinBits)0x00100000) diff --git a/tools/prj/d.lst b/tools/prj/d.lst index 76cb0107453c..6b4a99a3a676 100644 --- a/tools/prj/d.lst +++ b/tools/prj/d.lst @@ -34,6 +34,9 @@ mkdir: %_DEST%\inc%_EXT%\bootstrp ..\inc\tools\postx.h %_DEST%\inc%_EXT%\tools\postx.h ..\inc\tools\prex.h %_DEST%\inc%_EXT%\tools\prex.h +..\inc\tools\postextstl.h %_DEST%\inc%_EXT%\tools\postextstl.h +..\inc\tools\preextstl.h %_DEST%\inc%_EXT%\tools\preextstl.h + ..\inc\tools\solarmutex.hxx %_DEST%\inc%_EXT%\tools\solarmutex.hxx ..\inc\tools\wintypes.hxx %_DEST%\inc%_EXT%\tools\wintypes.hxx ..\inc\tools\mapunit.hxx %_DEST%\inc%_EXT%\tools\mapunit.hxx diff --git a/tools/qa/makefile.mk b/tools/qa/makefile.mk index 66ed19e20737..abaea848c1db 100644 --- a/tools/qa/makefile.mk +++ b/tools/qa/makefile.mk @@ -32,6 +32,7 @@ ENABLE_EXCEPTIONS = TRUE .INCLUDE: settings.mk +CFLAGSCXX += $(CPPUNIT_CFLAGS) DLLPRE = # no leading "lib" on .so files SHL1TARGET = test_pathutils diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx index 62f36e662ea9..e17457c60525 100644 --- a/tools/source/debug/debug.cxx +++ b/tools/source/debug/debug.cxx @@ -151,7 +151,6 @@ struct DebugData USHORT bInit; DbgPrintLine pDbgPrintMsgBox; DbgPrintLine pDbgPrintWindow; - DbgPrintLine pDbgPrintShell; DbgPrintLine pDbgPrintTestTool; ::std::vector< DbgPrintLine > aDbgPrintUserChannels; @@ -166,7 +165,6 @@ struct DebugData :bInit( FALSE ) ,pDbgPrintMsgBox( FALSE ) ,pDbgPrintWindow( NULL ) - ,pDbgPrintShell( NULL ) ,pDbgPrintTestTool( NULL ) ,pProfList( NULL ) ,pXtorList( NULL ) @@ -1037,9 +1035,7 @@ static void DebugDeInit() pData->aDbgData.nTestFlags &= (DBG_TEST_MEM | DBG_TEST_PROFILING); pData->aDbgPrintUserChannels.clear(); pData->pDbgPrintTestTool = NULL; - pData->pDbgPrintShell = NULL; pData->pDbgPrintWindow = NULL; - pData->pDbgPrintShell = NULL; pData->pOldDebugMessageFunc = NULL; ImplDbgDeInitLock(); } @@ -1199,10 +1195,6 @@ void* DbgFunc( USHORT nAction, void* pParam ) pDebugData->pDbgPrintWindow = (DbgPrintLine)(long)pParam; break; - case DBG_FUNC_SETPRINTSHELL: - pDebugData->pDbgPrintShell = (DbgPrintLine)(long)pParam; - break; - case DBG_FUNC_SETPRINTTESTTOOL: pDebugData->pDbgPrintTestTool = (DbgPrintLine)(long)pParam; break; @@ -1739,14 +1731,6 @@ void DbgOut( const sal_Char* pMsg, USHORT nDbgOut, const sal_Char* pFile, USHORT if ( pData->pDbgPrintMsgBox ) pData->pDbgPrintMsgBox( aBufOut ); else - nOut = DBG_OUT_SHELL; - } - - if ( nOut == DBG_OUT_SHELL ) - { - if ( pData->pDbgPrintShell ) - pData->pDbgPrintShell( aBufOut ); - else nOut = DBG_OUT_WINDOW; } @@ -1758,14 +1742,28 @@ void DbgOut( const sal_Char* pMsg, USHORT nDbgOut, const sal_Char* pFile, USHORT nOut = DBG_OUT_FILE; } - if ( nOut == DBG_OUT_FILE ) + switch ( nOut ) + { + case DBG_OUT_SHELL: + DbgPrintShell( aBufOut ); + break; + case DBG_OUT_FILE: ImplDbgPrintFile( aBufOut ); + break; + } ImplDbgUnlock(); bIn = FALSE; } +void DbgPrintShell(char const * message) { + fprintf(stderr, "%s\n", message); +#if defined WNT + OutputDebugStringA(message); +#endif +} + // ----------------------------------------------------------------------- void DbgOutTypef( USHORT nDbgOut, const sal_Char* pFStr, ... ) diff --git a/tools/source/fsys/tdir.cxx b/tools/source/fsys/tdir.cxx index 429835d35ab3..b6bf48a8cdf9 100644 --- a/tools/source/fsys/tdir.cxx +++ b/tools/source/fsys/tdir.cxx @@ -266,7 +266,7 @@ void Dir::Construct( DirEntryKind nKindFlags ) strcpy( pBuffer, aTStr.GetBuffer() ); CharLowerBuff( pBuffer, aTStr.Len() ); aNameMask = WildCard( String(pBuffer, osl_getThreadTextEncoding()), ';' ); - delete pBuffer; + delete [] pBuffer; } #else aNameMask = WildCard( CutName(), ';' ); diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 8a3504a417c0..9e4f501d1823 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -91,7 +91,7 @@ InternalStreamLock::InternalStreamLock( #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "locked %s", aFileName.GetBuffer() ); if( m_nStartPos || m_nEndPos ) - fprintf(stderr, " [ %d ... %d ]", m_nStartPos, m_nEndPos ); + fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); fprintf( stderr, "\n" ); #endif } @@ -103,7 +103,7 @@ InternalStreamLock::~InternalStreamLock() ByteString aFileName(m_pStream->GetFileName(), osl_getThreadTextEncoding()); fprintf( stderr, "unlocked %s", aFileName.GetBuffer() ); if( m_nStartPos || m_nEndPos ) - fprintf(stderr, " [ %d ... %d ]", m_nStartPos, m_nEndPos ); + fprintf(stderr, " [ %ld ... %ld ]", m_nStartPos, m_nEndPos ); fprintf( stderr, "\n" ); #endif } @@ -514,7 +514,7 @@ sal_Bool SvFileStream::LockRange( sal_Size nByteOffset, sal_Size nBytes ) if( ! InternalStreamLock::LockFile( nByteOffset, nByteOffset+nBytes, this ) ) { #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "InternalLock on %s [ %d ... %d ] failed\n", + fprintf( stderr, "InternalLock on %s [ %ld ... %ld ] failed\n", ByteString(aFilename, osl_getThreadTextEncoding()).GetBuffer(), nByteOffset, nByteOffset+nBytes ); #endif return sal_False; diff --git a/tools/test/export.map b/tools/test/export.map index 709047ae63e5..7321bbca16ad 100644 --- a/tools/test/export.map +++ b/tools/test/export.map @@ -25,7 +25,7 @@ # #************************************************************************* -UDK_3.1 { +UDK_3_0_0 { global: registerAllTestFunction; diff --git a/tools/test/makefile.mk b/tools/test/makefile.mk index 5dea8ce6f960..ab2cfd8e6676 100644 --- a/tools/test/makefile.mk +++ b/tools/test/makefile.mk @@ -36,6 +36,8 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +CFLAGSCXX += $(CPPUNIT_CFLAGS) + # --- Common ---------------------------------------------------------- SHL1OBJS= \ diff --git a/ucbhelper/workben/myucp/exports.map b/ucbhelper/workben/myucp/exports.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/ucbhelper/workben/myucp/exports.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/ucbhelper/workben/myucp/makefile.mk b/ucbhelper/workben/myucp/makefile.mk index 0d7f273fe877..77faad2e0396 100644 --- a/ucbhelper/workben/myucp/makefile.mk +++ b/ucbhelper/workben/myucp/makefile.mk @@ -68,7 +68,7 @@ LIB1OBJFILES=$(SLOFILES) SHL1TARGET=$(TARGET) SHL1IMPLIB=i$(TARGET) -SHL1VERSIONMAP=exports.map +SHL1VERSIONMAP=$(SOLARENV)/src/component.map # @@@ Add additional libs here. SHL1STDLIBS=\ diff --git a/unotools/inc/unotools/saveopt.hxx b/unotools/inc/unotools/saveopt.hxx index dad0cd742323..22cf75c5be3d 100644 --- a/unotools/inc/unotools/saveopt.hxx +++ b/unotools/inc/unotools/saveopt.hxx @@ -46,7 +46,6 @@ public: E_AUTOSAVEPROMPT, E_DOCINFSAVE, E_SAVEWORKINGSET, - E_SAVEDOCWINS, E_SAVEDOCVIEW, E_SAVERELINET, E_SAVERELFSYS, @@ -93,9 +92,6 @@ public: void SetSaveWorkingSet( sal_Bool b ); sal_Bool IsSaveWorkingSet() const; - void SetSaveDocWins( sal_Bool b ); - sal_Bool IsSaveDocWins() const; - void SetSaveDocView( sal_Bool b ); sal_Bool IsSaveDocView() const; diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index 2b739316a3f9..cbb7e763b38a 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -73,7 +73,6 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bAutoSavePrompt, bDocInfSave, bSaveWorkingSet, - bSaveDocWins, bSaveDocView, bSaveRelINet, bSaveRelFSys, @@ -89,7 +88,6 @@ class SvtSaveOptions_Impl : public utl::ConfigItem bROAutoSavePrompt, bRODocInfSave, bROSaveWorkingSet, - bROSaveDocWins, bROSaveDocView, bROSaveRelINet, bROSaveRelFSys, @@ -115,7 +113,6 @@ public: BOOL IsAutoSavePrompt() const { return bAutoSavePrompt; } BOOL IsDocInfoSave() const { return bDocInfSave; } BOOL IsSaveWorkingSet() const { return bSaveWorkingSet; } - BOOL IsSaveDocWins() const { return bSaveDocWins; } BOOL IsSaveDocView() const { return bSaveDocView; } BOOL IsSaveRelINet() const { return bSaveRelINet; } BOOL IsSaveRelFSys() const { return bSaveRelFSys; } @@ -133,7 +130,6 @@ public: void SetAutoSavePrompt( BOOL b ); void SetDocInfoSave( BOOL b ); void SetSaveWorkingSet( BOOL b ); - void SetSaveDocWins( BOOL b ); void SetSaveDocView( BOOL b ); void SetSaveRelINet( BOOL b ); void SetSaveRelFSys( BOOL b ); @@ -211,15 +207,6 @@ void SvtSaveOptions_Impl::SetSaveWorkingSet( BOOL b ) } } -void SvtSaveOptions_Impl::SetSaveDocWins( BOOL b ) -{ - if (!bROSaveDocWins && bSaveDocWins!=b) - { - bSaveDocWins = b; - SetModified(); - } -} - void SvtSaveOptions_Impl::SetSaveDocView( BOOL b ) { if (!bROSaveDocView && bSaveDocView!=b) @@ -318,9 +305,6 @@ sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) cons case SvtSaveOptions::E_SAVEWORKINGSET : bReadOnly = bROSaveWorkingSet; break; - case SvtSaveOptions::E_SAVEDOCWINS : - bReadOnly = bROSaveDocWins; - break; case SvtSaveOptions::E_SAVEDOCVIEW : bReadOnly = bROSaveDocView; break; @@ -356,16 +340,15 @@ sal_Bool SvtSaveOptions_Impl::IsReadOnly( SvtSaveOptions::EOption eOption ) cons #define AUTOSAVE 4 #define PROMPT 5 #define EDITPROPERTY 6 -#define SAVEDOCWINS 7 -#define SAVEVIEWINFO 8 -#define UNPACKED 9 -#define PRETTYPRINTING 10 -#define WARNALIENFORMAT 11 -#define LOADDOCPRINTER 12 -#define FILESYSTEM 13 -#define INTERNET 14 -#define SAVEWORKINGSET 15 -#define ODFDEFAULTVERSION 16 +#define SAVEVIEWINFO 7 +#define UNPACKED 8 +#define PRETTYPRINTING 9 +#define WARNALIENFORMAT 10 +#define LOADDOCPRINTER 11 +#define FILESYSTEM 12 +#define INTERNET 13 +#define SAVEWORKINGSET 14 +#define ODFDEFAULTVERSION 15 Sequence< OUString > GetPropertyNames() { @@ -378,7 +361,6 @@ Sequence< OUString > GetPropertyNames() "Document/AutoSave", "Document/AutoSavePrompt", "Document/EditProperty", - "Document/DocumentWindows", "Document/ViewInfo", "Document/Unpacked", "Document/PrettyPrinting", @@ -410,7 +392,6 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() , bAutoSavePrompt( sal_False ) , bDocInfSave( sal_False ) , bSaveWorkingSet( sal_False ) - , bSaveDocWins( sal_False ) , bSaveDocView( sal_False ) , bSaveRelINet( sal_False ) , bSaveRelFSys( sal_False ) @@ -425,7 +406,6 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() , bROAutoSavePrompt( CFG_READONLY_DEFAULT ) , bRODocInfSave( CFG_READONLY_DEFAULT ) , bROSaveWorkingSet( CFG_READONLY_DEFAULT ) - , bROSaveDocWins( CFG_READONLY_DEFAULT ) , bROSaveDocView( CFG_READONLY_DEFAULT ) , bROSaveRelINet( CFG_READONLY_DEFAULT ) , bROSaveRelFSys( CFG_READONLY_DEFAULT ) @@ -515,10 +495,6 @@ SvtSaveOptions_Impl::SvtSaveOptions_Impl() bSaveWorkingSet = bTemp; bROSaveWorkingSet = pROStates[nProp]; break; - case SAVEDOCWINS : - bSaveDocWins = bTemp; - bROSaveDocWins = pROStates[nProp]; - break; case SAVEVIEWINFO : bSaveDocView = bTemp; bROSaveDocView = pROStates[nProp]; @@ -664,14 +640,6 @@ void SvtSaveOptions_Impl::Commit() ++nRealCount; } break; - case SAVEDOCWINS : - if (!bROSaveDocWins) - { - pValues[nRealCount] <<= bSaveDocWins; - pNames[nRealCount] = pOrgNames[i]; - ++nRealCount; - } - break; case SAVEVIEWINFO : if (!bROSaveDocView) { @@ -937,16 +905,6 @@ sal_Bool SvtSaveOptions::IsSaveWorkingSet() const return pImp->pSaveOpt->IsSaveWorkingSet(); } -void SvtSaveOptions::SetSaveDocWins( sal_Bool b ) -{ - pImp->pSaveOpt->SetSaveDocWins( b ); -} - -sal_Bool SvtSaveOptions::IsSaveDocWins() const -{ - return pImp->pSaveOpt->IsSaveDocWins(); -} - void SvtSaveOptions::SetSaveDocView( sal_Bool b ) { pImp->pSaveOpt->SetSaveDocView( b ); diff --git a/unotools/source/misc/desktopterminationobserver.cxx b/unotools/source/misc/desktopterminationobserver.cxx index 23d5089f545e..3900449f03c9 100644 --- a/unotools/source/misc/desktopterminationobserver.cxx +++ b/unotools/source/misc/desktopterminationobserver.cxx @@ -211,12 +211,6 @@ namespace utl void DesktopTerminationObserver::revokeTerminationListener( ITerminationListener* _pListener ) { ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( getListenerAdminData().bAlreadyTerminated ) - { - _pListener->notifyTermination(); - return; - } - Listeners& rListeners = getListenerAdminData().aListeners; for ( Listeners::iterator lookup = rListeners.begin(); lookup != rListeners.end(); diff --git a/vcl/aqua/inc/salbmp.h b/vcl/aqua/inc/salbmp.h index a4ea1bcaee49..1c427cce0cd5 100644 --- a/vcl/aqua/inc/salbmp.h +++ b/vcl/aqua/inc/salbmp.h @@ -36,7 +36,6 @@ #include "salconst.h" #include "vcl/salvd.hxx" #include "salcolorutils.hxx" -#include "salpixmaputils.hxx" #include "vcl/salbmp.hxx" #include "salgdi.h" #include "basebmp/bitmapdevice.hxx" diff --git a/vcl/aqua/source/dtrans/DataFlavorMapping.cxx b/vcl/aqua/source/dtrans/DataFlavorMapping.cxx index 9c88a88e7b6b..e0a95a532bf8 100644 --- a/vcl/aqua/source/dtrans/DataFlavorMapping.cxx +++ b/vcl/aqua/source/dtrans/DataFlavorMapping.cxx @@ -42,7 +42,7 @@ #include <stdio.h> #include <premac.h> -#include <QuickTime/QuickTime.h> +#include <Cocoa/Cocoa.h> #include <postmac.h> using namespace ::com::sun::star::datatransfer; @@ -129,6 +129,7 @@ namespace // private { { NSStringPboardType, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", CPPUTYPE_OUSTRING }, { NSRTFPboardType, "text/richtext", "Rich Text Format", CPPUTYPE_SEQINT8 }, + { NSTIFFPboardType, "image/bmp", "Windows Bitmap", CPPUTYPE_SEQINT8 }, { NSPICTPboardType, "image/bmp", "Windows Bitmap", CPPUTYPE_SEQINT8 }, { NSHTMLPboardType, "text/html", "Plain Html", CPPUTYPE_SEQINT8 }, { NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", CPPUTYPE_SEQINT8 }, @@ -143,9 +144,6 @@ namespace // private { PBTYPE_EMF, FLAVOR_EMF, "Windows Enhanced MetaFile", CPPUTYPE_SEQINT8 }, { PBTYPE_SODX, FLAVOR_SODX, "Star Object Descriptor (XML)", CPPUTYPE_SEQINT8 }, { PBTYPE_DUMMY_INTERNAL, FLAVOR_DUMMY_INTERNAL, "internal data",CPPUTYPE_SEQINT8 } - // { PBTYPE_UT16, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", CPPUTYPE_OUSTRING } - // { kUTTypePICT, @"PICT", "image/x-macpict;windows_formatname=\"Mac Pict\"", "Mac Pict", CPPUTYPE_SEQINT8 } - // { kUTTypeHTML, @"HTML", "text/html", "Plain Html", CPPUTYPE_SEQINT8 } }; @@ -379,23 +377,26 @@ Any HTMLFormatDataProvider::getOOoData() class BMPDataProvider : public DataProviderBaseImpl { + NSBitmapImageFileType meImageType; public: - BMPDataProvider(const Any& data); + BMPDataProvider(const Any& data, NSBitmapImageFileType eImageType ); - BMPDataProvider(NSData* data); + BMPDataProvider(NSData* data, NSBitmapImageFileType eImageType); virtual NSData* getSystemData(); virtual Any getOOoData(); }; -BMPDataProvider::BMPDataProvider(const Any& data) : - DataProviderBaseImpl(data) +BMPDataProvider::BMPDataProvider(const Any& data, NSBitmapImageFileType eImageType) : + DataProviderBaseImpl(data), + meImageType( eImageType ) { } -BMPDataProvider::BMPDataProvider(NSData* data) : - DataProviderBaseImpl(data) +BMPDataProvider::BMPDataProvider(NSData* data, NSBitmapImageFileType eImageType) : + DataProviderBaseImpl(data), + meImageType( eImageType ) { } @@ -407,7 +408,7 @@ NSData* BMPDataProvider::getSystemData() Sequence<sal_Int8> pictData; NSData* sysData = NULL; - if (BMPtoPICT(bmpData, pictData)) + if (BMPToImage(bmpData, pictData, meImageType)) { sysData = [NSData dataWithBytes: pictData.getArray() length: pictData.getLength()]; } @@ -433,7 +434,7 @@ Any BMPDataProvider::getOOoData() Sequence<sal_Int8> bmpData; - if (PICTtoBMP(pictData, bmpData)) + if (ImageToBMP(pictData, bmpData, meImageType)) { oOOData = makeAny(bmpData); } @@ -555,6 +556,13 @@ NSString* DataFlavorMapper::openOfficeToSystemFlavor(const DataFlavor& oOOFlavor return sysFlavor; } +NSString* DataFlavorMapper::openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard) const +{ + NSArray *supportedTypes = [NSArray arrayWithObjects: NSTIFFPboardType, NSPICTPboardType, nil]; + NSString *sysFlavor = [pPasteboard availableTypeFromArray:supportedTypes]; + return sysFlavor; +} + DataProviderPtr_t DataFlavorMapper::getDataProvider(NSString* systemFlavor, Reference<XTransferable> rTransferable) const { DataProviderPtr_t dp; @@ -573,7 +581,11 @@ DataProviderPtr_t DataFlavorMapper::getDataProvider(NSString* systemFlavor, Refe } else if ([systemFlavor caseInsensitiveCompare: NSPICTPboardType] == NSOrderedSame) { - dp = DataProviderPtr_t(new BMPDataProvider(data)); + dp = DataProviderPtr_t(new BMPDataProvider(data, PICTImageFileType)); + } + else if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame) + { + dp = DataProviderPtr_t(new BMPDataProvider(data, NSTIFFFileType)); } else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame) { @@ -618,7 +630,11 @@ DataProviderPtr_t DataFlavorMapper::getDataProvider(const NSString* systemFlavor } else if ([systemFlavor caseInsensitiveCompare: NSPICTPboardType] == NSOrderedSame) { - dp = DataProviderPtr_t(new BMPDataProvider(systemData)); + dp = DataProviderPtr_t(new BMPDataProvider(systemData, PICTImageFileType)); + } + else if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame) + { + dp = DataProviderPtr_t(new BMPDataProvider(systemData, NSTIFFFileType)); } else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame) { @@ -655,11 +671,19 @@ NSArray* DataFlavorMapper::flavorSequenceToTypesArray(const com::sun::star::uno: for (sal_uInt32 i = 0; i < nFlavors; i++) { - NSString* str = openOfficeToSystemFlavor(flavors[i]); - - if (str != NULL) + if( flavors[i].MimeType.compareToAscii( "image/bmp", 9 ) == 0 ) { - [array addObject: str]; + [array addObject: NSTIFFPboardType]; + [array addObject: NSPICTPboardType]; + } + else + { + NSString* str = openOfficeToSystemFlavor(flavors[i]); + + if (str != NULL) + { + [array addObject: str]; + } } } diff --git a/vcl/aqua/source/dtrans/DataFlavorMapping.hxx b/vcl/aqua/source/dtrans/DataFlavorMapping.hxx index a1ebac6ab4a9..9847fcbd3987 100644 --- a/vcl/aqua/source/dtrans/DataFlavorMapping.hxx +++ b/vcl/aqua/source/dtrans/DataFlavorMapping.hxx @@ -89,6 +89,11 @@ public: */ NSString* openOfficeToSystemFlavor(const com::sun::star::datatransfer::DataFlavor& oooDataFlavor) const; + /* Select the best available image data type + If there is no suiteable mapping available NULL will + be returned. + */ + NSString* openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard) const; /* Get a data provider which is able to provide the data 'rTransferable' offers in a format that can be put on to the system clipboard. diff --git a/vcl/aqua/source/dtrans/OSXTransferable.cxx b/vcl/aqua/source/dtrans/OSXTransferable.cxx index 7b596768d061..2e6b327de446 100644 --- a/vcl/aqua/source/dtrans/OSXTransferable.cxx +++ b/vcl/aqua/source/dtrans/OSXTransferable.cxx @@ -88,7 +88,10 @@ Any SAL_CALL OSXTransferable::getTransferData( const DataFlavor& aFlavor ) static_cast<XTransferable*>(this)); } - NSString* sysFormat = (NSString*)mDataFlavorMapper->openOfficeToSystemFlavor(aFlavor); + NSString* sysFormat = + (aFlavor.MimeType.compareToAscii( "image/bmp", 9 ) == 0) + ? mDataFlavorMapper->openOfficeImageToSystemFlavor( mPasteboard ) + : mDataFlavorMapper->openOfficeToSystemFlavor(aFlavor); DataProviderPtr_t dp; if ([sysFormat caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame) diff --git a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx index 0643efae33ca..1410fc2bd66d 100644 --- a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx +++ b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx @@ -1,22 +1,52 @@ -#include "PictToBmpFlt.hxx" +/************************************************************************* + * + * 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: OSXTransferable.hxx,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ /* This is a work-around to prevent 'deprecated' warning for 'KillPicture' API Hopefully we can get rid of this whole code again when the OOo PICT filter are good enough to be used see #i78953 thus this hack would vanish to again. */ +#include <premac.h> #include <AvailabilityMacros.h> #undef DEPRECATED_ATTRIBUTE #define DEPRECATED_ATTRIBUTE -#include <premac.h> #include <Carbon/Carbon.h> #include <QuickTime/QuickTime.h> #include <postmac.h> +#include "PictToBmpFlt.hxx" bool PICTtoBMP(com::sun::star::uno::Sequence<sal_Int8>& aPict, com::sun::star::uno::Sequence<sal_Int8>& aBmp) { + bool result = false; ComponentInstance bmpExporter; @@ -112,3 +142,60 @@ bool BMPtoPICT(com::sun::star::uno::Sequence<sal_Int8>& aBmp, return result; } + +bool ImageToBMP( com::sun::star::uno::Sequence<sal_Int8>& aPict, + com::sun::star::uno::Sequence<sal_Int8>& aBmp, + NSBitmapImageFileType eInFormat) +{ + if( eInFormat == PICTImageFileType ) + return PICTtoBMP( aPict, aBmp ); + + bool bResult = false; + + NSData* pData = [NSData dataWithBytesNoCopy: (void*)aPict.getConstArray() length: aPict.getLength() freeWhenDone: 0]; + if( pData ) + { + NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData]; + if( pRep ) + { + NSData* pOut = [pRep representationUsingType: NSBMPFileType properties: nil]; + if( pOut ) + { + aBmp.realloc( [pOut length] ); + [pOut getBytes: aBmp.getArray() length: aBmp.getLength()]; + bResult = (aBmp.getLength() != 0); + } + } + } + + return bResult; +} + +bool BMPToImage( com::sun::star::uno::Sequence<sal_Int8>& aBmp, + com::sun::star::uno::Sequence<sal_Int8>& aPict, + NSBitmapImageFileType eOutFormat + ) +{ + if( eOutFormat == PICTImageFileType ) + return BMPtoPICT( aBmp, aPict ); + + bool bResult = false; + + NSData* pData = [NSData dataWithBytesNoCopy: const_cast<sal_Int8*>(aBmp.getConstArray()) length: aBmp.getLength() freeWhenDone: 0]; + if( pData ) + { + NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData]; + if( pRep ) + { + NSData* pOut = [pRep representationUsingType: eOutFormat properties: nil]; + if( pOut ) + { + aPict.realloc( [pOut length] ); + [pOut getBytes: aPict.getArray() length: aPict.getLength()]; + bResult = (aPict.getLength() != 0); + } + } + } + + return bResult; +} diff --git a/vcl/aqua/source/dtrans/PictToBmpFlt.hxx b/vcl/aqua/source/dtrans/PictToBmpFlt.hxx index 29e9c535546f..12a73452ad7b 100644 --- a/vcl/aqua/source/dtrans/PictToBmpFlt.hxx +++ b/vcl/aqua/source/dtrans/PictToBmpFlt.hxx @@ -3,6 +3,10 @@ #include <com/sun/star/uno/Sequence.hxx> +#include <premac.h> +#include <Cocoa/Cocoa.h> +#include <postmac.h> + /* Transform PICT into the a Window BMP. Returns true if the conversion was successful false @@ -19,4 +23,15 @@ bool PICTtoBMP(com::sun::star::uno::Sequence<sal_Int8>& aPict, bool BMPtoPICT(com::sun::star::uno::Sequence<sal_Int8>& aBmp, com::sun::star::uno::Sequence<sal_Int8>& aPict); +#define PICTImageFileType ((NSBitmapImageFileType)~0) + +bool ImageToBMP( com::sun::star::uno::Sequence<sal_Int8>& aPict, + com::sun::star::uno::Sequence<sal_Int8>& aBmp, + NSBitmapImageFileType eInFormat); + +bool BMPToImage( com::sun::star::uno::Sequence<sal_Int8>& aBmp, + com::sun::star::uno::Sequence<sal_Int8>& aPict, + NSBitmapImageFileType eOutFormat + ); + #endif diff --git a/vcl/aqua/source/dtrans/aqua_clipboard.cxx b/vcl/aqua/source/dtrans/aqua_clipboard.cxx index d3a4e9bc604c..52fb13e1e11f 100644 --- a/vcl/aqua/source/dtrans/aqua_clipboard.cxx +++ b/vcl/aqua/source/dtrans/aqua_clipboard.cxx @@ -189,6 +189,10 @@ void SAL_CALL AquaClipboard::setContents(const Reference<XTransferable>& xTransf const Reference<XClipboardOwner>& xClipboardOwner) throw( RuntimeException ) { + NSArray* types = xTransferable.is() ? + mpDataFlavorMapper->flavorSequenceToTypesArray(xTransferable->getTransferDataFlavors()) : + [NSArray array]; + ClearableMutexGuard aGuard(m_aMutex); Reference<XClipboardOwner> oldOwner(mXClipboardOwner); @@ -197,11 +201,10 @@ void SAL_CALL AquaClipboard::setContents(const Reference<XTransferable>& xTransf Reference<XTransferable> oldContent(mXClipboardContent); mXClipboardContent = xTransferable; - NSArray* types = mXClipboardContent.is() ? - mpDataFlavorMapper->flavorSequenceToTypesArray(mXClipboardContent->getTransferDataFlavors()) : - [NSArray array]; mPasteboardChangeCount = [mPasteboard declareTypes: types owner: mEventListener]; + aGuard.clear(); + // if we are already the owner of the clipboard // then fire lost ownership event if (oldOwner.is()) @@ -253,7 +256,7 @@ void SAL_CALL AquaClipboard::removeClipboardListener(const Reference< XClipboard void AquaClipboard::applicationDidBecomeActive(NSNotification* aNotification) { - MutexGuard aGuard(m_aMutex); + ClearableMutexGuard aGuard(m_aMutex); int currentPboardChgCount = [mPasteboard changeCount]; @@ -270,6 +273,8 @@ void AquaClipboard::applicationDidBecomeActive(NSNotification* aNotification) Reference<XTransferable> oldContent(mXClipboardContent); mXClipboardContent = Reference<XTransferable>(); + aGuard.clear(); + if (oldOwner.is()) { fireLostClipboardOwnershipEvent(oldOwner, oldContent); diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 74c66ab1401d..d00fc9a6cd0e 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -318,6 +318,12 @@ class ControllerProperties double fScaleX = double(aLogicSize.Width())/double(aPageSize.aSize.Width()); double fScaleY = double(aLogicSize.Height())/double(aPageSize.aSize.Height()); double fScale = (fScaleX < fScaleY) ? fScaleX : fScaleY; + // #i104784# if we render the page too small then rounding issues result in + // layout artifacts looking really bad. So scale the page unto a device that is not + // full page size but not too small either. This also results in much better visual + // quality of the preview, e.g. when its height approaches the number of text lines + if( fScale < 0.1 ) + fScale = 0.1; aMtf.WindStart(); aMtf.Scale( fScale, fScale ); aMtf.WindStart(); @@ -358,9 +364,10 @@ class ControllerProperties NSSize aMargins = [mpPreviewBox contentViewMargins]; aPreviewFrame.origin.x = 0; aPreviewFrame.origin.y = 34; + aPreviewFrame.size.width -= 2*(aMargins.width+1); aPreviewFrame.size.height -= 61; mpPreview = [[NSImageView alloc] initWithFrame: aPreviewFrame]; - [mpPreview setImageScaling: NSScaleNone]; + [mpPreview setImageScaling: NSScaleProportionally]; [mpPreview setImageAlignment: NSImageAlignCenter]; [mpPreview setImageFrameStyle: NSImageFrameNone]; [mpPreviewBox addSubview: [mpPreview autorelease]]; diff --git a/vcl/aqua/source/gdi/makefile.mk b/vcl/aqua/source/gdi/makefile.mk index 6cf1d498cce2..2aea58e49250 100644 --- a/vcl/aqua/source/gdi/makefile.mk +++ b/vcl/aqua/source/gdi/makefile.mk @@ -49,7 +49,6 @@ dummy: SLOFILES= $(SLO)$/salmathutils.obj \ $(SLO)$/salcolorutils.obj \ - $(SLO)$/salpixmaputils.obj \ $(SLO)$/salgdiutils.obj \ $(SLO)$/salnativewidgets.obj \ $(SLO)$/salatsuifontutils.obj \ diff --git a/vcl/aqua/source/gdi/salatsuifontutils.cxx b/vcl/aqua/source/gdi/salatsuifontutils.cxx index 1566f0961f54..8281c41ceeab 100644 --- a/vcl/aqua/source/gdi/salatsuifontutils.cxx +++ b/vcl/aqua/source/gdi/salatsuifontutils.cxx @@ -217,9 +217,6 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF // all scalable fonts on this platform are subsettable rDFA.mbSubsettable = true; rDFA.mbEmbeddable = false; - // TODO: these members are needed only for our X11 platform targets - rDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - rDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; // prepare iterating over all name strings of the font ItemCount nFontNameCount = 0; diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index a54a7fad7ac5..38fb068bb353 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -1095,7 +1095,8 @@ void AquaSalGraphics::copyBits( const SalTwoRect *pPosAry, SalGraphics *pSrcGrap DBG_ASSERT( pSrc->mxLayer!=NULL, "AquaSalGraphics::copyBits() from non-layered graphics" ); const CGPoint aDstPoint = { +pPosAry->mnDestX - pPosAry->mnSrcX, pPosAry->mnDestY - pPosAry->mnSrcY }; - if( !mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth ) // workaround a Quartz crasher + if( (pPosAry->mnSrcWidth == pPosAry->mnDestWidth && pPosAry->mnSrcHeight == pPosAry->mnDestHeight) && + (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher { // in XOR mode the drawing context is redirected to the XOR mask // if source and target are identical then copyBits() paints onto the target context though diff --git a/vcl/aqua/source/gdi/salnativewidgets.cxx b/vcl/aqua/source/gdi/salnativewidgets.cxx index 3baa38320075..b4b843eaca58 100644 --- a/vcl/aqua/source/gdi/salnativewidgets.cxx +++ b/vcl/aqua/source/gdi/salnativewidgets.cxx @@ -267,6 +267,11 @@ BOOL AquaSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart n return true; break; + case CTRL_SLIDER: + if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) + return true; + break; + case CTRL_EDITBOX: if( nPart == PART_ENTIRE_CONTROL || nPart == HAS_BACKGROUND_TEXTURE ) @@ -561,7 +566,7 @@ BOOL AquaSalGraphics::drawNativeControl(ControlType nType, // the Aqua grey theme when the item is selected is drawn here. aMenuItemDrawInfo.itemType = kThemeMenuItemPlain; - if ((nPart == PART_MENU_ITEM )) + if ((nPart == PART_MENU_ITEM ) && (nState & CTRL_STATE_SELECTED)) { // the blue theme when the item is selected is drawn here. aMenuItemDrawInfo.state = kThemeMenuSelected; @@ -785,6 +790,36 @@ BOOL AquaSalGraphics::drawNativeControl(ControlType nType, } break; + case CTRL_SLIDER: + { + SliderValue* pSLVal = (SliderValue*)aValue.getOptionalVal(); + + HIThemeTrackDrawInfo aTrackDraw; + aTrackDraw.kind = kThemeSliderMedium; + if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) + { + aTrackDraw.bounds = rc; + aTrackDraw.min = pSLVal->mnMin; + aTrackDraw.max = pSLVal->mnMax;; + aTrackDraw.value = pSLVal->mnCur; + aTrackDraw.reserved = 0; + aTrackDraw.attributes = kThemeTrackShowThumb; + if( nPart == PART_TRACK_HORZ_AREA ) + aTrackDraw.attributes |= kThemeTrackHorizontal; + aTrackDraw.enableState = (nState & CTRL_STATE_ENABLED) + ? kThemeTrackActive : kThemeTrackInactive; + + SliderTrackInfo aSlideInfo; + aSlideInfo.thumbDir = kThemeThumbUpward; + aSlideInfo.pressState = 0; + aTrackDraw.trackInfo.slider = aSlideInfo; + + HIThemeDrawTrack( &aTrackDraw, NULL, mrContext, kHIThemeOrientationNormal ); + bOK = true; + } + } + break; + case CTRL_SCROLLBAR: { ScrollbarValue* pScrollbarVal = (ScrollbarValue *)(aValue.getOptionalVal()); @@ -1223,18 +1258,38 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa { BOOL toReturn = FALSE; - short x = rControlRegion.GetBoundRect().Left(); - short y = rControlRegion.GetBoundRect().Top(); + Rectangle aCtrlBoundRect( rControlRegion.GetBoundRect() ); + short x = aCtrlBoundRect.Left(); + short y = aCtrlBoundRect.Top(); short w, h; sal_uInt8 nBorderCleanup = 0; switch (nType) { + case CTRL_SLIDER: + { + if( nPart == PART_THUMB_HORZ ) + { + w = 19; // taken from HIG + h = aCtrlBoundRect.GetHeight(); + rNativeBoundingRegion = rNativeContentRegion = Region( Rectangle( Point( x, y ), Size( w, h ) ) ); + toReturn = true; + } + else if( nPart == PART_THUMB_VERT ) + { + w = aCtrlBoundRect.GetWidth(); + h = 18; // taken from HIG + rNativeBoundingRegion = rNativeContentRegion = Region( Rectangle( Point( x, y ), Size( w, h ) ) ); + toReturn = true; + } + } + break; + case CTRL_SCROLLBAR: { Rectangle aRect; - if( AquaGetScrollRect( /* m_nScreen */ nPart, rControlRegion.GetBoundRect(), aRect ) ) + if( AquaGetScrollRect( /* m_nScreen */ nPart, aCtrlBoundRect, aRect ) ) { toReturn = TRUE; rNativeBoundingRegion = aRect; @@ -1249,8 +1304,8 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa { if ( nType == CTRL_PUSHBUTTON ) { - w = rControlRegion.GetBoundRect().GetWidth(); - h = rControlRegion.GetBoundRect().GetHeight(); + w = aCtrlBoundRect.GetWidth(); + h = aCtrlBoundRect.GetHeight(); } else { @@ -1271,7 +1326,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa break; case CTRL_PROGRESS: { - Rectangle aRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( aCtrlBoundRect ); if( aRect.GetHeight() < 16 ) aRect.Bottom() = aRect.Top() + 9; // values taken from HIG for medium progress else @@ -1284,7 +1339,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa case CTRL_INTROPROGRESS: { - Rectangle aRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( aCtrlBoundRect ); aRect.Bottom() = aRect.Top() + INTRO_PROGRESS_HEIGHT; // values taken from HIG for medium progress rNativeBoundingRegion = aRect; rNativeContentRegion = aRect; @@ -1294,7 +1349,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa case CTRL_TAB_ITEM: - w = rControlRegion.GetBoundRect().GetWidth() + 2*TAB_TEXT_OFFSET - 2*VCL_TAB_TEXT_OFFSET; + w = aCtrlBoundRect.GetWidth() + 2*TAB_TEXT_OFFSET - 2*VCL_TAB_TEXT_OFFSET; #ifdef OLD_TAB_STYLE h = TAB_HEIGHT_NORMAL; @@ -1310,7 +1365,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa case CTRL_EDITBOX: { - w = rControlRegion.GetBoundRect().GetWidth(); + w = aCtrlBoundRect.GetWidth(); if( w < 3+2*FOCUS_RING_WIDTH ) w = 3+2*FOCUS_RING_WIDTH; h = TEXT_EDIT_HEIGHT_NORMAL; @@ -1326,7 +1381,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa { if( nPart == PART_ENTIRE_CONTROL ) { - w = rControlRegion.GetBoundRect().GetWidth(); + w = aCtrlBoundRect.GetWidth(); h = COMBOBOX_HEIGHT_NORMAL;//listboxes and comboxes have the same height rNativeContentRegion = Rectangle( Point( x+FOCUS_RING_WIDTH, y+FOCUS_RING_WIDTH ), Size( w-2*FOCUS_RING_WIDTH, h ) ); @@ -1336,7 +1391,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa } else if( nPart == PART_BUTTON_DOWN ) { - w = rControlRegion.GetBoundRect().GetWidth(); + w = aCtrlBoundRect.GetWidth(); if( w < 3+2*FOCUS_RING_WIDTH ) w = 3+2*FOCUS_RING_WIDTH; h = COMBOBOX_HEIGHT_NORMAL;//listboxes and comboxes have the same height @@ -1352,7 +1407,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa } else if( nPart == PART_SUB_EDIT ) { - w = rControlRegion.GetBoundRect().GetWidth(); + w = aCtrlBoundRect.GetWidth(); h = COMBOBOX_HEIGHT_NORMAL;//listboxes and comboxes have the same height x += FOCUS_RING_WIDTH; @@ -1373,7 +1428,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa break; case CTRL_SPINBOX: if( nPart == PART_ENTIRE_CONTROL ) { - w = rControlRegion.GetBoundRect().GetWidth(); + w = aCtrlBoundRect.GetWidth(); if( w < 3+2*FOCUS_RING_WIDTH+SPIN_BUTTON_SPACE+SPIN_BUTTON_WIDTH ) w = 3+2*FOCUS_RING_WIDTH+SPIN_BUTTON_SPACE+SPIN_BUTTON_WIDTH; h = TEXT_EDIT_HEIGHT_NORMAL; @@ -1384,7 +1439,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa toReturn = TRUE; } else if( nPart == PART_SUB_EDIT ) { - w = rControlRegion.GetBoundRect().GetWidth() - SPIN_BUTTON_SPACE - SPIN_BUTTON_WIDTH; + w = aCtrlBoundRect.GetWidth() - SPIN_BUTTON_SPACE - SPIN_BUTTON_WIDTH; h = TEXT_EDIT_HEIGHT_NORMAL; x += 4; // add an offset for rounded borders y += 2; // don't draw into upper border @@ -1397,10 +1452,10 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa toReturn = TRUE; } else if( nPart == PART_BUTTON_UP ) { - //rControlRegion.GetBoundRect().GetWidth() contains the width of the full control + //aCtrlBoundRect.GetWidth() contains the width of the full control //ie the width of the textfield + button //x is the position of the left corner of the full control - x += rControlRegion.GetBoundRect().GetWidth() - SPIN_BUTTON_WIDTH - SPIN_BUTTON_SPACE - CLIP_FUZZ; + x += aCtrlBoundRect.GetWidth() - SPIN_BUTTON_WIDTH - SPIN_BUTTON_SPACE - CLIP_FUZZ; y += FOCUS_RING_WIDTH - CLIP_FUZZ; w = SPIN_BUTTON_WIDTH + 2*CLIP_FUZZ; h = SPIN_UPPER_BUTTON_HEIGHT + 2*CLIP_FUZZ; @@ -1411,7 +1466,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa toReturn = TRUE; } else if( nPart == PART_BUTTON_DOWN ) { - x += rControlRegion.GetBoundRect().GetWidth() - SPIN_BUTTON_WIDTH - SPIN_BUTTON_SPACE - CLIP_FUZZ; + x += aCtrlBoundRect.GetWidth() - SPIN_BUTTON_WIDTH - SPIN_BUTTON_SPACE - CLIP_FUZZ; y += SPIN_UPPER_BUTTON_HEIGHT + FOCUS_RING_WIDTH - CLIP_FUZZ; w = SPIN_BUTTON_WIDTH + 2*CLIP_FUZZ; h = SPIN_LOWER_BUTTON_HEIGHT + 2*CLIP_FUZZ; @@ -1428,7 +1483,7 @@ BOOL AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa if( ( nPart == PART_BORDER ) && !( nStyle & (FRAME_DRAW_MENU | FRAME_DRAW_WINDOWBORDER | FRAME_DRAW_BORDERWINDOWBORDER) ) ) { - Rectangle aRect = rControlRegion.GetBoundRect(); + Rectangle aRect(aCtrlBoundRect); if( nStyle & FRAME_DRAW_DOUBLEIN ) { aRect.Left() += 1; diff --git a/vcl/aqua/source/gdi/salpixmaputils.cxx b/vcl/aqua/source/gdi/salpixmaputils.cxx deleted file mode 100755 index b39120080b88..000000000000 --- a/vcl/aqua/source/gdi/salpixmaputils.cxx +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_vcl.hxx" - -#include "salpixmaputils.hxx" - -// ======================================================================= - -// ======================================================================= - diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index cee243093ff3..1c0401f769b5 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -532,8 +532,6 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, PrintAccessoryViewState aAccViewState; sal_Int32 nAllPages = 0; - aAccViewState.bNeedRestart = true; - // reset IsLastPage i_rController.setLastPage( sal_False ); @@ -549,111 +547,133 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( ! i_rController.isShowDialogs() ) bShowProgressPanel = sal_False; + // possibly create one job for collated output + sal_Bool bSinglePrintJobs = sal_False; + beans::PropertyValue* pSingleValue = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ) ); + if( pSingleValue ) + { + pSingleValue->Value >>= bSinglePrintJobs; + } + // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) // how do I know when that might be ? i_rController.jobStarted(); - do - { - if( aAccViewState.bNeedRestart ) - { - mnCurPageRangeStart = 0; - mnCurPageRangeCount = 0; - nAllPages = i_rController.getFilteredPageCount(); - } - aAccViewState.bNeedRestart = false; - Size aCurSize( 21000, 29700 ); - if( nAllPages > 0 ) + int nCopies = i_rController.getPrinter()->GetCopyCount(); + int nJobs = 1; + if( bSinglePrintJobs ) + { + nJobs = nCopies; + nCopies = 1; + } + + for( int nCurJob = 0; nCurJob < nJobs; nCurJob++ ) + { + aAccViewState.bNeedRestart = true; + do { - mnCurPageRangeCount = 1; - aCurSize = getPageSize( i_rController, mnCurPageRangeStart ); - Size aNextSize( aCurSize ); + if( aAccViewState.bNeedRestart ) + { + mnCurPageRangeStart = 0; + mnCurPageRangeCount = 0; + nAllPages = i_rController.getFilteredPageCount(); + } - // print pages up to a different size - while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) + aAccViewState.bNeedRestart = false; + + Size aCurSize( 21000, 29700 ); + if( nAllPages > 0 ) { - aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount ); - if( aCurSize == aNextSize // same page size - || - (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation - ) + mnCurPageRangeCount = 1; + aCurSize = getPageSize( i_rController, mnCurPageRangeStart ); + Size aNextSize( aCurSize ); + + // print pages up to a different size + while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) { - mnCurPageRangeCount++; + aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount ); + if( aCurSize == aNextSize // same page size + || + (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation + ) + { + mnCurPageRangeCount++; + } + else + break; } - else - break; } - } - else - mnCurPageRangeCount = 0; - - // now for the current run - mnStartPageOffsetX = mnStartPageOffsetY = 0; - // setup the paper size and orientation - // do this on our associated Printer object, since that is - // out interface to the applications which occasionally rely on the paper - // information (e.g. brochure printing scales to the found paper size) - // also SetPaperSizeUser has the advantage that we can share a - // platform independent paper matching algorithm - boost::shared_ptr<Printer> pPrinter( i_rController.getPrinter() ); - pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); - pPrinter->SetPaperSizeUser( aCurSize, true ); - - // create view - NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this]; - - NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; - - // set filename - if( i_pFileName ) - { - [mpPrintInfo setJobDisposition: NSPrintSaveJob]; - NSString* pPath = CreateNSString( *i_pFileName ); - [pPrintDict setObject: pPath forKey: NSPrintSavePath]; - [pPath release]; - } + else + mnCurPageRangeCount = 0; + + // now for the current run + mnStartPageOffsetX = mnStartPageOffsetY = 0; + // setup the paper size and orientation + // do this on our associated Printer object, since that is + // out interface to the applications which occasionally rely on the paper + // information (e.g. brochure printing scales to the found paper size) + // also SetPaperSizeUser has the advantage that we can share a + // platform independent paper matching algorithm + boost::shared_ptr<Printer> pPrinter( i_rController.getPrinter() ); + pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); + pPrinter->SetPaperSizeUser( aCurSize, true ); + + // create view + NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this]; + + NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; + + // set filename + if( i_pFileName ) + { + [mpPrintInfo setJobDisposition: NSPrintSaveJob]; + NSString* pPath = CreateNSString( *i_pFileName ); + [pPrintDict setObject: pPath forKey: NSPrintSavePath]; + [pPath release]; + } - [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rController.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; - [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; - [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; - // #i103253# weird: for some reason, autoreleasing the value below like the others above - // leads do a double free malloc error. Why this value should behave differently from all the others - // is a mystery. - [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage]; + [pPrintDict setObject: [[NSNumber numberWithInt: nCopies] autorelease] forKey: NSPrintCopies]; + [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; + [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; + // #i103253# weird: for some reason, autoreleasing the value below like the others above + // leads do a double free malloc error. Why this value should behave differently from all the others + // is a mystery. + [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage]; - // create print operation - NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; + // create print operation + NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; - if( pPrintOperation ) - { - NSObject* pReleaseAfterUse = nil; - bool bShowPanel = (! i_rController.isDirectPrint() && getUseNativeDialog() && i_rController.isShowDialogs() ); - [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; - [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; - - // set job title (since MacOSX 10.5) - if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] ) - [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]]; - - if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view - pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState]; - - bSuccess = TRUE; - mbJob = true; - pInst->startedPrintJob(); - [pPrintOperation runOperation]; - pInst->endedPrintJob(); - bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame; - mbJob = false; - if( pReleaseAfterUse ) - [pReleaseAfterUse release]; - } + if( pPrintOperation ) + { + NSObject* pReleaseAfterUse = nil; + bool bShowPanel = (! i_rController.isDirectPrint() && getUseNativeDialog() && i_rController.isShowDialogs() ); + [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; + [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; + + // set job title (since MacOSX 10.5) + if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] ) + [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]]; + + if( bShowPanel && mnCurPageRangeStart == 0 && nCurJob == 0) // only the first range of pages (in the first job) gets the accesory view + pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState]; + + bSuccess = TRUE; + mbJob = true; + pInst->startedPrintJob(); + [pPrintOperation runOperation]; + pInst->endedPrintJob(); + bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame; + mbJob = false; + if( pReleaseAfterUse ) + [pReleaseAfterUse release]; + } - mnCurPageRangeStart += mnCurPageRangeCount; - mnCurPageRangeCount = 1; - } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); + mnCurPageRangeStart += mnCurPageRangeCount; + mnCurPageRangeCount = 1; + } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); + } // inform application that it can release its data // this is awkward, but the XRenderable interface has no method for this, diff --git a/vcl/inc/postgraphitestl.h b/vcl/inc/postgraphitestl.h deleted file mode 100644 index 736aa248b7ff..000000000000 --- a/vcl/inc/postgraphitestl.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef std_was_redefined_as_stlport -// put things back the way they were -# define std std_was_redefined_as_stlport -# undef _STLP_OUTERMOST_HEADER_ID -// force config to be re-read -# undef _STLP_NOTHROW_INHERENTLY -# undef _STLP_CONFIG_H -# include <stddef.h> -#endif diff --git a/vcl/inc/pregraphitestl.h b/vcl/inc/pregraphitestl.h deleted file mode 100644 index ece0af477113..000000000000 --- a/vcl/inc/pregraphitestl.h +++ /dev/null @@ -1,30 +0,0 @@ -#if defined(GRAPHITEADAPTSTL) && defined(std) -# include <ostream> -# include <istream> -# include <fstream> -# include <iostream> -# include <vector> -# include <algorithm> -# define std_was_redefined_as_stlport std -# undef std -# define _STLP_OUTERMOST_HEADER_ID 0xdeadbeaf -# pragma GCC visibility push(default) -# include _STLP_NATIVE_HEADER(exception_defines.h) -# include _STLP_NATIVE_HEADER(limits) -# include _STLP_NATIVE_HEADER(memory) -# include _STLP_NATIVE_HEADER(exception) -# include _STLP_NATIVE_HEADER(iosfwd) -# include _STLP_NATIVE_HEADER(algorithm) -# include _STLP_NATIVE_HEADER(string) -# include _STLP_NATIVE_HEADER(streambuf) -# include _STLP_NATIVE_HEADER(ios) -# include _STLP_NATIVE_HEADER(locale) -# include _STLP_NATIVE_HEADER(stdexcept) -# include _STLP_NATIVE_HEADER(ostream) -# include _STLP_NATIVE_HEADER(istream) -# include _STLP_NATIVE_HEADER(iostream) -# include _STLP_NATIVE_HEADER(vector) -# pragma GCC visibility pop -#endif -//sil_std resolves to the std that Graphite was built with -namespace sil_std = std; diff --git a/vcl/inc/vcl/decoview.hxx b/vcl/inc/vcl/decoview.hxx index a30f209c69fc..2412ceda8431 100644 --- a/vcl/inc/vcl/decoview.hxx +++ b/vcl/inc/vcl/decoview.hxx @@ -33,6 +33,7 @@ #include <vcl/symbol.hxx> class Rectangle; +class Point; class Color; class OutputDevice; @@ -103,6 +104,7 @@ public: USHORT nStyle = FRAME_HIGHLIGHT_OUT ); Rectangle DrawFrame( const Rectangle& rRect, USHORT nStyle = FRAME_DRAW_OUT ); Rectangle DrawButton( const Rectangle& rRect, USHORT nStyle ); + void DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical = true ); }; #endif // _SV_DECOVIEW_HXX diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx index 7e1733b49bca..33fece8d88e1 100644 --- a/vcl/inc/vcl/fontmanager.hxx +++ b/vcl/inc/vcl/fontmanager.hxx @@ -49,6 +49,7 @@ // forward declarations namespace utl { class MultiAtomProvider; } // see unotools/atom.hxx class FontSubsetInfo; +class ImplFontOptions; namespace psp { class PPDParser; // see ppdparser.hxx @@ -162,8 +163,6 @@ struct FastPrintFontInfo weight::type m_eWeight; pitch::type m_ePitch; rtl_TextEncoding m_aEncoding; - fcstatus::type m_eEmbeddedbitmap; - fcstatus::type m_eAntialias; bool m_bSubsettable; bool m_bEmbeddable; @@ -175,9 +174,7 @@ struct FastPrintFontInfo m_eWidth( width::Unknown ), m_eWeight( weight::Unknown ), m_ePitch( pitch::Unknown ), - m_aEncoding( RTL_TEXTENCODING_DONTKNOW ), - m_eEmbeddedbitmap( fcstatus::isunset ), - m_eAntialias( fcstatus::isunset ) + m_aEncoding( RTL_TEXTENCODING_DONTKNOW ) {} }; @@ -294,9 +291,6 @@ class VCL_DLLPUBLIC PrintFontManager bool m_bHaveVerticalSubstitutedGlyphs; bool m_bUserOverride; - fcstatus::type m_eEmbeddedbitmap; - fcstatus::type m_eAntialias; - std::map< sal_Unicode, sal_Int32 > m_aEncodingVector; std::map< sal_Unicode, rtl::OString > m_aNonEncoded; @@ -443,7 +437,7 @@ class VCL_DLLPUBLIC PrintFontManager false else (e.g. no libfontconfig found) */ bool initFontconfig(); - int countFontconfigFonts(); + int countFontconfigFonts( std::hash_map<rtl::OString, int, rtl::OStringHash>& o_rVisitedPaths ); /* deinitialize fontconfig */ void deinitFontconfig(); @@ -736,10 +730,11 @@ public: false else */ bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ); + bool getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*), ImplFontOptions& rResult ) const; rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, - const rtl::OString& rLangAttrib, italic::type eItalic, weight::type eWeight, - width::type eWidth, pitch::type ePitch) const; + const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight, + width::type& rWidth, pitch::type& rPitch) const; bool hasFontconfig() const { return m_bFontconfigSuccess; } int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar ); diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx index 8c7d6e41b168..fa3e99f2373f 100644 --- a/vcl/inc/vcl/glyphcache.hxx +++ b/vcl/inc/vcl/glyphcache.hxx @@ -39,6 +39,7 @@ class ServerFontLayoutEngine; class ServerFontLayout; class ExtraKernInfo; struct ImplKernPairData; +class ImplFontOptions; #include <tools/gen.hxx> #include <hash_map> @@ -59,8 +60,8 @@ class ServerFontLayout; class VCL_DLLPUBLIC GlyphCache { public: - GlyphCache( GlyphCachePeer& ); - ~GlyphCache(); + explicit GlyphCache( GlyphCachePeer& ); + /*virtual*/ ~GlyphCache(); static GlyphCache& GetInstance(); void LoadFonts(); @@ -74,6 +75,7 @@ public: ServerFont* CacheFont( const ImplFontSelectData& ); void UncacheFont( ServerFont& ); + void InvalidateAllGlyphs(); protected: GlyphCachePeer& mrPeer; @@ -96,7 +98,6 @@ private: struct IFSD_Hash{ size_t operator()( const ImplFontSelectData& ) const; }; typedef ::std::hash_map<ImplFontSelectData,ServerFont*,IFSD_Hash,IFSD_Equal > FontList; FontList maFontList; - ULONG mnMaxSize; // max overall cache size in bytes mutable ULONG mnBytesUsed; mutable long mnLruIndex; @@ -179,6 +180,7 @@ public: virtual bool TestFont() const { return true; } virtual void* GetFtFace() const { return 0; } virtual int GetLoadFlags() const { return 0; } + virtual void SetFontOptions( const ImplFontOptions&) {} virtual bool NeedsArtificialBold() const { return false; } virtual bool NeedsArtificialItalic() const { return false; } @@ -208,7 +210,7 @@ public: protected: friend class GlyphCache; friend class ServerFontLayout; - ServerFont( const ImplFontSelectData& ); + explicit ServerFont( const ImplFontSelectData& ); virtual ~ServerFont(); void AddRef() const { ++mnRefCount; } diff --git a/vcl/inc/vcl/graphite_adaptors.hxx b/vcl/inc/vcl/graphite_adaptors.hxx index 0b5f88184ce4..43c2e37a5fb2 100644 --- a/vcl/inc/vcl/graphite_adaptors.hxx +++ b/vcl/inc/vcl/graphite_adaptors.hxx @@ -55,11 +55,11 @@ #include "vcl/dllapi.h" // Libraries -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/ITextSource.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> // Module type definitions and forward declarations. // @@ -119,7 +119,7 @@ public: const grutils::GrFeatureParser * features() const { return mpFeatures; }; private: - virtual void UniqueCacheInfo(sil_std::wstring &, bool &, bool &); + virtual void UniqueCacheInfo(ext_std::wstring &, bool &, bool &); FreetypeServerFont& mrFont; FontProperties maFontProperties; diff --git a/vcl/inc/vcl/graphite_features.hxx b/vcl/inc/vcl/graphite_features.hxx index 9f63a029eb5f..47f4c3a01e7f 100644 --- a/vcl/inc/vcl/graphite_features.hxx +++ b/vcl/inc/vcl/graphite_features.hxx @@ -29,11 +29,11 @@ // Parse a string of features specified as ; separated pairs. // e.g. // 1001=1&2002=2&fav1=0 -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/GrFeature.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> namespace grutils { diff --git a/vcl/inc/vcl/graphite_layout.hxx b/vcl/inc/vcl/graphite_layout.hxx index b3a3814e9ce6..1fbb11211ca0 100644 --- a/vcl/inc/vcl/graphite_layout.hxx +++ b/vcl/inc/vcl/graphite_layout.hxx @@ -40,13 +40,13 @@ #include <vector> #include <utility> // Libraries -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/GrConstants.h> #include <graphite/GrAppData.h> #include <graphite/SegmentAux.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> // Platform #include <vcl/sallayout.hxx> #include <vcl/dllapi.h> diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx index d53785bc691a..6ce9f21500b5 100644 --- a/vcl/inc/vcl/impfont.hxx +++ b/vcl/inc/vcl/impfont.hxx @@ -133,6 +133,41 @@ public: bool operator==( const ImplFontMetric& ) const; }; +// ------------------ +// - ImplFontHints - +// ------------------ + +class ImplFontOptions +{ +public: + FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used + FontAntiAlias meAntiAlias; // whether the font should be antialiased + FontAutoHint meAutoHint; // whether the font should be autohinted + FontHinting meHinting; // whether the font should be hinted + FontHintStyle meHintStyle; // type of font hinting to be used +public: + ImplFontOptions() : + meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW), + meAntiAlias(ANTIALIAS_DONTKNOW), + meAutoHint(AUTOHINT_DONTKNOW), + meHinting(HINTING_DONTKNOW), + meHintStyle(HINT_SLIGHT) + {} + ImplFontOptions( FontEmbeddedBitmap eEmbeddedBitmap, FontAntiAlias eAntiAlias, + FontAutoHint eAutoHint, FontHinting eHinting, FontHintStyle eHintStyle) : + meEmbeddedBitmap(eEmbeddedBitmap), + meAntiAlias(eAntiAlias), + meAutoHint(eAutoHint), + meHinting(eHinting), + meHintStyle(eHintStyle) + {} + FontAutoHint GetUseAutoHint() const { return meAutoHint; } + FontHintStyle GetHintStyle() const { return meHintStyle; } + bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; } + bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; } + bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); } +}; + // ------------------- // - ImplFontCharMap - // ------------------- diff --git a/vcl/inc/vcl/introwin.hxx b/vcl/inc/vcl/introwin.hxx index 5ffefe0950f8..40644019bc15 100644 --- a/vcl/inc/vcl/introwin.hxx +++ b/vcl/inc/vcl/introwin.hxx @@ -31,6 +31,7 @@ #include <vcl/sv.h> #include <vcl/dllapi.h> #include <vcl/wrkwin.hxx> +#include <vcl/bitmapex.hxx> // -------------- // - IntroWindow - @@ -46,6 +47,7 @@ public: ~IntroWindow(); void SetBackgroundBitmap( const Bitmap& rBitmap ); + void SetBackgroundBitmap( const BitmapEx& rBitmapEx ); }; #endif // _SV_INTROWIN_HXX diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index 101a368b0586..70c1e6aa624d 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -77,6 +77,7 @@ class AlphaMask; class FontCharMap; class SalLayout; class ImplLayoutArgs; +class ImplFontAttributes; class VirtualDevice; namespace com { @@ -541,7 +542,6 @@ public: SAL_DLLPRIVATE static FontEmphasisMark ImplGetEmphasisMarkStyle( const Font& rFont ); SAL_DLLPRIVATE static BOOL ImplIsUnderlineAbove( const Font& ); - // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI SAL_DLLPRIVATE bool ImplIsAntiparallel() const ; @@ -931,6 +931,10 @@ public: basegfx::B2DHomMatrix GetViewTransformation() const; basegfx::B2DHomMatrix GetInverseViewTransformation() const; + basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const; + basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const; + + /** Set an offset in pixel This method offsets every drawing operation that converts its @@ -967,7 +971,9 @@ public: Size LogicToPixel( const Size& rLogicSize ) const; Rectangle LogicToPixel( const Rectangle& rLogicRect ) const; Polygon LogicToPixel( const Polygon& rLogicPoly ) const; + basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPolyPoly ) const; PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const; Region LogicToPixel( const Region& rLogicRegion )const; Point LogicToPixel( const Point& rLogicPt, const MapMode& rMapMode ) const; @@ -977,15 +983,21 @@ public: const MapMode& rMapMode ) const; Polygon LogicToPixel( const Polygon& rLogicPoly, const MapMode& rMapMode ) const; + basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly, + const MapMode& rMapMode ) const; PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly, const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, + const MapMode& rMapMode ) const; Region LogicToPixel( const Region& rLogicRegion, const MapMode& rMapMode ) const; Point PixelToLogic( const Point& rDevicePt ) const; Size PixelToLogic( const Size& rDeviceSize ) const; Rectangle PixelToLogic( const Rectangle& rDeviceRect ) const; Polygon PixelToLogic( const Polygon& rDevicePoly ) const; + basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly ) const; PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const; Region PixelToLogic( const Region& rDeviceRegion ) const; Point PixelToLogic( const Point& rDevicePt, const MapMode& rMapMode ) const; @@ -995,8 +1007,12 @@ public: const MapMode& rMapMode ) const; Polygon PixelToLogic( const Polygon& rDevicePoly, const MapMode& rMapMode ) const; + basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly, + const MapMode& rMapMode ) const; PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly, const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly, + const MapMode& rMapMode ) const; Region PixelToLogic( const Region& rDeviceRegion, const MapMode& rMapMode ) const; @@ -1026,6 +1042,13 @@ public: MapUnit eUnitSource, MapUnit eUnitDest ); + static basegfx::B2DPolygon LogicToLogic( const basegfx::B2DPolygon& rPoly, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static basegfx::B2DPolyPolygon LogicToLogic( const basegfx::B2DPolyPolygon& rPolyPoly, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + Size GetOutputSizePixel() const { return Size( mnOutWidth, mnOutHeight ); } long GetOutputWidthPixel() const { return mnOutWidth; } diff --git a/vcl/inc/vcl/outfont.hxx b/vcl/inc/vcl/outfont.hxx index 87c20ebfd7f9..995fcd6009ff 100644 --- a/vcl/inc/vcl/outfont.hxx +++ b/vcl/inc/vcl/outfont.hxx @@ -94,8 +94,6 @@ public: // TODO: create matching interface class bool IsDeviceFont() const { return mbDevice; } bool IsEmbeddable() const { return mbEmbeddable; } bool IsSubsettable() const { return mbSubsettable; } - FontEmbeddedBitmap UseEmbeddedBitmap() const { return meEmbeddedBitmap; } - FontAntiAlias UseAntiAlias() const { return meAntiAlias; } public: // TODO: hide members behind accessor methods String maMapNames; // List of family name aliass separated with ';' @@ -104,8 +102,6 @@ public: // TODO: hide members behind accessor methods bool mbDevice; // true: built in font bool mbSubsettable; // true: a subset of the font can be created bool mbEmbeddable; // true: the font can be embedded - FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used - FontAntiAlias meAntiAlias; // whether the font should be antialiased }; // ---------------- @@ -339,15 +335,17 @@ public: // TODO: make data members private short mnOrientation; // text angle in 3600 system bool mbInit; // true if maMetric member is valid - void AddFallbackForUnicode( sal_UCS4, const String& rFontName ); - bool GetFallbackForUnicode( sal_UCS4, String* pFontName ) const; - void IgnoreFallbackForUnicode( sal_UCS4, const String& rFontName ); + void AddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const String& rFontName ); + bool GetFallbackForUnicode( sal_UCS4, FontWeight eWeight, String* pFontName ) const; + void IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const String& rFontName ); private: // cache of Unicode characters and replacement font names // TODO: a fallback map can be shared with many other ImplFontEntries // TODO: at least the ones which just differ in orientation, stretching or height - typedef ::std::hash_map<sal_UCS4,String> UnicodeFallbackList; + typedef ::std::pair<sal_UCS4,FontWeight> GFBCacheKey; + struct GFBCacheKey_Hash{ size_t operator()( const GFBCacheKey& ) const; }; + typedef ::std::hash_map<GFBCacheKey,String,GFBCacheKey_Hash> UnicodeFallbackList; UnicodeFallbackList* mpUnicodeFallbackList; }; diff --git a/vcl/inc/vcl/pdfwriter.hxx b/vcl/inc/vcl/pdfwriter.hxx index b4bdcce5c1b8..419814e5ce97 100644 --- a/vcl/inc/vcl/pdfwriter.hxx +++ b/vcl/inc/vcl/pdfwriter.hxx @@ -47,7 +47,6 @@ class Font; class Point; class OutputDevice; -class Region; class MapMode; class Polygon; class LineInfo; @@ -199,7 +198,7 @@ public: enum WidgetType { - PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox + PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox, Hierarchy }; enum WidgetState @@ -671,10 +670,10 @@ The following structure describes the permissions used in PDF security void Pop(); void SetClipRegion(); - void SetClipRegion( const Region& rRegion ); + void SetClipRegion( const basegfx::B2DPolyPolygon& rRegion ); void MoveClipRegion( long nHorzMove, long nVertMove ); void IntersectClipRegion( const Rectangle& rRect ); - void IntersectClipRegion( const Region& rRegion ); + void IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ); void SetAntialiasing( USHORT nMode = 0 ); diff --git a/vcl/inc/vcl/ppdparser.hxx b/vcl/inc/vcl/ppdparser.hxx index 12e8a16f6264..c7a1e09b81e4 100644 --- a/vcl/inc/vcl/ppdparser.hxx +++ b/vcl/inc/vcl/ppdparser.hxx @@ -221,7 +221,7 @@ public: bool isType42Capable() const { return m_bType42Capable; } ULONG getLanguageLevel() const { return m_nLanguageLevel; } - const String& getDefaultPaperDimension() const; + String getDefaultPaperDimension() const; void getDefaultPaperDimension( int& rWidth, int& rHeight ) const { getPaperDimension( getDefaultPaperDimension(), rWidth, rHeight ); } bool getPaperDimension( const String& rPaperName, @@ -230,12 +230,12 @@ public: // returns false if paper not found int getPaperDimensions() const { return m_pPaperDimensions ? m_pPaperDimensions->countValues() : 0; } - const String& getPaperDimension( int ) const; - const String& getPaperDimensionCommand( int ) const; - const String& getPaperDimensionCommand( const String & ) const; + String getPaperDimension( int ) const; + String getPaperDimensionCommand( int ) const; + String getPaperDimensionCommand( const String & ) const; // match the best paper for width and height - const String& matchPaper( int nWidth, int nHeight ) const; + String matchPaper( int nWidth, int nHeight ) const; bool getMargins( const String& rPaperName, int &rLeft, int& rRight, @@ -245,27 +245,27 @@ public: // values int pt - const String& getDefaultInputSlot() const; + String getDefaultInputSlot() const; int getInputSlots() const { return m_pInputSlots ? m_pInputSlots->countValues() : 0; } - const String& getSlot( int ) const; - const String& getSlotCommand( int ) const; - const String& getSlotCommand( const String& ) const; + String getSlot( int ) const; + String getSlotCommand( int ) const; + String getSlotCommand( const String& ) const; void getDefaultResolution( int& rXRes, int& rYRes ) const; int getResolutions() const; void getResolution( int, int& rXRes, int& rYRes ) const; - const String& getResolutionCommand( int nXRes, int nYRes ) const; + String getResolutionCommand( int nXRes, int nYRes ) const; // values in dpi void getResolutionFromString( const String&, int&, int& ) const; // helper function - const String& getDefaultDuplexType() const; + String getDefaultDuplexType() const; int getDuplexTypes() const { return m_pDuplexTypes ? m_pDuplexTypes->countValues() : 0; } - const String& getDuplex( int ) const; - const String& getDuplexCommand( int ) const; - const String& getDuplexCommand( const String& ) const; + String getDuplex( int ) const; + String getDuplexCommand( int ) const; + String getDuplexCommand( const String& ) const; int getFonts() const { return m_pFontList ? m_pFontList->countValues() : 0; } @@ -275,7 +275,7 @@ public: void getFontAttributes( const String&, String& rEncoding, String& rCharset ) const; - const String& getFont( int ) const; + String getFont( int ) const; rtl::OUString translateKey( const rtl::OUString& i_rKey, diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index bec612b65593..fdaf06c9854e 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -55,9 +55,12 @@ namespace vcl { GDIMetaFile maMtf; Size maOrigSize; + Size maPreviewSize; VirtualDevice maPageVDev; rtl::OUString maReplacementString; rtl::OUString maToolTipString; + + bool useHCColorReplacement() const; public: PrintPreviewWindow( Window* pParent, const ResId& ); virtual ~PrintPreviewWindow(); @@ -293,6 +296,7 @@ namespace vcl bool isPrintToFile(); int getCopyCount(); bool isCollate(); + bool isSingleJobs(); void previewForward(); void previewBackward(); @@ -321,6 +325,7 @@ namespace vcl bool isCanceled() const { return mbCanceled; } void setProgress( int i_nCurrent, int i_nMax = -1 ); void tick(); + void reset(); virtual void Paint( const Rectangle& ); }; diff --git a/vcl/inc/vcl/region.hxx b/vcl/inc/vcl/region.hxx index d4fe05ebe8a3..ddfba57ffdcf 100644 --- a/vcl/inc/vcl/region.hxx +++ b/vcl/inc/vcl/region.hxx @@ -113,7 +113,11 @@ public: BOOL HasPolyPolygon() const; PolyPolygon GetPolyPolygon() const; + // returns an empty polypolygon in case HasPolyPolygon is FALSE const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const; + // returns a PolyPolygon either copied from the set PolyPolygon region + // or created from the constituent rectangles + basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon(); ULONG GetRectCount() const; RegionHandle BeginEnumRects(); diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx index f72c4df57481..02e9efbc0f94 100644 --- a/vcl/inc/vcl/salgdi.hxx +++ b/vcl/inc/vcl/salgdi.hxx @@ -234,9 +234,10 @@ public: void ReleaseFonts() { SetFont( NULL, 0 ); } // get the current font's metrics virtual void GetFontMetric( ImplFontMetricData* ) = 0; + // get kernign pairs of the current font // return only PairCount if (pKernPairs == NULL) - virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ) = 0; + virtual ULONG GetKernPairs( ULONG nMaxPairCount, ImplKernPairData* ) = 0; // get the repertoire of the current font virtual ImplFontCharMap* GetImplFontCharMap() const = 0; // graphics must fill supplied font list diff --git a/vcl/inc/vcl/salnativewidgets.hxx b/vcl/inc/vcl/salnativewidgets.hxx index 8ce4c5c20615..8e98791d9f78 100644 --- a/vcl/inc/vcl/salnativewidgets.hxx +++ b/vcl/inc/vcl/salnativewidgets.hxx @@ -95,6 +95,8 @@ typedef sal_uInt32 ControlType; // all parts like slider, buttons #define CTRL_SCROLLBAR 60 +#define CTRL_SLIDER 65 + // Border around a group of related // items, perhaps also displaying // a label of identification @@ -289,6 +291,20 @@ class VCL_DLLPUBLIC ScrollbarValue inline ~ScrollbarValue() {}; }; +class VCL_DLLPUBLIC SliderValue +{ + public: + long mnMin; + long mnMax; + long mnCur; + Rectangle maThumbRect; + ControlState mnThumbState; + + SliderValue() : mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( 0 ) + {} + ~SliderValue() {} +}; + /* TabitemValue: * * Value container for tabitems. diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx index e55c2a53345b..24fd30750501 100644 --- a/vcl/inc/vcl/settings.hxx +++ b/vcl/inc/vcl/settings.hxx @@ -437,6 +437,7 @@ private: ULONG mnPreferredSymbolsStyle; USHORT mnSkipDisabledInMenus; Wallpaper maWorkspaceGradient; + const void* mpFontOptions; }; #define DEFAULT_WORKSPACE_GRADIENT_START_COLOR Color( 0xa3, 0xae, 0xb8 ) @@ -754,6 +755,11 @@ public: BOOL GetSkipDisabledInMenus() const { return (BOOL) mpData->mnSkipDisabledInMenus; } + void SetCairoFontOptions( const void *pOptions ) + { CopyData(); mpData->mpFontOptions = pOptions; } + const void* GetCairoFontOptions() const + { return mpData->mpFontOptions; } + void SetAppFont( const Font& rFont ) { CopyData(); mpData->maAppFont = rFont; } const Font& GetAppFont() const diff --git a/vcl/inc/vcl/status.hxx b/vcl/inc/vcl/status.hxx index 4d41ee450dd7..810ecf230960 100644 --- a/vcl/inc/vcl/status.hxx +++ b/vcl/inc/vcl/status.hxx @@ -116,6 +116,7 @@ private: USHORT nOldPerc, USHORT nNewPerc ); SAL_DLLPRIVATE void ImplCalcProgressRect(); SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( USHORT nPos ) const; + SAL_DLLPRIVATE USHORT ImplGetFirstVisiblePos() const; SAL_DLLPRIVATE void ImplCalcBorder(); public: diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index e7b87ff448d1..4c63b12f15fe 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -92,12 +92,12 @@ private: SAL_DLLPRIVATE void ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false ); SAL_DLLPRIVATE void ImplPaint( const Rectangle& rRect, bool bLayout = false ); SAL_DLLPRIVATE void ImplFreeLayoutData(); + SAL_DLLPRIVATE long ImplHandleKeyEvent( const KeyEvent& rKeyEvent ); + DECL_DLLPRIVATE_LINK( ImplScrollBtnHdl, PushButton* pBtn ); DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox* ); + DECL_DLLPRIVATE_LINK( ImplWindowEventListener, VclSimpleEvent* ); -public: - // just for dialog control - SAL_DLLPRIVATE bool ImplHandleNotifyEvent( NotifyEvent& rEvt ); protected: using Window::ImplInit; diff --git a/vcl/inc/vcl/tabdlg.hxx b/vcl/inc/vcl/tabdlg.hxx index b5f1dc14de5d..35543bb6aac0 100644 --- a/vcl/inc/vcl/tabdlg.hxx +++ b/vcl/inc/vcl/tabdlg.hxx @@ -59,8 +59,6 @@ public: virtual void Resize(); virtual void StateChanged( StateChangedType nStateChange ); - SAL_DLLPRIVATE TabControl* ImplGetFirstTabControl() const; - void AdjustLayout(); void SetViewWindow( Window* pWindow ) { mpViewWindow = pWindow; } diff --git a/vcl/inc/vcl/vclenum.hxx b/vcl/inc/vcl/vclenum.hxx index ded36cc163f0..a34c633479e7 100644 --- a/vcl/inc/vcl/vclenum.hxx +++ b/vcl/inc/vcl/vclenum.hxx @@ -281,6 +281,27 @@ enum FontAntiAlias { ANTIALIAS_DONTKNOW, ANTIALIAS_FALSE, ANTIALIAS_TRUE }; #endif +#ifndef ENUM_FONTAUTOHINT_DECLARED +#define ENUM_FONTAUTOHINT_DECLARED + +enum FontAutoHint { AUTOHINT_DONTKNOW, AUTOHINT_FALSE, AUTOHINT_TRUE }; + +#endif + +#ifndef ENUM_FONTHINTING_DECLARED +#define ENUM_FONTHINTING_DECLARED + +enum FontHinting { HINTING_DONTKNOW, HINTING_FALSE, HINTING_TRUE }; + +#endif + +#ifndef ENUM_FONTHINTSTYLE_DECLARED +#define ENUM_FONTHINTSTYLE_DECLARED + +enum FontHintStyle { HINT_NONE, HINT_SLIGHT, HINT_MEDIUM, HINT_FULL }; + +#endif + // ------------------------------------------------------------ #ifndef ENUM_KEYFUNCTYPE_DECLARED diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index b22a7d21f357..dd9a5b4a15ee 100644 --- a/vcl/source/app/dbggui.cxx +++ b/vcl/source/app/dbggui.cxx @@ -1783,8 +1783,6 @@ void DbgDialogTest( Window* pWindow ) } // ======================================================================= -void DbgPrintShell( const char* pLine ); - #ifndef WNT #define USE_VCL_MSGBOX #define COPY_BUTTON_ID 25 @@ -1963,27 +1961,6 @@ void DbgPrintWindow( const char* pLine ) bIn = FALSE; } -// ----------------------------------------------------------------------- - -void DbgPrintShell( const char* pLine ) -{ -#if defined( WNT ) - // TODO: Shouldn't this be a IsDebuggerPresent()? - if ( GetSystemMetrics( SM_DEBUG ) ) - { - strcpy( aDbgOutBuf, pLine ); - strcat( aDbgOutBuf, "\r\n" ); - OutputDebugString( aDbgOutBuf ); - return; - } - - DbgPrintWindow( pLine ); -#endif -#ifdef UNX - fprintf( stderr, "%s\n", pLine ); -#endif -} - // ======================================================================= #ifdef WNT @@ -1996,7 +1973,6 @@ void DbgGUIInit() { DbgSetPrintMsgBox( DbgPrintMsgBox ); DbgSetPrintWindow( DbgPrintWindow ); - DbgSetPrintShell( DbgPrintShell ); #ifdef WNT DbgSetTestSolarMutex( ImplDbgTestSolarMutex ); #endif @@ -2008,7 +1984,6 @@ void DbgGUIDeInit() { DbgSetPrintMsgBox( NULL ); DbgSetPrintWindow( NULL ); - DbgSetPrintShell( NULL ); #ifdef WNT DbgSetTestSolarMutex( NULL ); #endif diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 1aebe5913959..5ad3f6787461 100644..100755 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -433,6 +433,7 @@ ImplStyleData::ImplStyleData() mnToolbarIconSize = STYLE_TOOLBAR_ICONSIZE_UNKNOWN; mnSymbolsStyle = STYLE_SYMBOLS_AUTO; mnPreferredSymbolsStyle = STYLE_SYMBOLS_AUTO; + mpFontOptions = NULL; SetStandardStyles(); } @@ -539,6 +540,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) : mnToolbarIconSize = rData.mnToolbarIconSize; mnSymbolsStyle = rData.mnSymbolsStyle; mnPreferredSymbolsStyle = rData.mnPreferredSymbolsStyle; + mpFontOptions = rData.mpFontOptions; } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 1cda2308aa9c..1f45b5902381 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1191,7 +1191,10 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, ULONG nDrawFlags else { Rectangle aSymbolRect; - ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1, nDrawFlags, + ULONG nImageSep = 1 + (pDev->GetTextHeight()-10)/2; + if( nImageSep < 1 ) + nImageSep = 1; + ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags, nTextStyle, IsSymbol() ? &aSymbolRect : NULL ); if ( IsSymbol() && ! bLayout ) @@ -1320,6 +1323,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) if( bNativeOK ) return; + bool bRollOver = (IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() )); if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == TRUE ) { PushButtonValue aPBVal; @@ -1334,7 +1338,7 @@ void PushButton::ImplDrawPushButton( bool bLayout ) if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT; if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED; - if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) ) + if ( bRollOver ) nState |= CTRL_STATE_ROLLOVER; if( GetStyle() & WB_BEVELBUTTON ) @@ -1359,8 +1363,15 @@ void PushButton::ImplDrawPushButton( bool bLayout ) Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) ); aPBVal.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() ); - bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState, - aControlValue, rtl::OUString()/*PushButton::GetText()*/ ); + if( ((nState & CTRL_STATE_ROLLOVER) || HasFocus()) || ! (GetStyle() & WB_FLATBUTTON) ) + { + bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState, + aControlValue, rtl::OUString()/*PushButton::GetText()*/ ); + } + else + { + bNativeOK = true; + } // draw content using the same aInRect as non-native VCL would do ImplDrawPushButtonContent( this, @@ -1374,8 +1385,21 @@ void PushButton::ImplDrawPushButton( bool bLayout ) if ( bNativeOK == FALSE ) { // draw PushButtonFrame, aInRect has content size afterwards - if( ! bLayout ) - ImplDrawPushButtonFrame( this, aInRect, nButtonStyle ); + if( (GetStyle() & WB_FLATBUTTON) ) + { + Rectangle aTempRect( aInRect ); + if( ! bLayout && (bRollOver || HasFocus()) ) + ImplDrawPushButtonFrame( this, aTempRect, nButtonStyle ); + aInRect.Left() += 2; + aInRect.Top() += 2; + aInRect.Right() -= 2; + aInRect.Bottom() -= 2; + } + else + { + if( ! bLayout ) + ImplDrawPushButtonFrame( this, aInRect, nButtonStyle ); + } // draw content ImplDrawPushButtonContent( this, 0, aInRect, bLayout ); diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 4b83540c1aa1..37406293d7cf 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -496,16 +496,11 @@ void FixedLine::ImplDraw( bool bLayout ) { Size aOutSize = GetOutputSizePixel(); String aText = GetText(); - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); WinBits nWinStyle = GetStyle(); MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL; String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL; - if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) - SetLineColor( Color( COL_BLACK ) ); - else - SetLineColor( rStyleSettings.GetShadowColor() ); - + DecorationView aDecoView( this ); if ( !aText.Len() || (nWinStyle & WB_VERT) ) { if( !pVector ) @@ -516,21 +511,12 @@ void FixedLine::ImplDraw( bool bLayout ) if ( nWinStyle & WB_VERT ) { nX = (aOutSize.Width()-1)/2; - DrawLine( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) ); + aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) ); } else { nY = (aOutSize.Height()-1)/2; - DrawLine( Point( 0, nY ), Point( aOutSize.Width()-1, nY ) ); - } - - if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) - { - SetLineColor( rStyleSettings.GetLightColor() ); - if ( nWinStyle & WB_VERT ) - DrawLine( Point( nX+1, 0 ), Point( nX+1, aOutSize.Height()-1 ) ); - else - DrawLine( Point( 0, nY+1 ), Point( aOutSize.Width()-1, nY+1 ) ); + aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false ); } } } @@ -538,6 +524,7 @@ void FixedLine::ImplDraw( bool bLayout ) { USHORT nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS; Rectangle aRect( 0, 0, aOutSize.Width(), aOutSize.Height() ); + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); if ( !IsEnabled() ) nStyle |= TEXT_DRAW_DISABLE; @@ -551,12 +538,7 @@ void FixedLine::ImplDraw( bool bLayout ) if( !pVector ) { long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2); - DrawLine( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ) ); - if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) - { - SetLineColor( rStyleSettings.GetLightColor() ); - DrawLine( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop+1 ), Point( aOutSize.Width()-1, nTop+1 ) ); - } + aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false ); } } } diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 5e7e9709607f..2390a8e3e9a6 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -168,6 +168,7 @@ void Slider::ImplInitSettings() void Slider::ImplUpdateRects( BOOL bUpdate ) { Rectangle aOldThumbRect = maThumbRect; + bool bInvalidateAll = false; if ( mnThumbPixRange ) { @@ -193,6 +194,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) } else maChannel2Rect.SetEmpty(); + + const Region aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) ); + Region aThumbBounds, aThumbContent; + if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ, + aControlRegion, 0, ImplControlValue(), rtl::OUString(), + aThumbBounds, aThumbContent ) ) + { + Rectangle aRect( aThumbBounds.GetBoundRect() ); + maThumbRect.Left() = mnThumbPixPos - aRect.GetWidth()/2; + maThumbRect.Right() = maThumbRect.Left() + aRect.GetWidth() - 1; + bInvalidateAll = true; + } } else { @@ -216,6 +229,18 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) } else maChannel2Rect.SetEmpty(); + + const Region aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) ); + Region aThumbBounds, aThumbContent; + if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT, + aControlRegion, 0, ImplControlValue(), rtl::OUString(), + aThumbBounds, aThumbContent ) ) + { + Rectangle aRect( aThumbBounds.GetBoundRect() ); + maThumbRect.Top() = mnThumbPixPos - aRect.GetHeight()/2; + maThumbRect.Bottom() = maThumbRect.Top() + aRect.GetHeight() - 1; + bInvalidateAll = true; + } } } else @@ -229,17 +254,22 @@ void Slider::ImplUpdateRects( BOOL bUpdate ) { if ( aOldThumbRect != maThumbRect ) { - Region aInvalidRegion( aOldThumbRect ); - aInvalidRegion.Union( maThumbRect ); - - if( !IsBackground() && GetParent() ) + if( bInvalidateAll ) + Invalidate(); + else { - const Point aPos( GetPosPixel() ); - aInvalidRegion.Move( aPos.X(), aPos.Y() ); - GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE ); + Region aInvalidRegion( aOldThumbRect ); + aInvalidRegion.Union( maThumbRect ); + + if( !IsBackground() && GetParent() ) + { + const Point aPos( GetPosPixel() ); + aInvalidRegion.Move( aPos.X(), aPos.Y() ); + GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE ); + } + else + Invalidate( aInvalidRegion ); } - else - Invalidate( aInvalidRegion ); } } } @@ -357,6 +387,29 @@ void Slider::ImplDraw( USHORT nDrawFlags ) if ( mbCalcSize ) ImplCalc( FALSE ); + ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA; + ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + ControlState nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 ); + SliderValue sldValue; + + sldValue.mnMin = mnMinRange; + sldValue.mnMax = mnMaxRange; + sldValue.mnCur = mnThumbPos; + sldValue.maThumbRect = maThumbRect; + + if( IsMouseOver() ) + { + if( maThumbRect.IsInside( GetPointerPosPixel() ) ) + sldValue.mnThumbState |= CTRL_STATE_ROLLOVER; + } + aControlValue.setOptionalVal( (void *)(&sldValue) ); + + const Region aCtrlRegion( Rectangle( Point(0,0), GetOutputSizePixel() ) ); + bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart, + aCtrlRegion, nState, aControlValue, rtl::OUString() ); + if( bNativeOK ) + return; + if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() ) { long nRectSize; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 5c08cdb8a36b..741267044829 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -174,6 +174,9 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) // otherwise they will paint with a wrong background if( IsNativeControlSupported(CTRL_TAB_PANE, PART_ENTIRE_CONTROL) ) EnableChildTransparentMode( TRUE ); + + if ( pParent->IsDialog() ) + pParent->AddChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) ); } // ----------------------------------------------------------------- @@ -288,6 +291,9 @@ void TabControl::ImplLoadRes( const ResId& rResId ) TabControl::~TabControl() { + if ( GetParent()->IsDialog() ) + GetParent()->RemoveChildEventListener( LINK( this, TabControl, ImplWindowEventListener ) ); + ImplFreeLayoutData(); // TabCtrl-Daten loeschen @@ -1070,6 +1076,42 @@ void TabControl::ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bo // ----------------------------------------------------------------------- +long TabControl::ImplHandleKeyEvent( const KeyEvent& rKeyEvent ) +{ + long nRet = 0; + + if ( GetPageCount() > 1 ) + { + KeyCode aKeyCode = rKeyEvent.GetKeyCode(); + USHORT nKeyCode = aKeyCode.GetCode(); + + if ( aKeyCode.IsMod1() ) + { + if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) ) + { + if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) ) + { + ImplActivateTabPage( FALSE ); + nRet = 1; + } + } + else + { + if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) ) + { + ImplActivateTabPage( TRUE ); + nRet = 1; + } + } + } + } + + return nRet; +} + + +// ----------------------------------------------------------------------- + IMPL_LINK( TabControl, ImplScrollBtnHdl, PushButton*, EMPTYARG ) { ImplSetScrollBtnsState(); @@ -1086,6 +1128,24 @@ IMPL_LINK( TabControl, ImplListBoxSelectHdl, ListBox*, EMPTYARG ) // ----------------------------------------------------------------------- +IMPL_LINK( TabControl, ImplWindowEventListener, VclSimpleEvent*, pEvent ) +{ + if ( pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() == VCLEVENT_WINDOW_KEYINPUT) ) + { + VclWindowEvent* pWindowEvent = static_cast< VclWindowEvent* >(pEvent); + // Do not handle events from TabControl or it's children, which is done in Notify(), where the events can be consumed. + if ( !IsWindowOrChild( pWindowEvent->GetWindow() ) ) + { + KeyEvent* pKeyEvent = static_cast< KeyEvent* >(pWindowEvent->GetData()); + ImplHandleKeyEvent( *pKeyEvent ); + } + } + return 0; +} + + +// ----------------------------------------------------------------------- + void TabControl::MouseButtonDown( const MouseEvent& rMEvt ) { if( mpTabCtrlData->mpListBox == NULL ) @@ -1655,44 +1715,14 @@ long TabControl::PreNotify( NotifyEvent& rNEvt ) // ----------------------------------------------------------------------- -bool TabControl::ImplHandleNotifyEvent( NotifyEvent& rNEvt ) -{ - if ( (rNEvt.GetType() == EVENT_KEYINPUT) && (GetPageCount() > 1) ) - { - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - KeyCode aKeyCode = pKEvt->GetKeyCode(); - USHORT nKeyCode = aKeyCode.GetCode(); - - if ( aKeyCode.IsMod1() ) - { - if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) ) - { - if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) ) - { - ImplActivateTabPage( FALSE ); - return TRUE; - } - } - else - { - if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) ) - { - ImplActivateTabPage( TRUE ); - return TRUE; - } - } - } - } - return false; -} - - -// ----------------------------------------------------------------------- - long TabControl::Notify( NotifyEvent& rNEvt ) { + long nRet = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + nRet = ImplHandleKeyEvent( *rNEvt.GetKeyEvent() ); - return ImplHandleNotifyEvent( rNEvt ) ? TRUE : Control::Notify( rNEvt ); + return nRet ? nRet : Control::Notify( rNEvt ); } // ----------------------------------------------------------------------- diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx index 39964f635c9c..9884e7016fee 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -391,11 +391,9 @@ public: // used by charstring converter void setCharStringType( int); void fakeLocalSubrCount( int nLocalSubrs ) { maCffLocal[0].mnLocalSubrCount=nLocalSubrs;} - void readCharString( const U8* pTypeOps, int nTypeLen); protected: int convert2Type1Ops( CffLocal*, const U8* pType2Ops, int nType2Len, U8* pType1Ops); private: - void readTypeOp( CffSubsetterContext&); void convertOneTypeOp( void); void convertOneTypeEsc( void); void callType2Subr( bool bGlobal, int nSubrNumber); @@ -431,7 +429,6 @@ private: int getGlyphSID( int nGlyphIndex) const; const char* getGlyphName( int nGlyphIndex); - void readTypeOp( void); void read2push( void); void pop2write( void); void writeType1Val( ValType); @@ -611,25 +608,6 @@ void CffSubsetterContext::setCharStringType( int nVal) // -------------------------------------------------------------------- -void CffSubsetterContext::readCharString( const U8* pTypeOps, int nTypeLen) -{ - mnStackIdx = 0; - mnHintSize = 0; - mnHorzHintSize = 0; - maCharWidth = -1; - - assert( nTypeLen >= 0); -// assert( nEnd <= getLength()); - mpReadPtr = pTypeOps; - mpReadEnd = mpReadPtr + nTypeLen; - // reset the execution context - while( mpReadPtr < mpReadEnd) - readTypeOp(); -//### assert( tellRel() == nEnd); -} - -// -------------------------------------------------------------------- - void CffSubsetterContext::readDictOp( void) { ValType nVal = 0; @@ -765,112 +743,6 @@ void CffSubsetterContext::readDictOp( void) // -------------------------------------------------------------------- -void CffSubsetterContext::readTypeOp( void) -{ - int nVal = 0; - const U8 c = *mpReadPtr; - if( (c <= 31) && (c != 28) ) { - const int nOpId = *(mpReadPtr++); - const char* pCmdName; - if( nOpId != 12) - pCmdName = mpCharStringOps[ nOpId]; - else { - const int nExtId = *(mpReadPtr++); - pCmdName = mpCharStringEscs[ nExtId]; - } - - if( !pCmdName ) - pCmdName = ".NULL"; - // handle typeop parameters - int nMinStack = -1, nMaxStack = -1; - switch( *pCmdName) { - default: fprintf( stderr, "unsupported TypeOp.type=\'%c\'\n", *pCmdName); break; - case '.': nMinStack = 0; nMaxStack = 999; break; - case '0': nMinStack = nMaxStack = 0; break; - case '1': nMinStack = nMaxStack = 1; break; - case '2': nMinStack = nMaxStack = 2; break; - case '4': nMinStack = nMaxStack = 4; break; - case '5': nMinStack = nMaxStack = 5; break; // not used for Type2 ops - case '6': nMinStack = nMaxStack = 6; break; - case '7': nMinStack = nMaxStack = 7; break; - case '9': nMinStack = nMaxStack = 9; break; - case 'f': nMinStack = nMaxStack = 11; break; - case 'F': nMinStack = nMaxStack = 13; break; - case 'A': nMinStack = 2; nMaxStack = 999; break; - case 'C': nMinStack = 6; nMaxStack = 999; break; - case 'E': nMinStack = 1; nMaxStack = 999; break; - case 'G': nMinStack = 1; nMaxStack = 999; // global subr - nVal = peekInt(); - // TODO global subr - break; - case 'L': // local subr - nMinStack = 1; nMaxStack = 999; - nVal = peekInt(); - // TODO local subr - break; - case 'I': // operands for "index" -#if 0 - nMinStack = nValStack[ nStackIdx-1]; - if( nMinStack < 0) nMinStack = 0; - nMinStack += 1; -#else - fprintf( stderr, "TODO: Iindex op\n"); -#endif - break; - case 'R': // operands for "rol" -#if 0 - nMinStack = nValStack[ nStackIdx-2]; -#else - fprintf( stderr, "TODO: Rrol op\n"); -#endif - case 'X': // operands for "return" - nMinStack = 0; - nMaxStack = /*### (!bInSubrs)? 0 :###*/999; - break; - case 'H': // "hstemhm" - case 'h': // "hstem" - addHints( false); - nMinStack = nMaxStack = 0; - break; - case 'V': // "vstemhm" - case 'v': // "vstem" - addHints( true); - nMinStack = nMaxStack = 0; - break; - case 'K': // "hintmask" or "cntrmask" - addHints( true); // implicit vstemhm - nMinStack = nMaxStack = 0; - break; - case 'e': // endchar - updateWidth( (size() >= 1) && (size() != 4)); - nMinStack = nMaxStack = 0; - if( size() == 4) - fprintf( stderr,"Deprecated SEAC-like endchar is not supported for CFF subsetting!\n"); // TODO: handle deprecated op - break; - case 'm': // hmoveto or vmoveto - updateWidth( size() > 1); - nMinStack = 1; - nMaxStack = nMinStack; - break; - case 'M': // rmoveto - updateWidth( size() > 2); - nMinStack = 2; - nMaxStack = nMinStack; - break; - } - - clear(); - return; - } - - if( (c >= 32) || (c == 28)) { -// --mpReadPtr; - read2push(); - } -} - -// -------------------------------------------------------------------- - void CffSubsetterContext::read2push() { ValType aVal = 0; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index a5b274bfd8e8..38402af626c2 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -811,7 +811,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const } else { - if(0x00 != aBitmapColor.GetIndex()) + if(0x00 == aBitmapColor.GetIndex()) { nTransparency = 0x00; } diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 895a98dfaf1a..630e58a1f2bf 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -68,6 +68,9 @@ #ifdef ENABLE_GRAPHITE #include <vcl/graphite_features.hxx> #endif +#ifdef USE_BUILTIN_RASTERIZER +#include <vcl/glyphcache.hxx> +#endif #include <vcl/unohelp.hxx> #include <pdfwriter_impl.hxx> @@ -995,21 +998,28 @@ ImplFontEntry::~ImplFontEntry() // ----------------------------------------------------------------------- -inline void ImplFontEntry::AddFallbackForUnicode( sal_UCS4 cChar, const String& rFontName ) +size_t ImplFontEntry::GFBCacheKey_Hash::operator()( const GFBCacheKey& rData ) const +{ + std::hash<sal_UCS4> a; + std::hash<int > b; + return a(rData.first) ^ b(rData.second); +} + +inline void ImplFontEntry::AddFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const String& rFontName ) { if( !mpUnicodeFallbackList ) mpUnicodeFallbackList = new UnicodeFallbackList; - (*mpUnicodeFallbackList)[cChar] = rFontName; + (*mpUnicodeFallbackList)[ GFBCacheKey(cChar,eWeight) ] = rFontName; } // ----------------------------------------------------------------------- -inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, String* pFontName ) const +inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, String* pFontName ) const { if( !mpUnicodeFallbackList ) return false; - UnicodeFallbackList::const_iterator it = mpUnicodeFallbackList->find( cChar ); + UnicodeFallbackList::const_iterator it = mpUnicodeFallbackList->find( GFBCacheKey(cChar,eWeight) ); if( it == mpUnicodeFallbackList->end() ) return false; @@ -1019,10 +1029,10 @@ inline bool ImplFontEntry::GetFallbackForUnicode( sal_UCS4 cChar, String* pFontN // ----------------------------------------------------------------------- -inline void ImplFontEntry::IgnoreFallbackForUnicode( sal_UCS4 cChar, const String& rFontName ) +inline void ImplFontEntry::IgnoreFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const String& rFontName ) { // DBG_ASSERT( mpUnicodeFallbackList, "ImplFontEntry::IgnoreFallbackForUnicode no list" ); - UnicodeFallbackList::iterator it = mpUnicodeFallbackList->find( cChar ); + UnicodeFallbackList::iterator it = mpUnicodeFallbackList->find( GFBCacheKey(cChar,eWeight) ); // DBG_ASSERT( it != mpUnicodeFallbackList->end(), "ImplFontEntry::IgnoreFallbackForUnicode no match" ); if( it == mpUnicodeFallbackList->end() ) return; @@ -1327,6 +1337,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const "muktinarrow", "", "phetsarathot", "", "padauk", "pinlonmyanmar", "", + "iskoolapota", "lklug", "", 0 }; @@ -1417,7 +1428,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData& while( nStrIndex < rMissingCodes.getLength() ) { cChar = rMissingCodes.iterateCodePoints( &nStrIndex ); - bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &rFontSelData.maSearchName ); + bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName ); // ignore entries which don't have a fallback if( !bCached || (rFontSelData.maSearchName.Len() != 0) ) break; @@ -1433,7 +1444,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData& while( nStrIndex < rMissingCodes.getLength() ) { cChar = rMissingCodes.iterateCodePoints( &nStrIndex ); - bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &aFontName ); + bCached = rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &aFontName ); if( !bCached || (rFontSelData.maSearchName != aFontName) ) pRemainingCodes[ nRemainingLength++ ] = cChar; } @@ -1452,8 +1463,8 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData& // cache the result even if there was no match for(;;) { - if( !rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, &rFontSelData.maSearchName ) ) - rFontSelData.mpFontEntry->AddFallbackForUnicode( cChar, rFontSelData.maSearchName ); + if( !rFontSelData.mpFontEntry->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName ) ) + rFontSelData.mpFontEntry->AddFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName ); if( nStrIndex >= aOldMissingCodes.getLength() ) break; cChar = aOldMissingCodes.iterateCodePoints( &nStrIndex ); @@ -1464,7 +1475,7 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData& for( nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); ) { cChar = rMissingCodes.iterateCodePoints( &nStrIndex ); - rFontSelData.mpFontEntry->IgnoreFallbackForUnicode( cChar, rFontSelData.maSearchName ); + rFontSelData.mpFontEntry->IgnoreFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName ); } } } @@ -2080,11 +2091,14 @@ ImplDevFontListData* ImplDevFontList::FindDefaultFont() const ImplDevFontList* ImplDevFontList::Clone( bool bScalable, bool bEmbeddable ) const { ImplDevFontList* pClonedList = new ImplDevFontList; - pClonedList->mbMatchData = mbMatchData; +// pClonedList->mbMatchData = mbMatchData; pClonedList->mbMapNames = mbMapNames; pClonedList->mpPreMatchHook = mpPreMatchHook; pClonedList->mpFallbackHook = mpFallbackHook; + // TODO: clone the config-font attributes too? + pClonedList->mbMatchData = false; + DevFontList::const_iterator it = maDevFontList.begin(); for(; it != maDevFontList.end(); ++it ) { @@ -2780,6 +2794,11 @@ void ImplFontCache::Invalidate() maFontInstanceList.clear(); DBG_ASSERT( (mnRef0Count==0), "ImplFontCache::Invalidate() - mnRef0Count non-zero" ); + +#ifdef USE_BUILTIN_RASTERIZER + // TODO: eventually move into SalGraphics layer + GlyphCache::GetInstance().InvalidateAllGlyphs(); +#endif } // ======================================================================= @@ -5893,15 +5912,16 @@ SalLayout* OutputDevice::ImplLayout( const String& rOrigStr, ImplInitFont(); // check string index and length - String aStr = rOrigStr; - if( (ULONG)nMinIndex + nLen >= aStr.Len() ) + if( (unsigned)nMinIndex + nLen > rOrigStr.Len() ) { - if( nMinIndex < aStr.Len() ) - nLen = aStr.Len() - nMinIndex; - else + const int nNewLen = (int)rOrigStr.Len() - nMinIndex; + if( nNewLen <= 0 ) return NULL; + nLen = static_cast<xub_StrLen>(nNewLen); } + String aStr = rOrigStr; + // filter out special markers if( bFilter ) { diff --git a/vcl/source/gdi/outmap.cxx b/vcl/source/gdi/outmap.cxx index 568e8d836045..189ba4c29e59 100644 --- a/vcl/source/gdi/outmap.cxx +++ b/vcl/source/gdi/outmap.cxx @@ -50,6 +50,7 @@ #include <vcl/outdev.h> #include <vcl/salgdi.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #define USE_64BIT_INTS @@ -1097,6 +1098,41 @@ basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation() const // ----------------------------------------------------------------------- +// #i75163# +basegfx::B2DHomMatrix OutputDevice::GetViewTransformation( const MapMode& rMapMode ) const +{ + // #i82615# + ImplMapRes aMapRes; + ImplThresholdRes aThresRes; + ImplCalcMapResolution( rMapMode, mnDPIX, mnDPIY, aMapRes, aThresRes ); + + basegfx::B2DHomMatrix aTransform; + + const double fScaleFactorX((double)mnDPIX * (double)aMapRes.mnMapScNumX / (double)aMapRes.mnMapScDenomX); + const double fScaleFactorY((double)mnDPIY * (double)aMapRes.mnMapScNumY / (double)aMapRes.mnMapScDenomY); + const double fZeroPointX(((double)aMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); + const double fZeroPointY(((double)aMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); + + aTransform.set(0, 0, fScaleFactorX); + aTransform.set(1, 1, fScaleFactorY); + aTransform.set(0, 2, fZeroPointX); + aTransform.set(1, 2, fZeroPointY); + + return aTransform; +} + +// ----------------------------------------------------------------------- + +// #i75163# +basegfx::B2DHomMatrix OutputDevice::GetInverseViewTransformation( const MapMode& rMapMode ) const +{ + basegfx::B2DHomMatrix aMatrix( GetViewTransformation( rMapMode ) ); + aMatrix.invert(); + return aMatrix; +} + +// ----------------------------------------------------------------------- + basegfx::B2DHomMatrix OutputDevice::ImplGetDeviceTransformation() const { basegfx::B2DHomMatrix aTransformation = GetViewTransformation(); @@ -1218,6 +1254,26 @@ PolyPolygon OutputDevice::LogicToPixel( const PolyPolygon& rLogicPolyPoly ) cons // ----------------------------------------------------------------------- +basegfx::B2DPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolygon& rLogicPoly ) const +{ + basegfx::B2DPolygon aTransformedPoly = rLogicPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation(); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + +basegfx::B2DPolyPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const +{ + basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation(); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + Region OutputDevice::LogicToPixel( const Region& rLogicRegion ) const { DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -1402,6 +1458,28 @@ PolyPolygon OutputDevice::LogicToPixel( const PolyPolygon& rLogicPolyPoly, // ----------------------------------------------------------------------- +basegfx::B2DPolyPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, + const MapMode& rMapMode ) const +{ + basegfx::B2DPolyPolygon aTransformedPoly = rLogicPolyPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode ); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + +basegfx::B2DPolygon OutputDevice::LogicToPixel( const basegfx::B2DPolygon& rLogicPoly, + const MapMode& rMapMode ) const +{ + basegfx::B2DPolygon aTransformedPoly = rLogicPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetViewTransformation( rMapMode ); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + Region OutputDevice::LogicToPixel( const Region& rLogicRegion, const MapMode& rMapMode ) const { @@ -1553,6 +1631,26 @@ PolyPolygon OutputDevice::PixelToLogic( const PolyPolygon& rDevicePolyPoly ) con // ----------------------------------------------------------------------- +basegfx::B2DPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolygon& rPixelPoly ) const +{ + basegfx::B2DPolygon aTransformedPoly = rPixelPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation(); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + +basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygon& rPixelPolyPoly ) const +{ + basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation(); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + Region OutputDevice::PixelToLogic( const Region& rDeviceRegion ) const { DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -1732,6 +1830,28 @@ PolyPolygon OutputDevice::PixelToLogic( const PolyPolygon& rDevicePolyPoly, // ----------------------------------------------------------------------- +basegfx::B2DPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolygon& rPixelPoly, + const MapMode& rMapMode ) const +{ + basegfx::B2DPolygon aTransformedPoly = rPixelPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode ); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + +basegfx::B2DPolyPolygon OutputDevice::PixelToLogic( const basegfx::B2DPolyPolygon& rPixelPolyPoly, + const MapMode& rMapMode ) const +{ + basegfx::B2DPolyPolygon aTransformedPoly = rPixelPolyPoly; + const ::basegfx::B2DHomMatrix& rTransformationMatrix = GetInverseViewTransformation( rMapMode ); + aTransformedPoly.transform( rTransformationMatrix ); + return aTransformedPoly; +} + +// ----------------------------------------------------------------------- + Region OutputDevice::PixelToLogic( const Region& rDeviceRegion, const MapMode& rMapMode ) const { @@ -2159,6 +2279,96 @@ Size OutputDevice::LogicToLogic( const Size& rSzSource, // ----------------------------------------------------------------------- +basegfx::B2DPolygon OutputDevice::LogicToLogic( const basegfx::B2DPolygon& rPolySource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ) +{ + if ( rMapModeSource == rMapModeDest ) + return rPolySource; + + MapUnit eUnitSource = rMapModeSource.GetMapUnit(); + MapUnit eUnitDest = rMapModeDest.GetMapUnit(); + ENTER2( eUnitSource, eUnitDest ); + + basegfx::B2DHomMatrix aTransform; + + if ( rMapModeSource.mpImplMapMode->mbSimple && + rMapModeDest.mpImplMapMode->mbSimple ) + { + ENTER3( eUnitSource, eUnitDest ); + + const double fScaleFactor((double)nNumerator / (double)nDenominator); + aTransform.set(0, 0, fScaleFactor); + aTransform.set(1, 1, fScaleFactor); + } + else + { + ENTER4( rMapModeSource, rMapModeDest ); + + const double fScaleFactorX( (double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) + / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)) ); + const double fScaleFactorY( (double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) + / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)) ); + const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX)); + const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY)); + + aTransform.set(0, 0, fScaleFactorX); + aTransform.set(1, 1, fScaleFactorY); + aTransform.set(0, 2, fZeroPointX); + aTransform.set(1, 2, fZeroPointY); + } + basegfx::B2DPolygon aPoly( rPolySource ); + aPoly.transform( aTransform ); + return aPoly; +} + +// ----------------------------------------------------------------------- + +basegfx::B2DPolyPolygon OutputDevice::LogicToLogic( const basegfx::B2DPolyPolygon& rPolySource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ) +{ + if ( rMapModeSource == rMapModeDest ) + return rPolySource; + + MapUnit eUnitSource = rMapModeSource.GetMapUnit(); + MapUnit eUnitDest = rMapModeDest.GetMapUnit(); + ENTER2( eUnitSource, eUnitDest ); + + basegfx::B2DHomMatrix aTransform; + + if ( rMapModeSource.mpImplMapMode->mbSimple && + rMapModeDest.mpImplMapMode->mbSimple ) + { + ENTER3( eUnitSource, eUnitDest ); + + const double fScaleFactor((double)nNumerator / (double)nDenominator); + aTransform.set(0, 0, fScaleFactor); + aTransform.set(1, 1, fScaleFactor); + } + else + { + ENTER4( rMapModeSource, rMapModeDest ); + + const double fScaleFactorX( (double(aMapResSource.mnMapScNumX) * double(aMapResDest.mnMapScDenomX)) + / (double(aMapResSource.mnMapScDenomX) * double(aMapResDest.mnMapScNumX)) ); + const double fScaleFactorY( (double(aMapResSource.mnMapScNumY) * double(aMapResDest.mnMapScDenomY)) + / (double(aMapResSource.mnMapScDenomY) * double(aMapResDest.mnMapScNumY)) ); + const double fZeroPointX(double(aMapResSource.mnMapOfsX) * fScaleFactorX - double(aMapResDest.mnMapOfsX)); + const double fZeroPointY(double(aMapResSource.mnMapOfsY) * fScaleFactorY - double(aMapResDest.mnMapOfsY)); + + aTransform.set(0, 0, fScaleFactorX); + aTransform.set(1, 1, fScaleFactorY); + aTransform.set(0, 2, fZeroPointX); + aTransform.set(1, 2, fZeroPointY); + } + basegfx::B2DPolyPolygon aPoly( rPolySource ); + aPoly.transform( aTransform ); + return aPoly; +} + +// ----------------------------------------------------------------------- + Rectangle OutputDevice::LogicToLogic( const Rectangle& rRectSource, const MapMode& rMapModeSource, const MapMode& rMapModeDest ) diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index fefe904e371a..046bc4a8951d 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -27,10 +27,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/pdfextoutdevdata.hxx> -#include <vcl/graph.hxx> -#include <vcl/outdev.hxx> -#include <vcl/gfxlink.hxx> +#include "vcl/pdfextoutdevdata.hxx" +#include "vcl/graph.hxx" +#include "vcl/outdev.hxx" +#include "vcl/gfxlink.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "basegfx/polygon/b2dpolygontools.hxx" #include <boost/shared_ptr.hpp> @@ -430,7 +432,10 @@ sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIM if ( bClippingNeeded ) { rWriter.Push(); - rWriter.SetClipRegion( aVisibleOutputRect ); + basegfx::B2DPolyPolygon aRect( basegfx::tools::createPolygonFromRect( + basegfx::B2DRectangle( aVisibleOutputRect.Left(), aVisibleOutputRect.Top(), + aVisibleOutputRect.Right(), aVisibleOutputRect.Bottom() ) ) ); + rWriter.SetClipRegion( aRect); } Bitmap aMask; SvMemoryStream aTmp; diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 040d38f538c9..5dcce25a0315 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -346,7 +346,7 @@ void PDFWriter::SetClipRegion() ((PDFWriterImpl*)pImplementation)->clearClipRegion(); } -void PDFWriter::SetClipRegion( const Region& rRegion ) +void PDFWriter::SetClipRegion( const basegfx::B2DPolyPolygon& rRegion ) { ((PDFWriterImpl*)pImplementation)->setClipRegion( rRegion ); } @@ -356,7 +356,7 @@ void PDFWriter::MoveClipRegion( long nHorzMove, long nVertMove ) ((PDFWriterImpl*)pImplementation)->moveClipRegion( nHorzMove, nVertMove ); } -void PDFWriter::IntersectClipRegion( const Region& rRegion ) +void PDFWriter::IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ) { ((PDFWriterImpl*)pImplementation)->intersectClipRegion( rRegion ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4371feb8ee37..6a24775219d9 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -37,6 +37,8 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygoncutter.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> #include <tools/zcodec.hxx> @@ -115,7 +117,7 @@ void doTestCode() aDocInfo.Title = OUString( RTL_CONSTASCII_USTRINGPARAM( "PDF export test document" ) ); aDocInfo.Producer = OUString( RTL_CONSTASCII_USTRINGPARAM( "VCL" ) ); aWriter.SetDocInfo( aDocInfo ); - aWriter.NewPage(); + aWriter.NewPage( 595, 842 ); aWriter.BeginStructureElement( PDFWriter::Document ); // set duration of 3 sec for first page aWriter.SetAutoAdvanceTime( 3 ); @@ -166,7 +168,7 @@ void doTestCode() TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); - aWriter.NewPage(); + aWriter.NewPage( 595, 842 ); // test AddStream interface aWriter.AddStream( String( RTL_CONSTASCII_USTRINGPARAM( "text/plain" ) ), new PDFTestOutputStream(), true ); // set transitional mode @@ -208,7 +210,25 @@ void doTestCode() aWriter.BeginStructureElement( PDFWriter::Caption ); aWriter.DrawText( Point( 4500, 9000 ), String( RTL_CONSTASCII_USTRINGPARAM( "Some drawing stuff inside the structure" ) ) ); aWriter.EndStructureElement(); + + // test clipping + basegfx::B2DPolyPolygon aClip; + basegfx::B2DPolygon aClipPoly; + aClipPoly.append( basegfx::B2DPoint( 8250, 9600 ) ); + aClipPoly.append( basegfx::B2DPoint( 16500, 11100 ) ); + aClipPoly.append( basegfx::B2DPoint( 8250, 12600 ) ); + aClipPoly.append( basegfx::B2DPoint( 4500, 11100 ) ); + aClipPoly.setClosed( true ); + //aClipPoly.flip(); + aClip.append( aClipPoly ); + + aWriter.Push( PUSH_CLIPREGION | PUSH_FILLCOLOR ); + aWriter.SetClipRegion( aClip ); + aWriter.DrawEllipse( Rectangle( Point( 4500, 9600 ), Size( 12000, 3000 ) ) ); + aWriter.MoveClipRegion( 1000, 500 ); + aWriter.SetFillColor( Color( COL_RED ) ); aWriter.DrawEllipse( Rectangle( Point( 4500, 9600 ), Size( 12000, 3000 ) ) ); + aWriter.Pop(); // test transparency // draw background Rectangle aTranspRect( Point( 7500, 13500 ), Size( 9000, 6000 ) ); @@ -288,7 +308,7 @@ void doTestCode() aLIPoly.Move( 1000, 1000 ); aWriter.DrawPolyLine( aLIPoly, aLI ); - aWriter.NewPage(); + aWriter.NewPage( 595, 842 ); aWriter.SetMapMode( MapMode( MAP_100TH_MM ) ); Wallpaper aWall( aTransMask ); aWall.SetStyle( WALLPAPER_TILE ); @@ -312,7 +332,7 @@ void doTestCode() aWriter.SetLineColor( Color( COL_LIGHTBLUE ) ); aWriter.DrawRect( aPolyRect ); - aWriter.NewPage(); + aWriter.NewPage( 595, 842 ); aWriter.SetMapMode( MapMode( MAP_100TH_MM ) ); aWriter.SetFont( Font( String( RTL_CONSTASCII_USTRINGPARAM( "Times" ) ), Size( 0, 500 ) ) ); aWriter.SetTextColor( Color( COL_BLACK ) ); @@ -632,30 +652,25 @@ static void appendUnicodeTextString( const rtl::OUString& rString, OStringBuffer } } -OString PDFWriterImpl::convertWidgetFieldName( const rtl::OUString& rString ) +void PDFWriterImpl::createWidgetFieldName( sal_Int32 i_nWidgetIndex, const PDFWriter::AnyWidget& i_rControl ) { - OStringBuffer aBuffer( rString.getLength()+64 ); - /* #i80258# previously we use appendName here however we need a slightly different coding scheme than the normal name encoding for field names - - also replace all '.' by '_' as '.' indicates a hierarchy level which - we do not have here */ - - OString aStr( OUStringToOString( rString, RTL_TEXTENCODING_UTF8 ) ); + const OUString& rName = (m_aContext.Version > PDFWriter::PDF_1_2) ? i_rControl.Name : i_rControl.Text; + OString aStr( OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ) ); const sal_Char* pStr = aStr.getStr(); int nLen = aStr.getLength(); + + OStringBuffer aBuffer( rName.getLength()+64 ); for( int i = 0; i < nLen; i++ ) { /* #i16920# PDF recommendation: output UTF8, any byte - * outside the interval [33(=ASCII'!');126(=ASCII'~')] + * outside the interval [32(=ASCII' ');126(=ASCII'~')] * should be escaped hexadecimal */ - if( pStr[i] == '.' ) - aBuffer.append( '_' ); - else if( (pStr[i] >= 33 && pStr[i] <= 126 ) ) + if( (pStr[i] >= 32 && pStr[i] <= 126 ) ) aBuffer.append( pStr[i] ); else { @@ -664,31 +679,135 @@ OString PDFWriterImpl::convertWidgetFieldName( const rtl::OUString& rString ) } } - OString aRet = aBuffer.makeStringAndClear(); + OString aFullName( aBuffer.makeStringAndClear() ); + + /* #i82785# create hierarchical fields down to the for each dot in i_rName */ + sal_Int32 nTokenIndex = 0, nLastTokenIndex = 0; + OString aPartialName; + OString aDomain; + do + { + nLastTokenIndex = nTokenIndex; + aPartialName = aFullName.getToken( 0, '.', nTokenIndex ); + if( nTokenIndex != -1 ) + { + // find or create a hierarchical field + // first find the fully qualified name up to this field + aDomain = aFullName.copy( 0, nTokenIndex-1 ); + std::hash_map< rtl::OString, sal_Int32, rtl::OStringHash >::const_iterator it = m_aFieldNameMap.find( aDomain ); + if( it == m_aFieldNameMap.end() ) + { + // create new hierarchy field + sal_Int32 nNewWidget = m_aWidgets.size(); + m_aWidgets.push_back( PDFWidget() ); + m_aWidgets[nNewWidget].m_nObject = createObject(); + m_aWidgets[nNewWidget].m_eType = PDFWriter::Hierarchy; + m_aWidgets[nNewWidget].m_aName = aPartialName; + m_aWidgets[i_nWidgetIndex].m_nParent = m_aWidgets[nNewWidget].m_nObject; + m_aFieldNameMap[aDomain] = nNewWidget; + m_aWidgets[i_nWidgetIndex].m_nParent = m_aWidgets[nNewWidget].m_nObject; + if( nLastTokenIndex > 0 ) + { + // this field is not a root field and + // needs to be inserted to its parent + OString aParentDomain( aDomain.copy( 0, nLastTokenIndex-1 ) ); + it = m_aFieldNameMap.find( aParentDomain ); + OSL_ENSURE( it != m_aFieldNameMap.end(), "field name not found" ); + if( it != m_aFieldNameMap.end() ) + { + OSL_ENSURE( it->second < sal_Int32(m_aWidgets.size()), "invalid field number entry" ); + if( it->second < sal_Int32(m_aWidgets.size()) ) + { + PDFWidget& rParentField( m_aWidgets[it->second] ); + rParentField.m_aKids.push_back( m_aWidgets[nNewWidget].m_nObject ); + rParentField.m_aKidsIndex.push_back( nNewWidget ); + m_aWidgets[nNewWidget].m_nParent = rParentField.m_nObject; + } + } + } + } + else if( m_aWidgets[it->second].m_eType != PDFWriter::Hierarchy ) + { + // this is invalid, someone tries to have a terminal field as parent + // example: a button with the name foo.bar exists and + // another button is named foo.bar.no + // workaround: put the second terminal field as much up in the hierarchy as + // necessary to have a non-terminal field as parent (or none at all) + // since it->second already is terminal, we just need to use its parent + aDomain = OString(); + aPartialName = aFullName.copy( aFullName.lastIndexOf( '.' )+1 ); + if( nLastTokenIndex > 0 ) + { + aDomain = aFullName.copy( 0, nLastTokenIndex-1 ); + OStringBuffer aBuf( aDomain.getLength() + 1 + aPartialName.getLength() ); + aBuf.append( aDomain ); + aBuf.append( '.' ); + aBuf.append( aPartialName ); + aFullName = aBuf.makeStringAndClear(); + } + else + aFullName = aPartialName; + break; + } + } + } while( nTokenIndex != -1 ); + + // insert widget into its hierarchy field + if( aDomain.getLength() ) + { + std::hash_map< rtl::OString, sal_Int32, rtl::OStringHash >::const_iterator it = m_aFieldNameMap.find( aDomain ); + if( it != m_aFieldNameMap.end() ) + { + OSL_ENSURE( it->second >= 0 && it->second < sal_Int32( m_aWidgets.size() ), "invalid field index" ); + if( it->second >= 0 && it->second < sal_Int32(m_aWidgets.size()) ) + { + m_aWidgets[i_nWidgetIndex].m_nParent = m_aWidgets[it->second].m_nObject; + m_aWidgets[it->second].m_aKids.push_back( m_aWidgets[i_nWidgetIndex].m_nObject); + m_aWidgets[it->second].m_aKidsIndex.push_back( i_nWidgetIndex ); + } + } + } + + if( aPartialName.getLength() == 0 ) + { + // how funny, an empty field name + if( i_rControl.getType() == PDFWriter::RadioButton ) + { + aPartialName = "RadioGroup"; + aPartialName += OString::valueOf( static_cast<const PDFWriter::RadioButtonWidget&>(i_rControl).RadioGroup ); + } + else + aPartialName = OString( "Widget" ); + } + if( ! m_aContext.AllowDuplicateFieldNames ) { - std::hash_map<OString, sal_Int32, OStringHash>::iterator it = m_aFieldNameMap.find( aRet ); + std::hash_map<OString, sal_Int32, OStringHash>::iterator it = m_aFieldNameMap.find( aFullName ); if( it != m_aFieldNameMap.end() ) // not unique { std::hash_map< OString, sal_Int32, OStringHash >::const_iterator check_it; OString aTry; + sal_Int32 nTry = 2; do { - OStringBuffer aUnique( aRet.getLength() + 16 ); - aUnique.append( aRet ); + OStringBuffer aUnique( aFullName.getLength() + 16 ); + aUnique.append( aFullName ); aUnique.append( '_' ); - aUnique.append( it->second ); - it->second++; + aUnique.append( nTry++ ); aTry = aUnique.makeStringAndClear(); check_it = m_aFieldNameMap.find( aTry ); } while( check_it != m_aFieldNameMap.end() ); - aRet = aTry; + aFullName = aTry; + m_aFieldNameMap[ aFullName ] = i_nWidgetIndex; + aPartialName = aFullName.copy( aFullName.lastIndexOf( '.' )+1 ); } else - m_aFieldNameMap[ aRet ] = 2; + m_aFieldNameMap[ aFullName ] = i_nWidgetIndex; } - return aRet; + + // finally + m_aWidgets[i_nWidgetIndex].m_aName = aPartialName; } static void appendFixedInt( sal_Int32 nValue, OStringBuffer& rBuffer, sal_Int32 nPrecision = nLog10Divisor ) @@ -720,7 +839,7 @@ static void appendFixedInt( sal_Int32 nValue, OStringBuffer& rBuffer, sal_Int32 // appends a double. PDF does not accept exponential format, only fixed point -static void appendDouble( double fValue, OStringBuffer& rBuffer, int nPrecision = 5 ) +static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrecision = 5 ) { bool bNeg = false; if( fValue < 0.0 ) @@ -1273,6 +1392,19 @@ void PDFWriterImpl::PDFPage::appendPoint( const Point& rPoint, OStringBuffer& rB appendFixedInt( nValue, rBuffer ); } +void PDFWriterImpl::PDFPage::appendPixelPoint( const basegfx::B2DPoint& rPoint, OStringBuffer& rBuffer ) const +{ + double fValue = pixelToPoint(rPoint.getX()); + + appendDouble( fValue, rBuffer, nLog10Divisor ); + + rBuffer.append( ' ' ); + + fValue = double(getHeight()) - pixelToPoint(rPoint.getY()); + + appendDouble( fValue, rBuffer, nLog10Divisor ); +} + void PDFWriterImpl::PDFPage::appendRect( const Rectangle& rRect, OStringBuffer& rBuffer ) const { appendPoint( rRect.BottomLeft() + Point( 0, 1 ), rBuffer ); @@ -1345,6 +1477,82 @@ void PDFWriterImpl::PDFPage::appendPolygon( const Polygon& rPoly, OStringBuffer& } } +void PDFWriterImpl::PDFPage::appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rBuffer, bool bClose ) const +{ + basegfx::B2DPolygon aPoly( lcl_convert( m_pWriter->m_aGraphicsStack.front().m_aMapMode, + m_pWriter->m_aMapMode, + m_pWriter->getReferenceDevice(), + rPoly ) ); + + if( basegfx::tools::isRectangle( aPoly ) ) + { + basegfx::B2DRange aRange( aPoly.getB2DRange() ); + basegfx::B2DPoint aBL( aRange.getMinX(), aRange.getMaxY() ); + appendPixelPoint( aBL, rBuffer ); + rBuffer.append( ' ' ); + appendMappedLength( aRange.getWidth(), rBuffer, false, NULL, nLog10Divisor ); + rBuffer.append( ' ' ); + appendMappedLength( aRange.getHeight(), rBuffer, true, NULL, nLog10Divisor ); + rBuffer.append( " re\n" ); + return; + } + sal_uInt32 nPoints = aPoly.count(); + if( nPoints > 0 ) + { + sal_uInt32 nBufLen = rBuffer.getLength(); + basegfx::B2DPoint aLastPoint( aPoly.getB2DPoint( 0 ) ); + appendPixelPoint( aLastPoint, rBuffer ); + rBuffer.append( " m\n" ); + for( sal_uInt32 i = 1; i <= nPoints; i++ ) + { + if( i != nPoints || aPoly.isClosed() ) + { + sal_uInt32 nCurPoint = i % nPoints; + sal_uInt32 nLastPoint = i-1; + basegfx::B2DPoint aPoint( aPoly.getB2DPoint( nCurPoint ) ); + if( aPoly.isNextControlPointUsed( nLastPoint ) && + aPoly.isPrevControlPointUsed( nCurPoint ) ) + { + appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " c" ); + } + else if( aPoly.isNextControlPointUsed( nLastPoint ) ) + { + appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " y" ); + } + else if( aPoly.isPrevControlPointUsed( nCurPoint ) ) + { + appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " v" ); + } + else + { + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " l" ); + } + if( (rBuffer.getLength() - nBufLen) > 65 ) + { + rBuffer.append( "\n" ); + nBufLen = rBuffer.getLength(); + } + else + rBuffer.append( " " ); + } + } + if( bClose ) + rBuffer.append( "h\n" ); + } +} + void PDFWriterImpl::PDFPage::appendPolyPolygon( const PolyPolygon& rPolyPoly, OStringBuffer& rBuffer, bool bClose ) const { USHORT nPolygons = rPolyPoly.Count(); @@ -1352,6 +1560,13 @@ void PDFWriterImpl::PDFPage::appendPolyPolygon( const PolyPolygon& rPolyPoly, OS appendPolygon( rPolyPoly[n], rBuffer, bClose ); } +void PDFWriterImpl::PDFPage::appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, OStringBuffer& rBuffer, bool bClose ) const +{ + sal_uInt32 nPolygons = rPolyPoly.count(); + for( sal_uInt32 n = 0; n < nPolygons; n++ ) + appendPolygon( rPolyPoly.getB2DPolygon( n ), rBuffer, bClose ); +} + void PDFWriterImpl::PDFPage::appendMappedLength( sal_Int32 nLength, OStringBuffer& rBuffer, bool bVertical, sal_Int32* pOutLength ) const { sal_Int32 nValue = nLength; @@ -1371,7 +1586,7 @@ void PDFWriterImpl::PDFPage::appendMappedLength( sal_Int32 nLength, OStringBuffe appendFixedInt( nValue, rBuffer, 1 ); } -void PDFWriterImpl::PDFPage::appendMappedLength( double fLength, OStringBuffer& rBuffer, bool bVertical, sal_Int32* pOutLength ) const +void PDFWriterImpl::PDFPage::appendMappedLength( double fLength, OStringBuffer& rBuffer, bool bVertical, sal_Int32* pOutLength, sal_Int32 nPrecision ) const { Size aSize( lcl_convert( m_pWriter->m_aGraphicsStack.front().m_aMapMode, m_pWriter->m_aMapMode, @@ -1380,7 +1595,7 @@ void PDFWriterImpl::PDFPage::appendMappedLength( double fLength, OStringBuffer& if( pOutLength ) *pOutLength = (sal_Int32)(fLength*(double)(bVertical ? aSize.Height() : aSize.Width())/1000.0); fLength *= pixelToPoint((double)(bVertical ? aSize.Height() : aSize.Width()) / 1000.0); - appendDouble( fLength, rBuffer ); + appendDouble( fLength, rBuffer, nPrecision ); } bool PDFWriterImpl::PDFPage::appendLineInfo( const LineInfo& rInfo, OStringBuffer& rBuffer ) const @@ -5189,78 +5404,82 @@ bool PDFWriterImpl::emitWidgetAnnotations() aLine.append( rWidget.m_nObject ); aLine.append( " 0 obj\n" "<<" ); - // emit widget annotation only for terminal fields - if( rWidget.m_aKids.empty() ) - { - aLine.append( "/Type/Annot/Subtype/Widget/F 4\n" - "/Rect[" ); - appendFixedInt( rWidget.m_aRect.Left()-1, aLine ); - aLine.append( ' ' ); - appendFixedInt( rWidget.m_aRect.Top()+1, aLine ); - aLine.append( ' ' ); - appendFixedInt( rWidget.m_aRect.Right()+1, aLine ); - aLine.append( ' ' ); - appendFixedInt( rWidget.m_aRect.Bottom()-1, aLine ); - aLine.append( "]\n" ); - } - aLine.append( "/FT/" ); - switch( rWidget.m_eType ) + if( rWidget.m_eType != PDFWriter::Hierarchy ) { - case PDFWriter::RadioButton: - case PDFWriter::CheckBox: - // for radio buttons only the RadioButton field, not the - // CheckBox children should have a value, else acrobat reader - // does not always check the right button - // of course real check boxes (not belonging to a readio group) - // need their values, too - if( rWidget.m_eType == PDFWriter::RadioButton || rWidget.m_nRadioGroup < 0 ) - { - aValue.append( "/" ); - // check for radio group with all buttons unpressed - if( rWidget.m_aValue.getLength() == 0 ) - aValue.append( "Off" ); - else - appendName( rWidget.m_aValue, aValue ); - } - case PDFWriter::PushButton: - aLine.append( "Btn" ); - break; - case PDFWriter::ListBox: - if( rWidget.m_nFlags & 0x200000 ) // multiselect - { - aValue.append( "[" ); - for( unsigned int i = 0; i < rWidget.m_aSelectedEntries.size(); i++ ) + // emit widget annotation only for terminal fields + if( rWidget.m_aKids.empty() ) + { + aLine.append( "/Type/Annot/Subtype/Widget/F 4\n" + "/Rect[" ); + appendFixedInt( rWidget.m_aRect.Left()-1, aLine ); + aLine.append( ' ' ); + appendFixedInt( rWidget.m_aRect.Top()+1, aLine ); + aLine.append( ' ' ); + appendFixedInt( rWidget.m_aRect.Right()+1, aLine ); + aLine.append( ' ' ); + appendFixedInt( rWidget.m_aRect.Bottom()-1, aLine ); + aLine.append( "]\n" ); + } + aLine.append( "/FT/" ); + switch( rWidget.m_eType ) + { + case PDFWriter::RadioButton: + case PDFWriter::CheckBox: + // for radio buttons only the RadioButton field, not the + // CheckBox children should have a value, else acrobat reader + // does not always check the right button + // of course real check boxes (not belonging to a readio group) + // need their values, too + if( rWidget.m_eType == PDFWriter::RadioButton || rWidget.m_nRadioGroup < 0 ) { - sal_Int32 nEntry = rWidget.m_aSelectedEntries[i]; - if( nEntry >= 0 && nEntry < sal_Int32(rWidget.m_aListEntries.size()) ) - appendUnicodeTextStringEncrypt( rWidget.m_aListEntries[ nEntry ], rWidget.m_nObject, aValue ); + aValue.append( "/" ); + // check for radio group with all buttons unpressed + if( rWidget.m_aValue.getLength() == 0 ) + aValue.append( "Off" ); + else + appendName( rWidget.m_aValue, aValue ); } - aValue.append( "]" ); - } - else if( rWidget.m_aSelectedEntries.size() > 0 && - rWidget.m_aSelectedEntries[0] >= 0 && - rWidget.m_aSelectedEntries[0] < sal_Int32(rWidget.m_aListEntries.size()) ) - { - appendUnicodeTextStringEncrypt( rWidget.m_aListEntries[ rWidget.m_aSelectedEntries[0] ], rWidget.m_nObject, aValue ); - } - else - appendUnicodeTextStringEncrypt( rtl::OUString(), rWidget.m_nObject, aValue ); - aLine.append( "Ch" ); - break; - case PDFWriter::ComboBox: - appendUnicodeTextStringEncrypt( rWidget.m_aValue, rWidget.m_nObject, aValue ); - aLine.append( "Ch" ); - break; - case PDFWriter::Edit: - aLine.append( "Tx" ); - appendUnicodeTextStringEncrypt( rWidget.m_aValue, rWidget.m_nObject, aValue ); - break; + case PDFWriter::PushButton: + aLine.append( "Btn" ); + break; + case PDFWriter::ListBox: + if( rWidget.m_nFlags & 0x200000 ) // multiselect + { + aValue.append( "[" ); + for( unsigned int i = 0; i < rWidget.m_aSelectedEntries.size(); i++ ) + { + sal_Int32 nEntry = rWidget.m_aSelectedEntries[i]; + if( nEntry >= 0 && nEntry < sal_Int32(rWidget.m_aListEntries.size()) ) + appendUnicodeTextStringEncrypt( rWidget.m_aListEntries[ nEntry ], rWidget.m_nObject, aValue ); + } + aValue.append( "]" ); + } + else if( rWidget.m_aSelectedEntries.size() > 0 && + rWidget.m_aSelectedEntries[0] >= 0 && + rWidget.m_aSelectedEntries[0] < sal_Int32(rWidget.m_aListEntries.size()) ) + { + appendUnicodeTextStringEncrypt( rWidget.m_aListEntries[ rWidget.m_aSelectedEntries[0] ], rWidget.m_nObject, aValue ); + } + else + appendUnicodeTextStringEncrypt( rtl::OUString(), rWidget.m_nObject, aValue ); + aLine.append( "Ch" ); + break; + case PDFWriter::ComboBox: + appendUnicodeTextStringEncrypt( rWidget.m_aValue, rWidget.m_nObject, aValue ); + aLine.append( "Ch" ); + break; + case PDFWriter::Edit: + aLine.append( "Tx" ); + appendUnicodeTextStringEncrypt( rWidget.m_aValue, rWidget.m_nObject, aValue ); + break; + case PDFWriter::Hierarchy: // make the compiler happy + break; + } + aLine.append( "\n" ); + aLine.append( "/P " ); + aLine.append( m_aPages[ rWidget.m_nPage ].m_nPageObject ); + aLine.append( " 0 R\n" ); } - aLine.append( "\n" ); - aLine.append( "/P " ); - aLine.append( m_aPages[ rWidget.m_nPage ].m_nPageObject ); - aLine.append( " 0 R\n" ); - if( rWidget.m_nParent ) { aLine.append( "/Parent " ); @@ -5284,7 +5503,7 @@ bool PDFWriterImpl::emitWidgetAnnotations() appendLiteralStringEncrypt( rWidget.m_aName, rWidget.m_nObject, aLine ); aLine.append( "\n" ); } - if( m_aContext.Version > PDFWriter::PDF_1_2 ) + if( m_aContext.Version > PDFWriter::PDF_1_2 && rWidget.m_aDescription.getLength() ) { // the alternate field name should be unicode able since it is // supposed to be used in UI @@ -5346,7 +5565,7 @@ bool PDFWriterImpl::emitWidgetAnnotations() if(!m_bIsPDF_A1) { OStringBuffer aDest; - if( appendDest( rWidget.m_nDest, aDest ) ) + if( rWidget.m_nDest != -1 && appendDest( rWidget.m_nDest, aDest ) ) { aLine.append( "/AA<</D<</Type/Action/S/GoTo/D " ); aLine.append( aDest.makeStringAndClear() ); @@ -6379,16 +6598,19 @@ void PDFWriterImpl::sortWidgets() for( int nW = 0; nW < nWidgets; nW++ ) { const PDFWidget& rWidget = m_aWidgets[nW]; - AnnotSortContainer& rCont = sorted[ rWidget.m_nPage ]; - // optimize vector allocation - if( rCont.aSortedAnnots.empty() ) - rCont.aSortedAnnots.reserve( m_aPages[ rWidget.m_nPage ].m_aAnnotations.size() ); - // insert widget to tab sorter - // RadioButtons are not page annotations, only their individual check boxes are - if( rWidget.m_eType != PDFWriter::RadioButton ) - { - rCont.aObjects.insert( rWidget.m_nObject ); - rCont.aSortedAnnots.push_back( AnnotationSortEntry( rWidget.m_nTabOrder, rWidget.m_nObject, nW ) ); + if( rWidget.m_nPage >= 0 ) + { + AnnotSortContainer& rCont = sorted[ rWidget.m_nPage ]; + // optimize vector allocation + if( rCont.aSortedAnnots.empty() ) + rCont.aSortedAnnots.reserve( m_aPages[ rWidget.m_nPage ].m_aAnnotations.size() ); + // insert widget to tab sorter + // RadioButtons are not page annotations, only their individual check boxes are + if( rWidget.m_eType != PDFWriter::RadioButton ) + { + rCont.aObjects.insert( rWidget.m_nObject ); + rCont.aSortedAnnots.push_back( AnnotationSortEntry( rWidget.m_nTabOrder, rWidget.m_nObject, nW ) ); + } } } for( std::hash_map< sal_Int32, AnnotSortContainer >::iterator it = sorted.begin(); it != sorted.end(); ++it ) @@ -8278,7 +8500,7 @@ void PDFWriterImpl::beginRedirect( SvStream* pStream, const Rectangle& rTargetRe { push( PUSH_ALL ); - setClipRegion( Region() ); + clearClipRegion(); updateGraphicsState(); m_aOutputStreams.push_front( StreamRedirect() ); @@ -10214,25 +10436,17 @@ void PDFWriterImpl::updateGraphicsState() { rNewState.m_nUpdateFlags &= ~GraphicsState::updateClipRegion; - Region& rNewClip = rNewState.m_aClipRegion; - - /* #103137# equality operator is not implemented - * const as API promises but may change Region - * from Polygon to rectangles. Arrrgghh !!!! - */ - Region aLeft = m_aCurrentPDFState.m_aClipRegion; - Region aRight = rNewClip; - if( aLeft != aRight ) + if( m_aCurrentPDFState.m_bClipRegion != rNewState.m_bClipRegion || + ( rNewState.m_bClipRegion && m_aCurrentPDFState.m_aClipRegion != rNewState.m_aClipRegion ) ) { - if( ! m_aCurrentPDFState.m_aClipRegion.IsEmpty() && - ! m_aCurrentPDFState.m_aClipRegion.IsNull() ) + if( m_aCurrentPDFState.m_bClipRegion && m_aCurrentPDFState.m_aClipRegion.count() ) { aLine.append( "Q " ); // invalidate everything but the clip region m_aCurrentPDFState = GraphicsState(); rNewState.m_nUpdateFlags = sal::static_int_cast<sal_uInt16>(~GraphicsState::updateClipRegion); } - if( ! rNewClip.IsEmpty() && ! rNewClip.IsNull() ) + if( rNewState.m_bClipRegion && rNewState.m_aClipRegion.count() ) { // clip region is always stored in private PDF mapmode MapMode aNewMapMode = rNewState.m_aMapMode; @@ -10241,32 +10455,8 @@ void PDFWriterImpl::updateGraphicsState() m_aCurrentPDFState.m_aMapMode = rNewState.m_aMapMode; aLine.append( "q " ); - if( rNewClip.HasPolyPolygon() ) - { - m_aPages.back().appendPolyPolygon( rNewClip.GetPolyPolygon(), aLine ); - aLine.append( "W* n\n" ); - } - else - { - // need to clip all rectangles - RegionHandle aHandle = rNewClip.BeginEnumRects(); - Rectangle aRect; - while( rNewClip.GetNextEnumRect( aHandle, aRect ) ) - { - m_aPages.back().appendRect( aRect, aLine ); - if( aLine.getLength() > 80 ) - { - aLine.append( "\n" ); - writeBuffer( aLine.getStr(), aLine.getLength() ); - aLine.setLength( 0 ); - } - else - aLine.append( ' ' ); - } - rNewClip.EndEnumRects( aHandle ); - aLine.append( "W* n\n" ); - } - + m_aPages.back().appendPolyPolygon( rNewState.m_aClipRegion, aLine ); + aLine.append( "W* n\n" ); rNewState.m_aMapMode = aNewMapMode; getReferenceDevice()->SetMapMode( rNewState.m_aMapMode ); m_aCurrentPDFState.m_aMapMode = rNewState.m_aMapMode; @@ -10380,9 +10570,12 @@ void PDFWriterImpl::pop() if( ! (aState.m_nFlags & PUSH_MAPMODE) ) setMapMode( aState.m_aMapMode ); if( ! (aState.m_nFlags & PUSH_CLIPREGION) ) + { // do not use setClipRegion here // it would convert again assuming the current mapmode rOld.m_aClipRegion = aState.m_aClipRegion; + rOld.m_bClipRegion = aState.m_bClipRegion; + } if( ! (aState.m_nFlags & PUSH_TEXTLINECOLOR ) ) setTextLineColor( aState.m_aTextLineColor ); if( ! (aState.m_nFlags & PUSH_OVERLINECOLOR ) ) @@ -10406,45 +10599,59 @@ void PDFWriterImpl::setMapMode( const MapMode& rMapMode ) m_aCurrentPDFState.m_aMapMode = rMapMode; } -void PDFWriterImpl::setClipRegion( const Region& rRegion ) +void PDFWriterImpl::setClipRegion( const basegfx::B2DPolyPolygon& rRegion ) { - Region aRegion = getReferenceDevice()->LogicToPixel( rRegion, m_aGraphicsStack.front().m_aMapMode ); + basegfx::B2DPolyPolygon aRegion = getReferenceDevice()->LogicToPixel( rRegion, m_aGraphicsStack.front().m_aMapMode ); aRegion = getReferenceDevice()->PixelToLogic( aRegion, m_aMapMode ); m_aGraphicsStack.front().m_aClipRegion = aRegion; + m_aGraphicsStack.front().m_bClipRegion = true; m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; } void PDFWriterImpl::moveClipRegion( sal_Int32 nX, sal_Int32 nY ) { - Point aPoint( lcl_convert( m_aGraphicsStack.front().m_aMapMode, + if( m_aGraphicsStack.front().m_bClipRegion && m_aGraphicsStack.front().m_aClipRegion.count() ) + { + Point aPoint( lcl_convert( m_aGraphicsStack.front().m_aMapMode, + m_aMapMode, + getReferenceDevice(), + Point( nX, nY ) ) ); + aPoint -= lcl_convert( m_aGraphicsStack.front().m_aMapMode, m_aMapMode, getReferenceDevice(), - Point( nX, nY ) ) ); - aPoint -= lcl_convert( m_aGraphicsStack.front().m_aMapMode, - m_aMapMode, - getReferenceDevice(), - Point() ); - m_aGraphicsStack.front().m_aClipRegion.Move( aPoint.X(), aPoint.Y() ); - m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; + Point() ); + basegfx::B2DHomMatrix aMat; + aMat.translate( aPoint.X(), aPoint.Y() ); + m_aGraphicsStack.front().m_aClipRegion.transform( aMat ); + m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; + } } bool PDFWriterImpl::intersectClipRegion( const Rectangle& rRect ) { - Rectangle aRect( lcl_convert( m_aGraphicsStack.front().m_aMapMode, - m_aMapMode, - getReferenceDevice(), - rRect ) ); - m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; - return m_aGraphicsStack.front().m_aClipRegion.Intersect( aRect ); + basegfx::B2DPolyPolygon aRect( basegfx::tools::createPolygonFromRect( + basegfx::B2DRectangle( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() ) ) ); + return intersectClipRegion( aRect ); } -bool PDFWriterImpl::intersectClipRegion( const Region& rRegion ) +bool PDFWriterImpl::intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ) { - Region aRegion = getReferenceDevice()->LogicToPixel( rRegion, m_aGraphicsStack.front().m_aMapMode ); + basegfx::B2DPolyPolygon aRegion( getReferenceDevice()->LogicToPixel( rRegion, m_aGraphicsStack.front().m_aMapMode ) ); aRegion = getReferenceDevice()->PixelToLogic( aRegion, m_aMapMode ); m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; - return m_aGraphicsStack.front().m_aClipRegion.Intersect( aRegion ); + if( m_aGraphicsStack.front().m_bClipRegion ) + { + basegfx::B2DPolyPolygon aOld( basegfx::tools::prepareForPolygonOperation( m_aGraphicsStack.front().m_aClipRegion ) ); + aRegion = basegfx::tools::prepareForPolygonOperation( aRegion ); + m_aGraphicsStack.front().m_aClipRegion = basegfx::tools::solvePolygonOperationAnd( aOld, aRegion ); + } + else + { + m_aGraphicsStack.front().m_aClipRegion = aRegion; + m_aGraphicsStack.front().m_bClipRegion = true; + } + return true; } void PDFWriterImpl::createNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr ) @@ -11528,18 +11735,7 @@ sal_Int32 PDFWriterImpl::findRadioGroupWidget( const PDFWriter::RadioButtonWidge m_aWidgets.back().m_nRadioGroup = rBtn.RadioGroup; m_aWidgets.back().m_nFlags |= 0x00008000; - // create radio button field name - const rtl::OUString& rName = (m_aContext.Version > PDFWriter::PDF_1_2) ? - rBtn.Name : rBtn.Text; - if( rName.getLength() ) - { - m_aWidgets.back().m_aName = convertWidgetFieldName( rName ); - } - else - { - m_aWidgets.back().m_aName = "RadioGroup"; - m_aWidgets.back().m_aName += OString::valueOf( rBtn.RadioGroup ); - } + createWidgetFieldName( sal_Int32(m_aWidgets.size()-1), rBtn ); } else nRadioGroupWidget = it->second; @@ -11555,44 +11751,27 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) return -1; + sal_Int32 nNewWidget = m_aWidgets.size(); m_aWidgets.push_back( PDFWidget() ); - sal_Int32 nNewWidget = m_aWidgets.size()-1; - - // create eventual radio button before getting any references - // from m_aWidgets as the push_back operation potentially assigns new - // memory to the vector and thereby invalidates the reference - int nRadioGroupWidget = -1; - if( rControl.getType() == PDFWriter::RadioButton ) - nRadioGroupWidget = findRadioGroupWidget( static_cast<const PDFWriter::RadioButtonWidget&>(rControl) ); - PDFWidget& rNewWidget = m_aWidgets[nNewWidget]; - rNewWidget.m_nObject = createObject(); - rNewWidget.m_aRect = rControl.Location; - rNewWidget.m_nPage = nPageNr; - rNewWidget.m_eType = rControl.getType(); + m_aWidgets.back().m_nObject = createObject(); + m_aWidgets.back().m_aRect = rControl.Location; + m_aWidgets.back().m_nPage = nPageNr; + m_aWidgets.back().m_eType = rControl.getType(); + sal_Int32 nRadioGroupWidget = -1; // for unknown reasons the radio buttons of a radio group must not have a // field name, else the buttons are in fact check boxes - // that is multiple buttons of the radio group can be selected - if( rControl.getType() != PDFWriter::RadioButton ) + if( rControl.getType() == PDFWriter::RadioButton ) + nRadioGroupWidget = findRadioGroupWidget( static_cast<const PDFWriter::RadioButtonWidget&>(rControl) ); + else { - // acrobat reader since 3.0 does not support unicode text - // strings for the field name; so we need to encode unicodes - // larger than 255 - - rNewWidget.m_aName = - convertWidgetFieldName( (m_aContext.Version > PDFWriter::PDF_1_2) ? - rControl.Name : rControl.Text ); - // #i88040# acrobat reader crashes on empty field names, - // so always create one - if( rNewWidget.m_aName.getLength() == 0 ) - { - OUStringBuffer aBuf( 32 ); - aBuf.appendAscii( "Widget" ); - aBuf.append( nNewWidget ); - rNewWidget.m_aName = convertWidgetFieldName( aBuf.makeStringAndClear() ); - } + createWidgetFieldName( nNewWidget, rControl ); } + + // caution: m_aWidgets must not be changed after here or rNewWidget may be invalid + PDFWidget& rNewWidget = m_aWidgets[nNewWidget]; rNewWidget.m_aDescription = rControl.Description; rNewWidget.m_aText = rControl.Text; rNewWidget.m_nTextStyle = rControl.TextStyle & @@ -11823,6 +12002,7 @@ bool PDFWriterImpl::endControlAppearance( PDFWriter::WidgetState eState ) break; case PDFWriter::ListBox: case PDFWriter::ComboBox: + case PDFWriter::Hierarchy: break; } if( aState.getLength() && aStyle.getLength() ) diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 4adf54ea98a3..2eacdc215dd8 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -146,14 +146,20 @@ public: // if pOutPoint is set it will be updated to the emitted point // (in PDF map mode, that is 10th of point) void appendPoint( const Point& rPoint, rtl::OStringBuffer& rBuffer, bool bNeg = false, Point* pOutPoint = NULL ) const; + // appends a B2DPoint without further transformation + void appendPixelPoint( const basegfx::B2DPoint& rPoint, rtl::OStringBuffer& rBuffer ) const; // appends a rectangle void appendRect( const Rectangle& rRect, rtl::OStringBuffer& rBuffer ) const; // converts a rectangle to 10th points page space void convertRect( Rectangle& rRect ) const; // appends a polygon optionally closing it void appendPolygon( const Polygon& rPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const; + // appends a polygon optionally closing it + void appendPolygon( const basegfx::B2DPolygon& rPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const; // appends a polypolygon optionally closing the subpaths void appendPolyPolygon( const PolyPolygon& rPolyPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const; + // appends a polypolygon optionally closing the subpaths + void appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const; // converts a length (either vertical or horizontal; this // can be important if the source MapMode is not // symmetrical) to page length and appends it to the buffer @@ -161,7 +167,7 @@ public: // (in PDF map mode, that is 10th of point) void appendMappedLength( sal_Int32 nLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL ) const; // the same for double values - void appendMappedLength( double fLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL ) const; + void appendMappedLength( double fLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL, sal_Int32 nPrecision = 5 ) const; // appends LineInfo // returns false if too many dash array entry were created for // the implementation limits of some PDF readers @@ -695,19 +701,20 @@ private: // graphics state struct GraphicsState { - Font m_aFont; - MapMode m_aMapMode; - Color m_aLineColor; - Color m_aFillColor; - Color m_aTextLineColor; - Color m_aOverlineColor; - Region m_aClipRegion; - sal_Int32 m_nAntiAlias; - sal_Int32 m_nLayoutMode; - LanguageType m_aDigitLanguage; - sal_Int32 m_nTransparentPercent; - sal_uInt16 m_nFlags; - sal_uInt16 m_nUpdateFlags; + Font m_aFont; + MapMode m_aMapMode; + Color m_aLineColor; + Color m_aFillColor; + Color m_aTextLineColor; + Color m_aOverlineColor; + basegfx::B2DPolyPolygon m_aClipRegion; + bool m_bClipRegion; + sal_Int32 m_nAntiAlias; + sal_Int32 m_nLayoutMode; + LanguageType m_aDigitLanguage; + sal_Int32 m_nTransparentPercent; + sal_uInt16 m_nFlags; + sal_uInt16 m_nUpdateFlags; static const sal_uInt16 updateFont = 0x0001; static const sal_uInt16 updateMapMode = 0x0002; @@ -726,6 +733,7 @@ private: m_aFillColor( COL_TRANSPARENT ), m_aTextLineColor( COL_TRANSPARENT ), m_aOverlineColor( COL_TRANSPARENT ), + m_bClipRegion( false ), m_nAntiAlias( 1 ), m_nLayoutMode( 0 ), m_aDigitLanguage( 0 ), @@ -741,6 +749,7 @@ private: m_aTextLineColor( rState.m_aTextLineColor ), m_aOverlineColor( rState.m_aOverlineColor ), m_aClipRegion( rState.m_aClipRegion ), + m_bClipRegion( rState.m_bClipRegion ), m_nAntiAlias( rState.m_nAntiAlias ), m_nLayoutMode( rState.m_nLayoutMode ), m_aDigitLanguage( rState.m_aDigitLanguage ), @@ -759,6 +768,7 @@ private: m_aTextLineColor = rState.m_aTextLineColor; m_aOverlineColor = rState.m_aOverlineColor; m_aClipRegion = rState.m_aClipRegion; + m_bClipRegion = rState.m_bClipRegion; m_nAntiAlias = rState.m_nAntiAlias; m_nLayoutMode = rState.m_nLayoutMode; m_aDigitLanguage = rState.m_aDigitLanguage; @@ -1049,7 +1059,7 @@ i12626 void createDefaultListBoxAppearance( PDFWidget&, const PDFWriter::ListBoxWidget& rWidget ); /* ensure proper escapement and uniqueness of field names */ - rtl::OString convertWidgetFieldName( const rtl::OUString& rString ); + void createWidgetFieldName( sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget& i_rInWidget ); /* adds an entry to m_aObjects and returns its index+1, * sets the offset to ~0 */ @@ -1209,17 +1219,18 @@ public: void clearClipRegion() { - m_aGraphicsStack.front().m_aClipRegion.SetNull(); + m_aGraphicsStack.front().m_aClipRegion.clear(); + m_aGraphicsStack.front().m_bClipRegion = false; m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion; } - void setClipRegion( const Region& rRegion ); + void setClipRegion( const basegfx::B2DPolyPolygon& rRegion ); void moveClipRegion( sal_Int32 nX, sal_Int32 nY ); bool intersectClipRegion( const Rectangle& rRect ); - bool intersectClipRegion( const Region& rRegion ); + bool intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ); void setLayoutMode( sal_Int32 nLayoutMode ) { diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx index bd28135ca498..47152ea6ac11 100644 --- a/vcl/source/gdi/pngwrite.cxx +++ b/vcl/source/gdi/pngwrite.cxx @@ -131,6 +131,7 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBmpEx, mpAccess ( NULL ), mpMaskAccess ( NULL ), mpZCodec ( new ZCodec( DEFAULT_IN_BUFSIZE, DEFAULT_OUT_BUFSIZE, MAX_MEM_USAGE ) ), + mnCRC(0UL), mnLastPercent ( 0UL ) { if ( !rBmpEx.IsEmpty() ) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index de7cd2e139da..191f8f26dc75 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -36,6 +36,7 @@ #include "vcl/svids.hrc" #include "vcl/metaact.hxx" #include "vcl/msgbox.hxx" +#include "vcl/configsettings.hxx" #include "tools/urlobj.hxx" @@ -171,13 +172,15 @@ public: // set by user through printer config dialog // if set, pages are centered and trimmed onto the fixed page Size maFixedPageSize; + sal_Int32 mnDefaultPaperBin; ImplPrinterControllerData() : mbFirstPage( sal_True ), mbLastPage( sal_False ), mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), - mpProgress( NULL ) + mpProgress( NULL ), + mnDefaultPaperBin( -1 ) {} ~ImplPrinterControllerData() { delete mpProgress; } @@ -327,9 +330,25 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr // setup printer // if no specific printer is already set, create one + + // #i108686# + // in case of a UI (platform independent or system dialog) print job, make the printer persistent over jobs + // however if no printer was already set by the print job's originator, + // and this is an API job, then use the system default location (because + // this is the only sensible default available if the user has no means of changing + // the destination if( ! pController->getPrinter() ) { - boost::shared_ptr<Printer> pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); + rtl::OUString aPrinterName( i_rInitSetup.GetPrinterName() ); + if( ! aPrinterName.getLength() && pController->isShowDialogs() && ! pController->isDirectPrint() ) + { + // get printer name from configuration + SettingsConfigItem* pItem = SettingsConfigItem::get(); + aPrinterName = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinterUsed" ) ) ); + } + + boost::shared_ptr<Printer> pPrinter( new Printer( aPrinterName ) ); pController->setPrinter( pPrinter ); } @@ -440,7 +459,12 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr return; } pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), - makeAny( aFile ) ); + makeAny( aFile ) ); + } + else if( aDlg.isSingleJobs() ) + { + pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ), + makeAny( sal_True ) ); } } catch( std::bad_alloc& ) @@ -501,6 +525,13 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: if ( !mpPrinter ) return FALSE; + sal_Bool bSinglePrintJobs = sal_False; + beans::PropertyValue* pSingleValue = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ) ); + if( pSingleValue ) + { + pSingleValue->Value >>= bSinglePrintJobs; + } + // remark: currently it is still possible to use EnablePrintFile and // SetPrintFileName to redirect printout into file // it can be argued that those methods should be removed in favor @@ -514,6 +545,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: { mbPrintFile = TRUE; maPrintFile = aFile; + bSinglePrintJobs = sal_False; } } @@ -561,49 +593,90 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl:: i_pController->setJobState( view::PrintableState_JOB_STARTED ); i_pController->jobStarted(); - if( mpPrinter->StartJob( pPrintFile, - i_rJobName, - Application::GetDisplayName(), - nCopies, - bCollateCopy, - i_pController->isDirectPrint(), - maJobSetup.ImplGetConstData() ) ) + int nJobs = 1; + int nRepeatCount = bUserCopy ? mnCopyCount : 1; + if( bSinglePrintJobs ) { - mbJobActive = TRUE; - i_pController->createProgressDialog(); - int nPages = i_pController->getFilteredPageCount(); - int nRepeatCount = bUserCopy ? mnCopyCount : 1; - for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) + nJobs = mnCopyCount; + nCopies = 1; + nRepeatCount = 1; + } + + for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ ) + { + bool bError = false; + if( mpPrinter->StartJob( pPrintFile, + i_rJobName, + Application::GetDisplayName(), + nCopies, + bCollateCopy, + i_pController->isDirectPrint(), + maJobSetup.ImplGetConstData() ) ) { - for( int nPage = 0; nPage < nPages; nPage++ ) + mbJobActive = TRUE; + i_pController->createProgressDialog(); + int nPages = i_pController->getFilteredPageCount(); + for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) { - if( nPage == nPages-1 && nIteration == nRepeatCount-1 ) - i_pController->setLastPage( sal_True ); - i_pController->printFilteredPage( nPage ); + for( int nPage = 0; nPage < nPages; nPage++ ) + { + if( nPage == nPages-1 && nIteration == nRepeatCount-1 && nJobIteration == nJobs-1 ) + i_pController->setLastPage( sal_True ); + i_pController->printFilteredPage( nPage ); + } + // FIXME: duplex ? + } + EndJob(); + + if( nJobIteration < nJobs-1 ) + { + mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); + + if ( mpPrinter ) + { + maJobName = i_rJobName; + mnCurPage = 1; + mnCurPrintPage = 1; + mbPrinting = TRUE; + } + else + bError = true; } - // FIXME: duplex ? } - EndJob(); + else + bError = true; - if( i_pController->getJobState() == view::PrintableState_JOB_STARTED ) - i_pController->setJobState( view::PrintableState_JOB_SPOOLED ); + if( bError ) + { + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); + if ( !mnError ) + mnError = PRINTER_GENERALERROR; + i_pController->setJobState( mnError == PRINTER_ABORT + ? view::PrintableState_JOB_ABORTED + : view::PrintableState_JOB_FAILED ); + if( mpPrinter ) + pSVData->mpDefInst->DestroyPrinter( mpPrinter ); + mnCurPage = 0; + mnCurPrintPage = 0; + mbPrinting = FALSE; + mpPrinter = NULL; + + return false; + } } - else - { - mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); - if ( !mnError ) - mnError = PRINTER_GENERALERROR; - i_pController->setJobState( mnError == PRINTER_ABORT - ? view::PrintableState_JOB_ABORTED - : view::PrintableState_JOB_FAILED ); - pSVData->mpDefInst->DestroyPrinter( mpPrinter ); - mnCurPage = 0; - mnCurPrintPage = 0; - mbPrinting = FALSE; - mpPrinter = NULL; - return false; - } + if( i_pController->getJobState() == view::PrintableState_JOB_STARTED ) + i_pController->setJobState( view::PrintableState_JOB_SPOOLED ); + } + + // make last used printer persistent for UI jobs + if( i_pController->isShowDialogs() && ! i_pController->isDirectPrint() ) + { + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinterUsed" ) ), + GetName() + ); } return true; @@ -634,6 +707,7 @@ void PrinterController::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter mpImplData->mpPrinter = i_rPrinter; setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), makeAny( rtl::OUString( i_rPrinter->GetName() ) ) ); + mpImplData->mnDefaultPaperBin = mpImplData->mpPrinter->GetPaperBin(); } bool PrinterController::setupPrinter( Window* i_pParent ) @@ -668,27 +742,55 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons { PrinterController::PageSize aPageSize; aPageSize.aSize = mpPrinter->GetPaperSize(); + awt::Size aSetSize, aIsSize; + sal_Int32 nPaperBin = mnDefaultPaperBin; for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) { - if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) + if( i_rProps[ nProperty ].Name.equalsAscii( "PreferredPageSize" ) ) { - awt::Size aSize; - i_rProps[ nProperty].Value >>= aSize; - aPageSize.aSize.Width() = aSize.Width; - aPageSize.aSize.Height() = aSize.Height; - - Size aCurSize( mpPrinter->GetPaperSize() ); - Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); - if( aRealPaperSize != aCurSize ) - mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); + i_rProps[ nProperty ].Value >>= aSetSize; } - if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) + else if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) + { + i_rProps[ nProperty ].Value >>= aIsSize; + } + else if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) { sal_Bool bVal = sal_False; - i_rProps[ nProperty].Value >>= bVal; + i_rProps[ nProperty ].Value >>= bVal; aPageSize.bFullPaper = static_cast<bool>(bVal); } + else if( i_rProps[ nProperty ].Name.equalsAscii( "PrinterPaperTray" ) ) + { + sal_Int32 nBin = -1; + i_rProps[ nProperty ].Value >>= nBin; + if( nBin >= 0 && nBin < mpPrinter->GetPaperBinCount() ) + nPaperBin = nBin; + } + } + + Size aCurSize( mpPrinter->GetPaperSize() ); + if( aSetSize.Width && aSetSize.Height ) + { + Size aSetPaperSize( aSetSize.Width, aSetSize.Height ); + Size aRealPaperSize( getRealPaperSize( aSetPaperSize ) ); + if( aRealPaperSize != aCurSize ) + aIsSize = aSetSize; } + + if( aIsSize.Width && aIsSize.Height ) + { + aPageSize.aSize.Width() = aIsSize.Width; + aPageSize.aSize.Height() = aIsSize.Height; + + Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); + if( aRealPaperSize != aCurSize ) + mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); + } + + if( nPaperBin != -1 && nPaperBin != mpPrinter->GetPaperBin() ) + mpPrinter->SetPaperBin( nPaperBin ); + return aPageSize; } @@ -1393,6 +1495,8 @@ void PrinterController::createProgressDialog() mpImplData->mpProgress->Show(); } } + else + mpImplData->mpProgress->reset(); } void PrinterController::setMultipage( const MultiPageSetup& i_rMPS ) diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index 07351e1c0fce..4931ee66e93f 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -45,6 +45,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/range/b2drange.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> @@ -2004,6 +2005,32 @@ const basegfx::B2DPolyPolygon Region::GetB2DPolyPolygon() const // ----------------------------------------------------------------------- +basegfx::B2DPolyPolygon Region::ConvertToB2DPolyPolygon() +{ + DBG_CHKTHIS( Region, ImplDbgTestRegion ); + + basegfx::B2DPolyPolygon aRet; + + if( HasPolyPolygon() ) + aRet = GetB2DPolyPolygon(); + else + { + RegionHandle aHdl = BeginEnumRects(); + Rectangle aSubRect; + while( GetNextEnumRect( aHdl, aSubRect ) ) + { + basegfx::B2DPolygon aPoly( basegfx::tools::createPolygonFromRect( + basegfx::B2DRectangle( aSubRect.Left(), aSubRect.Top(), aSubRect.Right(), aSubRect.Bottom() ) ) ); + aRet.append( aPoly ); + } + EndEnumRects( aHdl ); + } + + return aRet; +} + +// ----------------------------------------------------------------------- + BOOL Region::ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo, long& rX, long& rY, long& rWidth, long& rHeight ) const diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 9354b0f72130..55d6f7bdd892 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -689,6 +689,12 @@ void SalGraphics::mirror( ControlType nType, const ImplControlValue& rVal, const { switch( nType ) { + case CTRL_SLIDER: + { + SliderValue* pSlVal = reinterpret_cast<SliderValue*>(rVal.getOptionalVal()); + mirror(pSlVal->maThumbRect,pOutDev,bBack); + } + break; case CTRL_SCROLLBAR: { ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(rVal.getOptionalVal()); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 344867ebb0b0..bf462d1d8add 100755 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -133,13 +133,13 @@ int GetVerticalFlags( sal_UCS4 nChar ) /* #i52932# remember: nChar == 0x2010 || nChar == 0x2015 nChar == 0x2016 || nChar == 0x2026 - are GF_NONE also, but already handled in the first if */ if((nChar >= 0x3008 && nChar <= 0x301C && nChar != 0x3012) - || nChar == 0xFF3B || nChar == 0xFF3D + || (nChar == 0xFF3B || nChar == 0xFF3D) || (nChar >= 0xFF5B && nChar <= 0xFF9F) // halfwidth forms - || nChar == 0xFFE3 ) + || (nChar == 0xFFE3) + || (nChar >= 0x02F800 && nChar <= 0x02FFFF) ) return GF_NONE; // not rotated else if( nChar == 0x30fc ) return GF_ROTR; // right diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index a337f2553ff7..ebdd59f517af 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -38,8 +38,6 @@ #include "vcl/svapp.hxx" #include "vcl/outfont.hxx" #include "vcl/impfont.hxx" -#include "vcl/bitmap.hxx" -#include "vcl/bmpacc.hxx" #include "tools/poly.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" @@ -80,7 +78,7 @@ typedef FT_Vector* FT_Vector_CPtr; // TODO: move file mapping stuff to OSL #if defined(UNX) #if !defined(HPUX) - // PORTERS: dlfcn is used for code dependend on FT version + // PORTERS: dlfcn is used for getting symbols from FT versions newer than baseline #include <dlfcn.h> #endif #include <unistd.h> @@ -93,10 +91,6 @@ typedef FT_Vector* FT_Vector_CPtr; #define strncasecmp strnicmp #endif -#include "vcl/svapp.hxx" -#include "vcl/settings.hxx" -#include "i18npool/lang.h" - typedef const unsigned char* CPU8; inline sal_uInt16 NEXT_U16( CPU8& p ) { p+=2; return (p[-2]<<8)|p[-1]; } inline sal_Int16 NEXT_S16( CPU8& p ) { return (sal_Int16)NEXT_U16(p); } @@ -623,9 +617,6 @@ long FreetypeManager::AddFontDir( const String& rUrlName ) aDFA.mbSubsettable= false; aDFA.mbEmbeddable = false; - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - FT_Done_Face( aFaceFT ); AddFontFile( aCFileName, nFaceNum, ++mnNextFontId, aDFA, NULL ); ++nCount; @@ -705,6 +696,7 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn : ServerFont( rFSD ), mnPrioEmbedded(nDefaultPrioEmbedded), mnPrioAntiAlias(nDefaultPrioAntiAlias), + mnPrioAutoHint(nDefaultPrioAutoHint), mpFontInfo( pFI ), maFaceFT( NULL ), maSizeFT( NULL ), @@ -838,46 +830,71 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn mbArtItalic = (rFSD.meItalic != ITALIC_NONE && pFI->GetFontAttributes().GetSlant() == ITALIC_NONE); mbArtBold = (rFSD.meWeight > WEIGHT_MEDIUM && pFI->GetFontAttributes().GetWeight() <= WEIGHT_MEDIUM); - - //static const int TT_CODEPAGE_RANGE_874 = (1L << 16); // Thai - //static const int TT_CODEPAGE_RANGE_932 = (1L << 17); // JIS/Japan - //static const int TT_CODEPAGE_RANGE_936 = (1L << 18); // Chinese: Simplified - //static const int TT_CODEPAGE_RANGE_949 = (1L << 19); // Korean Wansung - //static const int TT_CODEPAGE_RANGE_950 = (1L << 20); // Chinese: Traditional - //static const int TT_CODEPAGE_RANGE_1361 = (1L << 21); // Korean Johab - static const int TT_CODEPAGE_RANGES1_CJKT = 0x3F0000; // all of the above - const TT_OS2* pOs2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 ); - if ((pOs2) && (pOs2->ulCodePageRange1 & TT_CODEPAGE_RANGES1_CJKT ) + mbUseGamma = false; + if( mbArtBold ) + { + //static const int TT_CODEPAGE_RANGE_874 = (1L << 16); // Thai + //static const int TT_CODEPAGE_RANGE_932 = (1L << 17); // JIS/Japan + //static const int TT_CODEPAGE_RANGE_936 = (1L << 18); // Chinese: Simplified + //static const int TT_CODEPAGE_RANGE_949 = (1L << 19); // Korean Wansung + //static const int TT_CODEPAGE_RANGE_950 = (1L << 20); // Chinese: Traditional + //static const int TT_CODEPAGE_RANGE_1361 = (1L << 21); // Korean Johab + static const int TT_CODEPAGE_RANGES1_CJKT = 0x3F0000; // all of the above + const TT_OS2* pOs2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 ); + if ((pOs2) && (pOs2->ulCodePageRange1 & TT_CODEPAGE_RANGES1_CJKT ) && rFSD.mnHeight < 20) mbUseGamma = true; - else - mbUseGamma = false; + } + + if( ((mnCos != 0) && (mnSin != 0)) || (mnPrioEmbedded <= 0) ) + mnLoadFlags |= FT_LOAD_NO_BITMAP; +} + +void FreetypeServerFont::SetFontOptions( const ImplFontOptions& rFontOptions) +{ + FontAutoHint eHint = rFontOptions.GetUseAutoHint(); + if( eHint == AUTOHINT_DONTKNOW ) + eHint = mbUseGamma ? AUTOHINT_TRUE : AUTOHINT_FALSE; - if (mbUseGamma) + if( eHint == AUTOHINT_TRUE ) mnLoadFlags |= FT_LOAD_FORCE_AUTOHINT; if( (mnSin != 0) && (mnCos != 0) ) // hinting for 0/90/180/270 degrees only mnLoadFlags |= FT_LOAD_NO_HINTING; mnLoadFlags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; //#88334# - if (mpFontInfo->DontUseAntiAlias()) - mnPrioAntiAlias = 0; - if (mpFontInfo->DontUseEmbeddedBitmaps()) - mnPrioEmbedded = 0; + if( rFontOptions.DontUseAntiAlias() ) + mnPrioAntiAlias = 0; + if( rFontOptions.DontUseEmbeddedBitmaps() ) + mnPrioEmbedded = 0; + if( rFontOptions.DontUseHinting() ) + mnPrioAutoHint = 0; #if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER) - if( nDefaultPrioAutoHint <= 0 ) + if( mnPrioAutoHint <= 0 ) #endif mnLoadFlags |= FT_LOAD_NO_HINTING; -#ifdef FT_LOAD_TARGET_LIGHT - // enable "light hinting" if available +#if defined(FT_LOAD_TARGET_LIGHT) && defined(FT_LOAD_TARGET_NORMAL) if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103)) - mnLoadFlags |= FT_LOAD_TARGET_LIGHT; + { + mnLoadFlags |= FT_LOAD_TARGET_NORMAL; + switch( rFontOptions.GetHintStyle() ) + { + case HINT_NONE: + mnLoadFlags |= FT_LOAD_NO_HINTING; + break; + case HINT_SLIGHT: + mnLoadFlags |= FT_LOAD_TARGET_LIGHT; + break; + case HINT_MEDIUM: + break; + case HINT_FULL: + default: + break; + } + } #endif - - if( ((mnCos != 0) && (mnSin != 0)) || (mnPrioEmbedded <= 0) ) - mnLoadFlags |= FT_LOAD_NO_BITMAP; } // ----------------------------------------------------------------------- @@ -1231,13 +1248,15 @@ int FreetypeServerFont::FixupGlyphIndex( int nGlyphIndex, sal_UCS4 aChar ) const } } -#if !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER) +#if 0 // #95556# autohinting not yet optimized for non-western glyph styles if( !(mnLoadFlags & (FT_LOAD_NO_HINTING | FT_LOAD_FORCE_AUTOHINT) ) && ( (aChar >= 0x0600 && aChar < 0x1E00) // south-east asian + arabic ||(aChar >= 0x2900 && aChar < 0xD800) // CJKV ||(aChar >= 0xF800) ) ) // presentation + symbols + { nGlyphFlags |= GF_UNHINTED; + } #endif if( nGlyphIndex != 0 ) @@ -1377,13 +1396,13 @@ bool FreetypeServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& rRawBitmap nLoadFlags |= FT_LOAD_NO_BITMAP; #if (FTVERSION >= 2002) - // for 0/90/180/270 degree fonts enable autohinting even if not advisable + // for 0/90/180/270 degree fonts enable hinting even if not advisable // non-hinted and non-antialiased bitmaps just look too ugly - if( (mnCos==0 || mnSin==0) && (nDefaultPrioAutoHint > 0) ) + if( (mnCos==0 || mnSin==0) && (mnPrioAutoHint > 0) ) nLoadFlags &= ~FT_LOAD_NO_HINTING; #endif - if( mnPrioEmbedded <= nDefaultPrioAutoHint ) + if( mnPrioEmbedded <= mnPrioAutoHint ) nLoadFlags |= FT_LOAD_NO_BITMAP; FT_Error rc = -1; @@ -1548,7 +1567,7 @@ bool FreetypeServerFont::GetGlyphBitmap8( int nGlyphIndex, RawBitmap& rRawBitmap // autohinting in FT<=2.0.4 makes antialiased glyphs look worse nLoadFlags |= FT_LOAD_NO_HINTING; #else - if( (nGlyphFlags & GF_UNHINTED) || (nDefaultPrioAutoHint < mnPrioAntiAlias) ) + if( (nGlyphFlags & GF_UNHINTED) || (mnPrioAutoHint < mnPrioAntiAlias) ) nLoadFlags |= FT_LOAD_NO_HINTING; #endif diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx index 2a181b494c9f..5ebe70bcbdf9 100644 --- a/vcl/source/glyphs/gcach_ftyp.hxx +++ b/vcl/source/glyphs/gcach_ftyp.hxx @@ -33,6 +33,7 @@ #include <ft2build.h> #include FT_FREETYPE_H + class FreetypeServerFont; struct FT_GlyphRec_; @@ -85,10 +86,6 @@ public: int GetFaceNum() const { return mnFaceNum; } int GetSynthetic() const { return mnSynthetic; } sal_IntPtr GetFontId() const { return mnFontId; } - bool DontUseAntiAlias() const - { return maDevFontAttributes.UseAntiAlias() == ANTIALIAS_FALSE; } - bool DontUseEmbeddedBitmaps() const - { return maDevFontAttributes.UseEmbeddedBitmap() == EMBEDDEDBITMAP_FALSE; } bool IsSymbolFont() const { return maDevFontAttributes.IsSymbolFont(); } const ImplFontAttributes& GetFontAttributes() const { return maDevFontAttributes; } @@ -178,6 +175,7 @@ public: virtual int GetFontFaceNum() const { return mpFontInfo->GetFaceNum(); } virtual bool TestFont() const; virtual void* GetFtFace() const; + virtual void SetFontOptions( const ImplFontOptions&); virtual int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); } virtual bool NeedsArtificialBold() const { return mbArtBold; } virtual bool NeedsArtificialItalic() const { return mbArtItalic; } @@ -213,6 +211,7 @@ private: int mnWidth; int mnPrioEmbedded; int mnPrioAntiAlias; + int mnPrioAutoHint; FtFontInfo* mpFontInfo; FT_Int mnLoadFlags; double mfStretch; diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index 34133a39ac95..ea0f18896b7a 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -69,13 +69,22 @@ GlyphCache::GlyphCache( GlyphCachePeer& rPeer ) GlyphCache::~GlyphCache() { -// TODO: -// for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it ) -// delete const_cast<ServerFont*>( it->second ); + InvalidateAllGlyphs(); if( mpFtManager ) delete mpFtManager; } +// ----------------------------------------------------------------------- + +void GlyphCache::InvalidateAllGlyphs() +{ +#if 0 // TODO: implement uncaching of all glyph shapes and metrics + for( FontList::iterator it = maFontList.begin(); it != maFontList.end(); ++it ) + delete const_cast<ServerFont*>( it->second ); + maFontList.clear(); + mpCurrentGCFont = NULL; +#endif +} // ----------------------------------------------------------------------- @@ -582,3 +591,4 @@ int ExtraKernInfo::GetUnscaledKernValue( sal_Unicode cLeft, sal_Unicode cRight ) } // ======================================================================= + diff --git a/vcl/source/glyphs/graphite_adaptors.cxx b/vcl/source/glyphs/graphite_adaptors.cxx index 4afced765612..f66f5b48e39e 100644 --- a/vcl/source/glyphs/graphite_adaptors.cxx +++ b/vcl/source/glyphs/graphite_adaptors.cxx @@ -168,7 +168,7 @@ GraphiteFontAdaptor::~GraphiteFontAdaptor() throw() mpFeatures = NULL; } -void GraphiteFontAdaptor::UniqueCacheInfo(sil_std::wstring & face_name_out, bool & bold_out, bool & italic_out) +void GraphiteFontAdaptor::UniqueCacheInfo(ext_std::wstring & face_name_out, bool & bold_out, bool & italic_out) { face_name_out = maFontProperties.szFaceName; bold_out = maFontProperties.fBold; diff --git a/vcl/source/glyphs/graphite_cache.cxx b/vcl/source/glyphs/graphite_cache.cxx index 713f3c1ed088..64bbb0a38d60 100644 --- a/vcl/source/glyphs/graphite_cache.cxx +++ b/vcl/source/glyphs/graphite_cache.cxx @@ -36,10 +36,10 @@ #include <tools/debug.hxx> #include <vcl/sallayout.hxx> -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Segment.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> #include <rtl/ustring.hxx> #include <vcl/graphite_layout.hxx> diff --git a/vcl/source/glyphs/graphite_features.cxx b/vcl/source/glyphs/graphite_features.cxx index bae96642da30..1cb25306c4ee 100644 --- a/vcl/source/glyphs/graphite_features.cxx +++ b/vcl/source/glyphs/graphite_features.cxx @@ -88,7 +88,7 @@ GrFeatureParser::GrFeatureParser(gr::Font & font, const std::string features, co gr::isocode aLang = maLang; for (size_t i = pos; i < nFeatEnd; i++) aLang.rgch[i-pos] = features[i]; - sil_std::pair<gr::LanguageIterator,gr::LanguageIterator> aSupported + ext_std::pair<gr::LanguageIterator,gr::LanguageIterator> aSupported = font.getSupportedLanguages(); gr::LanguageIterator iL = aSupported.first; while (iL != aSupported.second) @@ -139,7 +139,7 @@ void GrFeatureParser::setLang(gr::Font & font, const std::string & lang) if (lang[i] == '-') break; aLang.rgch[i] = lang[i]; } - sil_std::pair<gr::LanguageIterator,gr::LanguageIterator> aSupported + ext_std::pair<gr::LanguageIterator,gr::LanguageIterator> aSupported = font.getSupportedLanguages(); gr::LanguageIterator iL = aSupported.first; while (iL != aSupported.second) @@ -186,7 +186,7 @@ bool GrFeatureParser::isValid(gr::Font & font, gr::FeatureSetting & setting) { return false; } - sil_std::pair< gr::FeatureSettingIterator, gr::FeatureSettingIterator > + ext_std::pair< gr::FeatureSettingIterator, gr::FeatureSettingIterator > validValues = font.getFeatureSettings(i); gr::FeatureSettingIterator j = validValues.first; while (j != validValues.second) diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx index 25ea77dd07a3..6e75d1fde868 100644 --- a/vcl/source/glyphs/graphite_layout.cxx +++ b/vcl/source/glyphs/graphite_layout.cxx @@ -63,13 +63,13 @@ #include <unicode/uscript.h> // Graphite Libraries (must be after vcl headers on windows) -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/ITextSource.h> #include <graphite/Segment.h> #include <graphite/SegmentPainter.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> #include <vcl/graphite_layout.hxx> #include <vcl/graphite_features.hxx> @@ -104,8 +104,8 @@ FILE * grLog() namespace { - typedef sil_std::pair<gr::GlyphIterator, gr::GlyphIterator> glyph_range_t; - typedef sil_std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyph_set_range_t; + typedef ext_std::pair<gr::GlyphIterator, gr::GlyphIterator> glyph_range_t; + typedef ext_std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyph_set_range_t; inline long round(const float n) { return long(n + (n < 0 ? -0.5 : 0.5)); @@ -170,7 +170,7 @@ GraphiteLayout::Glyphs::fill_from(gr::Segment & rSegment, ImplLayoutArgs &rArgs, bool bRtl, long &rWidth, float fScaling, std::vector<int> & rChar2Base, std::vector<int> & rGlyph2Char, std::vector<int> & rCharDxs) { // Create a glyph item for each of the glyph and append it to the base class glyph list. - typedef sil_std::pair< gr::GlyphSetIterator, gr::GlyphSetIterator > GrGlyphSet; + typedef ext_std::pair< gr::GlyphSetIterator, gr::GlyphSetIterator > GrGlyphSet; int nChar = rArgs.mnEndCharPos - rArgs.mnMinCharPos; glyph_range_t iGlyphs = rSegment.glyphs(); int nGlyphs = iGlyphs.second - iGlyphs.first; @@ -585,7 +585,7 @@ public: sal_Int32 hashCode(const grutils::GrFeatureParser * mpFeatures) { // is this sufficient? - sil_std::wstring aFace; + ext_std::wstring aFace; bool bBold; bool bItalic; UniqueCacheInfo(aFace, bBold, bItalic); diff --git a/vcl/source/glyphs/graphite_textsrc.cxx b/vcl/source/glyphs/graphite_textsrc.cxx index d7547662e065..5764ba9454c9 100644 --- a/vcl/source/glyphs/graphite_textsrc.cxx +++ b/vcl/source/glyphs/graphite_textsrc.cxx @@ -135,16 +135,16 @@ gr::isocode TextSourceAdaptor::getLanguage(gr::toffset) return unknown; } -sil_std::pair<gr::toffset, gr::toffset> TextSourceAdaptor::propertyRange(gr::toffset nCharIdx) +ext_std::pair<gr::toffset, gr::toffset> TextSourceAdaptor::propertyRange(gr::toffset nCharIdx) { if (nCharIdx < unsigned(maLayoutArgs.mnMinCharPos)) - return sil_std::make_pair(0, maLayoutArgs.mnMinCharPos); + return ext_std::make_pair(0, maLayoutArgs.mnMinCharPos); if (nCharIdx < mnEnd) - return sil_std::make_pair(maLayoutArgs.mnMinCharPos, mnEnd); + return ext_std::make_pair(maLayoutArgs.mnMinCharPos, mnEnd); - return sil_std::make_pair(mnEnd, maLayoutArgs.mnLength); + return ext_std::make_pair(mnEnd, maLayoutArgs.mnLength); } size_t TextSourceAdaptor::getFontFeatures(gr::toffset, gr::FeatureSetting * settings) @@ -156,7 +156,7 @@ size_t TextSourceAdaptor::getFontFeatures(gr::toffset, gr::FeatureSetting * sett bool TextSourceAdaptor::sameSegment(gr::toffset char_idx1, gr::toffset char_idx2) { - const sil_std::pair<gr::toffset, gr::toffset> + const ext_std::pair<gr::toffset, gr::toffset> range1 = propertyRange(char_idx1), range2 = propertyRange(char_idx2); diff --git a/vcl/source/glyphs/graphite_textsrc.hxx b/vcl/source/glyphs/graphite_textsrc.hxx index 2397d6a5f701..2b9c705a5ea7 100644 --- a/vcl/source/glyphs/graphite_textsrc.hxx +++ b/vcl/source/glyphs/graphite_textsrc.hxx @@ -59,11 +59,11 @@ #include "vcl/dllapi.h" // Libraries -#include "pregraphitestl.h" +#include <tools/preextstl.h> #include <graphite/GrClient.h> #include <graphite/Font.h> #include <graphite/ITextSource.h> -#include "postgraphitestl.h" +#include <tools/postextstl.h> // Module type definitions and forward declarations. // @@ -90,7 +90,7 @@ public: virtual float getVerticalOffset(gr::toffset ich); virtual gr::isocode getLanguage(gr::toffset ich); - virtual sil_std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich); + virtual ext_std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich); virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset); virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2); diff --git a/vcl/source/helper/xconnection.cxx b/vcl/source/helper/xconnection.cxx index 19ac9103bf96..caf7ee237d67 100644 --- a/vcl/source/helper/xconnection.cxx +++ b/vcl/source/helper/xconnection.cxx @@ -141,12 +141,16 @@ bool DisplayConnection::dispatchEvent( void* pThis, void* pData, int nBytes ) SolarMutexReleaser aRel; DisplayConnection* This = (DisplayConnection*)pThis; - MutexGuard aGuard( This->m_aMutex ); Sequence< sal_Int8 > aSeq( (sal_Int8*)pData, nBytes ); Any aEvent; aEvent <<= aSeq; - for( ::std::list< Reference< XEventHandler > >::const_iterator it = This->m_aHandlers.begin(); it != This->m_aHandlers.end(); ++it ) + ::std::list< Reference< XEventHandler > > handlers; + { + MutexGuard aGuard( This->m_aMutex ); + handlers = This->m_aHandlers; + } + for( ::std::list< Reference< XEventHandler > >::const_iterator it = handlers.begin(); it != handlers.end(); ++it ) if( (*it)->handleEvent( aEvent ) ) return true; return false; @@ -157,12 +161,16 @@ bool DisplayConnection::dispatchErrorEvent( void* pThis, void* pData, int nBytes SolarMutexReleaser aRel; DisplayConnection* This = (DisplayConnection*)pThis; - MutexGuard aGuard( This->m_aMutex ); Sequence< sal_Int8 > aSeq( (sal_Int8*)pData, nBytes ); Any aEvent; aEvent <<= aSeq; - for( ::std::list< Reference< XEventHandler > >::const_iterator it = This->m_aErrorHandlers.begin(); it != This->m_aErrorHandlers.end(); ++it ) + ::std::list< Reference< XEventHandler > > handlers; + { + MutexGuard aGuard( This->m_aMutex ); + handlers = This->m_aErrorHandlers; + } + for( ::std::list< Reference< XEventHandler > >::const_iterator it = handlers.begin(); it != handlers.end(); ++it ) if( (*it)->handleEvent( aEvent ) ) return true; diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index 03675ccf69ca..a32790cfb0d4 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -1353,3 +1353,36 @@ Rectangle DecorationView::DrawButton( const Rectangle& rRect, USHORT nStyle ) return aRect; } + +// ----------------------------------------------------------------------- + +void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical ) +{ + Point aStart( rStart ), aStop( rStop ); + const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); + + mpOutDev->Push( PUSH_LINECOLOR ); + if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) + mpOutDev->SetLineColor( Color( COL_BLACK ) ); + else + mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() ); + + mpOutDev->DrawLine( aStart, aStop ); + if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) + { + mpOutDev->SetLineColor( rStyleSettings.GetLightColor() ); + if( bVertical ) + { + aStart.X()++; + aStop.X()++; + } + else + { + aStart.Y()++; + aStop.Y()++; + } + mpOutDev->DrawLine( aStart, aStop ); + } + mpOutDev->Pop(); +} + diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx index daa26e2c7782..64f2b7e0d2a1 100644 --- a/vcl/source/window/dlgctrl.cxx +++ b/vcl/source/window/dlgctrl.cxx @@ -886,20 +886,6 @@ BOOL Window::ImplDlgCtrl( const KeyEvent& rKEvt, BOOL bKeyInput ) return TRUE; } - // if we have come here (and therefore the strange "formular" logic above - // turned up no result, then let's try to find a customer for Ctrl-TAB - if ( nKeyCode == KEY_TAB && aKeyCode.IsMod1() && ! aKeyCode.IsMod2() ) - { - TabDialog* pDlg = dynamic_cast<TabDialog*>(this); - if( pDlg ) - { - TabControl* pTabCtrl = pDlg->ImplGetFirstTabControl(); - NotifyEvent aEvt( bKeyInput ? EVENT_KEYINPUT : EVENT_KEYUP, - pTabCtrl, &rKEvt ); - return pTabCtrl->ImplHandleNotifyEvent( aEvt ); - } - } - return FALSE; } @@ -1093,10 +1079,15 @@ Window* Window::GetLabelFor() const return pWindow; sal_Unicode nAccel = getAccel( GetText() ); - if( GetType() == WINDOW_FIXEDTEXT || - GetType() == WINDOW_FIXEDLINE || - GetType() == WINDOW_GROUPBOX ) + + WindowType nMyType = GetType(); + if( nMyType == WINDOW_FIXEDTEXT || + nMyType == WINDOW_FIXEDLINE || + nMyType == WINDOW_GROUPBOX ) { + // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text. + // See tools/options/print for example. + BOOL bThisIsAGroupControl = (nMyType == WINDOW_GROUPBOX) || (nMyType == WINDOW_FIXEDLINE); Window* pSWindow = NULL; // get index, form start and form end USHORT nIndex=0, nFormStart=0, nFormEnd=0; @@ -1128,9 +1119,14 @@ Window* Window::GetLabelFor() const FALSE ); if( pSWindow && pSWindow->IsVisible() && ! (pSWindow->GetStyle() & WB_NOLABEL) ) { - if( pSWindow->GetType() != WINDOW_FIXEDTEXT && - pSWindow->GetType() != WINDOW_FIXEDLINE && - pSWindow->GetType() != WINDOW_GROUPBOX ) + WindowType nType = pSWindow->GetType(); + if( nType != WINDOW_FIXEDTEXT && + nType != WINDOW_FIXEDLINE && + nType != WINDOW_GROUPBOX ) + { + pWindow = pSWindow; + } + else if( bThisIsAGroupControl && ( nType == WINDOW_FIXEDTEXT ) ) { pWindow = pSWindow; } @@ -1163,9 +1159,13 @@ Window* Window::GetLabeledBy() const if( GetType() == WINDOW_CHECKBOX || GetType() == WINDOW_RADIOBUTTON ) return NULL; - if( ! ( GetType() == WINDOW_FIXEDTEXT || - GetType() == WINDOW_FIXEDLINE || - GetType() == WINDOW_GROUPBOX ) ) +// if( ! ( GetType() == WINDOW_FIXEDTEXT || +// GetType() == WINDOW_FIXEDLINE || +// GetType() == WINDOW_GROUPBOX ) ) + // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text. + // See tools/options/print for example. + WindowType nMyType = GetType(); + if ( (nMyType != WINDOW_GROUPBOX) && (nMyType != WINDOW_FIXEDLINE) ) { // search for a control that labels this window // a label is considered the last fixed text, fixed line or group box @@ -1196,14 +1196,18 @@ Window* Window::GetLabeledBy() const nSearchIndex, nFoundIndex, FALSE ); - if( pSWindow && pSWindow->IsVisible() && - ! (pSWindow->GetStyle() & WB_NOLABEL) && - ( pSWindow->GetType() == WINDOW_FIXEDTEXT || - pSWindow->GetType() == WINDOW_FIXEDLINE || - pSWindow->GetType() == WINDOW_GROUPBOX ) ) + if( pSWindow && pSWindow->IsVisible() && !(pSWindow->GetStyle() & WB_NOLABEL) ) { - pWindow = pSWindow; - break; + WindowType nType = pSWindow->GetType(); + if ( ( nType == WINDOW_FIXEDTEXT || + nType == WINDOW_FIXEDLINE || + nType == WINDOW_GROUPBOX ) ) + { + // a fixed text can't be labeld by a fixed text. + if ( ( nMyType != WINDOW_FIXEDTEXT ) || ( nType != WINDOW_FIXEDTEXT ) ) + pWindow = pSWindow; + break; + } } if( nFoundIndex > nSearchIndex || nSearchIndex == 0 ) break; diff --git a/vcl/source/window/introwin.cxx b/vcl/source/window/introwin.cxx index 02ccc2282a42..03f88adc3566 100644 --- a/vcl/source/window/introwin.cxx +++ b/vcl/source/window/introwin.cxx @@ -77,3 +77,12 @@ void IntroWindow::SetBackgroundBitmap( const Bitmap& rBitmap ) ImplGetFrame()->SetBackgroundBitmap( pBmp ); } } + +void IntroWindow::SetBackgroundBitmap( const BitmapEx& rBitmapEx ) +{ + if( ! rBitmapEx.IsEmpty() ) + { + SalBitmap* pBmp = rBitmapEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap(); + ImplGetFrame()->SetBackgroundBitmap( pBmp ); + } +} diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx index 74926ad3de4b..c2c6c18135f2 100644 --- a/vcl/source/window/mnemonic.cxx +++ b/vcl/source/window/mnemonic.cxx @@ -332,39 +332,41 @@ BOOL MnemonicGenerator::CreateMnemonic( XubString& rKey ) } } - if( ! bChanged ) - { - /* - * #97809# if all else fails use the first character of a word - * anyway and live with duplicate mnemonics - */ - nIndex = 0; - do - { - c = aKey.GetChar( nIndex ); - - nMnemonicIndex = ImplGetMnemonicIndex( c ); - if ( nMnemonicIndex != MNEMONIC_INDEX_NOTFOUND ) - { - maMnemonics[nMnemonicIndex] = 0; - rKey.Insert( MNEMONIC_CHAR, nIndex ); - bChanged = TRUE; - break; - } - - // Search for next word - do - { - nIndex++; - c = aKey.GetChar( nIndex ); - if ( c == ' ' ) - break; - } - while ( nIndex < nLen ); - nIndex++; - } - while ( nIndex < nLen ); - } +// #i87415# Duplicates mnemonics are bad for consistent keyboard accessibility +// It's probably better to not have mnemonics for some widgets, than to have ambiguous ones. +// if( ! bChanged ) +// { +// /* +// * #97809# if all else fails use the first character of a word +// * anyway and live with duplicate mnemonics +// */ +// nIndex = 0; +// do +// { +// c = aKey.GetChar( nIndex ); +// +// nMnemonicIndex = ImplGetMnemonicIndex( c ); +// if ( nMnemonicIndex != MNEMONIC_INDEX_NOTFOUND ) +// { +// maMnemonics[nMnemonicIndex] = 0; +// rKey.Insert( MNEMONIC_CHAR, nIndex ); +// bChanged = TRUE; +// break; +// } +// +// // Search for next word +// do +// { +// nIndex++; +// c = aKey.GetChar( nIndex ); +// if ( c == ' ' ) +// break; +// } +// while ( nIndex < nLen ); +// nIndex++; +// } +// while ( nIndex < nLen ); +// } return bChanged; } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index caf5705cbcd9..33e58b51d6d0 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -42,16 +42,22 @@ #include "vcl/help.hxx" #include "vcl/decoview.hxx" #include "vcl/svapp.hxx" +#include "vcl/unohelp.hxx" #include "unotools/localedatawrapper.hxx" #include "rtl/ustrbuf.hxx" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/container/XNameAccess.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/awt/Size.hpp" using namespace vcl; using namespace com::sun::star; using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::container; using namespace com::sun::star::beans; #define HELPID_PREFIX ".HelpId:vcl:PrintDialog" @@ -66,7 +72,7 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const Re { SetPaintTransparent( TRUE ); SetBackground(); - if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + if( useHCColorReplacement() ) maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); else maPageVDev.SetBackground( Color( COL_WHITE ) ); @@ -76,12 +82,76 @@ PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() { } +bool PrintDialog::PrintPreviewWindow::useHCColorReplacement() const +{ + bool bRet = false; + if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + try + { + // get service provider + Reference< XMultiServiceFactory > xSMgr( unohelper::GetMultiServiceFactory() ); + // create configuration hierachical access name + if( xSMgr.is() ) + { + try + { + Reference< XMultiServiceFactory > xConfigProvider( + Reference< XMultiServiceFactory >( + xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationProvider" ))), + UNO_QUERY ) + ); + if( xConfigProvider.is() ) + { + Sequence< Any > aArgs(1); + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); + aVal.Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Accessibility" ) ); + aArgs.getArray()[0] <<= aVal; + Reference< XNameAccess > xConfigAccess( + Reference< XNameAccess >( + xConfigProvider->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess" )), + aArgs ), + UNO_QUERY ) + ); + if( xConfigAccess.is() ) + { + try + { + sal_Bool bValue = sal_False; + Any aAny = xConfigAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsForPagePreviews" ) ) ); + if( aAny >>= bValue ) + bRet = bool(bValue); + } + catch( NoSuchElementException& ) + { + } + catch( WrappedTargetException& ) + { + } + } + } + } + catch( Exception& ) + { + } + } + } + catch( WrappedTargetException& ) + { + } + } + return bRet; +} + void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDCEvt ) { // react on settings changed if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) { - if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + if( useHCColorReplacement() ) maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); else maPageVDev.SetBackground( Color( COL_WHITE ) ); @@ -118,6 +188,23 @@ void PrintDialog::PrintPreviewWindow::Resize() } aScaledSize.Width() = long(aScaledSize.Width()*fScale); aScaledSize.Height() = long(aScaledSize.Height()*fScale); + + maPreviewSize = aScaledSize; + + // #i104784# if we render the page too small then rounding issues result in + // layout artifacts looking really bad. So scale the page unto a device that is not + // full page size but not too small either. This also results in much better visual + // quality of the preview, e.g. when its height approaches the number of text lines + // find a good scaling factor + Size aPreviewMMSize( maPageVDev.PixelToLogic( aScaledSize, MapMode( MAP_100TH_MM ) ) ); + double fZoom = double(maOrigSize.Height())/double(aPreviewMMSize.Height()); + while( fZoom > 10 ) + { + aScaledSize.Width() *= 2; + aScaledSize.Height() *= 2; + fZoom /= 2.0; + } + maPageVDev.SetOutputSizePixel( aScaledSize, FALSE ); } @@ -129,9 +216,14 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) // replacement is active Push(); Rectangle aTextRect( Point( 0, 0 ), aSize ); - Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); - aFont.SetSize( Size( 0, aSize.Height()/12 ) ); - SetFont( aFont ); + DecorationView aVw( this ); + aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP ); + aTextRect.Left() += 2; + aTextRect.Top() += 2; + aTextRect.Right() -= 2; + aTextRect.Bottom() -= 2; + Font aFont( GetSettings().GetStyleSettings().GetLabelFont() ); + SetZoomedPointFont( aFont ); DrawText( aTextRect, maReplacementString, TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE ); @@ -141,11 +233,11 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { GDIMetaFile aMtf( maMtf ); - Size aPreviewSize = maPageVDev.GetOutputSizePixel(); - Point aOffset( (aSize.Width() - aPreviewSize.Width()) / 2, - (aSize.Height() - aPreviewSize.Height()) / 2 ); + Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2, + (aSize.Height() - maPreviewSize.Height()) / 2 ); - const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) ); + Size aVDevSize( maPageVDev.GetOutputSizePixel() ); + const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); Size aOrigSize( maOrigSize ); if( aOrigSize.Width() < 1 ) aOrigSize.Width() = aLogicSize.Width(); @@ -165,11 +257,11 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) SetMapMode( MAP_PIXEL ); maPageVDev.SetMapMode( MAP_PIXEL ); - DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev ); + DrawOutDev( aOffset, maPreviewSize, Point( 0, 0 ), aVDevSize, maPageVDev ); DecorationView aVw( this ); - aOffset.X() -= 1; aOffset.Y() -=1; aPreviewSize.Width() += 2; aPreviewSize.Height() += 2; - aVw.DrawFrame( Rectangle( aOffset, aPreviewSize ), FRAME_DRAW_GROUP ); + Rectangle aFrame( aOffset + Point( -1, -1 ), Size( maPreviewSize.Width() + 2, maPreviewSize.Height() + 2 ) ); + aVw.DrawFrame( aFrame, FRAME_DRAW_GROUP ); } } @@ -211,9 +303,7 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi #endif SetQuickHelpText( aBuf.makeStringAndClear() ); maMtf = i_rNewPreview; - if( GetSettings().GetStyleSettings().GetHighContrastMode() && - GetSettings().GetStyleSettings().GetWindowColor().IsDark() - ) + if( useHCColorReplacement() ) { maMtf.ReplaceColors( Color( COL_BLACK ), Color( COL_WHITE ), 30 ); } @@ -834,6 +924,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont maNUpPage.maBorderCB.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.maToFileBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.maReverseOrderBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); + maOptionsPage.maCollateSingleJobsBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maNUpPage.maPagesBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); // setup modify hdl @@ -1027,6 +1118,11 @@ bool PrintDialog::isCollate() return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE; } +bool PrintDialog::isSingleJobs() +{ + return maOptionsPage.maCollateSingleJobsBox.IsChecked(); +} + static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId = -1, const rtl::OUString& i_rPropName = rtl::OUString() ) { rtl::OUStringBuffer aBuf( 256 ); @@ -1049,10 +1145,17 @@ static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear(), HID_PRINTDLG ) ); } -static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex ) +static void setHelpText( Window* /*i_pWindow*/, const Sequence< rtl::OUString >& /*i_rHelpTexts*/, sal_Int32 /*i_nIndex*/ ) { + // without a help text set and the correct smartID, + // help texts will be retrieved from the online help system + + // passed help texts for optional UI is used only for native dialogs which currently + // cannot access the same (rather implicit) mechanism + #if 0 if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() ) i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); + #endif } void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize ) @@ -1572,6 +1675,12 @@ void PrintDialog::setupOptionalUI() maJobPage.maLayout.setBorders( nIndex-1, 0, 0, 0, aBorder.Width() ); #endif + // create auto mnemomnics now so they can be calculated in layout + ImplWindowAutoMnemonic( &maJobPage ); + ImplWindowAutoMnemonic( &maNUpPage ); + ImplWindowAutoMnemonic( &maOptionsPage ); + ImplWindowAutoMnemonic( this ); + // calculate job page Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); // and layout page @@ -1654,6 +1763,7 @@ void PrintDialog::checkControlDependencies() maJobPage.maCollateImage.SetSizePixel( aImgSize ); maJobPage.maCollateImage.SetImage( bHC ? aHCImg : aImg ); maJobPage.maCollateImage.SetModeImage( aHCImg, BMP_COLOR_HIGHCONTRAST ); + maJobPage.maLayout.resize(); // enable setup button only for printers that can be setup bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); @@ -2444,6 +2554,11 @@ void PrintProgressDialog::tick() setProgress( ++mnCur ); } +void PrintProgressDialog::reset() +{ + setProgress( 0 ); +} + void PrintProgressDialog::Paint( const Rectangle& ) { if( maProgressRect.IsEmpty() ) diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 9987dae32dbb..c139ae1ffb30 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -61,13 +61,17 @@ public: ~ImplData(); VirtualDevice* mpVirDev; - BOOL mbTopBorder:1; + long mnItemBorderWidth; + bool mbTopBorder:1; + bool mbDrawItemFrames:1; }; StatusBar::ImplData::ImplData() { mpVirDev = NULL; - mbTopBorder = FALSE; + mbTopBorder = false; + mbDrawItemFrames = false; + mnItemBorderWidth = 0; } StatusBar::ImplData::~ImplData() @@ -351,9 +355,7 @@ Rectangle StatusBar::ImplGetItemRectPos( USHORT nPos ) const { Rectangle aRect; ImplStatusItem* pItem; - pItem = mpItemList->GetObject( nPos ); - if ( pItem ) { if ( pItem->mbVisible ) @@ -372,6 +374,25 @@ Rectangle StatusBar::ImplGetItemRectPos( USHORT nPos ) const // ----------------------------------------------------------------------- +USHORT StatusBar::ImplGetFirstVisiblePos() const +{ + ImplStatusItem* pItem; + + for( USHORT nPos = 0; nPos < mpItemList->Count(); nPos++ ) + { + pItem = mpItemList->GetObject( nPos ); + if ( pItem ) + { + if ( pItem->mbVisible ) + return nPos; + } + } + + return ~0; +} + +// ----------------------------------------------------------------------- + void StatusBar::ImplDrawText( BOOL bOffScreen, long nOldTextWidth ) { // Das ueberschreiben der Item-Box verhindern @@ -418,8 +439,9 @@ void StatusBar::ImplDrawItem( BOOL bOffScreen, USHORT nPos, BOOL bDrawText, BOOL // Ausgabebereich berechnen ImplStatusItem* pItem = mpItemList->GetObject( nPos ); - Rectangle aTextRect( aRect.Left()+1, aRect.Top()+1, - aRect.Right()-1, aRect.Bottom()-1 ); + long nW = mpImplData->mnItemBorderWidth + 1; + Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW, + aRect.Right()-nW, aRect.Bottom()-nW ); Size aTextRectSize( aTextRect.GetSize() ); if ( bOffScreen ) @@ -470,17 +492,36 @@ void StatusBar::ImplDrawItem( BOOL bOffScreen, USHORT nPos, BOOL bDrawText, BOOL SetClipRegion(); // Frame ausgeben - if ( bDrawFrame && !(pItem->mnBits & SIB_FLAT) ) + if ( bDrawFrame ) { - USHORT nStyle; + if( mpImplData->mbDrawItemFrames ) + { + if( !(pItem->mnBits & SIB_FLAT) ) + { + USHORT nStyle; - if ( pItem->mnBits & SIB_IN ) - nStyle = FRAME_DRAW_IN; - else - nStyle = FRAME_DRAW_OUT; + if ( pItem->mnBits & SIB_IN ) + nStyle = FRAME_DRAW_IN; + else + nStyle = FRAME_DRAW_OUT; + + DecorationView aDecoView( this ); + aDecoView.DrawFrame( aRect, nStyle ); + } + } + else if( nPos != ImplGetFirstVisiblePos() ) + { + // draw separator + Point aFrom( aRect.TopLeft() ); + aFrom.X()--; + aFrom.Y()++; + Point aTo( aRect.BottomLeft() ); + aTo.X()--; + aTo.Y()--; - DecorationView aDecoView( this ); - aDecoView.DrawFrame( aRect, nStyle ); + DecorationView aDecoView( this ); + aDecoView.DrawSeparator( aFrom, aTo ); + } } if ( !ImplIsRecordLayout() ) @@ -688,8 +729,6 @@ void StatusBar::ImplCalcProgressRect() } if( ! bNativeOK ) maPrgsTxtPos.Y() = mnTextY; - - } // ----------------------------------------------------------------------- @@ -1227,8 +1266,11 @@ Rectangle StatusBar::GetItemRect( USHORT nItemId ) const { // Rechteck holen und Rahmen abziehen aRect = ImplGetItemRectPos( nPos ); - aRect.Left()++; - aRect.Right()--; + long nW = mpImplData->mnItemBorderWidth+1; + aRect.Top() += nW-1; + aRect.Bottom() -= nW-1; + aRect.Left() += nW; + aRect.Right() -= nW; return aRect; } } @@ -1248,8 +1290,9 @@ Point StatusBar::GetItemTextPos( USHORT nItemId ) const // Rechteck holen ImplStatusItem* pItem = mpItemList->GetObject( nPos ); Rectangle aRect = ImplGetItemRectPos( nPos ); - Rectangle aTextRect( aRect.Left()+1, aRect.Top()+1, - aRect.Right()-1, aRect.Bottom()-1 ); + long nW = mpImplData->mnItemBorderWidth + 1; + Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW, + aRect.Right()-nW, aRect.Bottom()-nW ); Point aPos = ImplGetItemTextPos( aTextRect.GetSize(), Size( GetTextWidth( pItem->maText ), GetTextHeight() ), pItem->mnBits ); @@ -1524,9 +1567,9 @@ void StatusBar::SetBottomBorder( BOOL bBottomBorder ) void StatusBar::SetTopBorder( BOOL bTopBorder ) { - if ( mpImplData->mbTopBorder != bTopBorder ) + if ( mpImplData->mbTopBorder != static_cast<bool>(bTopBorder) ) { - mpImplData->mbTopBorder = bTopBorder; + mpImplData->mbTopBorder = static_cast<bool>(bTopBorder); ImplCalcBorder(); } } @@ -1690,7 +1733,22 @@ Size StatusBar::CalcWindowSizePixel() const } } - nCalcHeight = nMinHeight+nBarTextOffset; + if( mpImplData->mbDrawItemFrames && + pThis->IsNativeControlSupported( CTRL_FRAME, PART_BORDER ) ) + { + ImplControlValue aControlValue( FRAME_DRAW_NODRAW ); + Region aBound, aContent; + Region aNatRgn( Rectangle( Point( 0, 0 ), Size( 150, 50 ) ) ); + if( pThis->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, + aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) + { + mpImplData->mnItemBorderWidth = + ( aBound.GetBoundRect().GetHeight() - + aContent.GetBoundRect().GetHeight() ) / 2; + } + } + + nCalcHeight = nMinHeight+nBarTextOffset + 2*mpImplData->mnItemBorderWidth; if( nCalcHeight < nProgressHeight+2 ) nCalcHeight = nProgressHeight+2; diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx index 02a8b6a5b717..874881c0c5ef 100644 --- a/vcl/source/window/tabdlg.cxx +++ b/vcl/source/window/tabdlg.cxx @@ -274,20 +274,3 @@ void TabDialog::AdjustLayout() ImplPosControls(); } -// ----------------------------------------------------------------------- - -TabControl* TabDialog::ImplGetFirstTabControl() const -{ - Window* pChild = GetWindow( WINDOW_FIRSTCHILD ); - while ( pChild ) - { - if ( pChild->IsVisible() && (pChild != mpViewWindow) ) - { - if ( pChild->GetType() == WINDOW_TABCONTROL ) - return (TabControl*)pChild; - } - pChild = pChild->GetWindow( WINDOW_NEXT ); - } - return NULL; -} - diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 516bc53d8920..b47aa50a2e72 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -502,6 +502,13 @@ void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, BOOL bCallHdl ) } } + static const char* pEnvHC = getenv( "SAL_FORCE_HC" ); + if( pEnvHC && *pEnvHC ) + { + aStyleSettings.SetHighContrastMode( TRUE ); + rSettings.SetStyleSettings( aStyleSettings ); + } + #ifdef DBG_UTIL // Evt. AppFont auf Fett schalten, damit man feststellen kann, // ob fuer die Texte auf anderen Systemen genuegend Platz @@ -8147,7 +8154,7 @@ const XubString& Window::GetHelpText() const { rtl::OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.Len() ); aTxt.append( mpWindowImpl->maHelpText ); - aTxt.appendAscii( "\n+++++++++++++++\n" ); + aTxt.appendAscii( "\n------------------\n" ); if( bStrHelpId ) aTxt.append( rtl::OUString( aStrHelpId ) ); else diff --git a/vcl/source/window/window3.cxx b/vcl/source/window/window3.cxx index 9c10c5f131bf..aecbc9c3ef0c 100644 --- a/vcl/source/window/window3.cxx +++ b/vcl/source/window/window3.cxx @@ -104,6 +104,12 @@ void Window::ImplMoveControlValue( ControlType nType, const ImplControlValue& aV { switch( nType ) { + case CTRL_SLIDER: + { + SliderValue* pSlVal = reinterpret_cast<SliderValue*>(aValue.getOptionalVal()); + pSlVal->maThumbRect.Move( rDelta.X(), rDelta.Y() ); + } + break; case CTRL_SCROLLBAR: { ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(aValue.getOptionalVal()); diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 93e1b0837429..95ac5940b6d2 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -295,7 +295,7 @@ static BOOL ImplCallCommand( Window* pChild, USHORT nEvt, void* pData = NULL, else { // simulate mouseposition at center of window - Size aSize = pChild->GetOutputSize(); + Size aSize( pChild->GetOutputSizePixel() ); aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 ); } } diff --git a/vcl/unx/gtk/a11y/atkbridge.cxx b/vcl/unx/gtk/a11y/atkbridge.cxx index 9498c4570ae0..47efde7d3dfd 100644 --- a/vcl/unx/gtk/a11y/atkbridge.cxx +++ b/vcl/unx/gtk/a11y/atkbridge.cxx @@ -41,7 +41,7 @@ bool InitAtkBridge(void) const char* pVersion = atk_get_toolkit_version(); if( ! pVersion ) { - g_warning( "unable to get gail version number" ); + // g_warning( "unable to get gail version number" ); return false; } @@ -50,7 +50,7 @@ bool InitAtkBridge(void) /* check gail minimum version requirements */ if( sscanf( pVersion, "%u.%u.%u", &major, &minor, µ) < 3 ) { - g_warning( "unable to parse gail version number" ); + // g_warning( "unable to parse gail version number" ); return false; } diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx index 6ed99d0cf3a3..13492f3d4a5c 100644 --- a/vcl/unx/gtk/a11y/atkutil.cxx +++ b/vcl/unx/gtk/a11y/atkutil.cxx @@ -500,6 +500,7 @@ static void handle_toolbox_buttonchange(VclWindowEvent const *pEvent) /*****************************************************************************/ +/* currently not needed anymore... static void create_wrapper_for_children(Window *pWindow) { if( pWindow && pWindow->IsReallyVisible() ) @@ -517,6 +518,7 @@ static void create_wrapper_for_children(Window *pWindow) } } } +*/ /*****************************************************************************/ @@ -695,7 +697,11 @@ long WindowEventHandler(void *, ::VclSimpleEvent const * pEvent) break; case VCLEVENT_COMBOBOX_SETTEXT: - create_wrapper_for_children(static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow()); + // MT 2010/02: This looks quite strange to me. Stumbled over this when fixing #i104290#. + // This kicked in when leaving the combobox in the toolbar, after that the events worked. + // I guess this was a try to work around missing combobox events, which didn't do the full job, and shouldn't be necessary anymore. + // Fix for #i104290# was done in toolkit/source/awt/vclxaccessiblecomponent, FOCUSED state for compound controls in general. + // create_wrapper_for_children(static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow()); break; default: diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index b1529e060270..d1e5c5954352 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -221,8 +221,7 @@ void GtkSalDisplay::monitorsChanged( GdkScreen* pScreen ) { GdkRectangle dest; gdk_screen_get_monitor_geometry(pScreen, i, &dest); - m_aXineramaScreens.push_back( Rectangle( Point(dest.x, - dest.y ), Size( dest.width, dest.height ) ) ); + addXineramaScreenUnique( dest.x, dest.y, dest.width, dest.height ); } m_bXinerama = m_aXineramaScreens.size() > 1; if( ! m_aFrames.empty() ) @@ -663,7 +662,8 @@ void GtkXLib::Init() if( pScreen ) { g_signal_connect( G_OBJECT(pScreen), "size-changed", G_CALLBACK(signalScreenSizeChanged), m_pGtkSalDisplay ); - g_signal_connect( G_OBJECT(pScreen), "monitors-changed", G_CALLBACK(signalMonitorsChanged), m_pGtkSalDisplay ); + if( ! gtk_check_version( 2, 14, 0 ) ) // monitors-changed came in with 2.14, avoid an assertion + g_signal_connect( G_OBJECT(pScreen), "monitors-changed", G_CALLBACK(signalMonitorsChanged), m_pGtkSalDisplay ); } } } diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 372d10fa5aaf..de4d55b0230a 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -45,6 +45,8 @@ #include "saldisp.hxx" #include "vcl/svapp.hxx" +typedef struct _cairo_font_options cairo_font_options_t; + // initialize statics BOOL GtkSalGraphics::bThemeChanged = TRUE; BOOL GtkSalGraphics::bNeedPixmapPaint = FALSE; @@ -97,6 +99,8 @@ struct NWFWidgetData GtkWidget * gTooltipPopup; GtkWidget * gProgressBar; GtkWidget * gTreeView; + GtkWidget * gHScale; + GtkWidget * gVScale; NWPixmapCacheList* gNWPixmapCacheList; NWPixmapCache* gCacheTabItems; @@ -129,10 +133,12 @@ struct NWFWidgetData gMenuItemMenuWidget( NULL ), gMenuItemCheckMenuWidget( NULL ), gMenuItemRadioMenuWidget( NULL ), - gImageMenuItem( NULL ), + gImageMenuItem( NULL ), gTooltipPopup( NULL ), gProgressBar( NULL ), gTreeView( NULL ), + gHScale( NULL ), + gVScale( NULL ), gNWPixmapCacheList( NULL ), gCacheTabItems( NULL ), gCacheTabPages( NULL ) @@ -170,6 +176,7 @@ static void NWEnsureGTKMenu ( int nScreen ); static void NWEnsureGTKTooltip ( int nScreen ); static void NWEnsureGTKProgressBar ( int nScreen ); static void NWEnsureGTKTreeView ( int nScreen ); +static void NWEnsureGTKSlider ( int nScreen ); static void NWConvertVCLStateToGTKState( ControlState nVCLState, GtkStateType* nGTKState, GtkShadowType* nGTKShadow ); static void NWAddWidgetToCacheWindow( GtkWidget* widget, int nScreen ); @@ -587,8 +594,13 @@ BOOL GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP ) || ((nType == CTRL_LISTNODE || nType == CTRL_LISTNET) && ( (nPart == PART_ENTIRE_CONTROL) ) + ) || + ((nType == CTRL_SLIDER) && + ( (nPart == PART_TRACK_HORZ_AREA) + || (nPart == PART_TRACK_VERT_AREA) ) ) + ) return( TRUE ); return( FALSE ); @@ -873,6 +885,10 @@ BOOL GtkSalGraphics::drawNativeControl( ControlType nType, // don't actually draw anything; gtk treeviews do not draw lines returnVal = true; } + else if( (nType == CTRL_SLIDER) ) + { + returnVal = NWPaintGTKSlider( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rControlHandle, rCaption ); + } if( pixmap ) { @@ -1101,6 +1117,30 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, rNativeContentRegion = rNativeBoundingRegion; returnVal = TRUE; } + if( (nType == CTRL_SLIDER) && (nPart == PART_THUMB_HORZ || nPart == PART_THUMB_VERT) ) + { + NWEnsureGTKSlider( m_nScreen ); + GtkWidget* widget = (nPart == PART_THUMB_HORZ) ? gWidgetData[m_nScreen].gHScale : gWidgetData[m_nScreen].gVScale; + gint slider_length = 10; + gint slider_width = 10; + gtk_widget_style_get( widget, + "slider-width", &slider_width, + "slider-length", &slider_length, + (char *)NULL); + Rectangle aRect( rControlRegion.GetBoundRect() ); + if( nPart == PART_THUMB_HORZ ) + { + aRect.Right() = aRect.Left() + slider_length - 1; + aRect.Bottom() = aRect.Top() + slider_width - 1; + } + else + { + aRect.Bottom() = aRect.Top() + slider_length - 1; + aRect.Right() = aRect.Left() + slider_width - 1; + } + rNativeBoundingRegion = rNativeContentRegion = Region( aRect ); + returnVal = TRUE; + } return( returnVal ); } @@ -3010,6 +3050,133 @@ BOOL GtkSalGraphics::NWPaintGTKProgress( return bRet; } +BOOL GtkSalGraphics::NWPaintGTKSlider( + GdkDrawable*, + ControlType, ControlPart nPart, + const Rectangle& rControlRectangle, + const clipList&, + ControlState nState, const ImplControlValue& rValue, + SalControlHandle&, const OUString& ) +{ + NWEnsureGTKSlider( m_nScreen ); + + gint w, h; + w = rControlRectangle.GetWidth(); + h = rControlRectangle.GetHeight(); + + SliderValue* pVal = (SliderValue*)rValue.getOptionalVal(); + + GdkPixmap* pixmap = NWGetPixmapFromScreen( rControlRectangle ); + if( ! pixmap ) + return FALSE; + + (void)pVal; + + GdkDrawable* const &pixDrawable = GDK_DRAWABLE( pixmap ); + GtkWidget* pWidget = (nPart == PART_TRACK_HORZ_AREA) + ? GTK_WIDGET(gWidgetData[m_nScreen].gHScale) + : GTK_WIDGET(gWidgetData[m_nScreen].gVScale); + const gchar* pDetail = (nPart == PART_TRACK_HORZ_AREA) ? "hscale" : "vscale"; + GtkOrientation eOri = (nPart == PART_TRACK_HORZ_AREA) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; + GtkStateType eState = (nState & CTRL_STATE_ENABLED) ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE; + gint slider_width = 10; + gint slider_length = 10; + gint trough_border = 0; + gtk_widget_style_get( pWidget, + "slider-width", &slider_width, + "slider-length", &slider_length, + "trough-border", &trough_border, + NULL); + + eState = (nState & CTRL_STATE_ENABLED) ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE; + if( nPart == PART_TRACK_HORZ_AREA ) + { + gtk_paint_box( pWidget->style, + pixDrawable, + eState, + GTK_SHADOW_IN, + NULL, + pWidget, + "trough", + 0, (h-slider_width-2*trough_border)/2, w, slider_width + 2*trough_border); + gint x = (w - slider_length + 1) * (pVal->mnCur - pVal->mnMin) / (pVal->mnMax - pVal->mnMin); + gtk_paint_slider( pWidget->style, + pixDrawable, + eState, + GTK_SHADOW_OUT, + NULL, + pWidget, + pDetail, + x, (h-slider_width)/2, + slider_length, slider_width, + eOri ); + } + else + { + gtk_paint_box( pWidget->style, + pixDrawable, + eState, + GTK_SHADOW_IN, + NULL, + pWidget, + "trough", + (w-slider_width-2*trough_border)/2, 0, slider_width + 2*trough_border, h); + gint y = (h - slider_length + 1) * (pVal->mnCur - pVal->mnMin) / (pVal->mnMax - pVal->mnMin); + gtk_paint_slider( pWidget->style, + pixDrawable, + eState, + GTK_SHADOW_OUT, + NULL, + pWidget, + pDetail, + (w-slider_width)/2, y, + slider_width, slider_length, + eOri ); + } + #if 0 + // paint background + gtk_paint_flat_box( gWidgetData[m_nScreen].gProgressBar->style, + pixDrawable, + GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + NULL, + gWidgetData[m_nScreen].gProgressBar, + "trough", + 0, 0, w, h ); + if( nProgressWidth > 0 ) + { + // paint progress + if( Application::GetSettings().GetLayoutRTL() ) + { + gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style, + pixDrawable, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, + gWidgetData[m_nScreen].gProgressBar, + "bar", + w-nProgressWidth, 0, nProgressWidth, h + ); + } + else + { + gtk_paint_box( gWidgetData[m_nScreen].gProgressBar->style, + pixDrawable, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, + gWidgetData[m_nScreen].gProgressBar, + "bar", + 0, 0, nProgressWidth, h + ); + } + } + #endif + + BOOL bRet = NWRenderPixmapToScreen( pixmap, rControlRectangle ); + g_object_unref( pixmap ); + + return bRet; +} + //---- static Rectangle NWGetListBoxButtonRect( int nScreen, @@ -3269,20 +3436,23 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aStyleSet.SetHighlightColor( aHighlightColor ); aStyleSet.SetHighlightTextColor( aHighlightTextColor ); - // hyperlink colors - GdkColor *link_color = NULL; - gtk_widget_style_get (m_pWindow, "link-color", &link_color, NULL); - if (link_color) - { - aStyleSet.SetLinkColor(getColor(*link_color)); - gdk_color_free (link_color); - link_color = NULL; - } - gtk_widget_style_get (m_pWindow, "visited-link-color", &link_color, NULL); - if (link_color) + if( ! gtk_check_version( 2, 10, 0 ) ) // link colors came in with 2.10, avoid an assertion { - aStyleSet.SetVisitedLinkColor(getColor(*link_color)); - gdk_color_free (link_color); + // hyperlink colors + GdkColor *link_color = NULL; + gtk_widget_style_get (m_pWindow, "link-color", &link_color, NULL); + if (link_color) + { + aStyleSet.SetLinkColor(getColor(*link_color)); + gdk_color_free (link_color); + link_color = NULL; + } + gtk_widget_style_get (m_pWindow, "visited-link-color", &link_color, NULL); + if (link_color) + { + aStyleSet.SetVisitedLinkColor(getColor(*link_color)); + gdk_color_free (link_color); + } } // Tab colors @@ -3469,12 +3639,25 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) // preferred icon style gchar* pIconThemeName = NULL; g_object_get( gtk_settings_get_default(), "gtk-icon-theme-name", &pIconThemeName, (char *)NULL ); - aStyleSet.SetPreferredSymbolsStyleName( OUString::createFromAscii(pIconThemeName) ); - g_free (pIconThemeName); + aStyleSet.SetPreferredSymbolsStyleName( OUString::createFromAscii( pIconThemeName ) ); + g_free( pIconThemeName ); // FIXME: need some way of fetching toolbar icon size. // aStyleSet.SetToolbarIconSize( STYLE_TOOLBAR_ICONSIZE_SMALL ); + const cairo_font_options_t* pNewOptions = NULL; + if( GdkScreen* pScreen = gdk_display_get_screen( gdk_display_get_default(), m_nScreen ) ) + { +//#if !GTK_CHECK_VERSION(2,8,1) +#if !GTK_CHECK_VERSION(2,9,0) + static cairo_font_options_t* (*gdk_screen_get_font_options)(GdkScreen*) = + (cairo_font_options_t*(*)(GdkScreen*))osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_screen_get_font_options" ); + if( gdk_screen_get_font_options != NULL ) +#endif + pNewOptions = gdk_screen_get_font_options( pScreen ); + } + aStyleSet.SetCairoFontOptions( pNewOptions ); + // finally update the collected settings rSettings.SetStyleSettings( aStyleSet ); @@ -3947,3 +4130,17 @@ static void NWEnsureGTKTreeView( int nScreen ) NWAddWidgetToCacheWindow( gWidgetData[nScreen].gTreeView, nScreen ); } } + +static void NWEnsureGTKSlider( int nScreen ) +{ + if( !gWidgetData[nScreen].gHScale ) + { + gWidgetData[nScreen].gHScale = gtk_hscale_new_with_range(0, 10, 1); + NWAddWidgetToCacheWindow( gWidgetData[nScreen].gHScale, nScreen ); + } + if( !gWidgetData[nScreen].gVScale ) + { + gWidgetData[nScreen].gVScale = gtk_vscale_new_with_range(0, 10, 1); + NWAddWidgetToCacheWindow( gWidgetData[nScreen].gVScale, nScreen ); + } +} diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx index 5d7fcabb7c8f..ef356eb57aa9 100644 --- a/vcl/unx/gtk/window/gtkframe.cxx +++ b/vcl/unx/gtk/window/gtkframe.cxx @@ -806,8 +806,15 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) /* #i100116# metacity has a peculiar behavior regarding WM_HINT accept focus and _NET_WM_USER_TIME at some point that may be fixed in metacity and we will have to revisit this */ - bool bMetaCityToolWindowHack = getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("Metacity") && - (nStyle & SAL_FRAME_STYLE_TOOLWINDOW ); + + // MT/PL 2010/02: #i102694# and #i102803# have been introduced by this hack + // Nowadays the original issue referenced above doesn't seem to exist anymore, tested different szenarious described in the issues + // If some older versions of MetaCity are still in use somewhere, they need to be updated, instead of using strange hacks in OOo. + // As a work around for such old systems, people might consider to not use the GTK plugin. + + bool bMetaCityToolWindowHack = false; + // bMetaCityToolWindowHack = getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("Metacity") && (nStyle & SAL_FRAME_STYLE_TOOLWINDOW ); + if( bDecoHandling ) { bool bNoDecor = ! (nStyle & (SAL_FRAME_STYLE_MOVEABLE | SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_CLOSEABLE ) ); @@ -2081,7 +2088,14 @@ void GtkSalFrame::ToTop( USHORT nFlags ) * is set to false. */ if( (m_nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_FLOAT_FOCUSABLE)) ) + { + // sad but true: this can cause an XError, we need to catch that + // to do this we need to synchronize with the XServer + getDisplay()->GetXLib()->PushXErrorLevel( true ); XSetInputFocus( getDisplay()->GetDisplay(), GDK_WINDOW_XWINDOW( m_pWindow->window ), RevertToParent, CurrentTime ); + XSync( getDisplay()->GetDisplay(), False ); + getDisplay()->GetXLib()->PopXErrorLevel(); + } } else { @@ -3124,10 +3138,13 @@ void GtkSalFrame::signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer fram // redraw itself to adjust to the new style // where there IS no new style resulting in tremendous unnecessary flickering if( pPrevious != NULL ) + { // signalStyleSet does NOT usually have the gdk lock // so post user event to safely dispatch the SALEVENT_SETTINGSCHANGED // note: settings changed for multiple frames is avoided in winproc.cxx ImplHandleSettings pThis->getDisplay()->SendInternalEvent( pThis, NULL, SALEVENT_SETTINGSCHANGED ); + pThis->getDisplay()->SendInternalEvent( pThis, NULL, SALEVENT_FONTCHANGED ); + } /* #i64117# gtk sets a nice background pixmap * but we actually don't really want that, so save diff --git a/vcl/unx/headless/svpframe.cxx b/vcl/unx/headless/svpframe.cxx index 37c5eeb846a4..1adf9a51cce4 100644 --- a/vcl/unx/headless/svpframe.cxx +++ b/vcl/unx/headless/svpframe.cxx @@ -82,6 +82,33 @@ SvpSalFrame::~SvpSalFrame() (*it)->SetParent( m_pParent ); if( m_pParent ) m_pParent->m_aChildren.remove( this ); + + if( s_pFocusFrame == this ) + { + s_pFocusFrame = NULL; + // call directly here, else an event for a destroyed frame would be dispatched + CallCallback( SALEVENT_LOSEFOCUS, NULL ); + // if the handler has not set a new focus frame + // pass focus to another frame, preferably a document style window + if( s_pFocusFrame == NULL ) + { + const std::list< SalFrame* >& rFrames( m_pInstance->getFrames() ); + for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it ) + { + SvpSalFrame* pFrame = const_cast<SvpSalFrame*>(static_cast<const SvpSalFrame*>(*it)); + if( pFrame->m_bVisible && + pFrame->m_pParent == NULL && + (pFrame->m_nStyle & (SAL_FRAME_STYLE_MOVEABLE | + SAL_FRAME_STYLE_SIZEABLE | + SAL_FRAME_STYLE_CLOSEABLE) ) != 0 + ) + { + pFrame->GetFocus(); + break; + } + } + } + } } void SvpSalFrame::GetFocus() diff --git a/vcl/unx/headless/svpgdi.cxx b/vcl/unx/headless/svpgdi.cxx index 114bd4c8a5bc..e65c9faf1432 100644 --- a/vcl/unx/headless/svpgdi.cxx +++ b/vcl/unx/headless/svpgdi.cxx @@ -584,3 +584,4 @@ bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const { return false; } + diff --git a/vcl/unx/headless/svpgdi.hxx b/vcl/unx/headless/svpgdi.hxx index 9e25b67394e7..132dafaa9adf 100644 --- a/vcl/unx/headless/svpgdi.hxx +++ b/vcl/unx/headless/svpgdi.hxx @@ -170,3 +170,4 @@ public: }; #endif + diff --git a/vcl/unx/headless/svpinst.cxx b/vcl/unx/headless/svpinst.cxx index 485062bf0617..466b56868900 100644 --- a/vcl/unx/headless/svpinst.cxx +++ b/vcl/unx/headless/svpinst.cxx @@ -55,6 +55,19 @@ extern "C" } } +bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const +{ + for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin(); + it != m_aFrames.end(); ++it ) + { + if( *it == pFrame ) + { + return true; + } + } + return false; +} + SvpSalInstance* SvpSalInstance::s_pDefaultInstance = NULL; SvpSalInstance::SvpSalInstance() @@ -346,12 +359,15 @@ void SvpSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) { for( std::list<SalUserEvent>::const_iterator it = aEvents.begin(); it != aEvents.end(); ++it ) { - it->m_pFrame->CallCallback( it->m_nEvent, it->m_pData ); - if( it->m_nEvent == SALEVENT_RESIZE ) + if ( isFrameAlive( it->m_pFrame ) ) { - // this would be a good time to post a paint - const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>(it->m_pFrame); - pSvpFrame->PostPaint(); + it->m_pFrame->CallCallback( it->m_nEvent, it->m_pData ); + if( it->m_nEvent == SALEVENT_RESIZE ) + { + // this would be a good time to post a paint + const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>(it->m_pFrame); + pSvpFrame->PostPaint(); + } } } } diff --git a/vcl/unx/headless/svpinst.hxx b/vcl/unx/headless/svpinst.hxx index d37c1c7e126e..284a2d11cd82 100644 --- a/vcl/unx/headless/svpinst.hxx +++ b/vcl/unx/headless/svpinst.hxx @@ -108,6 +108,9 @@ class SvpSalInstance : public SalInstance std::list< SalUserEvent > m_aUserEvents; std::list< SalFrame* > m_aFrames; + + bool isFrameAlive( const SalFrame* pFrame ) const; + public: static SvpSalInstance* s_pDefaultInstance; diff --git a/vcl/unx/headless/svppspgraphics.cxx b/vcl/unx/headless/svppspgraphics.cxx index 353b10467d40..7f551051c1a7 100644 --- a/vcl/unx/headless/svppspgraphics.cxx +++ b/vcl/unx/headless/svppspgraphics.cxx @@ -1160,32 +1160,6 @@ ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintF aDFA.mePitch = ToFontPitch (rInfo.m_ePitch); aDFA.mbSymbolFlag = (rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL); - switch (rInfo.m_eEmbeddedbitmap) - { - default: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - break; - case psp::fcstatus::istrue: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_TRUE; - break; - case psp::fcstatus::isfalse: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_FALSE; - break; - } - - switch (rInfo.m_eAntialias) - { - default: - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - break; - case psp::fcstatus::istrue: - aDFA.meAntiAlias = ANTIALIAS_TRUE; - break; - case psp::fcstatus::isfalse: - aDFA.meAntiAlias = ANTIALIAS_FALSE; - break; - } - switch( rInfo.m_eType ) { case psp::fonttype::Builtin: diff --git a/vcl/unx/headless/svppspgraphics.hxx b/vcl/unx/headless/svppspgraphics.hxx index 8addbc3de5f7..82ba613615cb 100644 --- a/vcl/unx/headless/svppspgraphics.hxx +++ b/vcl/unx/headless/svppspgraphics.hxx @@ -190,3 +190,4 @@ public: }; #endif // _SVP_PSPGRAPHICS_HXX + diff --git a/vcl/unx/inc/plugins/gtk/gtkgdi.hxx b/vcl/unx/inc/plugins/gtk/gtkgdi.hxx index 9db81aa30a4d..ed3f782c8576 100644 --- a/vcl/unx/inc/plugins/gtk/gtkgdi.hxx +++ b/vcl/unx/inc/plugins/gtk/gtkgdi.hxx @@ -168,6 +168,11 @@ protected: const clipList& rClipList, ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& rCaption ); + BOOL NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, + const Rectangle& rControlRectangle, + const clipList& rClipList, + ControlState nState, const ImplControlValue& aValue, + SalControlHandle& rControlHandle, const OUString& rCaption ); BOOL NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, const Rectangle& rControlRectangle, const clipList& rClipList, diff --git a/vcl/unx/inc/pspgraphics.h b/vcl/unx/inc/pspgraphics.h index 4dce4ee8b06c..2eae73cdaa86 100644 --- a/vcl/unx/inc/pspgraphics.h +++ b/vcl/unx/inc/pspgraphics.h @@ -103,7 +103,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); virtual void GetFontMetric( ImplFontMetricData* ); - virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); + virtual ULONG GetKernPairs( ULONG nMaxPairs, ImplKernPairData* ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/unx/inc/saldisp.hxx b/vcl/unx/inc/saldisp.hxx index 368e554794ad..e54d6e828911 100644 --- a/vcl/unx/inc/saldisp.hxx +++ b/vcl/unx/inc/saldisp.hxx @@ -404,6 +404,7 @@ protected: int processRandREvent( XEvent* ); void doDestruct(); + void addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight ); public: static SalDisplay *GetSalDisplay( Display* display ); static BOOL BestVisual( Display *pDisp, diff --git a/vcl/unx/inc/salgdi.h b/vcl/unx/inc/salgdi.h index 09e85c6840b8..da69f04b6f8f 100644 --- a/vcl/unx/inc/salgdi.h +++ b/vcl/unx/inc/salgdi.h @@ -250,7 +250,7 @@ public: virtual void SetTextColor( SalColor nSalColor ); virtual USHORT SetFont( ImplFontSelectData*, int nFallbackLevel ); virtual void GetFontMetric( ImplFontMetricData* ); - virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); + virtual ULONG GetKernPairs( ULONG nMaxPairs, ImplKernPairData* ); virtual ImplFontCharMap* GetImplFontCharMap() const; virtual void GetDevFontList( ImplDevFontList* ); virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/unx/kde4/KDESalGraphics.cxx b/vcl/unx/kde4/KDESalGraphics.cxx index 79de48302649..25dd50ce3958 100644 --- a/vcl/unx/kde4/KDESalGraphics.cxx +++ b/vcl/unx/kde4/KDESalGraphics.cxx @@ -88,8 +88,18 @@ QRect region2QRect( const Region& rControlRegion ) { Rectangle aRect = rControlRegion.GetBoundRect(); - return QRect( QPoint( aRect.Left(), aRect.Top() ), - QPoint( aRect.Right(), aRect.Bottom() ) ); + return QRect(aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight()); +} + +KDESalGraphics::KDESalGraphics() : + m_image(0) +{ +} + +KDESalGraphics::~KDESalGraphics() +{ + if (m_image) + delete m_image; } BOOL KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart part ) @@ -133,6 +143,9 @@ BOOL KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart par if (type == CTRL_RADIOBUTTON) return true; + if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA) ) + return true; + return false; if ( (type == CTRL_TAB_ITEM) && (part == PART_ENTIRE_CONTROL) ) return true; @@ -143,7 +156,6 @@ BOOL KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart par return false; } - BOOL KDESalGraphics::hitTestNativeControl( ControlType, ControlPart, const Region&, const Point&, SalControlHandle&, BOOL& ) @@ -151,28 +163,59 @@ BOOL KDESalGraphics::hitTestNativeControl( ControlType, ControlPart, return FALSE; } -void lcl_drawFrame( QRect& i_rRect, QPainter& i_rPainter, QStyle::PrimitiveElement i_nElement, - ControlState i_nState, const ImplControlValue& i_rValue ) +/// helper drawing methods +namespace { + void draw( QStyle::ControlElement element, QStyleOption* option, QImage* image, QStyle::State state ) + { + option->state |= state; + option->rect = image->rect(); + + QPainter painter(image); + kapp->style()->drawControl(element, option, &painter); + } + + void draw( QStyle::PrimitiveElement element, QStyleOption* option, QImage* image, QStyle::State state, int nAdjust = 0 ) + { + option->state |= state; + option->rect = image->rect(); + if( nAdjust ) + option->rect.adjust( nAdjust, nAdjust, -nAdjust, -nAdjust ); + + QPainter painter(image); + kapp->style()->drawPrimitive(element, option, &painter); + } + + void draw( QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* image, QStyle::State state ) + { + option->state |= state; + option->rect = image->rect(); + + QPainter painter(image); + kapp->style()->drawComplexControl(element, option, &painter); + } + + void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State state) + { #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QStyleOptionFrameV3 styleOption; - styleOption.frameShape = QFrame::StyledPanel; + QStyleOptionFrameV3 option; + option.frameShape = QFrame::StyledPanel; + option.state = QStyle::State_Sunken; #else - QStyleOptionFrame styleOption; - QFrame aFrame( NULL ); - aFrame.setFrameRect( QRect(0, 0, i_rRect.width(), i_rRect.height()) ); - aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); - aFrame.ensurePolished(); - styleOption.initFrom( &aFrame ); - styleOption.lineWidth = aFrame.lineWidth(); - styleOption.midLineWidth = aFrame.midLineWidth(); - #endif - styleOption.rect = QRect(0, 0, i_rRect.width(), i_rRect.height()); - styleOption.state = vclStateValue2StateFlag( i_nState, i_rValue ); - #if ( QT_VERSION < QT_VERSION_CHECK( 4, 5, 0 ) ) - styleOption.state |= QStyle::State_Sunken; + QStyleOptionFrame option; + + QFrame aFrame( NULL ); + aFrame.setFrameRect( QRect(0, 0, image->width(), image->height()) ); + aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); + aFrame.ensurePolished(); + + option.initFrom( &aFrame ); + option.lineWidth = aFrame.lineWidth(); + option.midLineWidth = aFrame.midLineWidth(); #endif - kapp->style()->drawPrimitive(i_nElement, &styleOption, &i_rPainter); + + draw(element, &option, image, state); + } } BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, @@ -188,10 +231,6 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, BOOL returnVal = true; - Display* dpy = GetXDisplay(); - XLIB_Window drawable = GetDrawable(); - GC gc = SelectPen(); - QRect widgetRect = region2QRect(rControlRegion); if( type == CTRL_SPINBOX && part == PART_ALL_BUTTONS ) type = CTRL_SPINBUTTONS; @@ -204,337 +243,287 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, aButtonRect.Right(), aButtonRect.Bottom() ); } - //draw right onto the window - QPixmap pixmap(widgetRect.width(), widgetRect.height()); - - if (pixmap.isNull()) + //if no image, or resized, make a new image + if (!m_image || m_image->size() != widgetRect.size()) { - return false; + if (m_image) + delete m_image; + + m_image = new QImage( widgetRect.width(), + widgetRect.height(), + QImage::Format_ARGB32 ); } + m_image->fill(KApplication::palette().color(QPalette::Window).rgb()); - QPainter painter(&pixmap); - // painter.setBackgroundMode(Qt::OpaqueMode); - //copy previous screen contents for proper blending - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QPixmap screen = QPixmap::fromX11Pixmap(drawable); - painter.drawPixmap(0,0, screen, widgetRect.left(), widgetRect.top(), widgetRect.width(), widgetRect.height()); - #else - const QX11Info& rX11Info( pixmap.x11Info() ); - X11SalGraphics::CopyScreenArea( dpy, - drawable, GetScreenNumber(), GetBitCount(), - pixmap.handle(), rX11Info.screen(), rX11Info.depth(), - GetDisplay()->GetCopyGC( GetScreenNumber() ), - widgetRect.left(), widgetRect.top(), widgetRect.width(), widgetRect.height(), - 0, 0 ); - #endif + XLIB_Region pTempClipRegion = 0; if (type == CTRL_PUSHBUTTON) { - QStyleOptionButton styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state =vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawControl( QStyle::CE_PushButton, &styleOption, &painter); + QStyleOptionButton option; + draw( QStyle::CE_PushButton, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if ( (type == CTRL_MENUBAR)) { if (part == PART_MENU_ITEM) { - QStyleOptionMenuItem styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawControl( QStyle::CE_MenuBarItem, &styleOption, &painter); + QStyleOptionMenuItem option; + draw( QStyle::CE_MenuBarItem, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); + } + else if (part == PART_ENTIRE_CONTROL) + { } else { - pixmap.fill(KApplication::palette().color(QPalette::Window)); + returnVal = false; } } else if (type == CTRL_MENU_POPUP) { if (part == PART_MENU_ITEM) { - QStyleOptionMenuItem styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawControl( QStyle::CE_MenuItem, &styleOption, &painter); + QStyleOptionMenuItem option; + draw( QStyle::CE_MenuItem, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } - else if (part == PART_MENU_ITEM_CHECK_MARK) + else if (part == PART_MENU_ITEM_CHECK_MARK && (nControlState & CTRL_STATE_PRESSED) ) { - QStyleOptionButton styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - if (nControlState & CTRL_STATE_PRESSED) - { - kapp->style()->drawPrimitive( QStyle::PE_IndicatorMenuCheckMark, &styleOption, &painter); - } + QStyleOptionButton option; + draw( QStyle::PE_IndicatorMenuCheckMark, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } - else if (part == PART_MENU_ITEM_RADIO_MARK) + else if (part == PART_MENU_ITEM_RADIO_MARK && (nControlState & CTRL_STATE_PRESSED) ) { - QStyleOptionButton styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - if (nControlState & CTRL_STATE_PRESSED) - { - kapp->style()->drawPrimitive( QStyle::PE_IndicatorRadioButton, &styleOption, &painter); - } + QStyleOptionButton option; + draw( QStyle::PE_IndicatorRadioButton, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QStyleOptionFrameV3 styleOption; + QStyleOptionFrameV3 option; + option.frameShape = QFrame::StyledPanel; #else - QStyleOptionFrameV2 styleOption; - #endif - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - styleOption.frameShape = QFrame::StyledPanel; + QStyleOptionFrameV2 option; #endif - - kapp->style()->drawPrimitive( QStyle::PE_FrameMenu, &styleOption, &painter); + draw( QStyle::PE_FrameMenu, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } } else if ( (type == CTRL_TOOLBAR) && (part == PART_BUTTON) ) { - QStyleOptionToolButton styleOption; + QStyleOptionToolButton option; - styleOption.arrowType = Qt::NoArrow; - styleOption.subControls = QStyle::SC_ToolButton; + option.arrowType = Qt::NoArrow; + option.subControls = QStyle::SC_ToolButton; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - styleOption.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise; + option.state = vclStateValue2StateFlag( nControlState, value ); + option.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise; - kapp->style()->drawComplexControl( QStyle::CC_ToolButton, &styleOption, &painter); + draw( QStyle::CC_ToolButton, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if ( (type == CTRL_TOOLBAR) && (part == PART_ENTIRE_CONTROL) ) { - QStyleOptionToolBar styleOption; + QStyleOptionToolBar option; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); + option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); + option.state = vclStateValue2StateFlag( nControlState, value ); - kapp->style()->drawControl( QStyle::CE_ToolBar, &styleOption, &painter); + draw( QStyle::CE_ToolBar, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if ( (type == CTRL_TOOLBAR) && (part == PART_THUMB_VERT) ) { - QStyleOption styleOption; + const int tw = widgetRect.width(); + widgetRect.setWidth(kapp->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent)); - int width = kapp->style()->pixelMetric(QStyle::PM_ToolBarHandleExtent); + QStyleOption option; + option.state = QStyle::State_Horizontal; - styleOption.rect = QRect(0, 0, width, widgetRect.height()); - styleOption.state = QStyle::State_Horizontal; + draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); - kapp->style()->drawPrimitive( QStyle::PE_IndicatorToolBarHandle, &styleOption, &painter); + widgetRect.setWidth(tw); } else if (type == CTRL_EDITBOX) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - - //TODO hover?? OO does not seem to do this for line edits + QStyleOptionFrameV2 option; + draw( QStyle::PE_PanelLineEdit, &option, m_image, + vclStateValue2StateFlag(nControlState, value), 2 ); - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QStyleOptionFrameV3 styleOption; - #else - QStyleOptionFrameV2 styleOption; - #endif - - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - //TODO...how does the line edit draw itself internally?? - styleOption.rect = QRect(2, 2, widgetRect.width()-4, widgetRect.height()-4); - kapp->style()->drawPrimitive( QStyle::PE_PanelLineEdit, &styleOption, &painter); - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - kapp->style()->drawPrimitive( QStyle::PE_FrameLineEdit, &styleOption, &painter); + draw( QStyle::PE_FrameLineEdit, &option, m_image, + vclStateValue2StateFlag(nControlState, value), 0 ); } else if (type == CTRL_COMBOBOX) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - - QStyleOptionComboBox styleOption; + QStyleOptionComboBox option; + option.editable = true; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - styleOption.editable = true; - - kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter); + draw( QStyle::CC_ComboBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_LISTBOX) { if( part == PART_WINDOW ) { - lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value ); + lcl_drawFrame( QStyle::PE_Frame, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else { - QStyleOptionComboBox styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - + QStyleOptionComboBox option; if (part == PART_SUB_EDIT) { - kapp->style()->drawControl(QStyle::CE_ComboBoxLabel, &styleOption, &painter); + draw( QStyle::CE_ComboBoxLabel, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else { - kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter); + draw( QStyle::CC_ComboBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } } } else if (type == CTRL_LISTNODE) { - QStyleOption styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - styleOption.state |= QStyle::State_Item; - styleOption.state |= QStyle::State_Children; + QStyleOption option; + option.state = QStyle::State_Item | QStyle::State_Children; if (nControlState & CTRL_STATE_PRESSED) - { - styleOption.state |= QStyle::State_Open; - } + option.state |= QStyle::State_Open; - kapp->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &styleOption, &painter); + draw( QStyle::PE_IndicatorBranch, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_CHECKBOX) { - QStyleOptionButton styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawControl(QStyle::CE_CheckBox, &styleOption, &painter); + QStyleOptionButton option; + draw( QStyle::CE_CheckBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_SCROLLBAR) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - if ((part == PART_DRAW_BACKGROUND_VERT) || (part == PART_DRAW_BACKGROUND_HORZ)) { + QStyleOptionSlider option; ScrollbarValue* sbVal = static_cast<ScrollbarValue *> ( value.getOptionalVal() ); - QStyleOptionSlider styleOption; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - //if the scroll bar is active (aka not degenrate...allow for hover events if (sbVal->mnVisibleSize < sbVal->mnMax) - { - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - styleOption.state |= QStyle::State_MouseOver; - } + option.state = QStyle::State_MouseOver; //horizontal or vertical if (part == PART_DRAW_BACKGROUND_VERT) - { - styleOption.orientation = Qt::Vertical; - } + option.orientation = Qt::Vertical; else - { - styleOption.state |= QStyle::State_Horizontal; - } + option.state |= QStyle::State_Horizontal; //setup parameters from the OO values - styleOption.minimum = sbVal->mnMin; - styleOption.maximum = sbVal->mnMax - sbVal->mnVisibleSize; - styleOption.sliderValue = sbVal->mnCur; - styleOption.sliderPosition = sbVal->mnCur; - styleOption.pageStep = sbVal->mnVisibleSize; + option.minimum = sbVal->mnMin; + option.maximum = sbVal->mnMax - sbVal->mnVisibleSize; + option.sliderValue = sbVal->mnCur; + option.sliderPosition = sbVal->mnCur; + option.pageStep = sbVal->mnVisibleSize; //setup the active control...always the slider if (sbVal->mnThumbState & CTRL_STATE_ROLLOVER) - { - styleOption.activeSubControls = QStyle::SC_ScrollBarSlider; - } + option.activeSubControls = QStyle::SC_ScrollBarSlider; - kapp->style()->drawComplexControl(QStyle::CC_ScrollBar, &styleOption, &painter); + draw( QStyle::CC_ScrollBar, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); + } + else + { + returnVal = false; } } else if (type == CTRL_SPINBOX) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); + QStyleOptionSpinBox option; - QStyleOptionSpinBox styleOption; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); // determine active control SpinbuttonValue* pSpinVal = (SpinbuttonValue *)(value.getOptionalVal()); if( pSpinVal ) { if( (pSpinVal->mnUpperState & CTRL_STATE_PRESSED) ) - styleOption.activeSubControls |= QStyle::SC_SpinBoxUp; + option.activeSubControls |= QStyle::SC_SpinBoxUp; if( (pSpinVal->mnLowerState & CTRL_STATE_PRESSED) ) - styleOption.activeSubControls |= QStyle::SC_SpinBoxDown; + option.activeSubControls |= QStyle::SC_SpinBoxDown; } - kapp->style()->drawComplexControl(QStyle::CC_SpinBox, &styleOption, &painter); + draw( QStyle::CC_SpinBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_GROUPBOX) { - QStyleOptionGroupBox styleOption; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawComplexControl(QStyle::CC_GroupBox, &styleOption, &painter); + QStyleOptionGroupBox option; + draw( QStyle::CC_GroupBox, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_RADIOBUTTON) { - QStyleOptionButton styleOption; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawControl(QStyle::CE_RadioButton, &styleOption, &painter); + QStyleOptionButton option; + draw( QStyle::CE_RadioButton, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_TOOLTIP) { - QStyleOption styleOption; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - kapp->style()->drawPrimitive(QStyle::PE_PanelTipLabel, &styleOption, &painter); + QStyleOption option; + draw( QStyle::PE_PanelTipLabel, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_FRAME) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value ); + lcl_drawFrame( QStyle::PE_Frame, m_image, + vclStateValue2StateFlag(nControlState, value) ); + + int size = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin); + pTempClipRegion = XCreateRegion(); + XRectangle xRect = { widgetRect.left(), widgetRect.top(), widgetRect.width(), widgetRect.height() }; + XUnionRectWithRegion( &xRect, pTempClipRegion, pTempClipRegion ); + XLIB_Region pSubtract = XCreateRegion(); + xRect.x += size; + xRect.y += size; + xRect.width -= 2* size; + xRect.height -= 2*size; + XUnionRectWithRegion( &xRect, pSubtract, pSubtract ); + XSubtractRegion( pTempClipRegion, pSubtract, pTempClipRegion ); + XDestroyRegion( pSubtract ); } else if (type == CTRL_FIXEDBORDER) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); - lcl_drawFrame( widgetRect, painter, QStyle::PE_FrameWindow, nControlState, value ); + lcl_drawFrame( QStyle::PE_FrameWindow, m_image, + vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_WINDOW_BACKGROUND) { - pixmap.fill(KApplication::palette().color(QPalette::Window)); + m_image->fill(KApplication::palette().color(QPalette::Window).rgb()); } else if (type == CTRL_FIXEDLINE) { - QStyleOptionMenuItem styleOption; + QStyleOptionMenuItem option; + option.menuItemType = QStyleOptionMenuItem::Separator; + option.state |= QStyle::State_Item; - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - styleOption.menuItemType = QStyleOptionMenuItem::Separator; - styleOption.state |= QStyle::State_Item; + draw( QStyle::CE_MenuItem, &option, m_image, + vclStateValue2StateFlag(nControlState, value) ); + } + else if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA)) + { + SliderValue* slVal = static_cast<SliderValue *> ( value.getOptionalVal() ); + QStyleOptionSlider option; - kapp->style()->drawControl( QStyle::CE_MenuItem, &styleOption, &painter); + option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); + option.state = vclStateValue2StateFlag( nControlState, value ); + option.maximum = slVal->mnMax; + option.minimum = slVal->mnMin; + option.sliderPosition = option.sliderValue = slVal->mnCur; + option.orientation = (part == PART_TRACK_HORZ_AREA) ? Qt::Horizontal : Qt::Vertical; + + draw( QStyle::CC_Slider, &option, m_image, vclStateValue2StateFlag(nControlState, value) ); } else { @@ -543,11 +532,35 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if (returnVal) { - X11SalGraphics::CopyScreenArea( dpy, - pixmap.handle(), pixmap.x11Info().screen(), pixmap.x11Info().depth(), - drawable, GetScreenNumber(), GetVisual().GetDepth(), gc, - 0, 0, widgetRect.width(), widgetRect.height(), widgetRect.left(), widgetRect.top() ); + GC gc = SelectFont(); + + if( gc ) + { + if( pTempClipRegion ) + { + if( pClipRegion_ ) + XIntersectRegion( pTempClipRegion, pClipRegion_, pTempClipRegion ); + XSetRegion( GetXDisplay(), gc, pTempClipRegion ); + } + QPixmap pixmap = QPixmap::fromImage(*m_image, Qt::ColorOnly | Qt::OrderedDither | Qt::OrderedAlphaDither); + X11SalGraphics::CopyScreenArea( GetXDisplay(), + pixmap.handle(), pixmap.x11Info().screen(), pixmap.x11Info().depth(), + GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(), + gc, 0, 0, widgetRect.width(), widgetRect.height(), widgetRect.left(), widgetRect.top()); + + if( pTempClipRegion ) + { + if( pClipRegion_ ) + XSetRegion( GetXDisplay(), gc, pClipRegion_ ); + else + XSetClipMask( GetXDisplay(), gc, None ); + } + } + else + returnVal = false; } + if( pTempClipRegion ) + XDestroyRegion( pTempClipRegion ); return returnVal; } @@ -759,6 +772,24 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, boundingRect = contentRect; retVal = true; + break; + } + case CTRL_SLIDER: + { + const int w = kapp->style()->pixelMetric(QStyle::PM_SliderLength); + if( part == PART_THUMB_HORZ ) + { + contentRect = QRect(boundingRect.left(), boundingRect.top(), w, boundingRect.height()); + boundingRect = contentRect; + retVal = true; + } + else if( part == PART_THUMB_VERT ) + { + contentRect = QRect(boundingRect.left(), boundingRect.top(), boundingRect.width(), w); + boundingRect = contentRect; + retVal = true; + } + break; } default: break; diff --git a/vcl/unx/kde4/KDESalGraphics.hxx b/vcl/unx/kde4/KDESalGraphics.hxx index 3e9ac44e4981..b5328f462a16 100644 --- a/vcl/unx/kde4/KDESalGraphics.hxx +++ b/vcl/unx/kde4/KDESalGraphics.hxx @@ -31,12 +31,18 @@ #include <saldisp.hxx> #include <salgdi.h> +#define Region QtXRegion +#include <QImage> +#undef Region + /** handles graphics drawings requests and performs the needed drawing operations */ class KDESalGraphics : public X11SalGraphics { + QImage* m_image; + public: - KDESalGraphics() {} - virtual ~KDESalGraphics() {} + KDESalGraphics(); + virtual ~KDESalGraphics(); /** What widgets can be drawn the native way. diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index 97116626894e..2ed699ad0eb5 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -2594,6 +2594,28 @@ void SalDisplay::PrintInfo() const sal::static_int_cast< unsigned int >(GetVisual(m_nDefaultScreen).GetVisualId()) ); } +void SalDisplay::addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight ) +{ + // see if any frame buffers are at the same coordinates + // this can happen with weird configuration e.g. on + // XFree86 and Clone displays + const size_t nScreens = m_aXineramaScreens.size(); + for( size_t n = 0; n < nScreens; n++ ) + { + if( m_aXineramaScreens[n].Left() == i_nX && + m_aXineramaScreens[n].Top() == i_nY ) + { + if( m_aXineramaScreens[n].GetWidth() < i_nWidth || + m_aXineramaScreens[n].GetHeight() < i_nHeight ) + { + m_aXineramaScreens[n].SetSize( Size( i_nWidth, i_nHeight ) ); + } + return; + } + } + m_aXineramaScreens.push_back( Rectangle( Point( i_nX, i_nY ), Size( i_nWidth, i_nHeight ) ) ); +} + void SalDisplay::InitXinerama() { if( m_aScreens.size() > 1 ) @@ -2618,10 +2640,10 @@ void SalDisplay::InitXinerama() m_bXinerama = true; m_aXineramaScreens = std::vector<Rectangle>( nFramebuffers ); for( int i = 0; i < nFramebuffers; i++ ) - m_aXineramaScreens[i] = Rectangle( Point( pFramebuffers[i].x, - pFramebuffers[i].y ), - Size( pFramebuffers[i].width, - pFramebuffers[i].height ) ); + addXineramaScreenUnique( pFramebuffers[i].x, + pFramebuffers[i].y, + pFramebuffers[i].width, + pFramebuffers[i].height ); } } #elif defined(USE_XINERAMA_XORG) @@ -2637,30 +2659,10 @@ if( XineramaIsActive( pDisp_ ) ) m_aXineramaScreens = std::vector<Rectangle>(); for( int i = 0; i < nFramebuffers; i++ ) { - // see if any frame buffers are at the same coordinates - // this can happen with weird configuration e.g. on - // XFree86 and Clone displays - bool bDuplicate = false; - for( int n = 0; n < i; n++ ) - { - if( m_aXineramaScreens[n].Left() == pScreens[i].x_org && - m_aXineramaScreens[n].Top() == pScreens[i].y_org ) - { - bDuplicate = true; - if( m_aXineramaScreens[n].GetWidth() < pScreens[i].width || - m_aXineramaScreens[n].GetHeight() < pScreens[i].height ) - { - m_aXineramaScreens[n].SetSize( Size( pScreens[i].width, - pScreens[i].height ) ); - } - break; - } - } - if( ! bDuplicate ) - m_aXineramaScreens.push_back( Rectangle( Point( pScreens[i].x_org, - pScreens[i].y_org ), - Size( pScreens[i].width, - pScreens[i].height ) ) ); + addXineramaScreenUnique( pScreens[i].x_org, + pScreens[i].y_org, + pScreens[i].width, + pScreens[i].height ); } m_bXinerama = m_aXineramaScreens.size() > 1; } diff --git a/vcl/unx/source/fontmanager/fontcache.cxx b/vcl/unx/source/fontmanager/fontcache.cxx index 803e92d3cb14..db4a7d05e5fc 100644 --- a/vcl/unx/source/fontmanager/fontcache.cxx +++ b/vcl/unx/source/fontmanager/fontcache.cxx @@ -212,9 +212,9 @@ void FontCache::flush() aLine.Append( ';' ); aLine.Append( (*it)->m_bUserOverride ? "1" : "0" ); aLine.Append( ';' ); - aLine.Append( ByteString::CreateFromInt32( (*it)->m_eEmbeddedbitmap ) ); + aLine.Append( ByteString::CreateFromInt32( 0 ) ); aLine.Append( ';' ); - aLine.Append( ByteString::CreateFromInt32( (*it)->m_eAntialias ) ); + aLine.Append( ByteString::CreateFromInt32( 0 ) ); switch( (*it)->m_eType ) { @@ -424,9 +424,6 @@ void FontCache::read() = atoi( pLine + nTokenPos[14] ); pFont->m_bUserOverride = (atoi( pLine + nTokenPos[15] ) != 0); - pFont->m_eEmbeddedbitmap - = (fcstatus::type)atoi(pLine+nTokenPos[16]); - pFont->m_eAntialias = (fcstatus::type)atoi(pLine+nTokenPos[17]); int nStyleTokenNr = 18; switch( eType ) { @@ -558,8 +555,6 @@ void FontCache::copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFo pTo->m_nYMax = pFrom->m_nYMax; pTo->m_bHaveVerticalSubstitutedGlyphs = pFrom->m_bHaveVerticalSubstitutedGlyphs; pTo->m_bUserOverride = pFrom->m_bUserOverride; - pTo->m_eEmbeddedbitmap = pFrom->m_eEmbeddedbitmap; - pTo->m_eAntialias = pFrom->m_eAntialias; } /* @@ -621,9 +616,7 @@ bool FontCache::equalsPrintFont( const PrintFontManager::PrintFont* pLeft, Print pRight->m_nXMax != pLeft->m_nXMax || pRight->m_nYMax != pLeft->m_nYMax || pRight->m_bHaveVerticalSubstitutedGlyphs != pLeft->m_bHaveVerticalSubstitutedGlyphs || - pRight->m_bUserOverride != pLeft->m_bUserOverride || - pRight->m_eEmbeddedbitmap != pLeft->m_eEmbeddedbitmap || - pRight->m_eAntialias != pLeft->m_eAntialias + pRight->m_bUserOverride != pLeft->m_bUserOverride ) return false; std::list< int >::const_iterator lit, rit; diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx index 1d4573518879..bc6de4fbc94a 100644 --- a/vcl/unx/source/fontmanager/fontconfig.cxx +++ b/vcl/unx/source/fontmanager/fontconfig.cxx @@ -30,37 +30,45 @@ #include "vcl/fontmanager.hxx" #include "vcl/fontcache.hxx" +#include "vcl/impfont.hxx" using namespace psp; #ifdef ENABLE_FONTCONFIG -#include <fontconfig/fontconfig.h> -#include <ft2build.h> -#include <fontconfig/fcfreetype.h> -// be compatible with fontconfig 2.2.0 release -#ifndef FC_WEIGHT_BOOK - #define FC_WEIGHT_BOOK 75 -#endif -#ifndef FC_EMBEDDED_BITMAP - #define FC_EMBEDDED_BITMAP "embeddedbitmap" -#endif -#ifndef FC_FAMILYLANG - #define FC_FAMILYLANG "familylang" -#endif + #include <fontconfig/fontconfig.h> + #include <ft2build.h> + #include <fontconfig/fcfreetype.h> + // allow compile on baseline (currently with fontconfig 2.2.0) + #ifndef FC_WEIGHT_BOOK // TODO: remove when baseline moves to fc>=2.2.1 + #define FC_WEIGHT_BOOK 75 + #endif + #ifndef FC_EMBEDDED_BITMAP // TODO: remove when baseline moves to fc>=2.3.92 + #define FC_EMBEDDED_BITMAP "embeddedbitmap" + #endif + #ifndef FC_FAMILYLANG // TODO: remove when baseline moves to fc>=2.2.97 + #define FC_FAMILYLANG "familylang" + #endif + #ifndef FC_HINT_STYLE // TODO: remove when baseline moves to fc>=2.2.91 + #define FC_HINT_STYLE "hintstyle" + #define FC_HINT_NONE 0 + #define FC_HINT_SLIGHT 1 + #define FC_HINT_MEDIUM 2 + #define FC_HINT_FULL 3 + #endif #else -typedef void FcConfig; -typedef void FcObjectSet; -typedef void FcPattern; -typedef void FcFontSet; -typedef void FcCharSet; -typedef int FcResult; -typedef int FcBool; -typedef int FcMatchKind; -typedef char FcChar8; -typedef int FcChar32; -typedef unsigned int FT_UInt; -typedef void* FT_Face; -typedef int FcSetName; + typedef void FcConfig; + typedef void FcObjectSet; + typedef void FcPattern; + typedef void FcFontSet; + typedef void FcCharSet; + typedef int FcResult; + typedef int FcBool; + typedef int FcMatchKind; + typedef char FcChar8; + typedef int FcChar32; + typedef unsigned int FT_UInt; + typedef void* FT_Face; + typedef int FcSetName; #endif #include <cstdio> @@ -117,6 +125,7 @@ class FontCfgWrapper FcBool (*m_pFcConfigAppFontAddDir)(FcConfig*, const FcChar8*); FcBool (*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind); FcBool (*m_pFcPatternAddInteger)(FcPattern*,const char*,int); + FcBool (*m_pFcPatternAddDouble)(FcPattern*,const char*,double); FcBool (*m_pFcPatternAddBool)(FcPattern*,const char*,FcBool); FcBool (*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*); FcBool (*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*); @@ -220,6 +229,8 @@ public: { return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); } FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue ) { return m_pFcPatternAddInteger( pPattern, pObject, nValue ); } + FcBool FcPatternAddDouble( FcPattern* pPattern, const char* pObject, double nValue ) + { return m_pFcPatternAddDouble( pPattern, pObject, nValue ); } FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString ) { return m_pFcPatternAddString( pPattern, pObject, pString ); } FcBool FcPatternAddBool( FcPattern* pPattern, const char* pObject, bool nValue ) @@ -231,7 +242,9 @@ public: { return m_pFcFreeTypeCharIndex ? m_pFcFreeTypeCharIndex( face, ucs4 ) : 0; } public: // TODO: cleanup - std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash > m_aFontconfigNameToLocalized; + FcResult FamilyFromPattern(FcPattern* pPattern, FcChar8 **family); + std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash > m_aFontNameToLocalized; + std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash > m_aLocalizedToCanonical; }; oslGenericFunction FontCfgWrapper::loadSymbol( const char* pSymbol ) @@ -321,6 +334,8 @@ FontCfgWrapper::FontCfgWrapper() loadSymbol( "FcConfigSubstitute" ); m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int)) loadSymbol( "FcPatternAddInteger" ); + m_pFcPatternAddDouble = (FcBool(*)(FcPattern*,const char*,double)) + loadSymbol( "FcPatternAddDouble" ); m_pFcPatternAddBool = (FcBool(*)(FcPattern*,const char*,FcBool)) loadSymbol( "FcPatternAddBool" ); m_pFcPatternAddCharSet = (FcBool(*)(FcPattern*,const char*,const FcCharSet *)) @@ -371,6 +386,7 @@ FontCfgWrapper::FontCfgWrapper() m_pFcDefaultSubstitute && m_pFcConfigSubstitute && m_pFcPatternAddInteger && + m_pFcPatternAddDouble && m_pFcPatternAddCharSet && m_pFcPatternAddBool && m_pFcPatternAddString @@ -503,53 +519,52 @@ namespace return candidate; } +} +FcResult FontCfgWrapper::FamilyFromPattern(FcPattern* pPattern, FcChar8 **family) +{ + FcChar8 *origfamily; + FcResult eFamilyRes = FcPatternGetString( pPattern, FC_FAMILY, 0, &origfamily ); + *family = origfamily; - FcResult lcl_FamilyFromPattern(FontCfgWrapper& rWrapper, FcPattern* pPattern, FcChar8 **family, - std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash > &aFontconfigNameToLocalized) + if( eFamilyRes == FcResultMatch) { - FcChar8 *origfamily; - FcResult eFamilyRes = rWrapper.FcPatternGetString( pPattern, FC_FAMILY, 0, &origfamily ); - *family = origfamily; - - if( eFamilyRes == FcResultMatch) + FcChar8* familylang = NULL; + if (FcPatternGetString( pPattern, FC_FAMILYLANG, 0, &familylang ) == FcResultMatch) { - FcChar8* familylang = NULL; - if (rWrapper.FcPatternGetString( pPattern, FC_FAMILYLANG, 0, &familylang ) == FcResultMatch) + std::vector< lang_and_family > lang_and_families; + lang_and_families.push_back(lang_and_family(familylang, *family)); + int k = 1; + while (1) { - std::vector< lang_and_family > lang_and_families; + if (FcPatternGetString( pPattern, FC_FAMILYLANG, k, &familylang ) != FcResultMatch) + break; + if (FcPatternGetString( pPattern, FC_FAMILY, k, family ) != FcResultMatch) + break; lang_and_families.push_back(lang_and_family(familylang, *family)); - int k = 1; - while (1) - { - if (rWrapper.FcPatternGetString( pPattern, FC_FAMILYLANG, k, &familylang ) != FcResultMatch) - break; - if (rWrapper.FcPatternGetString( pPattern, FC_FAMILY, k, family ) != FcResultMatch) - break; - lang_and_families.push_back(lang_and_family(familylang, *family)); - ++k; - } + ++k; + } - //possible to-do, sort by UILocale instead of process locale - rtl_Locale* pLoc; - osl_getProcessLocale(&pLoc); - localizedsorter aSorter(pLoc); - *family = aSorter.bestname(lang_and_families); + //possible to-do, sort by UILocale instead of process locale + rtl_Locale* pLoc; + osl_getProcessLocale(&pLoc); + localizedsorter aSorter(pLoc); + *family = aSorter.bestname(lang_and_families); - std::vector<lang_and_family>::const_iterator aEnd = lang_and_families.end(); - for (std::vector<lang_and_family>::const_iterator aIter = lang_and_families.begin(); aIter != aEnd; ++aIter) - { - const char *candidate = (const char*)(aIter->second); - if (rtl_str_compare(candidate, (const char*)(*family)) != 0) - aFontconfigNameToLocalized[OString(candidate)] = OString((const char*)(*family)); - } + std::vector<lang_and_family>::const_iterator aEnd = lang_and_families.end(); + for (std::vector<lang_and_family>::const_iterator aIter = lang_and_families.begin(); aIter != aEnd; ++aIter) + { + const char *candidate = (const char*)(aIter->second); + if (rtl_str_compare(candidate, (const char*)(*family)) != 0) + m_aFontNameToLocalized[OString(candidate)] = OString((const char*)(*family)); } + if (rtl_str_compare((const char*)origfamily, (const char*)(*family)) != 0) + m_aLocalizedToCanonical[OString((const char*)(*family))] = OString((const char*)origfamily); } - - return eFamilyRes; } -} + return eFamilyRes; +} /* * PrintFontManager::initFontconfig @@ -562,7 +577,73 @@ bool PrintFontManager::initFontconfig() return true; } -int PrintFontManager::countFontconfigFonts() +namespace +{ + weight::type convertWeight(int weight) + { + // set weight + if( weight <= FC_WEIGHT_THIN ) + return weight::Thin; + else if( weight <= FC_WEIGHT_ULTRALIGHT ) + return weight::UltraLight; + else if( weight <= FC_WEIGHT_LIGHT ) + return weight::Light; + else if( weight <= FC_WEIGHT_BOOK ) + return weight::SemiLight; + else if( weight <= FC_WEIGHT_NORMAL ) + return weight::Normal; + else if( weight <= FC_WEIGHT_MEDIUM ) + return weight::Medium; + else if( weight <= FC_WEIGHT_SEMIBOLD ) + return weight::SemiBold; + else if( weight <= FC_WEIGHT_BOLD ) + return weight::Bold; + else if( weight <= FC_WEIGHT_ULTRABOLD ) + return weight::UltraBold; + return weight::Black; + } + + italic::type convertSlant(int slant) + { + // set italic + if( slant == FC_SLANT_ITALIC ) + return italic::Italic; + else if( slant == FC_SLANT_OBLIQUE ) + return italic::Oblique; + return italic::Upright; + } + + pitch::type convertSpacing(int spacing) + { + // set pitch + if( spacing == FC_MONO || spacing == FC_CHARCELL ) + return pitch::Fixed; + return pitch::Variable; + } + + width::type convertWidth(int width) + { + if (width == FC_WIDTH_ULTRACONDENSED) + return width::UltraCondensed; + else if (width == FC_WIDTH_EXTRACONDENSED) + return width::ExtraCondensed; + else if (width == FC_WIDTH_CONDENSED) + return width::Condensed; + else if (width == FC_WIDTH_SEMICONDENSED) + return width::SemiCondensed; + else if (width == FC_WIDTH_SEMIEXPANDED) + return width::SemiExpanded; + else if (width == FC_WIDTH_EXPANDED) + return width::Expanded; + else if (width == FC_WIDTH_EXTRAEXPANDED) + return width::ExtraExpanded; + else if (width == FC_WIDTH_ULTRAEXPANDED) + return width::UltraExpanded; + return width::Normal; + } +} + +int PrintFontManager::countFontconfigFonts( std::hash_map<rtl::OString, int, rtl::OStringHash>& o_rVisitedPaths ) { int nFonts = 0; @@ -585,18 +666,16 @@ int PrintFontManager::countFontconfigFonts() int weight = 0; int spacing = 0; int nCollectionEntry = -1; - FcBool outline = false, embitmap = true, antialias = true; + FcBool outline = false; FcResult eFileRes = rWrapper.FcPatternGetString( pFSet->fonts[i], FC_FILE, 0, &file ); - FcResult eFamilyRes = lcl_FamilyFromPattern(rWrapper, pFSet->fonts[i], &family, rWrapper.m_aFontconfigNameToLocalized ); + FcResult eFamilyRes = rWrapper.FamilyFromPattern( pFSet->fonts[i], &family ); FcResult eStyleRes = rWrapper.FcPatternGetString( pFSet->fonts[i], FC_STYLE, 0, &style ); FcResult eSlantRes = rWrapper.FcPatternGetInteger( pFSet->fonts[i], FC_SLANT, 0, &slant ); FcResult eWeightRes = rWrapper.FcPatternGetInteger( pFSet->fonts[i], FC_WEIGHT, 0, &weight ); FcResult eSpacRes = rWrapper.FcPatternGetInteger( pFSet->fonts[i], FC_SPACING, 0, &spacing ); FcResult eOutRes = rWrapper.FcPatternGetBool( pFSet->fonts[i], FC_OUTLINE, 0, &outline ); FcResult eIndexRes = rWrapper.FcPatternGetInteger( pFSet->fonts[i], FC_INDEX, 0, &nCollectionEntry ); - FcResult eEmbeddedBitmap = rWrapper.FcPatternGetBool( pFSet->fonts[i], FC_EMBEDDED_BITMAP, 0, &embitmap ); - FcResult eAntialias = rWrapper.FcPatternGetBool( pFSet->fonts[i], FC_ANTIALIAS, 0, &antialias ); if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch ) continue; @@ -625,6 +704,9 @@ int PrintFontManager::countFontconfigFonts() std::list< PrintFont* > aFonts; OString aDir, aBase, aOrgPath( (sal_Char*)file ); splitPath( aOrgPath, aDir, aBase ); + + o_rVisitedPaths[aDir] = 1; + int nDirID = getDirectoryAtom( aDir, true ); if( ! m_pFontCache->getFontCacheFile( nDirID, aBase, aFonts ) ) { @@ -691,60 +773,15 @@ int PrintFontManager::countFontconfigFonts() pUpdate->m_nFamilyName = nFamilyName; } if( eWeightRes == FcResultMatch ) - { - // set weight - if( weight <= FC_WEIGHT_THIN ) - pUpdate->m_eWeight = weight::Thin; - else if( weight <= FC_WEIGHT_ULTRALIGHT ) - pUpdate->m_eWeight = weight::UltraLight; - else if( weight <= FC_WEIGHT_LIGHT ) - pUpdate->m_eWeight = weight::Light; - else if( weight <= FC_WEIGHT_BOOK ) - pUpdate->m_eWeight = weight::SemiLight; - else if( weight <= FC_WEIGHT_NORMAL ) - pUpdate->m_eWeight = weight::Normal; - else if( weight <= FC_WEIGHT_MEDIUM ) - pUpdate->m_eWeight = weight::Medium; - else if( weight <= FC_WEIGHT_SEMIBOLD ) - pUpdate->m_eWeight = weight::SemiBold; - else if( weight <= FC_WEIGHT_BOLD ) - pUpdate->m_eWeight = weight::Bold; - else if( weight <= FC_WEIGHT_ULTRABOLD ) - pUpdate->m_eWeight = weight::UltraBold; - else - pUpdate->m_eWeight = weight::Black; - } + pUpdate->m_eWeight = convertWeight(weight); if( eSpacRes == FcResultMatch ) - { - // set pitch - if( spacing == FC_PROPORTIONAL ) - pUpdate->m_ePitch = pitch::Variable; - else if( spacing == FC_MONO || spacing == FC_CHARCELL ) - pUpdate->m_ePitch = pitch::Fixed; - } + pUpdate->m_ePitch = convertSpacing(spacing); if( eSlantRes == FcResultMatch ) - { - // set italic - if( slant == FC_SLANT_ROMAN ) - pUpdate->m_eItalic = italic::Upright; - else if( slant == FC_SLANT_ITALIC ) - pUpdate->m_eItalic = italic::Italic; - else if( slant == FC_SLANT_OBLIQUE ) - pUpdate->m_eItalic = italic::Oblique; - } + pUpdate->m_eItalic = convertSlant(slant); if( eStyleRes == FcResultMatch ) { pUpdate->m_aStyleName = OStringToOUString( OString( (sal_Char*)style ), RTL_TEXTENCODING_UTF8 ); } - if( eEmbeddedBitmap == FcResultMatch ) - { - pUpdate->m_eEmbeddedbitmap = embitmap ? fcstatus::istrue : fcstatus::isfalse; - } - if( eAntialias == FcResultMatch ) - { - pUpdate->m_eAntialias = antialias ? fcstatus::istrue : fcstatus::isfalse; - } - // update font cache m_pFontCache->updateFontCacheEntry( pUpdate, false ); @@ -880,8 +917,8 @@ static void addtopattern(FontCfgWrapper& rWrapper, FcPattern *pPattern, rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, const rtl::OString &rLangAttrib, - italic::type eItalic, weight::type eWeight, - width::type eWidth, pitch::type ePitch) const + italic::type &rItalic, weight::type &rWeight, + width::type &rWidth, pitch::type &rPitch) const { rtl::OUString aName; FontCfgWrapper& rWrapper = FontCfgWrapper::get(); @@ -916,7 +953,7 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName, rWrapper.FcCharSetDestroy( unicodes ); } - addtopattern(rWrapper, pPattern, eItalic, eWeight, eWidth, ePitch); + addtopattern(rWrapper, pPattern, rItalic, rWeight, rWidth, rPitch); // query fontconfig for a substitute rWrapper.FcConfigSubstitute( rWrapper.FcConfigGetCurrent(), pPattern, FcMatchPattern ); @@ -949,10 +986,21 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName, if( eFileRes == FcResultMatch ) { OString sFamily((sal_Char*)family); - std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI = rWrapper.m_aFontconfigNameToLocalized.find(sFamily); - if (aI != rWrapper.m_aFontconfigNameToLocalized.end()) + std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI = rWrapper.m_aFontNameToLocalized.find(sFamily); + if (aI != rWrapper.m_aFontNameToLocalized.end()) sFamily = aI->second; aName = rtl::OStringToOUString( sFamily, RTL_TEXTENCODING_UTF8 ); + + + int val = 0; + if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_WEIGHT, 0, &val)) + rWeight = convertWeight(val); + if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_SLANT, 0, &val)) + rItalic = convertSlant(val); + if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_SPACING, 0, &val)) + rPitch = convertSpacing(val); + if ( FcResultMatch == rWrapper.FcPatternGetInteger( pSet->fonts[0], FC_WIDTH, 0, &val)) + rWidth = convertWidth(val); } // update rMissingCodes by removing resolved unicodes @@ -981,6 +1029,89 @@ rtl::OUString PrintFontManager::Substitute(const rtl::OUString& rFontName, return aName; } +bool PrintFontManager::getFontOptions( + const FastPrintFontInfo& rInfo, int nSize, void (*subcallback)(void*), + ImplFontOptions& rOptions) const +{ +#ifndef ENABLE_FONTCONFIG + return false; +#else // ENABLE_FONTCONFIG + FontCfgWrapper& rWrapper = FontCfgWrapper::get(); + if( ! rWrapper.isValid() ) + return false; + + FcConfig* pConfig = rWrapper.FcConfigGetCurrent(); + FcPattern* pPattern = rWrapper.FcPatternCreate(); + + OString sFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 ); + + std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI = rWrapper.m_aLocalizedToCanonical.find(sFamily); + if (aI != rWrapper.m_aLocalizedToCanonical.end()) + sFamily = aI->second; + if( sFamily.getLength() ) + rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)sFamily.getStr() ); + + addtopattern(rWrapper, pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch); + rWrapper.FcPatternAddDouble( pPattern, FC_PIXEL_SIZE, nSize); + + FcBool embitmap = true, antialias = true, autohint = true, hinting = true; + int hintstyle = FC_HINT_FULL; + + rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern ); + if (subcallback) subcallback(pPattern); + rWrapper.FcDefaultSubstitute( pPattern ); + + FcResult eResult = FcResultNoMatch; + FcFontSet* pFontSet = rWrapper.getFontSet(); + FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult ); + if( pResult ) + { + FcFontSet* pSet = rWrapper.FcFontSetCreate(); + rWrapper.FcFontSetAdd( pSet, pResult ); + if( pSet->nfont > 0 ) + { + FcResult eEmbeddedBitmap = rWrapper.FcPatternGetBool(pSet->fonts[0], + FC_EMBEDDED_BITMAP, 0, &embitmap); + FcResult eAntialias = rWrapper.FcPatternGetBool(pSet->fonts[0], + FC_ANTIALIAS, 0, &antialias); + FcResult eAutoHint = rWrapper.FcPatternGetBool(pSet->fonts[0], + FC_AUTOHINT, 0, &autohint); + FcResult eHinting = rWrapper.FcPatternGetBool(pSet->fonts[0], + FC_HINTING, 0, &hinting); + /*FcResult eHintStyle =*/ rWrapper.FcPatternGetInteger( pSet->fonts[0], + FC_HINT_STYLE, 0, &hintstyle); + + if( eEmbeddedBitmap == FcResultMatch ) + rOptions.meEmbeddedBitmap = embitmap ? EMBEDDEDBITMAP_TRUE : EMBEDDEDBITMAP_FALSE; + if( eAntialias == FcResultMatch ) + rOptions.meAntiAlias = antialias ? ANTIALIAS_TRUE : ANTIALIAS_FALSE; + if( eAutoHint == FcResultMatch ) + rOptions.meAutoHint = autohint ? AUTOHINT_TRUE : AUTOHINT_FALSE; + if( eHinting == FcResultMatch ) + rOptions.meHinting = hinting ? HINTING_TRUE : HINTING_FALSE; + switch (hintstyle) + { + case FC_HINT_NONE: rOptions.meHintStyle = HINT_NONE; break; + case FC_HINT_SLIGHT: rOptions.meHintStyle = HINT_SLIGHT; break; + case FC_HINT_MEDIUM: rOptions.meHintStyle = HINT_MEDIUM; break; + default: // fall through + case FC_HINT_FULL: rOptions.meHintStyle = HINT_FULL; break; + } + } + // info: destroying the pSet destroys pResult implicitly + // since pResult was "added" to pSet + rWrapper.FcFontSetDestroy( pSet ); + } + + // cleanup + rWrapper.FcPatternDestroy( pPattern ); + + // TODO: return true only if non-default font options are set + const bool bOK = (pResult != NULL); + return bOK; +#endif +} + bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ) { FontCfgWrapper& rWrapper = FontCfgWrapper::get(); @@ -1055,7 +1186,7 @@ bool PrintFontManager::initFontconfig() return false; } -int PrintFontManager::countFontconfigFonts() +int PrintFontManager::countFontconfigFonts( std::hash_map<rtl::OString, int, rtl::OStringHash>& ) { return 0; } diff --git a/vcl/unx/source/fontmanager/fontmanager.cxx b/vcl/unx/source/fontmanager/fontmanager.cxx index aad53549f1ea..93e3eef53ab3 100644 --- a/vcl/unx/source/fontmanager/fontmanager.cxx +++ b/vcl/unx/source/fontmanager/fontmanager.cxx @@ -353,9 +353,7 @@ PrintFontManager::PrintFont::PrintFont( fonttype::type eType ) : m_nXMax( 0 ), m_nYMax( 0 ), m_bHaveVerticalSubstitutedGlyphs( false ), - m_bUserOverride( false ), - m_eEmbeddedbitmap( fcstatus::isunset ), - m_eAntialias( fcstatus::isunset ) + m_bUserOverride( false ) { } @@ -2151,10 +2149,14 @@ void PrintFontManager::initialize() } while( nIndex >= 0 ); } + // protect against duplicate paths + std::hash_map< OString, int, OStringHash > visited_dirs; + // now that all global and local font dirs are known to fontconfig // check that there are fonts actually managed by fontconfig + // also don't search directories that fontconfig already did if( m_bFontconfigSuccess ) - m_bFontconfigSuccess = (countFontconfigFonts() > 0); + m_bFontconfigSuccess = (countFontconfigFonts( visited_dirs ) > 0); // don't search through many directories fontconfig already told us about if( ! m_bFontconfigSuccess ) @@ -2165,8 +2167,6 @@ void PrintFontManager::initialize() // search for font files in each path std::list< OString >::iterator dir_it; - // protect against duplicate paths - std::hash_map< OString, int, OStringHash > visited_dirs; for( dir_it = m_aFontDirectories.begin(); dir_it != m_aFontDirectories.end(); ++dir_it ) { OString aPath( *dir_it ); @@ -2630,8 +2630,6 @@ void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& r rInfo.m_eWeight = pFont->m_eWeight; rInfo.m_ePitch = pFont->m_ePitch; rInfo.m_aEncoding = pFont->m_aEncoding; - rInfo.m_eEmbeddedbitmap = pFont->m_eEmbeddedbitmap; - rInfo.m_eAntialias = pFont->m_eAntialias; rInfo.m_bEmbeddable = (pFont->m_eType == fonttype::Type1); rInfo.m_bSubsettable = (pFont->m_eType == fonttype::TrueType); // TODO: rename to SfntType @@ -3936,8 +3934,6 @@ bool PrintFontManager::readOverrideMetrics() BuiltinFont* pFont = new BuiltinFont(); pFont->m_nDirectory = 0; pFont->m_bUserOverride = false; - pFont->m_eEmbeddedbitmap = fcstatus::isunset; - pFont->m_eAntialias = fcstatus::isunset; pFont->m_pMetrics = new PrintFontMetrics; memset( pFont->m_pMetrics->m_aPages, 0xff, sizeof( pFont->m_pMetrics->m_aPages ) ); pFont->m_pMetrics->m_bKernPairsQueried = true; diff --git a/vcl/unx/source/fontmanager/parseAFM.cxx b/vcl/unx/source/fontmanager/parseAFM.cxx index fd131121cbb5..e1a33b4d1b5d 100644 --- a/vcl/unx/source/fontmanager/parseAFM.cxx +++ b/vcl/unx/source/fontmanager/parseAFM.cxx @@ -403,89 +403,91 @@ static int parseGlobals( FileInputStream* fp, register GlobalFontInfo* gfi ) switch(recognize(keyword, tokenlen)) { case STARTFONTMETRICS: - keyword = token(fp,tokenlen); - gfi->afmVersion = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->afmVersion = strdup( keyword ); break; case COMMENT: keyword = linetoken(fp); break; case FONTNAME: - keyword = token(fp, tokenlen); - gfi->fontName = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->fontName = strdup( keyword ); break; case ENCODINGSCHEME: - keyword = token(fp, tokenlen); - gfi->encodingScheme = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->encodingScheme = strdup( keyword ); break; case FULLNAME: - keyword = linetoken(fp); - gfi->fullName = strdup( keyword ); + if ((keyword = linetoken(fp)) != NULL) + gfi->fullName = strdup( keyword ); break; case FAMILYNAME: - keyword = linetoken(fp); - gfi->familyName = strdup( keyword ); + if ((keyword = linetoken(fp)) != NULL) + gfi->familyName = strdup( keyword ); break; case WEIGHT: - keyword = token(fp, tokenlen); - gfi->weight = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->weight = strdup( keyword ); break; case ITALICANGLE: - keyword = token(fp,tokenlen); - gfi->italicAngle = StringToDouble( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->italicAngle = StringToDouble( keyword ); break; case ISFIXEDPITCH: - keyword = token(fp,tokenlen); - if (MATCH(keyword, False)) - gfi->isFixedPitch = 0; - else - gfi->isFixedPitch = 1; + if ((keyword = token(fp,tokenlen)) != NULL) + { + if (MATCH(keyword, False)) + gfi->isFixedPitch = 0; + else + gfi->isFixedPitch = 1; + } break; case UNDERLINEPOSITION: - keyword = token(fp,tokenlen); - gfi->underlinePosition = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->underlinePosition = atoi(keyword); break; case UNDERLINETHICKNESS: - keyword = token(fp,tokenlen); - gfi->underlineThickness = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->underlineThickness = atoi(keyword); break; case VERSION: - keyword = token(fp,tokenlen); - gfi->version = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->version = strdup( keyword ); break; case NOTICE: - keyword = linetoken(fp); - gfi->notice = strdup( keyword ); + if ((keyword = linetoken(fp)) != NULL) + gfi->notice = strdup( keyword ); break; case FONTBBOX: - keyword = token(fp,tokenlen); - gfi->fontBBox.llx = atoi(keyword); - keyword = token(fp,tokenlen); - gfi->fontBBox.lly = atoi(keyword); - keyword = token(fp,tokenlen); - gfi->fontBBox.urx = atoi(keyword); - keyword = token(fp,tokenlen); - gfi->fontBBox.ury = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->fontBBox.llx = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->fontBBox.lly = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->fontBBox.urx = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->fontBBox.ury = atoi(keyword); break; case CAPHEIGHT: - keyword = token(fp,tokenlen); - gfi->capHeight = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->capHeight = atoi(keyword); break; case XHEIGHT: - keyword = token(fp,tokenlen); - gfi->xHeight = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->xHeight = atoi(keyword); break; case DESCENT: - keyword = token(fp,tokenlen); - gfi->descender = -atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->descender = -atoi(keyword); break; case DESCENDER: - keyword = token(fp,tokenlen); - gfi->descender = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->descender = atoi(keyword); break; case ASCENT: case ASCENDER: - keyword = token(fp,tokenlen); - gfi->ascender = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + gfi->ascender = atoi(keyword); break; case STARTCHARMETRICS: cont = false; @@ -499,8 +501,8 @@ static int parseGlobals( FileInputStream* fp, register GlobalFontInfo* gfi ) keyword = token(fp,tokenlen); break; case STARTDIRECTION: - keyword = token(fp,tokenlen); - direction = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + direction = atoi(keyword); break; /* ignore this for now */ case ENDDIRECTION: break; /* ignore this for now */ @@ -523,9 +525,11 @@ static int parseGlobals( FileInputStream* fp, register GlobalFontInfo* gfi ) keyword=token(fp,tokenlen); //ignore break; case CHARWIDTH: - keyword = token(fp,tokenlen); - if (direction == 0) - gfi->charwidth = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + { + if (direction == 0) + gfi->charwidth = atoi(keyword); + } keyword = token(fp,tokenlen); /* ignore y-width for now */ break; @@ -584,24 +588,27 @@ static int initializeArray( FileInputStream* fp, register int* cwi) keyword = linetoken(fp); break; case CODE: - code = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + code = atoi(keyword); break; case CODEHEX: - sscanf(token(fp,tokenlen),"<%x>", &code); + if ((keyword = token(fp,tokenlen)) != NULL) + sscanf(keyword,"<%x>", &code); break; case XWIDTH: - width = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + width = atoi(keyword); break; case X0WIDTH: (void) token(fp,tokenlen); break; case CHARNAME: - keyword = token(fp,tokenlen); - if (MATCH(keyword, Space)) - { - cont = false; - found = true; - } + if ((keyword = token(fp,tokenlen)) != NULL) + if (MATCH(keyword, Space)) + { + cont = false; + found = true; + } break; case ENDCHARMETRICS: cont = false; @@ -690,8 +697,8 @@ static int parseCharWidths( FileInputStream* fp, register int* cwi) keyword = linetoken(fp); break; case CODE: - keyword = token(fp,tokenlen); - pos = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + pos = atoi(keyword); break; case XYWIDTH: /* PROBLEM: Should be no Y-WIDTH when doing "quick & dirty" */ @@ -699,16 +706,16 @@ static int parseCharWidths( FileInputStream* fp, register int* cwi) error = parseError; break; case CODEHEX: - keyword = token(fp,tokenlen); - sscanf(keyword, "<%x>", &pos); + if ((keyword = token(fp,tokenlen)) != NULL) + sscanf(keyword, "<%x>", &pos); break; case X0WIDTH: (void) token(fp,tokenlen); break; case XWIDTH: - keyword = token(fp,tokenlen); - if (pos >= 0) /* ignore unmapped chars */ - cwi[pos] = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + if (pos >= 0) /* ignore unmapped chars */ + cwi[pos] = atoi(keyword); break; case ENDCHARMETRICS: cont = false; @@ -835,7 +842,8 @@ static int parseCharMetrics( FileInputStream* fp, register FontInfo* fi) { if (firstTime) firstTime = false; else temp++; - temp->code = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->code = atoi(keyword); if (fi->gfi && fi->gfi->charwidth) temp->wx = fi->gfi->charwidth; count++; @@ -859,7 +867,8 @@ static int parseCharMetrics( FileInputStream* fp, register FontInfo* fi) firstTime = false; else temp++; - sscanf(token(fp,tokenlen),"<%x>", &temp->code); + if ((keyword = token(fp,tokenlen)) != NULL) + sscanf(keyword,"<%x>", &temp->code); if (fi->gfi && fi->gfi->charwidth) temp->wx = fi->gfi->charwidth; count++; @@ -870,24 +879,32 @@ static int parseCharMetrics( FileInputStream* fp, register FontInfo* fi) } break; case XYWIDTH: - temp->wx = atoi(token(fp,tokenlen)); - temp->wy = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->wx = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->wy = atoi(keyword); break; case X0WIDTH: - temp->wx = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->wx = atoi(keyword); break; case XWIDTH: - temp->wx = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->wx = atoi(keyword); break; case CHARNAME: - keyword = token(fp,tokenlen); - temp->name = (char *)strdup(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->name = (char *)strdup(keyword); break; case CHARBBOX: - temp->charBBox.llx = atoi(token(fp,tokenlen)); - temp->charBBox.lly = atoi(token(fp,tokenlen)); - temp->charBBox.urx = atoi(token(fp,tokenlen)); - temp->charBBox.ury = atoi(token(fp,tokenlen)); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->charBBox.llx = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->charBBox.lly = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->charBBox.urx = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + temp->charBBox.ury = atoi(keyword); break; case LIGATURE: { Ligature **tail = &(temp->ligs); @@ -901,10 +918,10 @@ static int parseCharMetrics( FileInputStream* fp, register FontInfo* fi) } *tail = (Ligature *) calloc(1, sizeof(Ligature)); - keyword = token(fp,tokenlen); - (*tail)->succ = (char *)strdup(keyword); - keyword = token(fp,tokenlen); - (*tail)->lig = (char *)strdup(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + (*tail)->succ = (char *)strdup(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + (*tail)->lig = (char *)strdup(keyword); break; } case ENDCHARMETRICS: cont = false;; @@ -1000,16 +1017,16 @@ static int parseTrackKernData( FileInputStream* fp, register FontInfo* fi) if (tcount < fi->numOfTracks) { - keyword = token(fp,tokenlen); - fi->tkd[pos].degree = atoi(keyword); - keyword = token(fp,tokenlen); - fi->tkd[pos].minPtSize = StringToDouble(keyword); - keyword = token(fp,tokenlen); - fi->tkd[pos].minKernAmt = StringToDouble(keyword); - keyword = token(fp,tokenlen); - fi->tkd[pos].maxPtSize = StringToDouble(keyword); - keyword = token(fp,tokenlen); - fi->tkd[pos++].maxKernAmt = StringToDouble(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->tkd[pos].degree = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->tkd[pos].minPtSize = StringToDouble(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->tkd[pos].minKernAmt = StringToDouble(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->tkd[pos].maxPtSize = StringToDouble(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->tkd[pos++].maxKernAmt = StringToDouble(keyword); tcount++; } else @@ -1107,14 +1124,14 @@ static int parsePairKernData( FileInputStream* fp, register FontInfo* fi) } if (pcount < fi->numOfPairs) { - keyword = token(fp,tokenlen); - fi->pkd[pos].name1 = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->pkd[pos].name2 = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->pkd[pos].xamt = atoi(keyword); - keyword = token(fp,tokenlen); - fi->pkd[pos++].yamt = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos].name1 = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos].name2 = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos].xamt = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos++].yamt = atoi(keyword); pcount++; } else @@ -1131,12 +1148,12 @@ static int parsePairKernData( FileInputStream* fp, register FontInfo* fi) } if (pcount < fi->numOfPairs) { - keyword = token(fp,tokenlen); - fi->pkd[pos].name1 = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->pkd[pos].name2 = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->pkd[pos++].xamt = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos].name1 = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos].name2 = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->pkd[pos++].xamt = atoi(keyword); pcount++; } else @@ -1258,8 +1275,8 @@ static int parseCompCharData( FileInputStream* fp, register FontInfo* fi) if (firstTime) firstTime = false; else pos++; fi->ccd[pos].ccName = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->ccd[pos].numOfPieces = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->ccd[pos].numOfPieces = atoi(keyword); fi->ccd[pos].pieces = (Pcc *) calloc(fi->ccd[pos].numOfPieces, sizeof(Pcc)); j = 0; @@ -1274,12 +1291,12 @@ static int parseCompCharData( FileInputStream* fp, register FontInfo* fi) case COMPCHARPIECE: if (pcount < fi->ccd[pos].numOfPieces) { - keyword = token(fp,tokenlen); - fi->ccd[pos].pieces[j].pccName = strdup( keyword ); - keyword = token(fp,tokenlen); - fi->ccd[pos].pieces[j].deltax = atoi(keyword); - keyword = token(fp,tokenlen); - fi->ccd[pos].pieces[j++].deltay = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->ccd[pos].pieces[j].pccName = strdup( keyword ); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->ccd[pos].pieces[j].deltax = atoi(keyword); + if ((keyword = token(fp,tokenlen)) != NULL) + fi->ccd[pos].pieces[j++].deltay = atoi(keyword); pcount++; } else @@ -1373,7 +1390,8 @@ int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags) if ((code != normalEOF) && (code != earlyEOF)) { - (*fi)->numOfChars = atoi(token(&aFile,tokenlen)); + if ((keyword = token(&aFile,tokenlen)) != NULL) + (*fi)->numOfChars = atoi(keyword); if (flags & (P_M ^ P_W)) { (*fi)->cmi = (CharMetricInfo *) @@ -1423,7 +1441,7 @@ int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags) break; case STARTTRACKKERN: keyword = token(&aFile,tokenlen); - if (flags & P_T) + if ((flags & P_T) && keyword) { (*fi)->numOfTracks = atoi(keyword); (*fi)->tkd = (TrackKernData *) @@ -1438,7 +1456,7 @@ int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags) break; case STARTKERNPAIRS: keyword = token(&aFile,tokenlen); - if (flags & P_P) + if ((flags & P_P) && keyword) { (*fi)->numOfPairs = atoi(keyword); (*fi)->pkd = (PairKernData *) @@ -1453,7 +1471,7 @@ int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags) break; case STARTCOMPOSITES: keyword = token(&aFile,tokenlen); - if (flags & P_C) + if ((flags & P_C) && keyword) { (*fi)->numOfComps = atoi(keyword); (*fi)->ccd = (CompCharData *) diff --git a/vcl/unx/source/gdi/gcach_xpeer.cxx b/vcl/unx/source/gdi/gcach_xpeer.cxx index 634f79d3e002..a69a2426b519 100644 --- a/vcl/unx/source/gdi/gcach_xpeer.cxx +++ b/vcl/unx/source/gdi/gcach_xpeer.cxx @@ -119,7 +119,7 @@ void X11GlyphPeer::InitAntialiasing() // enable XRENDER accelerated aliasing on screens that support it // unless it explicitly disabled by an environment variable if( (nEnvAntiAlias & 2) == 0 ) - mnUsingXRender = XRenderPeer::GetInstance().InitRenderText( mnMaxScreens ); + mnUsingXRender = XRenderPeer::GetInstance().InitRenderText(); // else enable client side antialiasing for these screens // unless it is explicitly disabled by an environment variable diff --git a/vcl/unx/source/gdi/pspgraphics.cxx b/vcl/unx/source/gdi/pspgraphics.cxx index 10a51afeb696..d599e09e71f2 100644 --- a/vcl/unx/source/gdi/pspgraphics.cxx +++ b/vcl/unx/source/gdi/pspgraphics.cxx @@ -1284,32 +1284,6 @@ ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintF aDFA.mbSubsettable = rInfo.m_bSubsettable; aDFA.mbEmbeddable = rInfo.m_bEmbeddable; - switch (rInfo.m_eEmbeddedbitmap) - { - default: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - break; - case psp::fcstatus::istrue: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_TRUE; - break; - case psp::fcstatus::isfalse: - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_FALSE; - break; - } - - switch (rInfo.m_eAntialias) - { - default: - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - break; - case psp::fcstatus::istrue: - aDFA.meAntiAlias = ANTIALIAS_TRUE; - break; - case psp::fcstatus::isfalse: - aDFA.meAntiAlias = ANTIALIAS_FALSE; - break; - } - switch( rInfo.m_eType ) { case psp::fonttype::Builtin: diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index bb5e7c68b356..7cf2009a3e07 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -630,12 +630,26 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev ServerFont* pServerFont = GlyphCache::GetInstance().CacheFont( *pEntry ); if( pServerFont != NULL ) { + // ignore fonts with e.g. corrupted font files if( !pServerFont->TestFont() ) { GlyphCache::GetInstance().UncacheFont( *pServerFont ); return false; } + + // register to use the font mpServerFont[ nFallbackLevel ] = pServerFont; + + // apply font specific-hint settings if needed + if( !bPrinter_ ) + { + // TODO: is it worth it to cache the hint settings, e.g. in the ImplFontEntry? + ImplFontOptions aFontOptions; + bool GetFCFontOptions( const ImplFontAttributes&, int nSize, ImplFontOptions&); + if( GetFCFontOptions( *pEntry->mpFontData, pEntry->mnHeight, aFontOptions ) ) + pServerFont->SetFontOptions( aFontOptions ); + } + return true; } @@ -743,6 +757,8 @@ private: void (*mp_set_font_matrix)(cairo_t *, const cairo_matrix_t *); void (*mp_show_glyphs)(cairo_t *, const cairo_glyph_t *, int ); void (*mp_set_source_rgb)(cairo_t *, double , double , double ); + void (*mp_set_font_options)(cairo_t *, const void *); + void (*mp_ft_font_options_substitute)(const void*, void*); bool canEmbolden() const { return false; } @@ -778,6 +794,10 @@ public: { (*mp_show_glyphs)(cr, glyphs, no_glyphs); } void set_source_rgb(cairo_t *cr, double red, double green, double blue) { (*mp_set_source_rgb)(cr, red, green, blue); } + void set_font_options(cairo_t *cr, const void *options) + { (*mp_set_font_options)(cr, options); } + void ft_font_options_substitute(const void *options, void *pattern) + { (*mp_ft_font_options_substitute)(options, pattern); } }; static CairoWrapper* pCairoInstance = NULL; @@ -847,6 +867,10 @@ CairoWrapper::CairoWrapper() osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_show_glyphs" ); mp_set_source_rgb = (void (*)(cairo_t *, double , double , double )) osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_set_source_rgb" ); + mp_set_font_options = (void (*)(cairo_t *, const void *options )) + osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_set_font_options" ); + mp_ft_font_options_substitute = (void (*)(const void *, void *)) + osl_getAsciiFunctionSymbol( mpCairoLib, "cairo_ft_font_options_substitute" ); if( !( mp_xlib_surface_create_with_xrender_format && @@ -863,7 +887,9 @@ CairoWrapper::CairoWrapper() mp_matrix_rotate && mp_set_font_matrix && mp_show_glyphs && - mp_set_source_rgb + mp_set_source_rgb && + mp_set_font_options && + mp_ft_font_options_substitute ) ) { osl_unloadModule( mpCairoLib ); @@ -971,6 +997,9 @@ void X11SalGraphics::DrawCairoAAFontString( const ServerFontLayout& rLayout ) cairo_t *cr = rCairo.create(surface); rCairo.surface_destroy(surface); + if (const void *pOptions = Application::GetSettings().GetStyleSettings().GetCairoFontOptions()) + rCairo.set_font_options( cr, pOptions); + if( pClipRegion_ && !XEmptyRegion( pClipRegion_ ) ) { for (long i = 0; i < pClipRegion_->numRects; ++i) @@ -1059,7 +1088,7 @@ void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout ) } // set font foreground color and opacity - XRenderColor aRenderColor = GetXRenderColor( nTextPixel_ ); + XRenderColor aRenderColor = GetXRenderColor( nTextColor_ ); rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 ); // set clipping @@ -1601,6 +1630,122 @@ void X11SalGraphics::GetDevFontSubstList( OutputDevice* ) // ---------------------------------------------------------------------------- +void cairosubcallback( void* pPattern ) +{ + CairoWrapper& rCairo = CairoWrapper::get(); + if( rCairo.isValid() ) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + rCairo.ft_font_options_substitute( rStyleSettings.GetCairoFontOptions(), pPattern); + } +} + +bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, + ImplFontOptions& rFontOptions) +{ + // TODO: get rid of these insane enum-conversions + // e.g. by using the classic vclenum values inside VCL + + psp::FastPrintFontInfo aInfo; + // set family name + aInfo.m_aFamilyName = rFontAttributes.GetFamilyName(); + // set italic + switch( rFontAttributes.GetSlant() ) + { + case ITALIC_NONE: + aInfo.m_eItalic = psp::italic::Upright; + break; + case ITALIC_NORMAL: + aInfo.m_eItalic = psp::italic::Italic; + break; + case ITALIC_OBLIQUE: + aInfo.m_eItalic = psp::italic::Oblique; + break; + default: + aInfo.m_eItalic = psp::italic::Unknown; + break; + + } + // set weight + switch( rFontAttributes.GetWeight() ) + { + case WEIGHT_THIN: + aInfo.m_eWeight = psp::weight::Thin; + break; + case WEIGHT_ULTRALIGHT: + aInfo.m_eWeight = psp::weight::UltraLight; + break; + case WEIGHT_LIGHT: + aInfo.m_eWeight = psp::weight::Light; + break; + case WEIGHT_SEMILIGHT: + aInfo.m_eWeight = psp::weight::SemiLight; + break; + case WEIGHT_NORMAL: + aInfo.m_eWeight = psp::weight::Normal; + break; + case WEIGHT_MEDIUM: + aInfo.m_eWeight = psp::weight::Medium; + break; + case WEIGHT_SEMIBOLD: + aInfo.m_eWeight = psp::weight::SemiBold; + break; + case WEIGHT_BOLD: + aInfo.m_eWeight = psp::weight::Bold; + break; + case WEIGHT_ULTRABOLD: + aInfo.m_eWeight = psp::weight::UltraBold; + break; + case WEIGHT_BLACK: + aInfo.m_eWeight = psp::weight::Black; + break; + default: + aInfo.m_eWeight = psp::weight::Unknown; + break; + } + // set width + switch( rFontAttributes.GetWidthType() ) + { + case WIDTH_ULTRA_CONDENSED: + aInfo.m_eWidth = psp::width::UltraCondensed; + break; + case WIDTH_EXTRA_CONDENSED: + aInfo.m_eWidth = psp::width::ExtraCondensed; + break; + case WIDTH_CONDENSED: + aInfo.m_eWidth = psp::width::Condensed; + break; + case WIDTH_SEMI_CONDENSED: + aInfo.m_eWidth = psp::width::SemiCondensed; + break; + case WIDTH_NORMAL: + aInfo.m_eWidth = psp::width::Normal; + break; + case WIDTH_SEMI_EXPANDED: + aInfo.m_eWidth = psp::width::SemiExpanded; + break; + case WIDTH_EXPANDED: + aInfo.m_eWidth = psp::width::Expanded; + break; + case WIDTH_EXTRA_EXPANDED: + aInfo.m_eWidth = psp::width::ExtraExpanded; + break; + case WIDTH_ULTRA_EXPANDED: + aInfo.m_eWidth = psp::width::UltraExpanded; + break; + default: + aInfo.m_eWidth = psp::width::Unknown; + break; + } + + const psp::PrintFontManager& rPFM = psp::PrintFontManager::get(); + bool bOK = rPFM.getFontOptions( aInfo, nSize, cairosubcallback, rFontOptions); + + return bOK; +} + +// ---------------------------------------------------------------------------- + void X11SalGraphics::GetFontMetric( ImplFontMetricData *pMetric ) { @@ -1876,8 +2021,10 @@ void RegisterFontSubstitutors( ImplDevFontList* pList ) // ----------------------------------------------------------------------- -static rtl::OUString GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUString& rMissingCodes ) +static ImplFontSelectData GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUString& rMissingCodes ) { + ImplFontSelectData aRet(rFontSelData); + const rtl::OString aLangAttrib; //TODO: = MsLangId::convertLanguageToIsoByteString( rFontSelData.meLanguage ); psp::italic::type eItalic = psp::italic::Unknown; @@ -1945,7 +2092,72 @@ static rtl::OUString GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUS } const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - return rMgr.Substitute( rFontSelData.maTargetName, rMissingCodes, aLangAttrib, eItalic, eWeight, eWidth, ePitch); + aRet.maSearchName = rMgr.Substitute( rFontSelData.maTargetName, rMissingCodes, aLangAttrib, eItalic, eWeight, eWidth, ePitch); + + switch (eItalic) + { + case psp::italic::Upright: aRet.meItalic = ITALIC_NONE; break; + case psp::italic::Italic: aRet.meItalic = ITALIC_NORMAL; break; + case psp::italic::Oblique: aRet.meItalic = ITALIC_OBLIQUE; break; + default: + break; + } + + switch (eWeight) + { + case psp::weight::Thin: aRet.meWeight = WEIGHT_THIN; break; + case psp::weight::UltraLight: aRet.meWeight = WEIGHT_ULTRALIGHT; break; + case psp::weight::Light: aRet.meWeight = WEIGHT_LIGHT; break; + case psp::weight::SemiLight: aRet.meWeight = WEIGHT_SEMILIGHT; break; + case psp::weight::Normal: aRet.meWeight = WEIGHT_NORMAL; break; + case psp::weight::Medium: aRet.meWeight = WEIGHT_MEDIUM; break; + case psp::weight::SemiBold: aRet.meWeight = WEIGHT_SEMIBOLD; break; + case psp::weight::Bold: aRet.meWeight = WEIGHT_BOLD; break; + case psp::weight::UltraBold: aRet.meWeight = WEIGHT_ULTRABOLD; break; + case psp::weight::Black: aRet.meWeight = WEIGHT_BLACK; break; + default: + break; + } + + switch (eWidth) + { + case psp::width::UltraCondensed: aRet.meWidthType = WIDTH_ULTRA_CONDENSED; break; + case psp::width::ExtraCondensed: aRet.meWidthType = WIDTH_EXTRA_CONDENSED; break; + case psp::width::Condensed: aRet.meWidthType = WIDTH_CONDENSED; break; + case psp::width::SemiCondensed: aRet.meWidthType = WIDTH_SEMI_CONDENSED; break; + case psp::width::Normal: aRet.meWidthType = WIDTH_NORMAL; break; + case psp::width::SemiExpanded: aRet.meWidthType = WIDTH_SEMI_EXPANDED; break; + case psp::width::Expanded: aRet.meWidthType = WIDTH_EXPANDED; break; + case psp::width::ExtraExpanded: aRet.meWidthType = WIDTH_EXTRA_EXPANDED; break; + case psp::width::UltraExpanded: aRet.meWidthType = WIDTH_ULTRA_EXPANDED; break; + default: + break; + } + + switch (ePitch) + { + case psp::pitch::Fixed: aRet.mePitch = PITCH_FIXED; break; + case psp::pitch::Variable: aRet.mePitch = PITCH_VARIABLE; break; + default: + break; + } + + return aRet; +} + +namespace +{ + bool uselessmatch(const ImplFontSelectData &rOrig, const ImplFontSelectData &rNew) + { + return + ( + rOrig.maTargetName == rNew.maSearchName && + rOrig.meWeight == rNew.meWeight && + rOrig.meItalic == rNew.meItalic && + rOrig.mePitch == rNew.mePitch && + rOrig.meWidthType == rNew.meWidthType + ); + } } //-------------------------------------------------------------------------- @@ -1953,7 +2165,7 @@ static rtl::OUString GetFcSubstitute(const ImplFontSelectData &rFontSelData, OUS bool FcPreMatchSubstititution::FindFontSubstitute( ImplFontSelectData &rFontSelData ) const { // We dont' actually want to talk to Fontconfig at all for symbol fonts - if (rFontSelData.IsSymbolFont()) + if( rFontSelData.IsSymbolFont() ) return false; // StarSymbol is a unicode font, but it still deserves the symbol flag if( 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "starsymbol", 10) @@ -1961,21 +2173,33 @@ bool FcPreMatchSubstititution::FindFontSubstitute( ImplFontSelectData &rFontSelD return false; rtl::OUString aDummy; - const rtl::OUString aOUName = GetFcSubstitute( rFontSelData, aDummy ); - if( !aOUName.getLength() ) - return false; - const String aName( aOUName ); - if( aName == rFontSelData.maTargetName ) + const ImplFontSelectData aOut = GetFcSubstitute( rFontSelData, aDummy ); + // TODO: cache the font substitution suggestion + // FC doing it would be preferable because it knows the invariables + // e.g. FC knows the FC rule that all Arial gets replaced by LiberationSans + // whereas we would have to check for every size or attribute + if( !aOut.maSearchName.Len() ) return false; + const bool bHaveSubstitute = !uselessmatch( rFontSelData, aOut ); + #ifdef DEBUG - ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 ); - ByteString aSubstName( aName, RTL_TEXTENCODING_UTF8 ); - printf( "FcPreMatchSubstititution \"%s\" -> \"%s\"\n", - aOrigName.GetBuffer(), aSubstName.GetBuffer() ); + const ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 ); + const ByteString aSubstName( aOut.maSearchName, RTL_TEXTENCODING_UTF8 ); + printf( "FcPreMatchSubstititution \"%s\" bipw=%d%d%d%d -> ", + aOrigName.GetBuffer(), rFontSelData.meWeight, rFontSelData.meItalic, + rFontSelData.mePitch, rFontSelData.meWidthType ); + if( !bHaveSubstitute ) + printf( "no substitute available\n" ); + else + printf( "\"%s\" bipw=%d%d%d%d\n", aSubstName.GetBuffer(), + aOut.meWeight, aOut.meItalic, aOut.mePitch, aOut.meWidthType ); #endif - rFontSelData.maSearchName = aName; - return true; + + if( bHaveSubstitute ) + rFontSelData = aOut; + + return bHaveSubstitute; } // ----------------------------------------------------------------------- @@ -1991,22 +2215,33 @@ bool FcGlyphFallbackSubstititution::FindFontSubstitute( ImplFontSelectData& rFon || 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) ) return false; - const rtl::OUString aOUName = GetFcSubstitute( rFontSelData, rMissingCodes ); - // TODO: cache the unicode+font specific result - if( !aOUName.getLength() ) - return false; - const String aName( aOUName ); - if( aName == rFontSelData.maTargetName ) + const ImplFontSelectData aOut = GetFcSubstitute( rFontSelData, rMissingCodes ); + // TODO: cache the unicode + srcfont specific result + // FC doing it would be preferable because it knows the invariables + // e.g. FC knows the FC rule that all Arial gets replaced by LiberationSans + // whereas we would have to check for every size or attribute + if( !aOut.maSearchName.Len() ) return false; + const bool bHaveSubstitute = !uselessmatch( rFontSelData, aOut ); + #ifdef DEBUG - ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 ); - ByteString aSubstName( aName, RTL_TEXTENCODING_UTF8 ); - printf( "FcGlyphFallbackSubstititution \"%s\" -> \"%s\"\n", - aOrigName.GetBuffer(), aSubstName.GetBuffer() ); + const ByteString aOrigName( rFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 ); + const ByteString aSubstName( aOut.maSearchName, RTL_TEXTENCODING_UTF8 ); + printf( "FcGFSubstititution \"%s\" bipw=%d%d%d%d ->", + aOrigName.GetBuffer(), rFontSelData.meWeight, rFontSelData.meItalic, + rFontSelData.mePitch, rFontSelData.meWidthType ); + if( !bHaveSubstitute ) + printf( "no substitute available\n" ); + else + printf( "\"%s\" bipw=%d%d%d%d\n", aSubstName.GetBuffer(), + aOut.meWeight, aOut.meItalic, aOut.mePitch, aOut.meWidthType ); #endif - rFontSelData.maSearchName = aName; - return true; + + if( bHaveSubstitute ) + rFontSelData = aOut; + + return bHaveSubstitute; } // =========================================================================== diff --git a/vcl/unx/source/gdi/xlfd_extd.cxx b/vcl/unx/source/gdi/xlfd_extd.cxx index 8449fcc5872e..73731eddf115 100644 --- a/vcl/unx/source/gdi/xlfd_extd.cxx +++ b/vcl/unx/source/gdi/xlfd_extd.cxx @@ -102,9 +102,6 @@ ExtendedXlfd::ExtendedXlfd( bool bScalable ) mbSubsettable = false; mbEmbeddable = false; - meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - meAntiAlias = ANTIALIAS_DONTKNOW; - mnQuality = -1; } diff --git a/vcl/unx/source/gdi/xrender_peer.cxx b/vcl/unx/source/gdi/xrender_peer.cxx index c5d84cffab58..8d24e4098df4 100644 --- a/vcl/unx/source/gdi/xrender_peer.cxx +++ b/vcl/unx/source/gdi/xrender_peer.cxx @@ -25,6 +25,9 @@ * ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_vcl.hxx" + #include <stdio.h> #include <rtl/ustring.hxx> #include <osl/module.h> @@ -172,7 +175,7 @@ void XRenderPeer::InitRenderLib() #if 0 // not having trapezoid support is supported if( !pFunc ) return; #endif - mpXRenderAddTraps = (void(*)(Display*,Picture,int,int,const XTrap*,int))pFunc; + mpXRenderAddTraps = (void(*)(Display*,Picture,int,int,const _XTrap*,int))pFunc; #endif // XRENDER_LINK @@ -190,12 +193,16 @@ void XRenderPeer::InitRenderLib() (*mpXRenderQueryVersion)( mpDisplay, &nMajor, &nMinor ); #endif mnRenderVersion = 16*nMajor + nMinor; + + // the 8bit alpha mask format must be there + XRenderPictFormat aPictFormat={0,0,8,{0,0,0,0,0,0,0,0xFF},0}; + mpStandardFormatA8 = FindPictureFormat( PictFormatAlphaMask|PictFormatDepth, aPictFormat ); } // --------------------------------------------------------------------------- // return mask of screens capable of XRENDER text -sal_uInt32 XRenderPeer::InitRenderText( int nMaxDepth ) +sal_uInt32 XRenderPeer::InitRenderText() { if( mnRenderVersion < 0x01 ) return 0; @@ -206,9 +213,6 @@ sal_uInt32 XRenderPeer::InitRenderText( int nMaxDepth ) if( mnRenderVersion < 0x02 ) return 0; - // the 8bit alpha mask format must be there - XRenderPictFormat aPictFormat={0,0,8,{0,0,0,0,0,0,0,0xFF},0}; - mpStandardFormatA8 = FindPictureFormat( PictFormatAlphaMask|PictFormatDepth, aPictFormat ); if( !mpStandardFormatA8 ) return 0; @@ -217,18 +221,24 @@ sal_uInt32 XRenderPeer::InitRenderText( int nMaxDepth ) SalDisplay* pSalDisp = GetX11SalData()->GetDisplay(); const int nScreenCount = pSalDisp->GetScreenCount(); XRenderPictFormat* pVisualFormat = NULL; + int nMaxDepth = 0; for( int nScreen = 0; nScreen < nScreenCount; ++nScreen ) { Visual* pXVisual = pSalDisp->GetVisual( nScreen ).GetVisual(); pVisualFormat = FindVisualFormat( pXVisual ); if( pVisualFormat != NULL ) + { + int nVDepth = pSalDisp->GetVisual( nScreen ).GetDepth(); + if( nVDepth > nMaxDepth ) + nMaxDepth = nVDepth; nRetMask |= 1U << nScreen; + } } // #97763# disable XRENDER on <15bit displays for XFree<=4.2.0 if( mnRenderVersion <= 0x02 ) if( nMaxDepth < 15 ) - return 0; + nRetMask = 0; return nRetMask; } diff --git a/vcl/unx/source/gdi/xrender_peer.hxx b/vcl/unx/source/gdi/xrender_peer.hxx index 6d40015ee94d..89dccfcef40b 100644 --- a/vcl/unx/source/gdi/xrender_peer.hxx +++ b/vcl/unx/source/gdi/xrender_peer.hxx @@ -29,6 +29,7 @@ #define _SV_XRENDER_PEER_HXX #include <tools/prex.h> +struct _XTrap; // on some older systems this is not declared within Xrender.h #include <X11/extensions/Xrender.h> #include <tools/postx.h> @@ -41,7 +42,7 @@ public: static XRenderPeer& GetInstance(); int GetVersion() const; - sal_uInt32 InitRenderText( int nMaxDepth ); + sal_uInt32 InitRenderText(); protected: XRenderPeer(); @@ -84,7 +85,7 @@ public: const XRenderPictFormat*, int nXSrc, int nYSrc, const XTrapezoid*, int nCount ) const; bool AddTraps( Picture aDst, int nXOfs, int nYOfs, - const XTrap*, int nCount ) const; + const _XTrap*, int nCount ) const; bool AreTrapezoidsSupported() const #ifdef XRENDER_LINK @@ -120,7 +121,7 @@ private: const XRenderColor*,int,int,unsigned int,unsigned int); void (*mpXRenderCompositeTrapezoids)(Display*,int,Picture,Picture, const XRenderPictFormat*,int,int,const XTrapezoid*,int); - void (*mpXRenderAddTraps)(Display*,Picture,int,int,const XTrap*,int); + void (*mpXRenderAddTraps)(Display*,Picture,int,int,const _XTrap*,int); #endif // XRENDER_LINK }; @@ -326,7 +327,7 @@ inline void XRenderPeer::CompositeTrapezoids( int nOp, } inline bool XRenderPeer::AddTraps( Picture aDst, int nXOfs, int nYOfs, - const XTrap* pTraps, int nCount ) const + const _XTrap* pTraps, int nCount ) const { #ifdef XRENDER_LINK XRenderAddTraps( mpDisplay, aDst, nXOfs, nYOfs, pTraps, nCount ); diff --git a/vcl/unx/source/printer/ppdparser.cxx b/vcl/unx/source/printer/ppdparser.cxx index 971db860cf42..b2549573d099 100644 --- a/vcl/unx/source/printer/ppdparser.cxx +++ b/vcl/unx/source/printer/ppdparser.cxx @@ -258,7 +258,6 @@ using namespace rtl; std::list< PPDParser* > PPDParser::aAllParsers; std::hash_map< OUString, OUString, OUStringHash >* PPDParser::pAllPPDFiles = NULL; -static String aEmptyString; class PPDDecompressStream { @@ -1284,12 +1283,12 @@ void PPDParser::parseConstraint( const ByteString& rLine ) m_aConstraints.push_back( aConstraint ); } -const String& PPDParser::getDefaultPaperDimension() const +String PPDParser::getDefaultPaperDimension() const { if( m_pDefaultPaperDimension ) return m_pDefaultPaperDimension->m_aOption; - return aEmptyString; + return String(); } bool PPDParser::getMargins( @@ -1356,10 +1355,10 @@ bool PPDParser::getPaperDimension( return true; } -const String& PPDParser::matchPaper( int nWidth, int nHeight ) const +String PPDParser::matchPaper( int nWidth, int nHeight ) const { if( ! m_pPaperDimensions ) - return aEmptyString; + return String(); int nPDim = -1; double PDWidth, PDHeight; @@ -1393,51 +1392,51 @@ const String& PPDParser::matchPaper( int nWidth, int nHeight ) const { // swap portrait/landscape and try again bDontSwap = true; - const String& rRet = matchPaper( nHeight, nWidth ); + String rRet = matchPaper( nHeight, nWidth ); bDontSwap = false; return rRet; } - return nPDim != -1 ? m_pPaperDimensions->getValue( nPDim )->m_aOption : aEmptyString; + return nPDim != -1 ? m_pPaperDimensions->getValue( nPDim )->m_aOption : String(); } -const String& PPDParser::getDefaultInputSlot() const +String PPDParser::getDefaultInputSlot() const { if( m_pDefaultInputSlot ) return m_pDefaultInputSlot->m_aValue; - return aEmptyString; + return String(); } -const String& PPDParser::getSlot( int nSlot ) const +String PPDParser::getSlot( int nSlot ) const { if( ! m_pInputSlots ) - return aEmptyString; + return String(); if( nSlot > 0 && nSlot < m_pInputSlots->countValues() ) return m_pInputSlots->getValue( nSlot )->m_aOption; else if( m_pInputSlots->countValues() > 0 ) return m_pInputSlots->getValue( (ULONG)0 )->m_aOption; - return aEmptyString; + return String(); } -const String& PPDParser::getSlotCommand( int nSlot ) const +String PPDParser::getSlotCommand( int nSlot ) const { if( ! m_pInputSlots ) - return aEmptyString; + return String(); if( nSlot > 0 && nSlot < m_pInputSlots->countValues() ) return m_pInputSlots->getValue( nSlot )->m_aValue; else if( m_pInputSlots->countValues() > 0 ) return m_pInputSlots->getValue( (ULONG)0 )->m_aValue; - return aEmptyString; + return String(); } -const String& PPDParser::getSlotCommand( const String& rSlot ) const +String PPDParser::getSlotCommand( const String& rSlot ) const { if( ! m_pInputSlots ) - return aEmptyString; + return String(); for( int i=0; i < m_pInputSlots->countValues(); i++ ) { @@ -1445,39 +1444,39 @@ const String& PPDParser::getSlotCommand( const String& rSlot ) const if( pValue->m_aOption == rSlot ) return pValue->m_aValue; } - return aEmptyString; + return String(); } -const String& PPDParser::getPaperDimension( int nPaperDimension ) const +String PPDParser::getPaperDimension( int nPaperDimension ) const { if( ! m_pPaperDimensions ) - return aEmptyString; + return String(); if( nPaperDimension > 0 && nPaperDimension < m_pPaperDimensions->countValues() ) return m_pPaperDimensions->getValue( nPaperDimension )->m_aOption; else if( m_pPaperDimensions->countValues() > 0 ) return m_pPaperDimensions->getValue( (ULONG)0 )->m_aOption; - return aEmptyString; + return String(); } -const String& PPDParser::getPaperDimensionCommand( int nPaperDimension ) const +String PPDParser::getPaperDimensionCommand( int nPaperDimension ) const { if( ! m_pPaperDimensions ) - return aEmptyString; + return String(); if( nPaperDimension > 0 && nPaperDimension < m_pPaperDimensions->countValues() ) return m_pPaperDimensions->getValue( nPaperDimension )->m_aValue; else if( m_pPaperDimensions->countValues() > 0 ) return m_pPaperDimensions->getValue( (ULONG)0 )->m_aValue; - return aEmptyString; + return String(); } -const String& PPDParser::getPaperDimensionCommand( const String& rPaperDimension ) const +String PPDParser::getPaperDimensionCommand( const String& rPaperDimension ) const { if( ! m_pPaperDimensions ) - return aEmptyString; + return String(); for( int i=0; i < m_pPaperDimensions->countValues(); i++ ) { @@ -1485,7 +1484,7 @@ const String& PPDParser::getPaperDimensionCommand( const String& rPaperDimension if( pValue->m_aOption == rPaperDimension ) return pValue->m_aValue; } - return aEmptyString; + return String(); } void PPDParser::getResolutionFromString( @@ -1543,13 +1542,13 @@ void PPDParser::getResolution( int nNr, int& rXRes, int& rYRes ) const rXRes, rYRes ); } -const String& PPDParser::getResolutionCommand( int nXRes, int nYRes ) const +String PPDParser::getResolutionCommand( int nXRes, int nYRes ) const { if( ( ! m_pResolutions || m_pResolutions->countValues() == 0 ) && m_pDefaultResolution ) return m_pDefaultResolution->m_aValue; if( ! m_pResolutions ) - return aEmptyString; + return String(); int nX, nY; for( int i = 0; i < m_pResolutions->countValues(); i++ ) @@ -1559,46 +1558,46 @@ const String& PPDParser::getResolutionCommand( int nXRes, int nYRes ) const if( nX == nXRes && nY == nYRes ) return m_pResolutions->getValue( i )->m_aValue; } - return aEmptyString; + return String(); } -const String& PPDParser::getDefaultDuplexType() const +String PPDParser::getDefaultDuplexType() const { if( m_pDefaultDuplexType ) return m_pDefaultDuplexType->m_aValue; - return aEmptyString; + return String(); } -const String& PPDParser::getDuplex( int nDuplex ) const +String PPDParser::getDuplex( int nDuplex ) const { if( ! m_pDuplexTypes ) - return aEmptyString; + return String(); if( nDuplex > 0 && nDuplex < m_pDuplexTypes->countValues() ) return m_pDuplexTypes->getValue( nDuplex )->m_aOption; else if( m_pDuplexTypes->countValues() > 0 ) return m_pDuplexTypes->getValue( (ULONG)0 )->m_aOption; - return aEmptyString; + return String(); } -const String& PPDParser::getDuplexCommand( int nDuplex ) const +String PPDParser::getDuplexCommand( int nDuplex ) const { if( ! m_pDuplexTypes ) - return aEmptyString; + return String(); if( nDuplex > 0 && nDuplex < m_pDuplexTypes->countValues() ) return m_pDuplexTypes->getValue( nDuplex )->m_aValue; else if( m_pDuplexTypes->countValues() > 0 ) return m_pDuplexTypes->getValue( (ULONG)0 )->m_aValue; - return aEmptyString; + return String(); } -const String& PPDParser::getDuplexCommand( const String& rDuplex ) const +String PPDParser::getDuplexCommand( const String& rDuplex ) const { if( ! m_pDuplexTypes ) - return aEmptyString; + return String(); for( int i=0; i < m_pDuplexTypes->countValues(); i++ ) { @@ -1606,7 +1605,7 @@ const String& PPDParser::getDuplexCommand( const String& rDuplex ) const if( pValue->m_aOption == rDuplex ) return pValue->m_aValue; } - return aEmptyString; + return String(); } void PPDParser::getFontAttributes( @@ -1636,14 +1635,14 @@ void PPDParser::getFontAttributes( } } -const String& PPDParser::getFont( int nFont ) const +String PPDParser::getFont( int nFont ) const { if( ! m_pFontList ) - return aEmptyString; + return String(); if( nFont >=0 && nFont < m_pFontList->countValues() ) return m_pFontList->getValue( nFont )->m_aOption; - return aEmptyString; + return String(); } rtl::OUString PPDParser::translateKey( const rtl::OUString& i_rKey, diff --git a/vcl/util/makefile2.pmk b/vcl/util/makefile2.pmk index 56102a256ea3..df9ba1a214d7 100644 --- a/vcl/util/makefile2.pmk +++ b/vcl/util/makefile2.pmk @@ -36,6 +36,6 @@ CFLAGSCXX+=$(OBJCXXFLAGS) #building with stlport, but graphite was not built with stlport .IF "$(USE_SYSTEM_STL)"!="YES" .IF "$(SYSTEM_GRAPHITE)"=="YES" -CDEFS += -DGRAPHITEADAPTSTL +CDEFS += -DADAPT_EXT_STL .ENDIF .ENDIF diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 84695baf3557..ebe470d3eb7e 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -590,11 +590,7 @@ static ImplDevFontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXA& rE aDFA.mnQuality += 500; } - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - // TODO: add alias names - return aDFA; } @@ -669,9 +665,6 @@ static ImplDevFontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rE aDFA.mnQuality += 500; } - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; - // TODO: add alias names return aDFA; } @@ -1998,8 +1991,6 @@ static bool ImplGetFontAttrFromFile( const String& rFontFileURL, rDFA.mePitch = PITCH_DONTKNOW;; rDFA.mbSubsettable= true; rDFA.mbEmbeddable = false; - rDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - rDFA.meAntiAlias = ANTIALIAS_DONTKNOW; // Create temporary file name char aFileName[] = "soAAT.fot"; @@ -2126,8 +2117,6 @@ bool WinSalGraphics::AddTempDevFont( ImplDevFontList* pFontList, aDFA.mePitch = PITCH_DONTKNOW;; aDFA.mbSubsettable= true; aDFA.mbEmbeddable = false; - aDFA.meEmbeddedBitmap = EMBEDDEDBITMAP_DONTKNOW; - aDFA.meAntiAlias = ANTIALIAS_DONTKNOW; /* // TODO: improve ImplDevFontAttributes using the "font resource file" diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index f95f42d6bf4d..1b7ed7dcfccb 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -291,6 +291,10 @@ BOOL WinSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP if( nPart == PART_ENTIRE_CONTROL ) hTheme = getThemeHandle( mhWnd, L"Progress"); break; + case CTRL_SLIDER: + if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) + hTheme = getThemeHandle( mhWnd, L"Trackbar" ); + break; default: hTheme = NULL; break; @@ -890,6 +894,38 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, return ImplDrawTheme( hTheme, hDC, PP_CHUNK, iState, aProgressRect, aCaption ); } + if( nType == CTRL_SLIDER ) + { + iPart = (nPart == PART_TRACK_HORZ_AREA) ? TKP_TRACK : TKP_TRACKVERT; + iState = (nPart == PART_TRACK_HORZ_AREA) ? TRS_NORMAL : TRVS_NORMAL; + + Rectangle aTrackRect = ImplGetThemeRect( hTheme, hDC, iPart, iState, Rectangle() ); + RECT aTRect = rc; + if( nPart == PART_TRACK_HORZ_AREA ) + { + long nH = aTrackRect.GetHeight(); + aTRect.top += (rc.bottom - rc.top - nH)/2; + aTRect.bottom = aTRect.top + nH; + } + else + { + long nW = aTrackRect.GetWidth(); + aTRect.left += (rc.right - rc.left - nW)/2; + aTRect.right = aTRect.left + nW; + } + ImplDrawTheme( hTheme, hDC, iPart, iState, aTRect, aCaption ); + + RECT aThumbRect; + SliderValue* pVal = (SliderValue*)aValue.getOptionalVal(); + aThumbRect.left = pVal->maThumbRect.Left(); + aThumbRect.top = pVal->maThumbRect.Top(); + aThumbRect.right = pVal->maThumbRect.Right(); + aThumbRect.bottom = pVal->maThumbRect.Bottom(); + iPart = (nPart == PART_TRACK_HORZ_AREA) ? TKP_THUMB : TKP_THUMBVERT; + iState = (nState & CTRL_STATE_ENABLED) ? TUS_NORMAL : TUS_DISABLED; + return ImplDrawTheme( hTheme, hDC, iPart, iState, aThumbRect, aCaption ); + } + return false; } @@ -970,6 +1006,10 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, if( nPart == PART_ENTIRE_CONTROL ) hTheme = getThemeHandle( mhWnd, L"Progress"); break; + case CTRL_SLIDER: + if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) + hTheme = getThemeHandle( mhWnd, L"Trackbar" ); + break; default: hTheme = NULL; break; @@ -1106,7 +1146,6 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, bRet = TRUE; } } - if( (nType == CTRL_LISTBOX || nType == CTRL_COMBOBOX ) && nPart == PART_ENTIRE_CONTROL ) { HTHEME hTheme = getThemeHandle( mhWnd, L"Combobox"); @@ -1162,6 +1201,33 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, } } } + if( nType == CTRL_SLIDER && ( (nPart == PART_THUMB_HORZ) || (nPart == PART_THUMB_VERT) ) ) + { + HTHEME hTheme = getThemeHandle( mhWnd, L"Trackbar"); + if( hTheme ) + { + int iPart = (nPart == PART_THUMB_HORZ) ? TKP_THUMB : TKP_THUMBVERT; + int iState = (nPart == PART_THUMB_HORZ) ? TUS_NORMAL : TUVS_NORMAL; + Rectangle aThumbRect = ImplGetThemeRect( hTheme, hDC, iPart, iState, Rectangle() ); + if( nPart == PART_THUMB_HORZ ) + { + long nW = aThumbRect.GetWidth(); + Rectangle aRect( rControlRegion.GetBoundRect() ); + aRect.Right() = aRect.Left() + nW - 1; + rNativeContentRegion = aRect; + rNativeBoundingRegion = rNativeContentRegion; + } + else + { + long nH = aThumbRect.GetHeight(); + Rectangle aRect( rControlRegion.GetBoundRect() ); + aRect.Bottom() = aRect.Top() + nH - 1; + rNativeContentRegion = aRect; + rNativeBoundingRegion = rNativeContentRegion; + } + bRet = TRUE; + } + } ReleaseDC( mhWnd, hDC ); return( bRet ); diff --git a/vcl/win/source/window/MAKEFILE.MK b/vcl/win/source/window/MAKEFILE.MK index e83f04cfdfb0..cecfbcf5b2e5 100644 --- a/vcl/win/source/window/MAKEFILE.MK +++ b/vcl/win/source/window/MAKEFILE.MK @@ -38,12 +38,7 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : $(PRJ)$/util$/makefile2.pmk # --- #105371# -.IF "$(COM)"=="GCC" -CFLAGS += -D_WIN32_WINNT=0x0501 -.ELSE -CFLAGS += -DWINVER=0x0400 -D_WIN32_WINNT=0x0501 - -.ENDIF +CDEFS +=-U_WIN32_WINNT -D_WIN32_WINNT=0x0501 # --- Files -------------------------------------------------------- |