diff options
387 files changed, 14151 insertions, 13059 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..9d80bf7050e6 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -287,7 +287,8 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] = { LANGUAGE_BELARUSIAN, "be", "BY" }, { LANGUAGE_CATALAN, "ca", "ES" }, // Spain (default) { LANGUAGE_CATALAN, "ca", "AD" }, // Andorra - { LANGUAGE_USER_CATALAN_VALENCIAN, "ca", "XV" }, // XV: ISO 3166 user-assigned; workaround for UI localization only, do not use in document content! + { LANGUAGE_USER_CATALAN_VALENCIAN, "ca", "XV" }, // XV: ISO 3166 user-assigned; old workaround for UI localization only, do not use in document content! Kept just in case.. + { LANGUAGE_USER_CATALAN_VALENCIAN, "qcv", "ES" }, // qcv: ISO 639-3 reserved-for-local-use; for UI localization, use in document content on own risk! { LANGUAGE_FRENCH_CAMEROON, "fr", "CM" }, { LANGUAGE_FRENCH_COTE_D_IVOIRE, "fr", "CI" }, { LANGUAGE_FRENCH_HAITI, "fr", "HT" }, @@ -349,6 +350,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 +403,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 +451,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..100644 --- 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..100644 --- 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/padmin/source/padialog.cxx b/padmin/source/padialog.cxx index 3ea15e28141c..583e14c06caa 100644 --- a/padmin/source/padialog.cxx +++ b/padmin/source/padialog.cxx @@ -147,6 +147,11 @@ void PADialog::Init() ::psp::PrintFontManager& rFontManager( ::psp::PrintFontManager::get() ); if( ! rFontManager.checkImportPossible() ) m_aFontsPB.Enable( FALSE ); + if( rFontManager.hasFontconfig() ) + { + m_aFontsPB.Enable( FALSE ); + m_aFontsPB.Show( FALSE ); + } } PADialog::~PADialog() diff --git a/rsc/inc/rsctools.hxx b/rsc/inc/rsctools.hxx index 287a079f63c8..3a3eff653cd7 100644 --- a/rsc/inc/rsctools.hxx +++ b/rsc/inc/rsctools.hxx @@ -68,7 +68,6 @@ class RscChar { public: static char * MakeUTF8( char * pStr, UINT16 nTextEncoding ); - static char * MakeUTF8FromL( char * pStr ); }; /****************** R s c P t r P t r ************************************/ 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/rsc/source/tools/rscchar.cxx b/rsc/source/tools/rscchar.cxx index ca421dde372a..c23022e4222e 100644 --- a/rsc/source/tools/rscchar.cxx +++ b/rsc/source/tools/rscchar.cxx @@ -194,136 +194,3 @@ char * RscChar::MakeUTF8( char * pStr, UINT16 nTextEncoding ) return pUtf8; }; - -/************************************************************************* -|* -|* RscChar::MakeChar() -|* -|* Beschreibung Der String wird nach C-Konvention umgesetzt -|* Ersterstellung MM 20.03.91 -|* Letzte Aenderung MM 20.03.91 -|* -*************************************************************************/ -char * RscChar::MakeUTF8FromL( char * pStr ) -{ - sal_Size nUniPos = 0; - sal_Unicode * pUniCode = new sal_Unicode[ strlen( pStr ) + 1 ]; - - char cOld = '1'; - while( cOld != 0 ) - { - sal_Unicode c; - if( *pStr == '\\' ) - { - ++pStr; - switch( *pStr ) - { - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case '\\': - c = '\\'; - break; - case '?': - c = '\?'; - break; - case '\'': - c = '\''; - break; - case '\"': - c = '\"'; - break; - default: - { - if( '0' <= *pStr && '7' >= *pStr ) - { - UINT32 nChar = 0; - int i = 0; - while( '0' <= *pStr && '7' >= *pStr && i != 6 ) - { - nChar = nChar * 8 + (BYTE)*pStr - (BYTE)'0'; - ++pStr; - i++; - } - if( nChar > 0xFFFF ) - // Wert zu gross, oder kein 3 Ziffern - return( FALSE ); - c = (UINT16)nChar; - pStr--; - } - else if( 'x' == *pStr || 'X' == *pStr ) - { - UINT32 nChar = 0; - int i = 0; - ++pStr; - while( isxdigit( *pStr ) && i != 4 ) - { - if( isdigit( *pStr ) ) - nChar = nChar * 16 + (BYTE)*pStr - (BYTE)'0'; - else if( isupper( *pStr ) ) - nChar = nChar * 16 + (BYTE)*pStr - (BYTE)'A' +10; - else - nChar = nChar * 16 + (BYTE)*pStr - (BYTE)'a' +10; - ++pStr; - i++; - } - c = (UINT16)nChar; - pStr--; - } - else - c = *pStr; - }; - } - } - else - c = *pStr; - - pUniCode[ nUniPos++ ] = c; - cOld = *pStr; - pStr++; - } - - // factor fo 6 is the maximum size of an UNICODE character as utf8 - sal_Size nMaxUtf8Len = nUniPos * 6; - if( nUniPos * 6 > 0x0FFFFF ) - RscExit( 10 ); - - char * pUtf8 = (char *)rtl_allocateMemory( nMaxUtf8Len ); - rtl_TextToUnicodeConverter hConv = rtl_createUnicodeToTextConverter( RTL_TEXTENCODING_UTF8 ); - - sal_uInt32 nInfo; - sal_Size nSrcCvtBytes; - rtl_convertUnicodeToText( hConv, 0, - pUniCode, nUniPos, - pUtf8, nMaxUtf8Len, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT - | RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT - | RTL_UNICODETOTEXT_FLAGS_FLUSH, - &nInfo, - &nSrcCvtBytes ); - - rtl_destroyUnicodeToTextConverter( hConv ); - - delete[] pUniCode; - - return pUtf8; -}; - 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/items/style.cxx b/svl/source/items/style.cxx index b8bed49b603b..60c622208d53 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -28,7 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svl.hxx" -#ifndef GCC +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ +#include <com/sun/star/lang/XComponent.hpp> #endif #define _SVSTDARR_STRINGS @@ -808,6 +809,16 @@ void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p ) { // Alle Styles umsetzen, deren Parent dieser hier ist ChangeParent( p->GetName(), p->GetParent() ); + + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY ); + if( xComp.is() ) try + { + xComp->dispose(); + } + catch( com::sun::star::uno::Exception& ) + { + } + aStyles.erase(aIter); Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) ); } @@ -838,6 +849,15 @@ void SfxStyleSheetBasePool::Clear() SfxStyles::iterator aIter( aClearStyles.begin() ); while( aIter != aClearStyles.end() ) { + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY ); + if( xComp.is() ) try + { + xComp->dispose(); + } + catch( com::sun::star::uno::Exception& ) + { + } + Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *(*aIter++).get() ) ); } } diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index bec8b91e7c22..ee9aa5932525 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -806,16 +806,13 @@ namespace unnamed_svl_inettype { MediaTypeEntry const * seekEntry(UniString const & rTypeName, MediaTypeEntry const * pMap, sal_Size nSize) { -#if defined DBG_UTIL || defined INETTYPE_DEBUG - static bool bChecked = false; - if (!bChecked) - { - for (sal_Size i = 0; i < nSize - 1; ++i) - DBG_ASSERT(pMap[i].m_pTypeName < pMap[i + 1].m_pTypeName, - "seekEntry(): Bad map"); - bChecked = true; - } -#endif // DBG_UTIL, INETTYPE_DEBUG +#if defined DBG_UTIL + for (sal_Size i = 0; i < nSize - 1; ++i) + DBG_ASSERT( + rtl_str_compare( + pMap[i].m_pTypeName, pMap[i + 1].m_pTypeName) < 0, + "seekEntry(): Bad map"); +#endif sal_Size nLow = 0; sal_Size nHigh = nSize; diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index a3a3f63367c1..46063564193d 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -123,8 +123,7 @@ inline UniString SmartRel2Abs_Impl(INetURLObject const & rTheBaseURIRef, eStyle); if (bCheckFileExists && !bWasAbsolute - && (aAbsURIRef.GetProtocol() == INET_PROT_FILE - || aAbsURIRef.GetProtocol() == INET_PROT_VND_SUN_STAR_WFS)) + && (aAbsURIRef.GetProtocol() == INET_PROT_FILE)) { INetURLObject aNonFileURIRef; aNonFileURIRef.SetSmartURL(rTheRelURIRef, 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/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 5b7821aa457e..32c65b06d2f1 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -675,7 +675,7 @@ SvNumberformat::SvNumberformat(String& rString, xub_StrLen nAnzChars = ImpGetNumber(rString, nPos, sStr); if (nAnzChars > 0) { - short F_Type; + short F_Type = NUMBERFORMAT_UNDEFINED; if (!pISc->IsNumberFormat(sStr,F_Type,fNumber) || ( F_Type != NUMBERFORMAT_NUMBER && F_Type != NUMBERFORMAT_SCIENTIFIC) ) 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/filter.vcl/wmf/winmtf.cxx b/svtools/source/filter.vcl/wmf/winmtf.cxx index 21f6e69c8d9e..bf176015fd77 100644 --- a/svtools/source/filter.vcl/wmf/winmtf.cxx +++ b/svtools/source/filter.vcl/wmf/winmtf.cxx @@ -36,7 +36,7 @@ // ------------------------------------------------------------------------ -#define WIN_MTF_MAX_POLYPOLYCOUNT 16 +#define WIN_MTF_MAX_CLIP_DEPTH 16 void WinMtfClipPath::ImpUpdateType() { @@ -54,26 +54,28 @@ void WinMtfClipPath::IntersectClipRect( const Rectangle& rRect ) { if ( !aPolyPoly.Count() ) aPolyPoly = Polygon( rRect ); - else if ( aPolyPoly.Count() < WIN_MTF_MAX_POLYPOLYCOUNT ) + else if ( nDepth < WIN_MTF_MAX_CLIP_DEPTH ) { Polygon aPolygon( rRect ); PolyPolygon aIntersection; PolyPolygon aPolyPolyRect( aPolygon ); aPolyPoly.GetIntersection( aPolyPolyRect, aIntersection ); aPolyPoly = aIntersection; + nDepth++; } ImpUpdateType(); } void WinMtfClipPath::ExcludeClipRect( const Rectangle& rRect ) { - if ( aPolyPoly.Count() && ( aPolyPoly.Count() < WIN_MTF_MAX_POLYPOLYCOUNT ) ) + if ( aPolyPoly.Count() && ( nDepth < WIN_MTF_MAX_CLIP_DEPTH ) ) { Polygon aPolygon( rRect ); PolyPolygon aPolyPolyRect( aPolygon ); PolyPolygon aDifference; aPolyPoly.GetDifference( aPolyPolyRect, aDifference ); aPolyPoly = aDifference; + nDepth++; } ImpUpdateType(); } @@ -82,8 +84,10 @@ void WinMtfClipPath::SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nCl { if ( !rPolyPolygon.Count() ) aPolyPoly = rPolyPolygon; - else if ( rPolyPolygon.Count() < WIN_MTF_MAX_POLYPOLYCOUNT ) + else if ( nDepth < WIN_MTF_MAX_CLIP_DEPTH ) { + nDepth++; + PolyPolygon aNewClipPath; // #115345# Watch out for empty aPolyPoly here - conceptually, diff --git a/svtools/source/filter.vcl/wmf/winmtf.hxx b/svtools/source/filter.vcl/wmf/winmtf.hxx index beb1f62e22d6..fb4fd2fe0c57 100644 --- a/svtools/source/filter.vcl/wmf/winmtf.hxx +++ b/svtools/source/filter.vcl/wmf/winmtf.hxx @@ -314,6 +314,7 @@ class WinMtfClipPath { PolyPolygon aPolyPoly; WinMtfClipPathType eType; + sal_Int32 nDepth; void ImpUpdateType(); @@ -321,7 +322,7 @@ class WinMtfClipPath sal_Bool bNeedsUpdate; - WinMtfClipPath(): eType(EMPTY), bNeedsUpdate( sal_False ){}; + WinMtfClipPath(): eType(EMPTY), nDepth( 0 ), bNeedsUpdate( sal_False ){}; void SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode ); void IntersectClipRect( const Rectangle& rRect ); 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/toolkit/source/layout/core/box-base.cxx b/toolkit/source/layout/core/box-base.cxx index dbe9163e2117..d203e63ce2ed 100644 --- a/toolkit/source/layout/core/box-base.cxx +++ b/toolkit/source/layout/core/box-base.cxx @@ -104,15 +104,16 @@ Box_Base::addChild (uno::Reference <awt::XLayoutConstrains> const& xChild) } Box_Base::ChildData* -Box_Base::removeChildData( std::list< ChildData* > lst, css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ) +Box_Base::removeChildData( std::list< ChildData* >& lst, css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ) { for ( std::list< ChildData* >::iterator it = lst.begin(); it != lst.end(); it++ ) { if ( (*it)->mxChild == xChild ) { + ChildData* pRet = *it; lst.erase( it ); - return *it; + return pRet; } } return 0; diff --git a/toolkit/source/layout/core/box-base.hxx b/toolkit/source/layout/core/box-base.hxx index 4f50f55bf5c4..685e0e35e8b6 100644 --- a/toolkit/source/layout/core/box-base.hxx +++ b/toolkit/source/layout/core/box-base.hxx @@ -62,7 +62,7 @@ protected: virtual ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild ) = 0; virtual ChildProps *createChildProps( ChildData* pData ) = 0; - ChildData *removeChildData( std::list< ChildData *>, css::uno::Reference< css::awt::XLayoutConstrains > const& Child ); + ChildData *removeChildData( std::list< ChildData *>&, css::uno::Reference< css::awt::XLayoutConstrains > const& Child ); public: void AddChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child); diff --git a/toolkit/src2xml/include.lst b/toolkit/src2xml/include.lst index a93449625585..2bf5fced6fd3 100644 --- a/toolkit/src2xml/include.lst +++ b/toolkit/src2xml/include.lst @@ -106,7 +106,6 @@ ../../basic/unxlngi6.pro/inc ../../boost/unxlngi6.pro/inc ../../XmlSearch/unxlngi6.pro/inc -../../fondu/unxlngi6.pro/inc ../../forms/inc ../../forms/source/inc ../../forms/source/solar/inc 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/solar.h b/tools/inc/tools/solar.h index 1d248853f895..2ae0fa5f2f32 100644 --- a/tools/inc/tools/solar.h +++ b/tools/inc/tools/solar.h @@ -384,6 +384,8 @@ template<typename T> inline T Abs(T a) { return (a>=0?a:-a); } #define __DLLEXTENSION "lm.so" #elif defined LINUX && defined HPPA #define __DLLEXTENSION "lh.so" +#elif defined LINUX && defined AXP + #define __DLLEXTENSION "ll.so" #elif defined LINUX #error unknown plattform #elif defined FREEBSD && defined X86 diff --git a/tools/inc/tools/urlobj.hxx b/tools/inc/tools/urlobj.hxx index 86a8114ab0b8..17d52432e206 100644 --- a/tools/inc/tools/urlobj.hxx +++ b/tools/inc/tools/urlobj.hxx @@ -125,22 +125,21 @@ enum INetProtocol INET_PROT_DATA = 15, INET_PROT_CID = 16, INET_PROT_OUT = 17, - INET_PROT_VND_SUN_STAR_WFS = 18, - INET_PROT_VND_SUN_STAR_HIER = 19, - INET_PROT_VIM = 20, - INET_PROT_UNO = 21, - INET_PROT_COMPONENT = 22, - INET_PROT_VND_SUN_STAR_PKG = 23, - INET_PROT_LDAP = 24, - INET_PROT_DB = 25, - INET_PROT_VND_SUN_STAR_CMD = 26, - INET_PROT_VND_SUN_STAR_ODMA = 27, - INET_PROT_TELNET = 28, - INET_PROT_VND_SUN_STAR_EXPAND = 29, - INET_PROT_VND_SUN_STAR_TDOC = 30, - INET_PROT_GENERIC = 31, - INET_PROT_SMB = 32, - INET_PROT_END = 33 + INET_PROT_VND_SUN_STAR_HIER = 18, + INET_PROT_VIM = 19, + INET_PROT_UNO = 20, + INET_PROT_COMPONENT = 21, + INET_PROT_VND_SUN_STAR_PKG = 22, + INET_PROT_LDAP = 23, + INET_PROT_DB = 24, + INET_PROT_VND_SUN_STAR_CMD = 25, + INET_PROT_VND_SUN_STAR_ODMA = 26, + INET_PROT_TELNET = 27, + INET_PROT_VND_SUN_STAR_EXPAND = 28, + INET_PROT_VND_SUN_STAR_TDOC = 29, + INET_PROT_GENERIC = 30, + INET_PROT_SMB = 31, + INET_PROT_END = 32 }; //============================================================================ 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/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 07c532e60dd7..a6d7bc6fd04e 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -191,11 +191,6 @@ using namespace com::sun; name = *(escaped / alphanum / "!" / "$" / "'" / "(" / ")" / "*" / "+" / "," / "-" / "." / ":" / ";" / "=" / "?" / "@" / "_" / "~" - ; prvate (see RFC 1738, RFC 2396) - vnd-sun-star-wfs-url = "VND.SUN.STAR.WFS://" [host / "LOCALHOST"] ["/" segment *("/" segment)] - segment = *pchar - - ; private vnd-sun-star-hier-url = "VND.SUN.STAR.HIER:" ["//"reg_name] *("/" *pchar) reg_name = 1*(escaped / alphanum / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / "-" / "." / ":" / ";" / "=" / "@" / "_" / "~") @@ -403,8 +398,6 @@ static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END] false, false }, { "out", "out://", 0, true, false, false, false, false, false, false, false }, - { "vnd.sun.star.wfs", "vnd.sun.star.wfs://", 0, true, false, false, - false, true, true, true, false }, { "vnd.sun.star.hier", "vnd.sun.star.hier:", 0, true, false, false, false, false, false, true, false }, { "vim", "vim://", 0, true, true, false, true, false, false, true, @@ -429,7 +422,7 @@ static INetURLObject::SchemeInfo const aSchemeInfoMap[INET_PROT_END] false, false, false, false, false }, { "vnd.sun.star.tdoc", "vnd.sun.star.tdoc:", 0, false, false, false, false, false, false, true, false }, - { "", "", 0, false, false, false, false, false, false, false, false }, + { "", "", 0, false, false, false, false, true, true, true, false }, { "smb", "smb://", 139, true, true, false, true, true, true, true, true } }; @@ -1338,7 +1331,7 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, if (pHostPortBegin) { sal_Unicode const * pPort = pHostPortEnd; - if (getSchemeInfo().m_bPort && pHostPortBegin < pHostPortEnd) + if ( getSchemeInfo().m_bPort && pHostPortBegin < pHostPortEnd ) { sal_Unicode const * p1 = pHostPortEnd - 1; while (p1 > pHostPortBegin && INetMIME::isDigit(*p1)) @@ -1350,7 +1343,6 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: // If the host equals "LOCALHOST" (unencoded and ignoring // case), turn it into an empty host: if (INetMIME::equalIgnoreCase(pHostPortBegin, pPort, @@ -1367,7 +1359,6 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, return false; } break; - default: if (pHostPortBegin == pPort) { @@ -1609,7 +1600,23 @@ bool INetURLObject::convertRelToAbs(rtl::OUString const & rTheRelURIRef, STATE_DONE }; rtl::OUStringBuffer aSynAbsURIRef; - aSynAbsURIRef.appendAscii(getSchemeInfo().m_pScheme); + // make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme + // is empty ("") in that case, so take the scheme from m_aAbsURIRef + if (m_eScheme != INET_PROT_GENERIC) + { + aSynAbsURIRef.appendAscii(getSchemeInfo().m_pScheme); + } + else + { + sal_Unicode const * pSchemeBegin + = m_aAbsURIRef.getStr(); + sal_Unicode const * pSchemeEnd = pSchemeBegin; + while (pSchemeEnd[0] != ':') + { + ++pSchemeEnd; + } + aSynAbsURIRef.append(pSchemeBegin, pSchemeEnd - pSchemeBegin); + } aSynAbsURIRef.append(sal_Unicode(':')); sal_Char cEscapePrefix = getEscapePrefix(); @@ -2162,11 +2169,7 @@ INetURLObject::getPrefix(sal_Unicode const *& rBegin, { "vnd.sun.star.tdoc:", 0, INET_PROT_VND_SUN_STAR_TDOC, PrefixInfo::OFFICIAL }, { "vnd.sun.star.webdav:", 0, INET_PROT_VND_SUN_STAR_WEBDAV, - PrefixInfo::OFFICIAL }, - { "vnd.sun.star.wfs:", 0, INET_PROT_VND_SUN_STAR_WFS, - PrefixInfo::OFFICIAL }, - { "wfs:", "vnd.sun.star.wfs:", INET_PROT_VND_SUN_STAR_WFS, - PrefixInfo::ALIAS } }; + PrefixInfo::OFFICIAL } }; PrefixInfo const * pFirst = aMap + 1; PrefixInfo const * pLast = aMap + sizeof aMap / sizeof (PrefixInfo) - 1; PrefixInfo const * pMatch = 0; @@ -2889,7 +2892,6 @@ bool INetURLObject::setHost(rtl::OUString const & rTheHost, bool bOctets, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { rtl::OUString sTemp(aSynHost); if (sTemp.equalsIgnoreAsciiCaseAsciiL( @@ -2985,7 +2987,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme, break; case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { if (bSkippedInitialSlash) aTheSynPath.append(sal_Unicode('/')); @@ -3398,7 +3399,6 @@ bool INetURLObject::parsePath(INetProtocol eScheme, if (aTheSynPath.getLength() == 0) return false; break; - default: OSL_ASSERT(false); break; @@ -3825,7 +3825,27 @@ INetURLObject::getAbbreviated( OSL_ENSURE(rStringWidth.is(), "specification violation"); sal_Char cEscapePrefix = getEscapePrefix(); rtl::OUStringBuffer aBuffer; - aBuffer.appendAscii(getSchemeInfo().m_pScheme); + // make sure that the scheme is copied for generic schemes: getSchemeInfo().m_pScheme + // is empty ("") in that case, so take the scheme from m_aAbsURIRef + if (m_eScheme != INET_PROT_GENERIC) + { + aBuffer.appendAscii(getSchemeInfo().m_pScheme); + } + else + { + if (m_aAbsURIRef) + { + sal_Unicode const * pSchemeBegin + = m_aAbsURIRef.getStr(); + sal_Unicode const * pSchemeEnd = pSchemeBegin; + + while (pSchemeEnd[0] != ':') + { + ++pSchemeEnd; + } + aBuffer.append(pSchemeBegin, pSchemeEnd - pSchemeBegin); + } + } aBuffer.append(static_cast< sal_Unicode >(':')); bool bAuthority = getSchemeInfo().m_bAuthority; sal_Unicode const * pCoreBegin @@ -4007,7 +4027,6 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { // If the URL paths of two file URLs only differ in that one has a // final '/' and the other has not, take the two paths as @@ -4162,7 +4181,6 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme, switch (m_eScheme) { case INET_PROT_FILE: - case INET_PROT_VND_SUN_STAR_WFS: { rtl::OUString sTemp(aSynHost); if (sTemp.equalsIgnoreAsciiCaseAsciiL( 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/tools/workben/urltest.cxx b/tools/workben/urltest.cxx index 694698297680..0930dfcc5239 100644 --- a/tools/workben/urltest.cxx +++ b/tools/workben/urltest.cxx @@ -523,6 +523,8 @@ main() /*TODO "vnd.sun.star.wfs:///c|/xyz/",*/ /*TODO "vnd.sun.star.wfs://xxx/yyy?zzz",*/ "vnd.sun.star.wfs:///x/y/z", + "vnd.sun.star.generic:///x/y/z", + "vnd.sun.star.generic://host:34/x/y/z" /*TODO "wfs://",*/ /*TODO "wfs://LocalHost",*/ /*TODO "wfs:///c|/xyz/",*/ @@ -533,13 +535,21 @@ main() INetURLObject aUrl(aTest[i]); if (aUrl.HasError()) printf("BAD %s\n", aTest[i]); - else if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). - equalsAscii(aTest[i]) != sal_True) + else { + if (aUrl.GetProtocol() != INET_PROT_GENERIC) { + printf("BAD PROTOCOL %i -> %i\n", + aUrl.GetProtocol(), + INET_PROT_GENERIC); + } + if (aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI). + equalsAscii(aTest[i]) != sal_True) + { String sTest(aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI)); printf("BAD %s -> %s\n", aTest[i], ByteString(sTest, RTL_TEXTENCODING_ASCII_US).GetBuffer()); + } } } } diff --git a/ucbhelper/inc/ucbhelper/configureucb.hxx b/ucbhelper/inc/ucbhelper/configureucb.hxx deleted file mode 100644 index 2e70467a4e9f..000000000000 --- a/ucbhelper/inc/ucbhelper/configureucb.hxx +++ /dev/null @@ -1,201 +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 _UCBHELPER_CONFIGUREUCB_HXX_ -#define _UCBHELPER_CONFIGUREUCB_HXX_ - -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <rtl/ustring.hxx> - -#include <vector> -#include "ucbhelper/ucbhelperdllapi.h" - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace ucb { - class XContentProvider; - class XContentProviderManager; - } - namespace uno { class Any; } -} } } - -namespace ucbhelper { - -//============================================================================ -/** Information about a registered content provider, passed from - <method>configureUcb</method> to <method>unconfigureUcb</method> (and from - <method>registerAtUcb</method> to <method>deregisterFromUcb</method>). - */ -struct ContentProviderRegistrationInfo -{ - /** The registered content provider (or null if registration failed). - */ - com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > - m_xProvider; - - /** The arguments the content provider was instantiated with. - */ - rtl::OUString m_aArguments; - - /** The URL template the content provider is registered on. - */ - rtl::OUString m_aTemplate; -}; - //@@@ if registerucb.hxx were exported, too, this might better reside in - // there... - -typedef std::vector< ContentProviderRegistrationInfo > - ContentProviderRegistrationInfoList; - -//============================================================================ -/** Information about a content provider, passed to - <method>configureUcb</method>. - */ -struct ContentProviderData -{ - /** The UNO service name to use to instanciate the content provider. - */ - rtl::OUString ServiceName; - - /** The URL template to use to instanciate the content provider. - */ - rtl::OUString URLTemplate; - - /** The arguments to use to instanciate the content provider. - */ - rtl::OUString Arguments; - - ContentProviderData() {}; - ContentProviderData( const rtl::OUString & rService, - const rtl::OUString & rTemplate, - const rtl::OUString & rArgs ) - : ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {} -}; - -typedef std::vector< ContentProviderData > ContentProviderDataList; - -//============================================================================ -/** Configure a (newly instantiated) Universal Content Broker. - - @descr This function tries to register at the given content provider - manager all the content provider services listed under a given key in the - configuration database. - - @param rManager A content provider manager (normally, this would be a - newly intantiated UCB). - - @param rServiceFactory A service factory through which to obtain the - various services required. - - @param rData A list containing the data for the content providers for - the UCB to configure. - - @pInfos If not null, an entry will be added to this vector for every - content provider that is registered (sucessfully or not). - - @return True if the UCB has successfuly been configured (though not all - content providers have necessarily been registered due to individual - problems). - */ -bool -configureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - ContentProviderDataList const & rData, - ContentProviderRegistrationInfoList * pInfos) - throw (com::sun::star::uno::RuntimeException); - - -//============================================================================ -/** Configure a (newly instantiated) Universal Content Broker. - - @descr This function tries to register at the given content provider - manager all the content provider services listed under a given key in the - configuration database. - - @param rManager A content provider manager (normally, this would be a - newly intantiated UCB). - - @param rServiceFactory A service factory through which to obtain the - various services required. - - @param rArguments A sequence of at least two strings: the primary and - secondary key addressing a chosen UCB configuration in the configuration - database. The sequence can be longer, in which case the excess elements - must be strings that form key/value pairs. These key/value pairs will be - used to replace placeholders in the data from the configuration database - with (dynamic) values. This is a (rather unstructured) sequence of - <type>Any<type/>s, since normally this parameter will simply be forwarded - by the UCB's <method>initialize<method/> method, which has a parameter of - the same type. - - @pInfos If not null, an entry will be added to this vector for every - content provider that is registered (sucessfully or not). - - @return True if the UCB has successfuly been configured (though not all - content providers have necessarily been registered due to individual - problems). - */ -UCBHELPER_DLLPUBLIC bool -configureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - com::sun::star::uno::Sequence< com::sun::star::uno::Any > const & - rArguments, - std::vector< ContentProviderRegistrationInfo > * pInfos) - throw (com::sun::star::uno::RuntimeException); - -//============================================================================ -/** Undo the configuration of a Universal Content Broker. - - @descr This function is the reverse of <method>configureUcb</method>. - - @param rManager A content provider manager. - - @param rInfos Information about all the registered content providers. - */ -void -unconfigureUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - std::vector< ContentProviderRegistrationInfo > const & rInfos) - throw (com::sun::star::uno::RuntimeException); - -} - -#endif // _UCBHELPER_CONFIGUREUCB_HXX_ diff --git a/ucbhelper/inc/ucbhelper/contentbroker.hxx b/ucbhelper/inc/ucbhelper/contentbroker.hxx index eea72cc689e0..54139d3ffdea 100644 --- a/ucbhelper/inc/ucbhelper/contentbroker.hxx +++ b/ucbhelper/inc/ucbhelper/contentbroker.hxx @@ -41,7 +41,7 @@ namespace com { namespace sun { namespace star { namespace ucb { class XContentProviderManager; class XCommandProcessor; } } } } -#include <ucbhelper/configureucb.hxx> +#include <ucbhelper/registerucb.hxx> #include "ucbhelper/ucbhelperdllapi.h" namespace ucbhelper diff --git a/ucbhelper/inc/ucbhelper/registerucb.hxx b/ucbhelper/inc/ucbhelper/registerucb.hxx new file mode 100644 index 000000000000..e2427248dce2 --- /dev/null +++ b/ucbhelper/inc/ucbhelper/registerucb.hxx @@ -0,0 +1,129 @@ +/************************************************************************* +* +* 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 _UCBHELPER_REGISTERUCB_HXX_ +#define _UCBHELPER_REGISTERUCB_HXX_ + +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/ucb/XContentProvider.hpp> +#include <com/sun/star/ucb/XContentProviderManager.hpp> +#include <vector> + +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } +} } } + +namespace rtl { class OUString; } + +namespace ucbhelper { + +//============================================================================ +/** Information about a registered content provider. + */ +struct ContentProviderRegistrationInfo +{ + /** The registered content provider (or null if registration failed). + */ + com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > + m_xProvider; + + /** The arguments the content provider was instantiated with. + */ + rtl::OUString m_aArguments; + + /** The URL template the content provider is registered on. + */ + rtl::OUString m_aTemplate; +}; + +typedef std::vector< ContentProviderRegistrationInfo > + ContentProviderRegistrationInfoList; + +//============================================================================ +/** Information about a content provider, passed to + <method>configureUcb</method>. + */ +struct ContentProviderData +{ + /** The UNO service name to use to instanciate the content provider. + */ + rtl::OUString ServiceName; + + /** The URL template to use to instanciate the content provider. + */ + rtl::OUString URLTemplate; + + /** The arguments to use to instanciate the content provider. + */ + rtl::OUString Arguments; + + ContentProviderData() {}; + ContentProviderData( const rtl::OUString & rService, + const rtl::OUString & rTemplate, + const rtl::OUString & rArgs ) + : ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {} +}; + +typedef std::vector< ContentProviderData > ContentProviderDataList; +//============================================================================ +/** Register a content provider at a Universal Content Broker. + + @param rManager A content provider manager (normally, this would be a + UCB). May be null, which is only useful if the content provider is an + <type>XParamterizedContentProvider</type>s. + + @param rServiceFactory A factory through which to obtain the required + services. + + @param rName The service name of the content provider. + + @param rArguments Any arguments to instantiate the content provider with. + + @param rTemplate The URL template to register the content provider on. + + @param pInfo If not null, this output parameter is filled with + information about the (atemptively) registered provider. + */ + +UCBHELPER_DLLPUBLIC bool registerAtUcb( + com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProviderManager > const & + rManager, + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > const & + rServiceFactory, + rtl::OUString const & rName, + rtl::OUString const & rArguments, + rtl::OUString const & rTemplate, + ContentProviderRegistrationInfo * pInfo) + throw (com::sun::star::uno::RuntimeException); + +} +#endif // _UCBHELPER_REGISTERUCB_HXX_ diff --git a/ucbhelper/prj/d.lst b/ucbhelper/prj/d.lst index 64da268b6143..21a46483789b 100644 --- a/ucbhelper/prj/d.lst +++ b/ucbhelper/prj/d.lst @@ -9,7 +9,7 @@ mkdir: %_DEST%\inc%_EXT%\ucbhelper ..\inc\ucbhelper\configurationkeys.hxx %_DEST%\inc%_EXT%\ucbhelper\configurationkeys.hxx -..\inc\ucbhelper\configureucb.hxx %_DEST%\inc%_EXT%\ucbhelper\configureucb.hxx +..\inc\ucbhelper\registerucb.hxx %_DEST%\inc%_EXT%\ucbhelper\registerucb.hxx ..\inc\ucbhelper\content.hxx %_DEST%\inc%_EXT%\ucbhelper\content.hxx ..\inc\ucbhelper\contentbroker.hxx %_DEST%\inc%_EXT%\ucbhelper\contentbroker.hxx ..\inc\ucbhelper\commandenvironment.hxx %_DEST%\inc%_EXT%\ucbhelper\commandenvironment.hxx diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx index 7e0e7f3657ca..408ff6af0dee 100644 --- a/ucbhelper/source/client/contentbroker.cxx +++ b/ucbhelper/source/client/contentbroker.cxx @@ -298,14 +298,18 @@ bool ContentBroker_Impl::initialize() if ( m_xProviderMgr.is() ) { - if ( !configureUcb( m_xProviderMgr, - m_xSMgr, - m_aProvData, - 0 ) ) + ContentProviderDataList::const_iterator aEnd(m_aProvData.end()); + for (ContentProviderDataList::const_iterator aIt(m_aProvData.begin()); + aIt != aEnd; ++aIt) { - OSL_ENSURE( false, "Failed to configure UCB!" ); - return false; + registerAtUcb(m_xProviderMgr, + m_xSMgr, + aIt->ServiceName, + aIt->Arguments, + aIt->URLTemplate, + 0); } + } } } diff --git a/ucbhelper/source/provider/makefile.mk b/ucbhelper/source/provider/makefile.mk index db06a5df131c..5999192f7bdb 100644 --- a/ucbhelper/source/provider/makefile.mk +++ b/ucbhelper/source/provider/makefile.mk @@ -43,7 +43,6 @@ ENABLE_EXCEPTIONS=TRUE .IF "$(header)" == "" SLOFILES=\ - $(SLO)$/configureucb.obj \ $(SLO)$/contentidentifier.obj \ $(SLO)$/providerhelper.obj \ $(SLO)$/contenthelper.obj \ @@ -53,7 +52,6 @@ SLOFILES=\ $(SLO)$/resultsetmetadata.obj \ $(SLO)$/resultset.obj \ $(SLO)$/resultsethelper.obj \ - $(SLO)$/provconf.obj \ $(SLO)$/commandenvironmentproxy.obj \ $(SLO)$/interactionrequest.obj \ $(SLO)$/simpleinteractionrequest.obj \ diff --git a/ucbhelper/source/provider/registerucb.cxx b/ucbhelper/source/provider/registerucb.cxx index 0a749c9ccb5c..e6ccaf4743a8 100644 --- a/ucbhelper/source/provider/registerucb.cxx +++ b/ucbhelper/source/provider/registerucb.cxx @@ -27,7 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_ucbhelper.hxx" -#include <registerucb.hxx> +#include <ucbhelper/registerucb.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XParameterizedContentProvider.hpp> @@ -35,7 +35,6 @@ #include <com/sun/star/uno/RuntimeException.hpp> #include "osl/diagnose.h" -#include <ucbhelper/configureucb.hxx> using namespace com::sun::star; @@ -162,41 +161,4 @@ registerAtUcb( return bSuccess; } -//============================================================================ -// -// deregisterFromUcb -// -//============================================================================ - -void -deregisterFromUcb( - uno::Reference< ucb::XContentProviderManager > const & rManager, - ContentProviderRegistrationInfo const & rInfo) - throw (uno::RuntimeException) -{ - uno::Reference< ucb::XContentProvider > - xProvider(rInfo.m_xProvider); - uno::Reference< ucb::XParameterizedContentProvider > - xParameterized(xProvider, uno::UNO_QUERY); - if (xParameterized.is()) - { - uno::Reference< ucb::XContentProvider > xInstance; - try - { - xInstance - = xParameterized->deregisterInstance(rInfo.m_aTemplate, - rInfo.m_aArguments); - } - catch (lang::IllegalArgumentException const &) {} - - if (xInstance.is()) - xProvider = xInstance; - } - - if (rManager.is()) - rManager->deregisterContentProvider(xProvider, rInfo.m_aTemplate); - //@@@ if this fails, a roll-back of deregisterInstance() is - // missing -} - } diff --git a/ucbhelper/source/provider/registerucb.hxx b/ucbhelper/source/provider/registerucb.hxx deleted file mode 100644 index f17321c76cd5..000000000000 --- a/ucbhelper/source/provider/registerucb.hxx +++ /dev/null @@ -1,96 +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 _UCBHELPER_REGISTERUCB_HXX_ -#define _UCBHELPER_REGISTERUCB_HXX_ - -#include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/uno/Reference.h> - -namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } - namespace ucb { class XContentProviderManager; } -} } } -namespace rtl { class OUString; } - -namespace ucbhelper { - -struct ContentProviderRegistrationInfo; - -//============================================================================ -/** Register a content provider at a Universal Content Broker. - - @param rManager A content provider manager (normally, this would be a - UCB). May be null, which is only useful if the content provider is an - <type>XParamterizedContentProvider</type>s. - - @param rServiceFactory A factory through which to obtain the required - services. - - @param rName The service name of the content provider. - - @param rArguments Any arguments to instantiate the content provider with. - - @param rTemplate The URL template to register the content provider on. - - @param pInfo If not null, this output parameter is filled with - information about the (atemptively) registered provider. - */ -bool -registerAtUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory, - rtl::OUString const & rName, - rtl::OUString const & rArguments, - rtl::OUString const & rTemplate, - ContentProviderRegistrationInfo * pInfo) - throw (com::sun::star::uno::RuntimeException); - -//============================================================================ -/** Deregister a content provider from a Universal Content Broker. - - @param rManager A content provider manager (normally, this would be a - UCB). May be null, which is only useful if the content provider is an - <type>XParamterizedContentProvider</type>s. - - @param rInfo Information about the content provider to deregister. - */ -void -deregisterFromUcb( - com::sun::star::uno::Reference< - com::sun::star::ucb::XContentProviderManager > const & - rManager, - ContentProviderRegistrationInfo const & rInfo) - throw (com::sun::star::uno::RuntimeException); - -} - -#endif // _UCBHELPER_REGISTERUCB_HXX_ 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/inc/salframe.h b/vcl/aqua/inc/salframe.h index fd783270875e..c2ded3267f45 100644 --- a/vcl/aqua/inc/salframe.h +++ b/vcl/aqua/inc/salframe.h @@ -184,6 +184,8 @@ public: NSView* getView() const { return mpView; } unsigned int getStyleMask() const { return mnStyleMask; } + void getResolution( long& o_rDPIX, long& o_rDPIY ); + // actually the follwing methods do the same thing: flipping y coordinates // but having two of them makes clearer what the coordinate system // is supposed to be before and after diff --git a/vcl/aqua/inc/salinst.h b/vcl/aqua/inc/salinst.h index 8a44f7ef3304..0bceb99d1d0e 100644 --- a/vcl/aqua/inc/salinst.h +++ b/vcl/aqua/inc/salinst.h @@ -32,6 +32,7 @@ #include "vos/mutex.hxx" #include "vos/thread.hxx" #include "vcl/salinst.hxx" +#include "osl/conditn.h" #include "aquavcltypes.h" @@ -96,6 +97,7 @@ public: int mnActivePrintJobs; std::list< SalUserEvent > maUserEvents; oslMutex maUserEventListMutex; + oslCondition maWaitingYieldCond; typedef std::list<const ApplicationEvent*> AppEventList; static AppEventList aAppEventList; diff --git a/vcl/aqua/source/a11y/aqua11yfactory.mm b/vcl/aqua/source/a11y/aqua11yfactory.mm index eb745ea24aa5..7732ce202cd2 100644 --- a/vcl/aqua/source/a11y/aqua11yfactory.mm +++ b/vcl/aqua/source/a11y/aqua11yfactory.mm @@ -48,6 +48,7 @@ #include "aqua11ywrappersplitter.h" #include "aqua11ywrappertabgroup.h" #include "aqua11ywrappertoolbar.h" +#include "aqua11ytablewrapper.h" #include <com/sun/star/accessibility/AccessibleStateType.hpp> using namespace ::com::sun::star::accessibility; @@ -142,6 +143,8 @@ static bool enabled = false; aWrapper = [ [ AquaA11yWrapperList alloc ] initWithAccessibleContext: rxAccessibleContext ]; } else if ( [ nativeRole isEqualToString: NSAccessibilitySplitterRole ] ) { aWrapper = [ [ AquaA11yWrapperSplitter alloc ] initWithAccessibleContext: rxAccessibleContext ]; + } else if ( [ nativeRole isEqualToString: NSAccessibilityTableRole ] ) { + aWrapper = [ [ AquaA11yTableWrapper alloc ] initWithAccessibleContext: rxAccessibleContext ]; } else { aWrapper = [ [ AquaA11yWrapper alloc ] initWithAccessibleContext: rxAccessibleContext ]; } diff --git a/vcl/aqua/source/a11y/aqua11ytablewrapper.h b/vcl/aqua/source/a11y/aqua11ytablewrapper.h index 8753365377e3..7bf3e44a2945 100644 --- a/vcl/aqua/source/a11y/aqua11ytablewrapper.h +++ b/vcl/aqua/source/a11y/aqua11ytablewrapper.h @@ -30,9 +30,15 @@ #include "aqua11ywrapper.h" -@interface AquaA11yTableWrapper : NSObject +#define MAXIMUM_ACCESSIBLE_TABLE_CELLS 1000 + +@interface AquaA11yTableWrapper : AquaA11yWrapper { } -+(id)childrenAttributeForElement:(AquaA11yWrapper *)wrapper; ++(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper; ++(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject; + +-(id)rowsAttribute; +-(id)columnsAttribute; @end #endif // _SV_AQUA11TABLEWRAPPER_H diff --git a/vcl/aqua/source/a11y/aqua11ytablewrapper.mm b/vcl/aqua/source/a11y/aqua11ytablewrapper.mm index 08205ac8a66b..98454ab8d57b 100644 --- a/vcl/aqua/source/a11y/aqua11ytablewrapper.mm +++ b/vcl/aqua/source/a11y/aqua11ytablewrapper.mm @@ -35,38 +35,120 @@ using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; -@implementation AquaA11yTableWrapper : NSObject +@implementation AquaA11yTableWrapper : AquaA11yWrapper -+(id)childrenAttributeForElement:(AquaA11yWrapper *)wrapper ++(id)childrenAttributeForElement:(AquaA11yTableWrapper *)wrapper { - try + XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; + NSArray* pResult = nil; + if( accessibleTable ) { NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; - XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; - XAccessibleTable * accessibleTable = [ wrapper accessibleTable ]; - // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell - Size tableSize = accessibleComponent -> getSize(); - Point point; - point.X = 0; - point.Y = 0; - Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); - point.X = tableSize.Width - 1; - point.Y = tableSize.Height - 1; - Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); - if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) + try { - sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); - sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); - sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); - sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); - sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); - sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); - // create an array containing the visible cells - for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { - for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) + // make all children visible to the hierarchy + for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ ) { - Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + for ( sal_Int32 columnCount = 0; columnCount < nCols; columnCount++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + } + } + else + { + XAccessibleComponent * accessibleComponent = [ wrapper accessibleComponent ]; + // find out which cells are actually visible by determining the top-left-cell and the bottom-right-cell + Size tableSize = accessibleComponent -> getSize(); + Point point; + point.X = 0; + point.Y = 0; + Reference < XAccessible > rAccessibleTopLeft = accessibleComponent -> getAccessibleAtPoint ( point ); + point.X = tableSize.Width - 1; + point.Y = tableSize.Height - 1; + Reference < XAccessible > rAccessibleBottomRight = accessibleComponent -> getAccessibleAtPoint ( point ); + if ( rAccessibleTopLeft.is() && rAccessibleBottomRight.is() ) + { + sal_Int32 idxTopLeft = rAccessibleTopLeft -> getAccessibleContext() -> getAccessibleIndexInParent(); + sal_Int32 idxBottomRight = rAccessibleBottomRight -> getAccessibleContext() -> getAccessibleIndexInParent(); + sal_Int32 rowTopLeft = accessibleTable -> getAccessibleRow ( idxTopLeft ); + sal_Int32 columnTopLeft = accessibleTable -> getAccessibleColumn ( idxTopLeft ); + sal_Int32 rowBottomRight = accessibleTable -> getAccessibleRow ( idxBottomRight ); + sal_Int32 columnBottomRight = accessibleTable -> getAccessibleColumn ( idxBottomRight ); + // create an array containing the visible cells + for ( sal_Int32 rowCount = rowTopLeft; rowCount <= rowBottomRight; rowCount++ ) + { + for ( sal_Int32 columnCount = columnTopLeft; columnCount <= columnBottomRight; columnCount++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( rowCount, columnCount ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + } + } + } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + } + [cells autorelease]; + } + + return pResult; +} + ++(void)addAttributeNamesTo: (NSMutableArray *)attributeNames object: (AquaA11yWrapper*)pObject +{ + XAccessibleTable * accessibleTable = [ pObject accessibleTable ]; + if( accessibleTable ) + { + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + + + if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + [ attributeNames addObject: NSAccessibilityRowsAttribute ]; + [ attributeNames addObject: NSAccessibilityColumnsAttribute ]; + } + } +} + +-(id)rowsAttribute +{ + NSArray* pResult = nil; + + XAccessibleTable * accessibleTable = [ self accessibleTable ]; + if( accessibleTable ) + { + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; + try + { + // find out number of rows + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + for( sal_Int32 n = 0; n < nRows; n++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( n, 0 ); if ( rAccessibleCell.is() ) { id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; @@ -74,16 +156,56 @@ using namespace ::com::sun::star::uno; [ cell_wrapper release ]; } } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + pResult = nil; } + [ cells autorelease ]; } - [ cells autorelease ]; - return NSAccessibilityUnignoredChildren( cells ); } - catch (const Exception &e) + + return pResult; +} + +-(id)columnsAttribute +{ + NSArray* pResult = nil; + + XAccessibleTable * accessibleTable = [ self accessibleTable ]; + + if( accessibleTable ) { - // TODO: Log - return nil; + sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); + sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); + if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + { + NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; + try + { + // find out number of columns + for( sal_Int32 n = 0; n < nCols; n++ ) + { + Reference < XAccessible > rAccessibleCell = accessibleTable -> getAccessibleCellAt ( 0, n ); + if ( rAccessibleCell.is() ) + { + id cell_wrapper = [ AquaA11yFactory wrapperForAccessibleContext: rAccessibleCell -> getAccessibleContext() ]; + [ cells addObject: cell_wrapper ]; + [ cell_wrapper release ]; + } + } + pResult = NSAccessibilityUnignoredChildren( cells ); + } + catch (const Exception &e) + { + pResult = nil; + } + [ cells autorelease ]; + } } + + return pResult; } @end diff --git a/vcl/aqua/source/a11y/aqua11ywrapper.mm b/vcl/aqua/source/a11y/aqua11ywrapper.mm index 959746d533dc..e86676e725f2 100644 --- a/vcl/aqua/source/a11y/aqua11ywrapper.mm +++ b/vcl/aqua/source/a11y/aqua11ywrapper.mm @@ -29,6 +29,8 @@ #include "precompiled_vcl.hxx" #include "salinst.h" +#include "saldata.hxx" + #include "aqua11ywrapper.h" #include "aqua11yactionwrapper.h" #include "aqua11ycomponentwrapper.h" @@ -41,6 +43,7 @@ #include "aqua11yfocuslistener.hxx" #include "aqua11yfocustracker.hxx" #include "aqua11yrolehelper.h" + #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> @@ -217,7 +220,8 @@ static MacOSBOOL isPopupMenuOpen = NO; -(id)roleAttribute { if ( mActsAsRadioGroup ) { return NSAccessibilityRadioGroupRole; - } else { + } + else { return [ AquaA11yRoleHelper getNativeRoleFrom: [ self accessibleContext ] ]; } } @@ -323,8 +327,10 @@ static MacOSBOOL isPopupMenuOpen = NO; } } return children; - } else if ( [ self accessibleTable ] != nil ) { - return [ AquaA11yTableWrapper childrenAttributeForElement: self ]; + } else if ( [ self accessibleTable ] != nil ) + { + AquaA11yTableWrapper* pTable = [self isKindOfClass: [AquaA11yTableWrapper class]] ? (AquaA11yTableWrapper*)self : nil; + return [ AquaA11yTableWrapper childrenAttributeForElement: pTable ]; } else { try { NSMutableArray * children = [ [ NSMutableArray alloc ] init ]; @@ -663,6 +669,7 @@ static MacOSBOOL isPopupMenuOpen = NO; if ( isPopupMenuOpen ) { return nil; } + id value = nil; // if we are no longer in the wrapper repository, we have been disposed AquaA11yWrapper * theWrapper = [ AquaA11yFactory wrapperForAccessibleContext: [ self accessibleContext ] createIfNotExists: NO ]; @@ -717,6 +724,7 @@ static MacOSBOOL isPopupMenuOpen = NO; NSString * nativeSubrole = nil; NSString * title = nil; NSMutableArray * attributeNames = nil; + sal_Int32 nAccessibleChildren = 0; try { // Default Attributes attributeNames = [ NSMutableArray arrayWithObjects: @@ -737,8 +745,9 @@ static MacOSBOOL isPopupMenuOpen = NO; } try { - if ( [ self accessibleContext ] -> getAccessibleChildCount() > 0 ) { - [ attributeNames addObject: NSAccessibilityChildrenAttribute ]; + nAccessibleChildren = [ self accessibleContext ] -> getAccessibleChildCount(); + if ( nAccessibleChildren > 0 ) { + [ attributeNames addObject: NSAccessibilityChildrenAttribute ]; } } catch( DisposedException& ) {} @@ -754,6 +763,9 @@ static MacOSBOOL isPopupMenuOpen = NO; [ attributeNames addObject: NSAccessibilityServesAsTitleForUIElementsAttribute ]; } // Special Attributes depending on interface + if( [self accessibleContext ] -> getAccessibleRole() == AccessibleRole::TABLE ) + [AquaA11yTableWrapper addAttributeNamesTo: attributeNames object: self]; + if ( [ self accessibleText ] != nil ) { [ AquaA11yTextWrapper addAttributeNamesTo: attributeNames ]; } @@ -953,14 +965,15 @@ static MacOSBOOL isPopupMenuOpen = NO; return hit; } -Reference < XAccessibleContext > hitTestRunner ( Point point, Reference < XAccessibleContext > rxAccessibleContext ) { +Reference < XAccessibleContext > hitTestRunner ( com::sun::star::awt::Point point, + Reference < XAccessibleContext > rxAccessibleContext ) { Reference < XAccessibleContext > hitChild; Reference < XAccessibleContext > emptyReference; try { Reference < XAccessibleComponent > rxAccessibleComponent ( rxAccessibleContext, UNO_QUERY ); if ( rxAccessibleComponent.is() ) { - Point location = rxAccessibleComponent -> getLocationOnScreen(); - Point hitPoint ( point.X - location.X , point.Y - location.Y); + com::sun::star::awt::Point location = rxAccessibleComponent -> getLocationOnScreen(); + com::sun::star::awt::Point hitPoint ( point.X - location.X , point.Y - location.Y); Reference < XAccessible > rxAccessible = rxAccessibleComponent -> getAccessibleAtPoint ( hitPoint ); if ( rxAccessible.is() && rxAccessible -> getAccessibleContext().is() ) { if ( rxAccessible -> getAccessibleContext() -> getAccessibleChildCount() > 0 ) { @@ -999,7 +1012,7 @@ Reference < XAccessibleContext > hitTestRunner ( Point point, Reference < XAcces } Reference < XAccessibleContext > hitChild; NSRect screenRect = [ [ NSScreen mainScreen ] frame ]; - Point hitPoint ( static_cast<long>(point.x) , static_cast<long>(screenRect.size.height - point.y) ); + com::sun::star::awt::Point hitPoint ( static_cast<long>(point.x) , static_cast<long>(screenRect.size.height - point.y) ); // check child windows first NSWindow * window = (NSWindow *) [ self accessibilityAttributeValue: NSAccessibilityWindowAttribute ]; NSArray * childWindows = [ window childWindows ]; diff --git a/vcl/aqua/source/app/salinst.cxx b/vcl/aqua/source/app/salinst.cxx index 62c59e78c963..b8a2261ed9db 100644 --- a/vcl/aqua/source/app/salinst.cxx +++ b/vcl/aqua/source/app/salinst.cxx @@ -474,6 +474,7 @@ AquaSalInstance::AquaSalInstance() mbWaitingYield = false; maUserEventListMutex = osl_createMutex(); mnActivePrintJobs = 0; + maWaitingYieldCond = osl_createCondition(); } // ----------------------------------------------------------------------- @@ -484,6 +485,7 @@ AquaSalInstance::~AquaSalInstance() mpSalYieldMutex->release(); delete mpSalYieldMutex; osl_destroyMutex( maUserEventListMutex ); + osl_destroyCondition( maWaitingYieldCond ); } // ----------------------------------------------------------------------- @@ -713,6 +715,7 @@ void AquaSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) if( aEvent.mpFrame && AquaSalFrame::isAlive( aEvent.mpFrame ) ) { aEvent.mpFrame->CallCallback( aEvent.mnType, aEvent.mpData ); + osl_setCondition( maWaitingYieldCond ); // return if only one event is asked for if( ! bHandleAllCurrentEvents ) return; @@ -785,6 +788,18 @@ void AquaSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) (*it)->maInvalidRect.SetEmpty(); } } + osl_setCondition( maWaitingYieldCond ); + } + else if( bWait ) + { + // #i103162# + // wait until any thread (most likely the main thread) + // has dispatched an event, cop out at 200 ms + osl_resetCondition( maWaitingYieldCond ); + TimeValue aVal = { 0, 200000000 }; + ULONG nCount = ReleaseYieldMutex(); + osl_waitCondition( maWaitingYieldCond, &aVal ); + AcquireYieldMutex( nCount ); } // we get some apple events way too early 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/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index a54a7fad7ac5..1ef370f43a92 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -694,6 +694,13 @@ void AquaSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) void AquaSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) { + if( nX1 == nX2 && nY1 == nY2 ) + { + // #i109453# platform independent code expects at least one pixel to be drawn + drawPixel( nX1, nY1 ); + return; + } + if( !CheckContext() ) return; @@ -1095,7 +1102,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/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx index 71c84ee0c2f1..0fd028864bf4 100644 --- a/vcl/aqua/source/window/salframe.cxx +++ b/vcl/aqua/source/window/salframe.cxx @@ -1128,6 +1128,16 @@ static Font getFont( NSFont* pFont, long nDPIY, const Font& rDefault ) return aResult; } +void AquaSalFrame::getResolution( long& o_rDPIX, long& o_rDPIY ) +{ + if( ! mpGraphics ) + { + GetGraphics(); + ReleaseGraphics( mpGraphics ); + } + mpGraphics->GetResolution( o_rDPIX, o_rDPIY ); +} + // on OSX-Aqua the style settings are independent of the frame, so it does // not really belong here. Since the connection to the Appearance_Manager // is currently done in salnativewidgets.cxx this would be a good place. @@ -1157,13 +1167,8 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings ) // get the system font settings Font aAppFont = aStyleSettings.GetAppFont(); - if( ! mpGraphics ) - { - GetGraphics(); - ReleaseGraphics( mpGraphics ); - } long nDPIX = 72, nDPIY = 72; - mpGraphics->GetResolution( nDPIX, nDPIY ); + getResolution( nDPIX, nDPIY ); aAppFont = getFont( [NSFont systemFontOfSize: 0], nDPIY, aAppFont ); // TODO: better mapping of aqua<->ooo font settings diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm index 67926a38608d..0dfa0fa356aa 100755 --- a/vcl/aqua/source/window/salframeview.mm +++ b/vcl/aqua/source/window/salframeview.mm @@ -37,7 +37,9 @@ #include "vcl/window.hxx" #include "vcl/svapp.hxx" - + +#define WHEEL_EVENT_FACTOR 1.5 + static USHORT ImplGetModifierMask( unsigned int nMask ) { USHORT nRet = 0; @@ -654,11 +656,12 @@ private: mpFrame->CocoaToVCL( aPt ); SalWheelMouseEvent aEvent; - aEvent.mnTime = mpFrame->mnLastEventTime; - aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; - aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; - aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); - aEvent.mnCode |= KEY_MOD1; // we want zooming, no scrolling + aEvent.mnTime = mpFrame->mnLastEventTime; + aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; + aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; + aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); + aEvent.mnCode |= KEY_MOD1; // we want zooming, no scrolling + aEvent.mbDeltaIsPixel = TRUE; // --- RTL --- (mirror mouse pos) if( Application::GetSettings().GetLayoutRTL() ) @@ -667,11 +670,11 @@ private: if( dZ != 0.0 ) { aEvent.mnDelta = static_cast<long>(floor(dZ)); - aEvent.mnNotchDelta = aEvent.mnDelta / 8; - if( aEvent.mnNotchDelta == 0 ) - aEvent.mnNotchDelta = dZ < 0.0 ? -1 : 1; + aEvent.mnNotchDelta = dZ < 0 ? -1 : 1; + if( aEvent.mnDelta == 0 ) + aEvent.mnDelta = aEvent.mnNotchDelta; aEvent.mbHorz = FALSE; - aEvent.mnScrollLines = aEvent.mnNotchDelta > 0 ? aEvent.mnNotchDelta : -aEvent.mnNotchDelta; + aEvent.mnScrollLines = dZ > 0 ? dZ/WHEEL_EVENT_FACTOR : -dZ/WHEEL_EVENT_FACTOR; if( aEvent.mnScrollLines == 0 ) aEvent.mnScrollLines = 1; mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); @@ -712,10 +715,11 @@ private: mpFrame->CocoaToVCL( aPt ); SalWheelMouseEvent aEvent; - aEvent.mnTime = mpFrame->mnLastEventTime; - aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; - aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; - aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); + aEvent.mnTime = mpFrame->mnLastEventTime; + aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; + aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; + aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); + aEvent.mbDeltaIsPixel = TRUE; // --- RTL --- (mirror mouse pos) if( Application::GetSettings().GetLayoutRTL() ) @@ -724,9 +728,9 @@ private: if( dX != 0.0 ) { aEvent.mnDelta = static_cast<long>(floor(dX)); - aEvent.mnNotchDelta = aEvent.mnDelta / 8; - if( aEvent.mnNotchDelta == 0 ) - aEvent.mnNotchDelta = dX < 0.0 ? -1 : 1; + aEvent.mnNotchDelta = dX < 0 ? -1 : 1; + if( aEvent.mnDelta == 0 ) + aEvent.mnDelta = aEvent.mnNotchDelta; aEvent.mbHorz = TRUE; aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); @@ -734,9 +738,9 @@ private: if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame )) { aEvent.mnDelta = static_cast<long>(floor(dY)); - aEvent.mnNotchDelta = aEvent.mnDelta / 8; - if( aEvent.mnNotchDelta == 0 ) - aEvent.mnNotchDelta = dY < 0.0 ? -1 : 1; + aEvent.mnNotchDelta = dY < 0 ? -1 : 1; + if( aEvent.mnDelta == 0 ) + aEvent.mnDelta = aEvent.mnNotchDelta; aEvent.mbHorz = FALSE; aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); @@ -771,10 +775,11 @@ private: mpFrame->CocoaToVCL( aPt ); SalWheelMouseEvent aEvent; - aEvent.mnTime = mpFrame->mnLastEventTime; - aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; - aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; - aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); + aEvent.mnTime = mpFrame->mnLastEventTime; + aEvent.mnX = static_cast<long>(aPt.x) - mpFrame->maGeometry.nX; + aEvent.mnY = static_cast<long>(aPt.y) - mpFrame->maGeometry.nY; + aEvent.mnCode = ImplGetModifierMask( mpFrame->mnLastModifierFlags ); + aEvent.mbDeltaIsPixel = TRUE; // --- RTL --- (mirror mouse pos) if( Application::GetSettings().GetLayoutRTL() ) @@ -783,30 +788,27 @@ private: if( dX != 0.0 ) { aEvent.mnDelta = static_cast<long>(floor(dX)); - aEvent.mnNotchDelta = aEvent.mnDelta / 8; - if( aEvent.mnNotchDelta == 0 ) - aEvent.mnNotchDelta = dX < 0.0 ? -1 : 1; + aEvent.mnNotchDelta = dX < 0 ? -1 : 1; + if( aEvent.mnDelta == 0 ) + aEvent.mnDelta = aEvent.mnNotchDelta; aEvent.mbHorz = TRUE; - aEvent.mnScrollLines = aEvent.mnNotchDelta > 0 ? aEvent.mnNotchDelta : -aEvent.mnNotchDelta; + aEvent.mnScrollLines = dY > 0 ? dX/WHEEL_EVENT_FACTOR : -dX/WHEEL_EVENT_FACTOR; if( aEvent.mnScrollLines == 0 ) aEvent.mnScrollLines = 1; - if( aEvent.mnScrollLines > 15 ) - aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; + mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); } if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ) ) { aEvent.mnDelta = static_cast<long>(floor(dY)); - aEvent.mnNotchDelta = aEvent.mnDelta / 8; - if( aEvent.mnNotchDelta == 0 ) - aEvent.mnNotchDelta = dY < 0.0 ? -1 : 1; + aEvent.mnNotchDelta = dY < 0 ? -1 : 1; + if( aEvent.mnDelta == 0 ) + aEvent.mnDelta = aEvent.mnNotchDelta; aEvent.mbHorz = FALSE; - aEvent.mnScrollLines = aEvent.mnNotchDelta > 0 ? aEvent.mnNotchDelta : -aEvent.mnNotchDelta; - if( aEvent.mnScrollLines == 0 ) + aEvent.mnScrollLines = dY > 0 ? dY/WHEEL_EVENT_FACTOR : -dY/WHEEL_EVENT_FACTOR; + if( aEvent.mnScrollLines < 1 ) aEvent.mnScrollLines = 1; - if( aEvent.mnScrollLines > 15 ) - aEvent.mnScrollLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL; - + mpFrame->CallCallback( SALEVENT_WHEELMOUSE, &aEvent ); } } 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/button.hxx b/vcl/inc/vcl/button.hxx index 317a98026f45..8f4b94bf7b18 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -60,7 +60,7 @@ public: SAL_DLLPRIVATE USHORT ImplGetTextStyle( XubString& rText, WinBits nWinStyle, ULONG nDrawFlags ); SAL_DLLPRIVATE void ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize, BOOL bLayout, ULONG nImageSep, ULONG nDrawFlags, - USHORT nTextStyle, Rectangle *pSymbolRect=NULL ); + USHORT nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false ); SAL_DLLPRIVATE void ImplSetFocusRect( const Rectangle &rFocusRect ); SAL_DLLPRIVATE const Rectangle& ImplGetFocusRect() const; SAL_DLLPRIVATE void ImplSetSymbolAlign( SymbolAlign eAlign ); diff --git a/vcl/inc/vcl/cmdevt.hxx b/vcl/inc/vcl/cmdevt.hxx index 0faac8472253..7e968b6c7a54 100644 --- a/vcl/inc/vcl/cmdevt.hxx +++ b/vcl/inc/vcl/cmdevt.hxx @@ -138,18 +138,20 @@ private: USHORT mnMode; USHORT mnCode; BOOL mbHorz; + BOOL mbDeltaIsPixel; public: CommandWheelData(); CommandWheelData( long nWheelDelta, long nWheelNotchDelta, ULONG nScrollLines, USHORT nWheelMode, USHORT nKeyModifier, - BOOL mbHorz = FALSE ); + BOOL bHorz = FALSE, BOOL bDeltaIsPixel = FALSE ); long GetDelta() const { return mnDelta; } long GetNotchDelta() const { return mnNotchDelta; } ULONG GetScrollLines() const { return mnLines; } BOOL IsHorz() const { return mbHorz; } + BOOL IsDeltaPixel() const { return mbDeltaIsPixel; } USHORT GetMode() const { return mnMode; } @@ -173,12 +175,13 @@ inline CommandWheelData::CommandWheelData() mnMode = 0; mnCode = 0; mbHorz = FALSE; + mbDeltaIsPixel = FALSE; } inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta, ULONG nScrollLines, USHORT nWheelMode, USHORT nKeyModifier, - BOOL bHorz ) + BOOL bHorz, BOOL bDeltaIsPixel ) { mnDelta = nWheelDelta; mnNotchDelta = nWheelNotchDelta; @@ -186,6 +189,7 @@ inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDel mnMode = nWheelMode; mnCode = nKeyModifier; mbHorz = bHorz; + mbDeltaIsPixel = bDeltaIsPixel; } // --------------------- 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 6ebd777f1c61..33fece8d88e1 100644 --- a/vcl/inc/vcl/fontmanager.hxx +++ b/vcl/inc/vcl/fontmanager.hxx @@ -437,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(); diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx index fa3e99f2373f..a77c1626dc24 100644 --- a/vcl/inc/vcl/glyphcache.hxx +++ b/vcl/inc/vcl/glyphcache.hxx @@ -51,6 +51,7 @@ class RawBitmap; class CmapResult; #include <vcl/outfont.hxx> +#include <vcl/impfont.hxx> class ServerFontLayout; #include <vcl/sallayout.hxx> @@ -258,11 +259,15 @@ class VCL_DLLPUBLIC ImplServerFontEntry : public ImplFontEntry { private: ServerFont* mpServerFont; + ImplFontOptions maFontOptions; + bool mbGotFontOptions; + bool mbValidFontOptions; public: ImplServerFontEntry( ImplFontSelectData& ); virtual ~ImplServerFontEntry(); void SetServerFont( ServerFont* p) { mpServerFont = p; } + void HandleFontOptions(); }; // ======================================================================= 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/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 be5c0a880ed7..70c1e6aa624d 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -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 995fcd6009ff..4bbf7176ddb2 100644 --- a/vcl/inc/vcl/outfont.hxx +++ b/vcl/inc/vcl/outfont.hxx @@ -39,6 +39,8 @@ #include <hash_map> +#include <com/sun/star/linguistic2/XLinguServiceManager.hpp> + class ImplDevFontListData; class ImplGetDevFontList; class ImplGetDevSizeList; @@ -186,6 +188,7 @@ public: // TODO: change to private class VCL_DLLPUBLIC ImplDevFontList { private: + friend class WinGlyphFallbackSubstititution; mutable bool mbMatchData; // true if matching attributes are initialized bool mbMapNames; // true if MapNames are available @@ -222,6 +225,9 @@ public: ImplGetDevFontList* GetDevFontList() const; ImplGetDevSizeList* GetDevSizeList( const String& rFontName ) const; + //used by 2-level font fallback + ImplDevFontListData* ImplFindByLocale(com::sun::star::lang::Locale lc) const; + protected: void InitMatchData() const; bool AreMapNamesAvailable() const { return mbMapNames; } 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/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/salwtype.hxx b/vcl/inc/vcl/salwtype.hxx index c67d36ac4ea9..95b3806d648b 100644 --- a/vcl/inc/vcl/salwtype.hxx +++ b/vcl/inc/vcl/salwtype.hxx @@ -180,6 +180,11 @@ struct SalWheelMouseEvent ULONG mnScrollLines; // Aktuelle Anzahl zu scrollende Zeilen USHORT mnCode; // SV-ModifierCode (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT) BOOL mbHorz; // Horizontal + BOOL mbDeltaIsPixel; // delta value is a pixel value (on mac) + + SalWheelMouseEvent() + : mnTime( 0 ), mnX( 0 ), mnY( 0 ), mnDelta( 0 ), mnNotchDelta( 0 ), mnScrollLines( 0 ), mnCode( 0 ), mbHorz( FALSE ), mbDeltaIsPixel( FALSE ) + {} }; // MOUSEACTIVATE 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/os2/source/window/salframe.cxx b/vcl/os2/source/window/salframe.cxx index 7ecc27ff9754..f3314c725255 100644 --- a/vcl/os2/source/window/salframe.cxx +++ b/vcl/os2/source/window/salframe.cxx @@ -3032,10 +3032,8 @@ static void ImplHandleMoveMsg( HWND hWnd) // ----------------------------------------------------------------------- -static long ImplHandleSizeMsg( HWND hWnd, MPARAM nMP2 ) +static void ImplHandleSizeMsg( HWND hWnd, MPARAM nMP2 ) { - long nRet; - Os2SalFrame* pFrame = GetWindowPtr( hWnd ); if ( pFrame ) { @@ -3047,11 +3045,10 @@ static long ImplHandleSizeMsg( HWND hWnd, MPARAM nMP2 ) pFrame->mpGraphics->mnHeight = (int)SHORT2FROMMP(nMP2); // Status merken ImplSaveFrameState( pFrame ); - nRet = pFrame->CallCallback( SALEVENT_RESIZE, 0 ); + pFrame->CallCallback( SALEVENT_RESIZE, 0 ); if ( WinIsWindowVisible( pFrame->mhWndFrame ) && !pFrame->mbInShow ) WinUpdateWindow( pFrame->mhWndClient ); } - return nRet; } // ----------------------------------------------------------------------- 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 5ad3f6787461..980e0f1c5b58 100644..100755 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -188,7 +188,7 @@ ImplMouseData::ImplMouseData() mnActionDelay = 250; mnMenuDelay = 150; mnFollow = MOUSE_FOLLOW_MENU | MOUSE_FOLLOW_DDLIST; - mnWheelBehavior = MOUSE_WHEEL_FOCUS_ONLY; + mnWheelBehavior = MOUSE_WHEEL_ALWAYS; } // ----------------------------------------------------------------------- diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 1cda2308aa9c..08759f37d7a6 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -367,7 +367,8 @@ USHORT Button::ImplGetTextStyle( XubString& rText, WinBits nWinStyle, void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize, BOOL bLayout, ULONG nImageSep, ULONG nDrawFlags, - USHORT nTextStyle, Rectangle *pSymbolRect ) + USHORT nTextStyle, Rectangle *pSymbolRect, + bool bAddImageSep ) { XubString aText( GetText() ); BOOL bDrawImage = HasImage() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOIMAGE ); @@ -502,6 +503,13 @@ void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, if ( aTSSize.Height() < aTextSize.Height() ) aTSSize.Height() = aTextSize.Height(); + + if( bAddImageSep && bDrawImage ) + { + long nDiff = (aImageSize.Height() - aTextSize.Height()) / 3; + if( nDiff > 0 ) + nImageSep += nDiff; + } } aMax.Width() = aTSSize.Width() > aImageSize.Width() ? aTSSize.Width() : aImageSize.Width(); @@ -880,7 +888,9 @@ void PushButton::ImplInitSettings( BOOL bFont, EnableChildTransparentMode( TRUE ); SetParentClipMode( PARENTCLIPMODE_NOCLIP ); SetPaintTransparent( TRUE ); - mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; + mpWindowImpl->mbUseNativeFocus = (GetStyle() & WB_FLATBUTTON) + ? false + : ImplGetSVData()->maNWFData.mbNoFocusRects; } else { @@ -1191,8 +1201,13 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, ULONG nDrawFlags else { Rectangle aSymbolRect; - ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1, nDrawFlags, - nTextStyle, IsSymbol() ? &aSymbolRect : NULL ); + ULONG nImageSep = 1 + (pDev->GetTextHeight()-10)/2; + if( nImageSep < 1 ) + nImageSep = 1; + // FIXME: (GetStyle() & WB_FLATBUTTON) != 0 is preliminary + // in the next major this should be replaced by "true" + ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags, + nTextStyle, IsSymbol() ? &aSymbolRect : NULL, (GetStyle() & WB_FLATBUTTON) != 0 ); if ( IsSymbol() && ! bLayout ) { @@ -1320,6 +1335,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 +1350,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 +1375,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)) || ! (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 +1397,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 ) + 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 ); @@ -1855,7 +1891,8 @@ long PushButton::PreNotify( NotifyEvent& rNEvt ) pBorder->Update(); } } - else if( IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) ) + else if( (GetStyle() & WB_FLATBUTTON) || + IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) ) { Invalidate(); } 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..89fbe6d3db78 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 ) @@ -1096,8 +1156,6 @@ void TabControl::MouseButtonDown( const MouseEvent& rMEvt ) ImplTabItem* pItem = ImplGetItem( nPageId ); if( pItem && pItem->mbEnabled ) SelectTabPage( nPageId ); - else - Sound::Beep( SOUND_ERROR, this ); } } } @@ -1655,44 +1713,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..620ca64f44d9 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -33,6 +33,7 @@ #include <assert.h> #include <vcl/fontsubset.hxx> +#include <vcl/strhelper.hxx> //#define IGNORE_HINTS @@ -391,11 +392,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 +430,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 +609,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 +744,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; @@ -2155,6 +2028,17 @@ void Type1Emitter::emitAllCrypted( void) // -------------------------------------------------------------------- +// #i110387# quick-and-dirty double->ascii conversion +// needed because sprintf/ecvt/etc. alone are too localized (LC_NUMERIC) +// also strip off trailing zeros in fraction while we are at it +inline int dbl2str( char* pOut, double fVal, int nPrecision=6) +{ + const int nLen = psp::getValueOfDouble( pOut, fVal, nPrecision); + return nLen; +} + +// -------------------------------------------------------------------- + void Type1Emitter::emitValVector( const char* pLineHead, const char* pLineTail, const ValVector& rVector) { @@ -2170,10 +2054,11 @@ void Type1Emitter::emitValVector( const char* pLineHead, const char* pLineTail, aVal = *it; if( ++it == rVector.end() ) break; - mpPtr += sprintf( mpPtr, "%g ", aVal); + mpPtr += dbl2str( mpPtr, aVal); + *(mpPtr++) = ' '; } // emit the last value - mpPtr += sprintf( mpPtr, "%g", aVal); + mpPtr += dbl2str( mpPtr, aVal); // emit the line tail mpPtr += sprintf( mpPtr, pLineTail); } @@ -2330,18 +2215,33 @@ bool CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter, rEmitter.emitValVector( "/FamilyBlues [", "]ND\n", mpCffLocal->maFamilyBlues); rEmitter.emitValVector( "/FamilyOtherBlues [", "]ND\n", mpCffLocal->maFamilyOtherBlues); - if( mpCffLocal->mfBlueScale) - pOut += sprintf( pOut, "/BlueScale %.6f def\n", mpCffLocal->mfBlueScale); - if( mpCffLocal->mfBlueShift) // default BlueShift==7 - pOut += sprintf( pOut, "/BlueShift %.1f def\n", mpCffLocal->mfBlueShift); - if( mpCffLocal->mfBlueFuzz) // default BlueFuzz==1 - pOut += sprintf( pOut, "/BlueFuzz %.1f def\n", mpCffLocal->mfBlueFuzz); + if( mpCffLocal->mfBlueScale) { + pOut += sprintf( pOut, "/BlueScale "); + pOut += dbl2str( pOut, mpCffLocal->mfBlueScale, 6); + pOut += sprintf( pOut, " def\n"); + } + if( mpCffLocal->mfBlueShift) { // default BlueShift==7 + pOut += sprintf( pOut, "/BlueShift "); + pOut += dbl2str( pOut, mpCffLocal->mfBlueShift); + pOut += sprintf( pOut, " def\n"); + } + if( mpCffLocal->mfBlueFuzz) { // default BlueFuzz==1 + pOut += sprintf( pOut, "/BlueFuzz "); + pOut += dbl2str( pOut, mpCffLocal->mfBlueFuzz); + pOut += sprintf( pOut, " def\n"); + } // emit stem hint related privdict entries - if( mpCffLocal->maStemStdHW) - pOut += sprintf( pOut, "/StdHW [%g] def\n", mpCffLocal->maStemStdHW); - if( mpCffLocal->maStemStdVW) - pOut += sprintf( pOut, "/StdVW [%g] def\n", mpCffLocal->maStemStdVW); + if( mpCffLocal->maStemStdHW) { + pOut += sprintf( pOut, "/StdHW ["); + pOut += dbl2str( pOut, mpCffLocal->maStemStdHW); + pOut += sprintf( pOut, "] def\n"); + } + if( mpCffLocal->maStemStdVW) { + pOut += sprintf( pOut, "/StdVW ["); + pOut += dbl2str( pOut, mpCffLocal->maStemStdVW); + pOut += sprintf( pOut, "] def\n"); + } rEmitter.emitValVector( "/StemSnapH [", "]ND\n", mpCffLocal->maStemSnapH); rEmitter.emitValVector( "/StemSnapV [", "]ND\n", mpCffLocal->maStemSnapV); @@ -2352,8 +2252,11 @@ bool CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter, pOut += sprintf( pOut, "/LanguageGroup %d def\n", mpCffLocal->mnLangGroup); if( mpCffLocal->mnLangGroup == 1) // compatibility with ancient printers pOut += sprintf( pOut, "/RndStemUp false def\n"); - if( mpCffLocal->mfExpFactor) - pOut += sprintf( pOut, "/ExpansionFactor %.2f def\n", mpCffLocal->mfExpFactor); + if( mpCffLocal->mfExpFactor) { + pOut += sprintf( pOut, "/ExpansionFactor "); + pOut += dbl2str( pOut, mpCffLocal->mfExpFactor); + pOut += sprintf( pOut, " def\n"); + } #endif // IGNORE_HINTS // emit remaining privdict entries @@ -2376,6 +2279,7 @@ bool CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter, // emit used GlobalSubr charstrings // these are the just the default subrs + // TODO: do we need them as the flex hints are resolved differently? static const char aSubrs[] = "/Subrs 5 array\n" "dup 0 15 RD \x5F\x3D\x6B\xAC\x3C\xBD\x74\x3D\x3E\x17\xA0\x86\x58\x08\x85 NP\n" diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 51c76b5a4626..074935086b0b 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -323,7 +323,23 @@ BOOL Bitmap::HasGreyPalette() const BOOL bRet = FALSE; if( 1 == nBitCount ) - bRet = TRUE; + { + BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess(); + + if( pRAcc ) + { + const BitmapColor& rCol0( pRAcc->GetPaletteColor( 0 ) ); + const BitmapColor& rCol1( pRAcc->GetPaletteColor( 1 ) ); + if( rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() == rCol0.GetBlue() && + rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() == rCol1.GetBlue() ) + { + bRet = TRUE; + } + ( (Bitmap*) this )->ReleaseAccess( pRAcc ); + } + else + bRet = TRUE; + } else if( 4 == nBitCount || 8 == nBitCount ) { BitmapReadAccess* pRAcc = ( (Bitmap*) this )->AcquireReadAccess(); 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 6ca90540d8ee..f4fcba72b0c2 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -1337,6 +1337,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const "muktinarrow", "", "phetsarathot", "", "padauk", "pinlonmyanmar", "", + "iskoolapota", "lklug", "", 0 }; @@ -1671,6 +1672,18 @@ void ImplDevFontList::InitMatchData() const } } +//---------------------------------------------------------------------------- +ImplDevFontListData* ImplDevFontList::ImplFindByLocale(com::sun::star::lang::Locale lc) const +{ + // get the default font for a specified locale + const DefaultFontConfiguration& rDefaults = *DefaultFontConfiguration::get(); + String aDefault = rDefaults.getUserInterfaceFont( lc ); + ImplDevFontListData* pFontData = ImplFindByTokenNames( aDefault ); + if( pFontData ) + return pFontData; + return 0; +} + // ----------------------------------------------------------------------- ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType, @@ -2090,11 +2103,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 ) { @@ -5908,15 +5924,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..7ee5889ba532 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 ) @@ -11526,20 +11733,9 @@ sal_Int32 PDFWriterImpl::findRadioGroupWidget( const PDFWriter::RadioButtonWidge m_aWidgets.back().m_nPage = m_nCurrentPage; m_aWidgets.back().m_eType = PDFWriter::RadioButton; m_aWidgets.back().m_nRadioGroup = rBtn.RadioGroup; - m_aWidgets.back().m_nFlags |= 0x00008000; + m_aWidgets.back().m_nFlags |= 0x0000C000; // NoToggleToOff and Radio bits - // 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..80ae3a3a8c7f 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 @@ -1800,8 +1800,8 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) int nRunStart, nRunEnd; while (rArgs.GetNextRun(&nRunStart, &nRunEnd, &bRtl)) { - if (bRtl) std::fill(vRtl.begin() + nRunStart - rArgs.mnMinCharPos, - vRtl.begin() + nRunEnd - rArgs.mnMinCharPos, true); + if (bRtl) std::fill(vRtl.begin() + ( nRunStart - rArgs.mnMinCharPos ), + vRtl.begin() + ( nRunEnd - rArgs.mnMinCharPos ), true); } rArgs.ResetPos(); diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index ea0f18896b7a..1953ecf553c4 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -519,8 +519,10 @@ bool ServerFont::IsGlyphInvisible( int nGlyphIndex ) // ======================================================================= ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD ) -: ImplFontEntry( rFSD ), - mpServerFont( NULL ) +: ImplFontEntry( rFSD ) +, mpServerFont( NULL ) +, mbGotFontOptions( false ) +, mbValidFontOptions( false ) {} // ----------------------------------------------------------------------- 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/src/print.src b/vcl/source/src/print.src index 3158926f5e6d..58f0a477c848 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -356,7 +356,7 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 5, 35 ); Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "Range and Copies"; + Text [en-US] = "Range and copies"; }; FixedText SV_PRINT_COPYCOUNT { 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..35077b1cff0e 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 ); } @@ -557,7 +647,7 @@ void PrintDialog::JobTabPage::setupLayout() // add printer fixed line maLayout.addWindow( &maPrinterFL ); // add print LB - maLayout.addWindow( &maPrinters ); + maLayout.addWindow( &maPrinters, 3 ); // create a row for details button/text and properties button boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) ); @@ -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..7b0512a1320b 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 ); } } @@ -1474,6 +1474,7 @@ static long ImplHandleWheelEvent( Window* pWindow, const SalWheelMouseEvent& rEv USHORT nMode; USHORT nCode = rEvt.mnCode; bool bHorz = rEvt.mbHorz; + bool bPixel = rEvt.mbDeltaIsPixel; if ( nCode & KEY_MOD1 ) nMode = COMMAND_WHEEL_ZOOM; else if ( nCode & KEY_MOD2 ) @@ -1486,7 +1487,7 @@ static long ImplHandleWheelEvent( Window* pWindow, const SalWheelMouseEvent& rEv bHorz = true; } - CommandWheelData aWheelData( rEvt.mnDelta, rEvt.mnNotchDelta, rEvt.mnScrollLines, nMode, nCode, bHorz ); + CommandWheelData aWheelData( rEvt.mnDelta, rEvt.mnNotchDelta, rEvt.mnScrollLines, nMode, nCode, bHorz, bPixel ); Point aMousePos( rEvt.mnX, rEvt.mnY ); BOOL bRet = TRUE; diff --git a/vcl/unx/gtk/a11y/atkbridge.cxx b/vcl/unx/gtk/a11y/atkbridge.cxx index 9498c4570ae0..25add8e0dd18 100644 --- a/vcl/unx/gtk/a11y/atkbridge.cxx +++ b/vcl/unx/gtk/a11y/atkbridge.cxx @@ -40,17 +40,14 @@ bool InitAtkBridge(void) { const char* pVersion = atk_get_toolkit_version(); if( ! pVersion ) - { - g_warning( "unable to get gail version number" ); return false; - } unsigned int major, minor, micro; /* 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/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx index f346a6a5a02c..e6d3276891de 100644 --- a/vcl/unx/gtk/a11y/atktext.cxx +++ b/vcl/unx/gtk/a11y/atktext.cxx @@ -454,6 +454,84 @@ text_wrapper_set_caret_offset (AtkText *text, return FALSE; } +// --> OD 2010-03-04 #i92232# +AtkAttributeSet* +handle_text_markup_as_run_attribute( accessibility::XAccessibleTextMarkup* pTextMarkup, + const gint nTextMarkupType, + const gint offset, + AtkAttributeSet* pSet, + gint *start_offset, + gint *end_offset ) +{ + const gint nTextMarkupCount( pTextMarkup->getTextMarkupCount( nTextMarkupType ) ); + if ( nTextMarkupCount > 0 ) + { + for ( gint nTextMarkupIndex = 0; + nTextMarkupIndex < nTextMarkupCount; + ++nTextMarkupIndex ) + { + accessibility::TextSegment aTextSegment = + pTextMarkup->getTextMarkup( nTextMarkupIndex, nTextMarkupType ); + const gint nStartOffsetTextMarkup = aTextSegment.SegmentStart; + const gint nEndOffsetTextMarkup = aTextSegment.SegmentEnd; + if ( nStartOffsetTextMarkup <= offset ) + { + if ( offset < nEndOffsetTextMarkup ) + { + // text markup at <offset> + *start_offset = ::std::max( *start_offset, + nStartOffsetTextMarkup ); + *end_offset = ::std::min( *end_offset, + nEndOffsetTextMarkup ); + switch ( nTextMarkupType ) + { + case com::sun::star::text::TextMarkupType::SPELLCHECK: + { + pSet = attribute_set_prepend_misspelled( pSet ); + } + break; + case com::sun::star::text::TextMarkupType::TRACK_CHANGE_INSERTION: + { + pSet = attribute_set_prepend_tracked_change_insertion( pSet ); + } + break; + case com::sun::star::text::TextMarkupType::TRACK_CHANGE_DELETION: + { + pSet = attribute_set_prepend_tracked_change_deletion( pSet ); + } + break; + case com::sun::star::text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE: + { + pSet = attribute_set_prepend_tracked_change_formatchange( pSet ); + } + break; + default: + { + OSL_ASSERT( false ); + } + } + break; // no further iteration needed. + } + else + { + *start_offset = ::std::max( *start_offset, + nEndOffsetTextMarkup ); + // continue iteration. + } + } + else + { + *end_offset = ::std::min( *end_offset, + nStartOffsetTextMarkup ); + break; // no further iteration. + } + } // eof iteration over text markups + } + + return pSet; +} +// <-- + static AtkAttributeSet * text_wrapper_get_run_attributes( AtkText *text, gint offset, @@ -491,41 +569,41 @@ text_wrapper_get_run_attributes( AtkText *text, } } - // Special handling for missspelled + // Special handling for misspelled text + // --> OD 2010-03-01 #i92232# + // - add special handling for tracked changes and refactor the + // corresponding code for handling misspelled text. accessibility::XAccessibleTextMarkup* pTextMarkup = getTextMarkup( text ); if( pTextMarkup ) { - uno::Sequence< accessibility::TextSegment > aTextSegmentSeq = - pTextMarkup->getTextMarkupAtIndex( offset, com::sun::star::text::TextMarkupType::SPELLCHECK ); - if( aTextSegmentSeq.getLength() > 0 ) + // Get attribute run here if it hasn't been done before + if( !bOffsetsAreValid ) { - accessibility::TextSegment aTextSegment = aTextSegmentSeq[0]; - gint nStartOffsetMisspelled = aTextSegment.SegmentStart; - gint nEndOffsetMisspelled = aTextSegment.SegmentEnd; - - // Get attribute run here if it hasn't been done before - if( !bOffsetsAreValid ) - { - accessibility::TextSegment aAttributeTextSegment = - pText->getTextAtIndex(offset, accessibility::AccessibleTextType::ATTRIBUTE_RUN); - *start_offset = aAttributeTextSegment.SegmentStart; - *end_offset = aAttributeTextSegment.SegmentEnd; - } - - if( nEndOffsetMisspelled <= offset ) - *start_offset = ::std::max( *start_offset, nEndOffsetMisspelled ); - else if( nStartOffsetMisspelled <= offset ) - *start_offset = ::std::max( *start_offset, nStartOffsetMisspelled ); - - if( nStartOffsetMisspelled > offset ) - *end_offset = ::std::min( *end_offset, nStartOffsetMisspelled ); - else if( nEndOffsetMisspelled > offset ) - *end_offset = ::std::min( *end_offset, nEndOffsetMisspelled ); - - if( nStartOffsetMisspelled <= offset && nEndOffsetMisspelled > offset ) - pSet = attribute_set_prepend_misspelled( pSet ); + accessibility::TextSegment aAttributeTextSegment = + pText->getTextAtIndex(offset, accessibility::AccessibleTextType::ATTRIBUTE_RUN); + *start_offset = aAttributeTextSegment.SegmentStart; + *end_offset = aAttributeTextSegment.SegmentEnd; } + // handle misspelled text + pSet = handle_text_markup_as_run_attribute( + pTextMarkup, + com::sun::star::text::TextMarkupType::SPELLCHECK, + offset, pSet, start_offset, end_offset ); + // handle tracked changes + pSet = handle_text_markup_as_run_attribute( + pTextMarkup, + com::sun::star::text::TextMarkupType::TRACK_CHANGE_INSERTION, + offset, pSet, start_offset, end_offset ); + pSet = handle_text_markup_as_run_attribute( + pTextMarkup, + com::sun::star::text::TextMarkupType::TRACK_CHANGE_DELETION, + offset, pSet, start_offset, end_offset ); + pSet = handle_text_markup_as_run_attribute( + pTextMarkup, + com::sun::star::text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE, + offset, pSet, start_offset, end_offset ); } + // <-- } catch(const uno::Exception& e){ diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx index 02624a9628cf..04498810597f 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk/a11y/atktextattributes.cxx @@ -74,6 +74,12 @@ static AtkTextAttribute atk_text_attribute_tab_stops = ATK_TEXT_ATTR_INVALID; static AtkTextAttribute atk_text_attribute_writing_mode = ATK_TEXT_ATTR_INVALID; static AtkTextAttribute atk_text_attribute_vertical_align = ATK_TEXT_ATTR_INVALID; static AtkTextAttribute atk_text_attribute_misspelled = ATK_TEXT_ATTR_INVALID; +// --> OD 2010-03-01 #i92232# +static AtkTextAttribute atk_text_attribute_tracked_change = ATK_TEXT_ATTR_INVALID; +// <-- +// --> OD 2010-03-05 #i92233# +static AtkTextAttribute atk_text_attribute_mm_to_pixel_ratio = ATK_TEXT_ATTR_INVALID; +// <-- /*****************************************************************************/ @@ -103,6 +109,9 @@ enum ExportedAttribute TEXT_ATTRIBUTE_STRIKETHROUGH, TEXT_ATTRIBUTE_UNDERLINE, TEXT_ATTRIBUTE_WEIGHT, + // --> OD 2010-03-05 #i92233# + TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO, + // <-- TEXT_ATTRIBUTE_JUSTIFICATION, TEXT_ATTRIBUTE_BOTTOM_MARGIN, TEXT_ATTRIBUTE_FIRST_LINE_INDENT, @@ -137,6 +146,9 @@ static const char * ExportedTextAttributes[TEXT_ATTRIBUTE_LAST] = "CharStrikeout", // TEXT_ATTRIBUTE_STRIKETHROUGH "CharUnderline", // TEXT_ATTRIBUTE_UNDERLINE "CharWeight", // TEXT_ATTRIBUTE_WEIGHT + // --> OD 2010-03-05 #i92233# + "MMToPixelRatio", // TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO + // <-- "ParaAdjust", // TEXT_ATTRIBUTE_JUSTIFICATION "ParaBottomMargin", // TEXT_ATTRIBUTE_BOTTOM_MARGIN "ParaFirstLineIndent", // TEXT_ATTRIBUTE_FIRST_LINE_INDENT @@ -1293,6 +1305,14 @@ attribute_set_new_from_property_values( attribute_set = attribute_set_prepend(attribute_set, atk_text_attribute_tab_stops, get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_TAB_STOPS], TabStops2String)); + // --> OD 2010-03-05 #i92233# + if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_mm_to_pixel_ratio ) + atk_text_attribute_mm_to_pixel_ratio = atk_text_attribute_register("mm-to-pixel-ratio"); + + attribute_set = attribute_set_prepend( attribute_set, atk_text_attribute_mm_to_pixel_ratio, + get_value(rAttributeList, aIndexList[TEXT_ATTRIBUTE_MM_TO_PIXEL_RATIO], Float2String)); + // <-- + return attribute_set; } @@ -1308,6 +1328,49 @@ AtkAttributeSet* attribute_set_prepend_misspelled( AtkAttributeSet* attribute_se return attribute_set; } +// --> OD 2010-03-01 #i92232# +AtkAttributeSet* attribute_set_prepend_tracked_change_insertion( AtkAttributeSet* attribute_set ) +{ + if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change ) + { + atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" ); + } + + attribute_set = attribute_set_prepend( attribute_set, + atk_text_attribute_tracked_change, + g_strdup_printf( "insertion" ) ); + + return attribute_set; +} + +AtkAttributeSet* attribute_set_prepend_tracked_change_deletion( AtkAttributeSet* attribute_set ) +{ + if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change ) + { + atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" ); + } + + attribute_set = attribute_set_prepend( attribute_set, + atk_text_attribute_tracked_change, + g_strdup_printf( "deletion" ) ); + + return attribute_set; +} + +AtkAttributeSet* attribute_set_prepend_tracked_change_formatchange( AtkAttributeSet* attribute_set ) +{ + if ( ATK_TEXT_ATTR_INVALID == atk_text_attribute_tracked_change ) + { + atk_text_attribute_tracked_change = atk_text_attribute_register( "text-tracked-change" ); + } + + attribute_set = attribute_set_prepend( attribute_set, + atk_text_attribute_tracked_change, + g_strdup_printf( "attribute-change" ) ); + + return attribute_set; +} +// <-- /*****************************************************************************/ diff --git a/vcl/unx/gtk/a11y/atktextattributes.hxx b/vcl/unx/gtk/a11y/atktextattributes.hxx index e363460bb578..9c7628bf927e 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.hxx +++ b/vcl/unx/gtk/a11y/atktextattributes.hxx @@ -45,5 +45,10 @@ attribute_set_map_to_property_values( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rValueList ); AtkAttributeSet* attribute_set_prepend_misspelled( AtkAttributeSet* attribute_set ); +// --> OD 2010-03-01 #i92232# +AtkAttributeSet* attribute_set_prepend_tracked_change_insertion( AtkAttributeSet* attribute_set ); +AtkAttributeSet* attribute_set_prepend_tracked_change_deletion( AtkAttributeSet* attribute_set ); +AtkAttributeSet* attribute_set_prepend_tracked_change_formatchange( AtkAttributeSet* attribute_set ); +// <-- #endif 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/a11y/atkwindow.cxx b/vcl/unx/gtk/a11y/atkwindow.cxx index f588c1e345e4..5448235998e8 100644 --- a/vcl/unx/gtk/a11y/atkwindow.cxx +++ b/vcl/unx/gtk/a11y/atkwindow.cxx @@ -143,6 +143,22 @@ ooo_window_wrapper_real_focus_gtk (GtkWidget *, GdkEventFocus *) return FALSE; } +static gboolean ooo_tooltip_map( GtkWidget* pToolTip, gpointer ) +{ + AtkObject* pAccessible = gtk_widget_get_accessible( pToolTip ); + if( pAccessible ) + atk_object_notify_state_change( pAccessible, ATK_STATE_SHOWING, TRUE ); + return FALSE; +} + +static gboolean ooo_tooltip_unmap( GtkWidget* pToolTip, gpointer ) +{ + AtkObject* pAccessible = gtk_widget_get_accessible( pToolTip ); + if( pAccessible ) + atk_object_notify_state_change( pAccessible, ATK_STATE_SHOWING, FALSE ); + return FALSE; +} + /*****************************************************************************/ static bool @@ -208,6 +224,16 @@ ooo_window_wrapper_real_initialize(AtkObject *obj, gpointer data) g_signal_connect_after( GTK_WIDGET( data ), "focus-out-event", G_CALLBACK (ooo_window_wrapper_real_focus_gtk), NULL); + + if( obj->role == ATK_ROLE_TOOL_TIP ) + { + g_signal_connect_after( GTK_WIDGET( data ), "map-event", + G_CALLBACK (ooo_tooltip_map), + NULL); + g_signal_connect_after( GTK_WIDGET( data ), "unmap-event", + G_CALLBACK (ooo_tooltip_unmap), + NULL); + } } /*****************************************************************************/ diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index 5beb838c0e82..10f75309708d 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -283,7 +283,9 @@ static AtkRole mapToAtkRole( sal_Int16 nRole ) ATK_ROLE_RULER, ATK_ROLE_UNKNOWN, // SECTION - registered below ATK_ROLE_UNKNOWN, // TREE_ITEM - registered below - ATK_ROLE_TREE_TABLE + ATK_ROLE_TREE_TABLE, + ATK_ROLE_SCROLL_PANE, // COMMENT - mapped to atk_role_scroll_pane + ATK_ROLE_UNKNOWN // COMMENT_END - mapped to atk_role_unknown }; static bool initialized = false; diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index b1529e060270..f63f999738a7 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 ); } } } @@ -800,15 +800,12 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) */ bool bDispatchThread = false; + gboolean wasEvent = FALSE; { // release YieldMutex (and re-acquire at block end) YieldMutexReleaser aReleaser; if( osl_tryToAcquireMutex( m_aDispatchMutex ) ) - { - // we are the dispatch thread - osl_resetCondition( m_aDispatchCondition ); bDispatchThread = true; - } else if( ! bWait ) return; // someone else is waiting already, return @@ -816,7 +813,7 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) if( bDispatchThread ) { int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1; - gboolean wasEvent = FALSE, wasOneEvent = TRUE; + gboolean wasOneEvent = TRUE; while( nMaxEvents-- && wasOneEvent ) { wasOneEvent = g_main_context_iteration( NULL, FALSE ); @@ -824,17 +821,17 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) wasEvent = TRUE; } if( bWait && ! wasEvent ) - g_main_context_iteration( NULL, TRUE ); + wasEvent = g_main_context_iteration( NULL, TRUE ); } - else if( userEventFn( this ) ) + else if( bWait ) { /* #i41693# in case the dispatch thread hangs in join * for this thread the condition will never be set * workaround: timeout of 1 second a emergency exit */ - TimeValue aValue; - aValue.Seconds = 1; - aValue.Nanosec = 0; + // we are the dispatch thread + osl_resetCondition( m_aDispatchCondition ); + TimeValue aValue = { 1, 0 }; osl_waitCondition( m_aDispatchCondition, &aValue ); } } @@ -842,8 +839,8 @@ void GtkXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) if( bDispatchThread ) { osl_releaseMutex( m_aDispatchMutex ); - osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields - osl_resetCondition( m_aDispatchCondition ); + if( wasEvent ) + osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields } } diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 869189fb1415..de4d55b0230a 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -99,6 +99,8 @@ struct NWFWidgetData GtkWidget * gTooltipPopup; GtkWidget * gProgressBar; GtkWidget * gTreeView; + GtkWidget * gHScale; + GtkWidget * gVScale; NWPixmapCacheList* gNWPixmapCacheList; NWPixmapCache* gCacheTabItems; @@ -131,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 ) @@ -172,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 ); @@ -589,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 ); @@ -875,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 ) { @@ -1103,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 ); } @@ -3012,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, @@ -3271,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 @@ -3962,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 ba42cfc5ae82..16e478c22f6e 100644 --- a/vcl/unx/gtk/window/gtkframe.cxx +++ b/vcl/unx/gtk/window/gtkframe.cxx @@ -690,7 +690,7 @@ static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBe XFree( pHints ); if (GetX11SalData()->GetDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("compiz")) - return; + return; /* remove WM_TAKE_FOCUS protocol; this would usually be the * right thing, but gtk handles it internally whereas we @@ -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 ) ); @@ -837,7 +844,8 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) eType = GDK_WINDOW_TYPE_HINT_UTILITY; } - if( (nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) ) + if( (nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) + && getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) { eType = GDK_WINDOW_TYPE_HINT_TOOLBAR; gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), true ); @@ -1297,7 +1305,8 @@ void GtkSalFrame::Show( BOOL bVisible, BOOL bNoActivate ) { if( m_pWindow ) { - if( m_pParent && (m_pParent->m_nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN) ) + if( m_pParent && (m_pParent->m_nStyle & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN) + && getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), bVisible ); if( bVisible ) { @@ -1458,6 +1467,12 @@ void GtkSalFrame::setMinMaxSize() aHints |= GDK_HINT_MAX_SIZE; } } + if( m_bFullscreen ) + { + aGeo.max_width = m_aMaxSize.Width(); + aGeo.max_height = m_aMaxSize.Height(); + aHints |= GDK_HINT_MAX_SIZE; + } if( aHints ) gtk_window_set_geometry_hints( GTK_WINDOW(m_pWindow), NULL, @@ -1809,8 +1824,6 @@ void GtkSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen ) { m_aRestorePosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ), Size( maGeometry.nWidth, maGeometry.nHeight ) ); - // workaround different window managers have different opinions about - // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin) bool bVisible = GTK_WIDGET_MAPPED(m_pWindow); if( bVisible ) Show( FALSE ); @@ -1827,12 +1840,22 @@ void GtkSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen ) gtk_window_move( GTK_WINDOW(m_pWindow), maGeometry.nX = aNewPosSize.Left(), maGeometry.nY = aNewPosSize.Top() ); + // #i110881# for the benefit of compiz set a max size here + // else setting to fullscreen fails for unknown reasons + m_aMaxSize.Width() = aNewPosSize.GetWidth()+100; + m_aMaxSize.Height() = aNewPosSize.GetHeight()+100; + // workaround different legacy version window managers have different opinions about + // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin) + if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + gtk_window_fullscreen( GTK_WINDOW( m_pWindow ) ); if( bVisible ) Show( TRUE ); } else { bool bVisible = GTK_WIDGET_MAPPED(m_pWindow); + if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + gtk_window_unfullscreen( GTK_WINDOW(m_pWindow) ); if( bVisible ) Show( FALSE ); m_nStyle &= ~SAL_FRAME_STYLE_PARTIAL_FULLSCREEN; @@ -1855,8 +1878,11 @@ void GtkSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen ) { if( bFullScreen ) { - if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) ) - gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE ); + if( getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + { + if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) ) + gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE ); + } gtk_window_fullscreen( GTK_WINDOW(m_pWindow) ); moveToScreen( nScreen ); Size aScreenSize = pDisp->GetScreenSize( m_nScreen ); @@ -1868,8 +1894,11 @@ void GtkSalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen ) else { gtk_window_unfullscreen( GTK_WINDOW(m_pWindow) ); - if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) ) - gtk_window_set_resizable( GTK_WINDOW(m_pWindow), FALSE ); + if( getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + { + if( !(m_nStyle & SAL_FRAME_STYLE_SIZEABLE) ) + gtk_window_set_resizable( GTK_WINDOW(m_pWindow), FALSE ); + } moveToScreen( nScreen ); } } @@ -2081,7 +2110,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 { @@ -3170,6 +3206,15 @@ gboolean GtkSalFrame::signalState( GtkWidget*, GdkEvent* pEvent, gpointer frame } pThis->m_nState = pEvent->window_state.new_window_state; + #if OSL_DEBUG_LEVEL > 1 + if( (pEvent->window_state.changed_mask & GDK_WINDOW_STATE_FULLSCREEN) ) + { + fprintf( stderr, "window %p %s full screen state\n", + pThis, + (pEvent->window_state.new_window_state & GDK_WINDOW_STATE_FULLSCREEN) ? "enters" : "leaves"); + } + #endif + return FALSE; } 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/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/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/saldata.hxx b/vcl/unx/inc/saldata.hxx index 3810558d470d..7e38e0a89bf2 100644 --- a/vcl/unx/inc/saldata.hxx +++ b/vcl/unx/inc/saldata.hxx @@ -62,6 +62,7 @@ protected: SalXLib *pXLib_; SalDisplay *m_pSalDisplay; pthread_t hMainThread_; + rtl::OUString maLocalHostName; public: X11SalData(); @@ -87,6 +88,9 @@ public: inline void StopTimer(); void Timeout() const; + const rtl::OUString& GetLocalHostName() const + { return maLocalHostName; } + static int XErrorHdl( Display*, XErrorEvent* ); static int XIOErrorHdl( Display* ); 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/wmadaptor.hxx b/vcl/unx/inc/wmadaptor.hxx index c628cfe091ef..cbedede2cc99 100644 --- a/vcl/unx/inc/wmadaptor.hxx +++ b/vcl/unx/inc/wmadaptor.hxx @@ -58,6 +58,8 @@ public: NET_WM_NAME, NET_WM_DESKTOP, NET_WM_ICON_NAME, + NET_WM_PID, + NET_WM_PING, NET_WM_STATE, NET_WM_STATE_MAXIMIZED_HORZ, NET_WM_STATE_MAXIMIZED_VERT, @@ -160,6 +162,7 @@ protected: m_aWMWorkAreas; bool m_bTransientBehaviour; bool m_bEnableAlwaysOnTopWorks; + bool m_bLegacyPartialFullscreen; int m_nWinGravity; int m_nInitWinGravity; @@ -220,6 +223,18 @@ public: virtual void setWMName( X11SalFrame* pFrame, const String& rWMName ) const; /* + * set NET_WM_PID + */ + virtual void setPID( X11SalFrame* pFrame ) const; + + /* + * set WM_CLIENT_MACHINE + */ + virtual void setClientMachine( X11SalFrame* pFrame ) const; + + virtual void answerPing( X11SalFrame*, XClientMessageEvent* ) const; + + /* * maximizes frame * maximization can be toggled in either direction * to get the original position and size @@ -231,6 +246,15 @@ public: */ virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const; /* + * tell whether legacy partial full screen handling is necessary + * see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto + * modern WM's interpret it the "right" way, namely they make "full screen" + * taking twin view or Xinerama into accound and honor the positioning hints + * to see which screen actually was meant to use for fullscreen. + */ + bool isLegacyPartialFullscreen() const + { return m_bLegacyPartialFullscreen; } + /* * set window struts */ virtual void setFrameStruts( X11SalFrame*pFrame, 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/saldata.cxx b/vcl/unx/source/app/saldata.cxx index 4155887a9875..75d18de0787a 100644 --- a/vcl/unx/source/app/saldata.cxx +++ b/vcl/unx/source/app/saldata.cxx @@ -276,6 +276,7 @@ X11SalData::X11SalData() m_pPlugin = NULL; hMainThread_ = pthread_self(); + osl_getLocalHostname( &maLocalHostName.pData ); } X11SalData::~X11SalData() diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index 97116626894e..aa2afab93657 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -322,12 +322,12 @@ sal_IsLocalDisplay( Display *pDisplay ) if( pPtr != NULL ) { - OUString aLocalHostname; - if( osl_getLocalHostname( &aLocalHostname.pData ) == osl_Socket_Ok) + const OUString& rLocalHostname( GetX11SalData()->GetLocalHostName() ); + if( rLocalHostname.getLength() ) { *pPtr = '\0'; OUString aDisplayHostname( pDisplayHost, strlen( pDisplayHost ), osl_getThreadTextEncoding() ); - bEqual = sal_EqualHosts( aLocalHostname, aDisplayHostname ); + bEqual = sal_EqualHosts( rLocalHostname, aDisplayHostname ); bEqual = bEqual && sal_IsDisplayNumber( pPtr + 1 ); } } @@ -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/app/wmadaptor.cxx b/vcl/unx/source/app/wmadaptor.cxx index 89c8bb56291c..fb2317e19573 100644 --- a/vcl/unx/source/app/wmadaptor.cxx +++ b/vcl/unx/source/app/wmadaptor.cxx @@ -34,6 +34,7 @@ #include <sal/alloca.h> #include <wmadaptor.hxx> #include <saldisp.hxx> +#include <saldata.hxx> #include <salframe.h> #include <vcl/salgdi.hxx> #include <osl/thread.h> @@ -118,6 +119,7 @@ static const WMAdaptorProtocol aProtocolTab[] = { "_NET_NUMBER_OF_DESKTOPS", WMAdaptor::NET_NUMBER_OF_DESKTOPS }, { "_NET_WM_DESKTOP", WMAdaptor::NET_WM_DESKTOP }, { "_NET_WM_ICON_NAME", WMAdaptor::NET_WM_ICON_NAME }, + { "_NET_WM_PING", WMAdaptor::NET_WM_PING }, { "_NET_WM_STATE", WMAdaptor::NET_WM_STATE }, { "_NET_WM_STATE_ABOVE", WMAdaptor::NET_WM_STATE_STAYS_ON_TOP }, { "_NET_WM_STATE_FULLSCREEN", WMAdaptor::NET_WM_STATE_FULLSCREEN }, @@ -179,7 +181,8 @@ static const WMAdaptorProtocol aAtomTab[] = { "_XSETTINGS_SETTINGS", WMAdaptor::XSETTINGS }, { "_XEMBED", WMAdaptor::XEMBED }, { "_XEMBED_INFO", WMAdaptor::XEMBED_INFO }, - { "_NET_WM_USER_TIME", WMAdaptor::NET_WM_USER_TIME } + { "_NET_WM_USER_TIME", WMAdaptor::NET_WM_USER_TIME }, + { "_NET_WM_PID", WMAdaptor::NET_WM_PID } }; extern "C" { @@ -233,6 +236,7 @@ WMAdaptor::WMAdaptor( SalDisplay* pDisplay ) : m_pSalDisplay( pDisplay ), m_bTransientBehaviour( true ), m_bEnableAlwaysOnTopWorks( false ), + m_bLegacyPartialFullscreen( false ), m_nWinGravity( StaticGravity ), m_nInitWinGravity( StaticGravity ) { @@ -909,6 +913,40 @@ bool WMAdaptor::getNetWmName() XFree( pProperty ); pProperty = NULL; } + // if this is metacity, check for version to enable a legacy workaround + if( m_aWMName.EqualsAscii( "Metacity" ) ) + { + int nVersionMajor = 0, nVersionMinor = 0; + Atom nVersionAtom = XInternAtom( m_pDisplay, "_METACITY_VERSION", True ); + if( nVersionAtom ) + { + if( XGetWindowProperty( m_pDisplay, + aWMChild, + nVersionAtom, + 0, 256, + False, + m_aWMAtoms[ UTF8_STRING ], + &aRealType, + &nFormat, + &nItems, + &nBytesLeft, + &pProperty ) == 0 + && nItems != 0 + ) + { + String aMetaVersion( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 ); + nVersionMajor = aMetaVersion.GetToken( 0, '.' ).ToInt32(); + nVersionMinor = aMetaVersion.GetToken( 1, '.' ).ToInt32(); + } + if( pProperty ) + { + XFree( pProperty ); + pProperty = NULL; + } + } + if( nVersionMajor < 2 || (nVersionMajor == 2 && nVersionMinor < 12) ) + m_bLegacyPartialFullscreen = true; + } } } else if( pProperty ) @@ -2412,3 +2450,52 @@ void NetWMAdaptor::setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const ); } } + +/* + * WMAdaptor::setPID + */ +void WMAdaptor::setPID( X11SalFrame* i_pFrame ) const +{ + if( m_aWMAtoms[NET_WM_PID] ) + { + long nPID = (long)getpid(); + XChangeProperty( m_pDisplay, + i_pFrame->GetShellWindow(), + m_aWMAtoms[NET_WM_PID], + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char*)&nPID, + 1 + ); + } +} + +/* +* WMAdaptor::setClientMachine +*/ +void WMAdaptor::setClientMachine( X11SalFrame* i_pFrame ) const +{ + rtl::OString aWmClient( rtl::OUStringToOString( GetX11SalData()->GetLocalHostName(), RTL_TEXTENCODING_ASCII_US ) ); + XTextProperty aClientProp = { (unsigned char*)aWmClient.getStr(), XA_STRING, 8, aWmClient.getLength() }; + XSetWMClientMachine( m_pDisplay, i_pFrame->GetShellWindow(), &aClientProp ); +} + +void WMAdaptor::answerPing( X11SalFrame* i_pFrame, XClientMessageEvent* i_pEvent ) const +{ + if( m_aWMAtoms[NET_WM_PING] && + i_pEvent->message_type == m_aWMAtoms[ WM_PROTOCOLS ] && + (Atom)i_pEvent->data.l[0] == m_aWMAtoms[ NET_WM_PING ] ) + { + XEvent aEvent; + aEvent.xclient = *i_pEvent; + aEvent.xclient.window = m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ); + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); + XFlush( m_pDisplay ); + } +} diff --git a/vcl/unx/source/fontmanager/fontconfig.cxx b/vcl/unx/source/fontmanager/fontconfig.cxx index 18d8a8d85a43..bc6de4fbc94a 100644 --- a/vcl/unx/source/fontmanager/fontconfig.cxx +++ b/vcl/unx/source/fontmanager/fontconfig.cxx @@ -643,7 +643,7 @@ namespace } } -int PrintFontManager::countFontconfigFonts() +int PrintFontManager::countFontconfigFonts( std::hash_map<rtl::OString, int, rtl::OStringHash>& o_rVisitedPaths ) { int nFonts = 0; @@ -704,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 ) ) { @@ -1183,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 7d5224707f72..93e3eef53ab3 100644 --- a/vcl/unx/source/fontmanager/fontmanager.cxx +++ b/vcl/unx/source/fontmanager/fontmanager.cxx @@ -2149,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 ) @@ -2163,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 ); 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/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index 0c1fcd7c77bd..f00ee26c0d4d 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -641,13 +641,11 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev mpServerFont[ nFallbackLevel ] = pServerFont; // apply font specific-hint settings if needed + // TODO: also disable it for reference devices 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 ); + ImplServerFontEntry* pSFE = static_cast<ImplServerFontEntry*>( pEntry->mpFontEntry ); + pSFE->HandleFontOptions(); } return true; @@ -656,6 +654,24 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev return false; } +void ImplServerFontEntry::HandleFontOptions( void ) +{ + bool GetFCFontOptions( const ImplFontAttributes&, int nSize, ImplFontOptions& ); + + if( !mpServerFont ) + return; + if( !mbGotFontOptions ) + { + // get and cache the font options + mbGotFontOptions = true; + mbValidFontOptions = GetFCFontOptions( *maFontSelData.mpFontData, + maFontSelData.mnHeight, maFontOptions ); + } + // apply the font options + if( mbValidFontOptions ) + mpServerFont->SetFontOptions( maFontOptions ); +} + //-------------------------------------------------------------------------- inline sal_Unicode SwapBytes( const sal_Unicode nIn ) @@ -1088,7 +1104,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 @@ -1633,11 +1649,13 @@ void X11SalGraphics::GetDevFontSubstList( OutputDevice* ) void cairosubcallback( void* pPattern ) { CairoWrapper& rCairo = CairoWrapper::get(); - if( rCairo.isValid() ) - { + if( !rCairo.isValid() ) + return; const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - rCairo.ft_font_options_substitute( rStyleSettings.GetCairoFontOptions(), pPattern); - } + const void* pFontOptions = rStyleSettings.GetCairoFontOptions(); + if( !pFontOptions ) + return; + rCairo.ft_font_options_substitute( pFontOptions, pPattern ); } bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, @@ -1664,7 +1682,6 @@ bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, default: aInfo.m_eItalic = psp::italic::Unknown; break; - } // set weight switch( rFontAttributes.GetWeight() ) @@ -1740,7 +1757,6 @@ bool GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize, const psp::PrintFontManager& rPFM = psp::PrintFontManager::get(); bool bOK = rPFM.getFontOptions( aInfo, nSize, cairosubcallback, rFontOptions); - return bOK; } 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/plugadapt/salplug.cxx b/vcl/unx/source/plugadapt/salplug.cxx index c42c22bc0592..a438760cffba 100644 --- a/vcl/unx/source/plugadapt/salplug.cxx +++ b/vcl/unx/source/plugadapt/salplug.cxx @@ -98,6 +98,14 @@ static SalInstance* tryInstance( const OUString& rModuleBase ) { pCloseModule = NULL; } + /* + * #i109007# KDE3 seems to have the same problem; an atexit cleanup + * handler, which cannot be resolved anymore if the plugin is already unloaded. + */ + else if( rModuleBase.equalsAscii("kde") ) + { + pCloseModule = NULL; + } GetSalData()->m_pPlugin = aMod; } 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/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx index 5b538626a634..6d243e41db8c 100644 --- a/vcl/unx/source/window/salframe.cxx +++ b/vcl/unx/source/window/salframe.cxx @@ -528,6 +528,8 @@ void X11SalFrame::Init( ULONG nSalFrameStyle, int nScreen, SystemParentData* pPa Atom a[4]; int n = 0; a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_DELETE_WINDOW ); + if( pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING ) ) + a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING ); if( ! s_pSaveYourselfFrame && ! mpParent) { // at all times have only one frame with SaveYourself @@ -549,11 +551,23 @@ void X11SalFrame::Init( ULONG nSalFrameStyle, int nScreen, SystemParentData* pPa pHints->win_gravity = GetDisplay()->getWMAdaptor()->getPositionWinGravity(); pHints->x = 0; pHints->y = 0; + if( mbFullScreen ) + { + pHints->flags |= PMaxSize | PMinSize; + pHints->max_width = w+100; + pHints->max_height = h+100; + pHints->min_width = w; + pHints->min_height = h; + } XSetWMNormalHints( GetXDisplay(), GetShellWindow(), pHints ); XFree (pHints); + // set PID and WM_CLIENT_MACHINE + pDisplay_->getWMAdaptor()->setClientMachine( this ); + pDisplay_->getWMAdaptor()->setPID( this ); + // set client leader if( aClientLeader ) { @@ -605,7 +619,8 @@ void X11SalFrame::Init( ULONG nSalFrameStyle, int nScreen, SystemParentData* pPa eType = WMAdaptor::windowType_Utility; if( nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION ) eType = WMAdaptor::windowType_Toolbar; - if( nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) + if( (nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN) + && GetDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) eType = WMAdaptor::windowType_Dock; GetDisplay()->getWMAdaptor()-> @@ -735,6 +750,8 @@ void X11SalFrame::passOnSaveYourSelf() int n = 0; a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_DELETE_WINDOW ); a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_SAVE_YOURSELF ); + if( pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING ) ) + a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING ); XSetWMProtocols( GetXDisplay(), s_pSaveYourselfFrame->GetShellWindow(), a, n ); } } @@ -1130,7 +1147,7 @@ void X11SalFrame::Show( BOOL bVisible, BOOL bNoActivate ) // even though transient frames should be kept above their parent // this does not necessarily hold true for DOCK type windows // so artificially set ABOVE and remove it again on hide - if( mpParent && (mpParent->nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) ) + if( mpParent && (mpParent->nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) && pDisplay_->getWMAdaptor()->isLegacyPartialFullscreen()) pDisplay_->getWMAdaptor()->enableAlwaysOnTop( this, bVisible ); bMapped_ = bVisible; @@ -1322,11 +1339,6 @@ void X11SalFrame::Show( BOOL bVisible, BOOL bNoActivate ) } else { -#if OSL_DEBUG_LEVEL > 1 - if( nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION ) - fprintf( stderr, "hide on ownerdraw\n" ); -#endif - if( getInputContext() ) getInputContext()->Unmap( this ); @@ -1616,6 +1628,7 @@ void X11SalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, USHOR } else SetPosSize( aPosSize ); + bDefaultPosition_ = False; } @@ -2042,6 +2055,12 @@ void X11SalFrame::SetPosSize( const Rectangle &rPosSize ) pHints->y = values.y; pHints->win_gravity = pDisplay_->getWMAdaptor()->getPositionWinGravity(); } + if( mbFullScreen ) + { + pHints->max_width = 10000; + pHints->max_height = 10000; + pHints->flags |= PMaxSize; + } XSetWMNormalHints( GetXDisplay(), GetShellWindow(), pHints ); @@ -2199,28 +2218,15 @@ void X11SalFrame::ShowFullScreen( BOOL bFullScreen, sal_Int32 nScreen ) maGeometry.nWidth = aRect.GetWidth(); maGeometry.nHeight = aRect.GetHeight(); mbMaximizedHorz = mbMaximizedVert = false; + mbFullScreen = true; createNewWindow( None, m_nScreen ); - GetDisplay()->getWMAdaptor()->enableAlwaysOnTop( this, true ); - #if 0 - // this would give additional intent to the window - // manager to force the positioning of the window; - // alas all other windows will be expunged from that - // region, leaving us in a pity state afterwards - Size aScreenSize = pDisplay_->GetScreenSize( m_nScreen ); - pDisplay_->getWMAdaptor()->setFrameStruts( this, - aRect.Left(), aRect.Top(), - aScreenSize.Width() - aRect.Right(), - aScreenSize.Height() - aRect.Bottom(), - aRect.Left(), aRect.Right(), - aRect.Top(), aRect.Bottom(), - aRect.Left(), aRect.Right(), - aRect.Top(), aRect.Bottom() - ); - #endif - + if( GetDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) + GetDisplay()->getWMAdaptor()->enableAlwaysOnTop( this, true ); + else + GetDisplay()->getWMAdaptor()->showFullScreen( this, true ); if( bVisible ) Show(TRUE); - mbFullScreen = true; + } else { @@ -3927,52 +3933,56 @@ long X11SalFrame::HandleClientMessage( XClientMessageEvent *pEvent ) Close(); // ??? return 1; } - else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::WM_PROTOCOLS ) - && ! ( nStyle_ & SAL_FRAME_STYLE_PLUG ) - && ! (( nStyle_ & SAL_FRAME_STYLE_FLOAT ) && (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION)) - ) + else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::WM_PROTOCOLS ) ) { - if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_DELETE_WINDOW ) ) - { - Close(); - return 1; - } - else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_TAKE_FOCUS ) ) - { - // do nothing, we set the input focus in ToTop() if necessary -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "got WM_TAKE_FOCUS on %s window\n", - (nStyle_&SAL_FRAME_STYLE_OWNERDRAWDECORATION) ? - "ownerdraw" : "NON OWNERDRAW" ); -#endif - } - else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_SAVE_YOURSELF ) ) + if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::NET_WM_PING ) ) + rWMAdaptor.answerPing( this, pEvent ); + else if( ! ( nStyle_ & SAL_FRAME_STYLE_PLUG ) + && ! (( nStyle_ & SAL_FRAME_STYLE_FLOAT ) && (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION)) + ) { - bool bSession = rWMAdaptor.getWindowManagerName().EqualsAscii( "Dtwm" ); - - if( ! bSession ) + if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_DELETE_WINDOW ) ) + { + Close(); + return 1; + } + else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_TAKE_FOCUS ) ) { - if( this == s_pSaveYourselfFrame ) + // do nothing, we set the input focus in ToTop() if necessary + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "got WM_TAKE_FOCUS on %s window\n", + (nStyle_&SAL_FRAME_STYLE_OWNERDRAWDECORATION) ? + "ownerdraw" : "NON OWNERDRAW" ); + #endif + } + else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_SAVE_YOURSELF ) ) + { + bool bSession = rWMAdaptor.getWindowManagerName().EqualsAscii( "Dtwm" ); + + if( ! bSession ) { - ByteString aExec( SessionManagerClient::getExecName(), osl_getThreadTextEncoding() ); - const char* argv[2]; - argv[0] = "/bin/sh"; - argv[1] = const_cast<char*>(aExec.GetBuffer()); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "SaveYourself request, setting command: %s %s\n", argv[0], argv[1] ); -#endif - XSetCommand( GetXDisplay(), GetShellWindow(), (char**)argv, 2 ); + if( this == s_pSaveYourselfFrame ) + { + ByteString aExec( SessionManagerClient::getExecName(), osl_getThreadTextEncoding() ); + const char* argv[2]; + argv[0] = "/bin/sh"; + argv[1] = const_cast<char*>(aExec.GetBuffer()); + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "SaveYourself request, setting command: %s %s\n", argv[0], argv[1] ); + #endif + XSetCommand( GetXDisplay(), GetShellWindow(), (char**)argv, 2 ); + } + else + // can only happen in race between WM and window closing + XChangeProperty( GetXDisplay(), GetShellWindow(), rWMAdaptor.getAtom( WMAdaptor::WM_COMMAND ), XA_STRING, 8, PropModeReplace, (unsigned char*)"", 0 ); } else - // can only happen in race between WM and window closing - XChangeProperty( GetXDisplay(), GetShellWindow(), rWMAdaptor.getAtom( WMAdaptor::WM_COMMAND ), XA_STRING, 8, PropModeReplace, (unsigned char*)"", 0 ); - } - else - { - // save open documents; would be good for non Dtwm, too, - // but there is no real Shutdown message in the ancient - // SM protocol; on Dtwm SaveYourself really means Shutdown, too. - IceSalSession::handleOldX11SaveYourself( this ); + { + // save open documents; would be good for non Dtwm, too, + // but there is no real Shutdown message in the ancient + // SM protocol; on Dtwm SaveYourself really means Shutdown, too. + IceSalSession::handleOldX11SaveYourself( this ); + } } } } 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 ebe470d3eb7e..1638c4e1bd36 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -47,11 +47,15 @@ #include "vcl/fontsubset.hxx" #include "vcl/sallayout.hxx" +#include "vcl/outdev.h" // for ImplGlyphFallbackFontSubstitution +#include "unotools/fontcfg.hxx" // for IMPL_FONT_ATTR_SYMBOL + #include "rtl/logfile.hxx" #include "rtl/tencinfo.h" #include "rtl/textcvt.h" #include "rtl/bootstrap.hxx" +#include "i18npool/mslangid.hxx" #include "osl/module.h" #include "osl/file.hxx" @@ -82,7 +86,6 @@ #include <set> #include <map> - using namespace vcl; static const int MAXFONTHEIGHT = 2048; @@ -314,6 +317,308 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) } } +// =========================================================================== +// platform specific font substitution hooks for glyph fallback enhancement +// TODO: move into i18n module (maybe merge with svx/ucsubset.* +// or merge with i18nutil/source/utility/unicode_data.h) +struct Unicode2LangType +{ + sal_UCS4 mnMinCode; + sal_UCS4 mnMaxCode; + LanguageType mnLangID; +}; + +// entries marked with default-CJK get replaced with the default-CJK language +#define LANGUAGE_DEFAULT_CJK 0xFFF0 + +// map unicode ranges to languages supported by OOo +// NOTE: due to the binary search used this list must be sorted by mnMinCode +static Unicode2LangType aLangFromCodeChart[]= { + {0x0000, 0x007F, LANGUAGE_ENGLISH}, // Basic Latin + {0x0080, 0x024F, LANGUAGE_ENGLISH}, // Latin Extended-A and Latin Extended-B + {0x0250, 0x02AF, LANGUAGE_SYSTEM}, // IPA Extensions + {0x0370, 0x03FF, LANGUAGE_GREEK}, // Greek + {0x0590, 0x05FF, LANGUAGE_HEBREW}, // Hebrew + {0x0600, 0x06FF, LANGUAGE_ARABIC_PRIMARY_ONLY}, // Arabic + {0x0900, 0x097F, LANGUAGE_HINDI}, // Devanagari + {0x0980, 0x09FF, LANGUAGE_BENGALI}, // Bengali + {0x0A80, 0x0AFF, LANGUAGE_GUJARATI}, // Gujarati + {0x0B00, 0x0B7F, LANGUAGE_ORIYA}, // Oriya + {0x0B80, 0x0BFF, LANGUAGE_TAMIL}, // Tamil + {0x0C00, 0x0C7F, LANGUAGE_TELUGU}, // Telugu + {0x0C80, 0x0CFF, LANGUAGE_KANNADA}, // Kannada + {0x0D00, 0x0D7F, LANGUAGE_MALAYALAM}, // Malayalam + {0x0D80, 0x0D7F, LANGUAGE_SINHALESE_SRI_LANKA}, // Sinhala + {0x0E00, 0x0E7F, LANGUAGE_THAI}, // Thai + {0x0E80, 0x0EFF, LANGUAGE_LAO}, // Lao + {0x0F00, 0x0FFF, LANGUAGE_TIBETAN}, // Tibetan + {0x1000, 0x109F, LANGUAGE_BURMESE}, // Burmese + {0x10A0, 0x10FF, LANGUAGE_GEORGIAN}, // Georgian + {0x1100, 0x11FF, LANGUAGE_KOREAN}, // Hangul Jamo, Korean-specific +// {0x1200, 0x139F, LANGUAGE_AMHARIC_ETHIOPIA}, // Ethiopic +// {0x1200, 0x139F, LANGUAGE_TIGRIGNA_ETHIOPIA}, // Ethiopic + {0x13A0, 0x13FF, LANGUAGE_CHEROKEE_UNITED_STATES}, // Cherokee +// {0x1400, 0x167F, LANGUAGE_CANADIAN_ABORIGINAL}, // Canadian Aboriginial Syllabics +// {0x1680, 0x169F, LANGUAGE_OGHAM}, // Ogham +// {0x16A0, 0x16F0, LANGUAGE_RUNIC}, // Runic +// {0x1700, 0x171F, LANGUAGE_TAGALOG}, // Tagalog +// {0x1720, 0x173F, LANGUAGE_HANUNOO}, // Hanunoo +// {0x1740, 0x175F, LANGUAGE_BUHID}, // Buhid +// {0x1760, 0x177F, LANGUAGE_TAGBANWA}, // Tagbanwa + {0x1780, 0x17FF, LANGUAGE_KHMER}, // Khmer + {0x18A0, 0x18AF, LANGUAGE_MONGOLIAN}, // Mongolian +// {0x1900, 0x194F, LANGUAGE_LIMBU}, // Limbu +// {0x1950, 0x197F, LANGUAGE_TAILE}, // Tai Le +// {0x1980, 0x19DF, LANGUAGE_TAILUE}, // Tai Lue + {0x19E0, 0x19FF, LANGUAGE_KHMER}, // Khmer Symbols +// {0x1A00, 0x1A1F, LANGUAGE_BUGINESE}, // Buginese/Lontara +// {0x1B00, 0x1B7F, LANGUAGE_BALINESE}, // Balinese +// {0x1D00, 0x1DFF, LANGUAGE_NONE}, // Phonetic Symbols + {0x1E00, 0x1EFF, LANGUAGE_ENGLISH}, // Latin Extended Additional + {0x1F00, 0x1FFF, LANGUAGE_GREEK}, // Greek Extended + {0x2C60, 0x2C7F, LANGUAGE_ENGLISH}, // Latin Extended-C + {0x2E80, 0x2FFf, LANGUAGE_CHINESE_SIMPLIFIED}, // CJK Radicals Supplement + Kangxi Radical + Ideographic Description Characters + {0x3000, 0x303F, LANGUAGE_DEFAULT_CJK}, // CJK Symbols and punctuation + {0x3040, 0x30FF, LANGUAGE_JAPANESE}, // Japanese Hiragana + Katakana + {0x3100, 0x312F, LANGUAGE_CHINESE_TRADITIONAL}, // Bopomofo + {0x3130, 0x318F, LANGUAGE_KOREAN}, // Hangul Compatibility Jamo, Kocrean-specific + {0x3190, 0x319F, LANGUAGE_JAPANESE}, // Kanbun + {0x31A0, 0x31BF, LANGUAGE_CHINESE_TRADITIONAL}, // Bopomofo Extended + {0x31C0, 0x31EF, LANGUAGE_DEFAULT_CJK}, // CJK Ideographs + {0x31F0, 0x31FF, LANGUAGE_JAPANESE}, // Japanese Katakana Phonetic Extensions + {0x3200, 0x321F, LANGUAGE_KOREAN}, // Parenthesized Hangul + {0x3220, 0x325F, LANGUAGE_DEFAULT_CJK}, // Parenthesized Ideographs + {0x3260, 0x327F, LANGUAGE_KOREAN}, // Circled Hangul + {0x3280, 0x32CF, LANGUAGE_DEFAULT_CJK}, // Circled Ideographs + {0x32d0, 0x32FF, LANGUAGE_JAPANESE}, // Japanese Circled Katakana + {0x3400, 0x4DBF, LANGUAGE_DEFAULT_CJK}, // CJK Unified Ideographs Extension A + {0x4E00, 0x9FCF, LANGUAGE_DEFAULT_CJK}, // Unified CJK Ideographs + {0xA720, 0xA7FF, LANGUAGE_ENGLISH}, // Latin Extended-D + {0xAC00, 0xD7AF, LANGUAGE_KOREAN}, // Hangul Syllables, Korean-specific + {0xF900, 0xFAFF, LANGUAGE_DEFAULT_CJK}, // CJK Compatibility Ideographs + {0xFB00, 0xFB4F, LANGUAGE_HEBREW}, // Hebrew Presentation Forms + {0xFB50, 0xFDFF, LANGUAGE_ARABIC_PRIMARY_ONLY}, // Arabic Presentation Forms-A + {0xFE70, 0xFEFE, LANGUAGE_ARABIC_PRIMARY_ONLY}, // Arabic Presentation Forms-B + {0xFF65, 0xFF9F, LANGUAGE_JAPANESE}, // Japanese Halfwidth Katakana variant + {0xFFA0, 0xFFDC, LANGUAGE_KOREAN}, // Kocrean halfwidth hangual variant + {0x10140, 0x1018F, LANGUAGE_GREEK}, // Ancient Greak numbers + {0x1D200, 0x1D24F, LANGUAGE_GREEK}, // Ancient Greek Musical + {0x20000, 0x2A6DF, LANGUAGE_DEFAULT_CJK}, // CJK Unified Ideographs Extension B + {0x2F800, 0x2FA1F, LANGUAGE_DEFAULT_CJK} // CJK Compatibility Ideographs Supplement +}; + +// get language matching to the missing char +LanguageType MapCharToLanguage( sal_UCS4 uChar ) +{ + // entries marked with default-CJK get replaced with the prefered CJK language + static bool bFirst = true; + if( bFirst ) + { + bFirst = false; + + // use method suggested in #i97086# to determnine the systems default language + // TODO: move into i18npool or sal/osl/w32/nlsupport.c + LanguageType nDefaultLang = 0; + HKEY hKey = NULL; + LONG lResult = ::RegOpenKeyExA( HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Nls\\Language", + 0, KEY_QUERY_VALUE, &hKey ); + char aKeyValBuf[16]; + DWORD nKeyValSize = sizeof(aKeyValBuf); + if( ERROR_SUCCESS == lResult ) + lResult = RegQueryValueExA( hKey, "Default", NULL, NULL, (LPBYTE)aKeyValBuf, &nKeyValSize ); + aKeyValBuf[ sizeof(aKeyValBuf)-1 ] = '\0'; + if( ERROR_SUCCESS == lResult ) + nDefaultLang = (LanguageType)rtl_str_toInt32( aKeyValBuf, 16 ); + + // TODO: use the default-CJK language selected in + // Tools->Options->LangSettings->Languages when it becomes available here + if( !nDefaultLang ) + nDefaultLang = Application::GetSettings().GetUILanguage(); + + LanguageType nDefaultCJK = LANGUAGE_CHINESE; + switch( nDefaultLang ) + { + case LANGUAGE_JAPANESE: + case LANGUAGE_KOREAN: + case LANGUAGE_KOREAN_JOHAB: + case LANGUAGE_CHINESE_SIMPLIFIED: + case LANGUAGE_CHINESE_TRADITIONAL: + case LANGUAGE_CHINESE_SINGAPORE: + case LANGUAGE_CHINESE_HONGKONG: + case LANGUAGE_CHINESE_MACAU: + nDefaultCJK = nDefaultLang; + break; + default: + nDefaultCJK = LANGUAGE_CHINESE; + break; + } + + // change the marked entries to prefered language + static const int nCount = (sizeof(aLangFromCodeChart) / sizeof(*aLangFromCodeChart)); + for( int i = 0; i < nCount; ++i ) + { + if( aLangFromCodeChart[ i].mnLangID == LANGUAGE_DEFAULT_CJK ) + aLangFromCodeChart[ i].mnLangID = nDefaultCJK; + } + } + + // binary search + int nLow = 0; + int nHigh = (sizeof(aLangFromCodeChart) / sizeof(*aLangFromCodeChart)) - 1; + while( nLow <= nHigh ) + { + int nMiddle = (nHigh + nLow) / 2; + if( uChar < aLangFromCodeChart[ nMiddle].mnMinCode ) + nHigh = nMiddle - 1; + else if( uChar > aLangFromCodeChart[ nMiddle].mnMaxCode ) + nLow = nMiddle + 1; + else + return aLangFromCodeChart[ nMiddle].mnLangID; + } + + return LANGUAGE_DONTKNOW; +} + +class WinGlyphFallbackSubstititution +: public ImplGlyphFallbackFontSubstitution +{ +public: + explicit WinGlyphFallbackSubstititution( HDC ); + + bool FindFontSubstitute( ImplFontSelectData&, rtl::OUString& rMissingChars ) const; +private: + HDC mhDC; + bool HasMissingChars( const ImplFontData*, const rtl::OUString& rMissingChars ) const; +}; + +inline WinGlyphFallbackSubstititution::WinGlyphFallbackSubstititution( HDC hDC ) +: mhDC( hDC ) +{} + +void ImplGetLogFontFromFontSelect( HDC, const ImplFontSelectData*, + LOGFONTW&, bool /*bTestVerticalAvail*/ ); + +// does a font face hold the given missing characters? +bool WinGlyphFallbackSubstititution::HasMissingChars( const ImplFontData* pFace, const rtl::OUString& rMissingChars ) const +{ + const ImplWinFontData* pWinFont = static_cast<const ImplWinFontData*>(pFace); + const ImplFontCharMap* pCharMap = pWinFont->GetImplFontCharMap(); + if( !pCharMap ) + { + // construct a Size structure as the parameter of constructor of class ImplFontSelectData + const Size aSize( pFace->GetWidth(), pFace->GetHeight() ); + // create a ImplFontSelectData object for getting s LOGFONT + const ImplFontSelectData aFSD( *pFace, aSize, (float)aSize.Height(), 0, false ); + // construct log font + LOGFONTW aLogFont; + ImplGetLogFontFromFontSelect( mhDC, &aFSD, aLogFont, true ); + + // create HFONT from log font + HFONT hNewFont = ::CreateFontIndirectW( &aLogFont ); + // select the new font into device + HFONT hOldFont = ::SelectFont( mhDC, hNewFont ); + + // read CMAP table to update their pCharMap + pWinFont->UpdateFromHDC( mhDC );; + + // cleanup temporary font + ::SelectFont( mhDC, hOldFont ); + ::DeleteFont( hNewFont ); + + // get the new charmap + pCharMap = pWinFont->GetImplFontCharMap(); + } + + // avoid fonts with unknown CMAP subtables for glyph fallback + if( !pCharMap || pCharMap->IsDefaultMap() ) + return false; + + int nMatchCount = 0; + // static const int nMaxMatchCount = 1; // TODO: check more missing characters? + const sal_Int32 nStrLen = rMissingChars.getLength(); + for( sal_Int32 nStrIdx = 0; nStrIdx < nStrLen; ++nStrIdx ) + { + const sal_UCS4 uChar = rMissingChars.iterateCodePoints( &nStrIdx ); + nMatchCount += pCharMap->HasChar( uChar ); + break; // for now + } + + const bool bHasMatches = (nMatchCount > 0); + return bHasMatches; +} + +// find a fallback font for missing characters +// TODO: should stylistic matches be searched and prefered? +bool WinGlyphFallbackSubstititution::FindFontSubstitute( ImplFontSelectData& rFontSelData, rtl::OUString& rMissingChars ) const +{ + // guess a locale matching to the missing chars + com::sun::star::lang::Locale aLocale; + + sal_Int32 nStrIdx = 0; + const sal_Int32 nStrLen = rMissingChars.getLength(); + while( nStrIdx < nStrLen ) + { + const sal_UCS4 uChar = rMissingChars.iterateCodePoints( &nStrIdx ); + const LanguageType eLang = MapCharToLanguage( uChar ); + if( eLang == LANGUAGE_DONTKNOW ) + continue; + MsLangId::convertLanguageToLocale( eLang, aLocale ); + break; + } + + // fall back to default UI locale if the missing characters are inconclusive + if( nStrIdx >= nStrLen ) + aLocale = Application::GetSettings().GetUILocale(); + + // first level fallback: + // try use the locale specific default fonts defined in VCL.xcu + const ImplDevFontList* pDevFontList = ImplGetSVData()->maGDIData.mpScreenFontList; + /*const*/ ImplDevFontListData* pDevFont = pDevFontList->ImplFindByLocale( aLocale ); + if( pDevFont ) + { + const ImplFontData* pFace = pDevFont->FindBestFontFace( rFontSelData ); + if( HasMissingChars( pFace, rMissingChars ) ) + { + rFontSelData.maSearchName = pDevFont->GetSearchName(); + return true; + } + } + + // are the missing characters symbols? + pDevFont = pDevFontList->ImplFindByAttributes( IMPL_FONT_ATTR_SYMBOL, + rFontSelData.meWeight, rFontSelData.meWidthType, + rFontSelData.meFamily, rFontSelData.meItalic, rFontSelData.maSearchName ); + if( pDevFont ) + { + const ImplFontData* pFace = pDevFont->FindBestFontFace( rFontSelData ); + if( HasMissingChars( pFace, rMissingChars ) ) + { + rFontSelData.maSearchName = pDevFont->GetSearchName(); + return true; + } + } + + // last level fallback, check each font type face one by one + const ImplGetDevFontList* pTestFontList = pDevFontList->GetDevFontList(); + // limit the count of fonts to be checked to prevent hangs + static const int MAX_GFBFONT_COUNT = 600; + int nTestFontCount = pTestFontList->Count(); + if( nTestFontCount > MAX_GFBFONT_COUNT ) + nTestFontCount = MAX_GFBFONT_COUNT; + + for( int i = 0; i < nTestFontCount; ++i ) + { + const ImplFontData* pFace = pTestFontList->Get( i ); + if( !HasMissingChars( pFace, rMissingChars ) ) + continue; + rFontSelData.maSearchName = pFace->maName; + return true; + } + + return false; +} + // ======================================================================= struct ImplEnumInfo @@ -903,6 +1208,8 @@ bool ImplWinFontData::IsGSUBstituted( sal_UCS4 cChar ) const ImplFontCharMap* ImplWinFontData::GetImplFontCharMap() const { + if( !mpUnicodeMap ) + return NULL; mpUnicodeMap->AddReference(); return mpUnicodeMap; } @@ -2237,6 +2544,10 @@ void WinSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) bImplSalCourierScalable = aInfo.mbImplSalCourierScalable; bImplSalCourierNew = aInfo.mbImplSalCourierNew; } + + // set glyph fallback hook + static WinGlyphFallbackSubstititution aSubstFallback( mhDC ); + pFontList->SetFallbackHook( &aSubstFallback ); } // ---------------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index f95f42d6bf4d..d1f11433d532 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -291,6 +291,14 @@ 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; + case CTRL_LISTNODE: + if( nPart == PART_ENTIRE_CONTROL ) + hTheme = getThemeHandle( mhWnd, L"TreeView" ); + break; default: hTheme = NULL; break; @@ -890,6 +898,59 @@ 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 ); + } + + if( nType == CTRL_LISTNODE ) + { + if( nPart != PART_ENTIRE_CONTROL ) + return FALSE; + + ButtonValue aButtonValue = aValue.getTristateVal(); + iPart = TVP_GLYPH; + switch( aButtonValue ) + { + case BUTTONVALUE_ON: + iState = GLPS_OPENED; + break; + case BUTTONVALUE_OFF: + iState = GLPS_CLOSED; + break; + default: + return FALSE; + } + return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption ); + } + return false; } @@ -970,6 +1031,14 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, if( nPart == PART_ENTIRE_CONTROL ) hTheme = getThemeHandle( mhWnd, L"Progress"); break; + case CTRL_LISTNODE: + if( nPart == PART_ENTIRE_CONTROL ) + hTheme = getThemeHandle( mhWnd, L"TreeView"); + 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 +1175,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 +1230,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 -------------------------------------------------------- |