/************************************************************************* * * $RCSfile: canvastools.cxx,v $ * * $Revision: 1.2 $ * * last change: $Author: rt $ $Date: 2004-11-26 18:40:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library 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 for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALSIZE2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALPOINT2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALRECTANGLE2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_REALBEZIERSEGMENT2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_AFFINEMATRIX2D_HPP_ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_INTEGERSIZE2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_INTEGERPOINT2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_GEOMETRY_INTEGERRECTANGLE2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XPOLYPOLYGON2D_HPP__ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XGRAPHICDEVICE_HPP__ #include #endif #ifndef _COM_SUN_STAR_AWT_SIZE_HPP__ #include #endif #ifndef _COM_SUN_STAR_AWT_POINT_HPP__ #include #endif #ifndef _COM_SUN_STAR_AWT_RECTANGLE_HPP__ #include #endif #include #include #include #include #include #include #include #include #include #include #include using namespace ::drafts::com::sun::star; using namespace ::com::sun::star; namespace basegfx { namespace unotools { namespace { uno::Sequence< geometry::RealBezierSegment2D > bezierSequenceFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly ) { const sal_uInt32 nNumPoints( rPoly.count() ); uno::Sequence< geometry::RealBezierSegment2D > outputSequence( nNumPoints ); // fill sequence from polygon sal_uInt32 i; for( i=0; i pointSequenceFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly ) { const sal_uInt32 nNumPoints( rPoly.count() ); uno::Sequence< geometry::RealPoint2D > outputSequence( nNumPoints ); // fill sequence from polygon sal_uInt32 i; for( i=0; i xPolyPolygonFromB2DPolygon( const uno::Reference< rendering::XGraphicDevice >& xGraphicDevice, const ::basegfx::B2DPolygon& rPoly ) { uno::Reference< rendering::XPolyPolygon2D > xRes; if( !xGraphicDevice.is() ) return xRes; if( rPoly.areControlPointsUsed() ) { uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( 1 ); outputSequence[0] = bezierSequenceFromB2DPolygon( rPoly ); xRes.set( xGraphicDevice->createCompatibleBezierPolyPolygon( outputSequence ), uno::UNO_QUERY ); } else { uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( 1 ); outputSequence[0] = pointSequenceFromB2DPolygon( rPoly ); xRes.set( xGraphicDevice->createCompatibleLinePolyPolygon( outputSequence ), uno::UNO_QUERY ); } if( xRes.is() && rPoly.isClosed() ) xRes->setClosed( 0, sal_True ); return xRes; } //--------------------------------------------------------------------------------------- uno::Reference< rendering::XPolyPolygon2D > xPolyPolygonFromB2DPolyPolygon( const uno::Reference< rendering::XGraphicDevice >& xGraphicDevice, const ::basegfx::B2DPolyPolygon& rPolyPoly ) { uno::Reference< rendering::XPolyPolygon2D > xRes; if( !xGraphicDevice.is() ) return xRes; const sal_uInt32 nNumPolies( rPolyPoly.count() ); sal_uInt32 i; if( rPolyPoly.areControlPointsUsed() ) { uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( nNumPolies ); for( i=0; icreateCompatibleBezierPolyPolygon( outputSequence ), uno::UNO_QUERY ); } else { uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( nNumPolies ); for( i=0; icreateCompatibleLinePolyPolygon( outputSequence ), uno::UNO_QUERY ); } for( i=0; isetClosed( i, sal_True ); } return xRes; } //--------------------------------------------------------------------------------------- ::basegfx::B2DPolygon polygonFromPoint2DSequence( const uno::Sequence< geometry::RealPoint2D >& points ) { const sal_Int32 nCurrSize( points.getLength() ); ::basegfx::B2DPolygon aPoly; for( sal_Int32 nCurrPoint=0; nCurrPoint >& points ) { ::basegfx::B2DPolyPolygon aRes; for( sal_Int32 nCurrPoly=0; nCurrPoly& curves ) { const sal_Int32 nSize( curves.getLength() ); ::basegfx::B2DPolygon aPoly; for( sal_Int32 nCurrPoint=0; nCurrPoint >& curves ) { ::basegfx::B2DPolyPolygon aRes; for( sal_Int32 nCurrPoly=0; nCurrPoly::max() && rRect.getWidth() > ::std::numeric_limits< sal_Int32 >::min(), "awtRectangleFromB2IRectangle(): width overflow" ); OSL_ENSURE( rRect.getHeight() < ::std::numeric_limits< sal_Int32 >::max() && rRect.getHeight() > ::std::numeric_limits< sal_Int32 >::min(), "awtRectangleFromB2IRectangle(): height overflow" ); return awt::Rectangle( rRect.getMinX(), rRect.getMinY(), static_cast< sal_Int32 >(rRect.getWidth()), static_cast< sal_Int32 >(rRect.getHeight()) ); } ::basegfx::B2IVector b2ISizeFromAwtSize( const awt::Size& rSize ) { return ::basegfx::B2IVector( rSize.Width, rSize.Height ); } ::basegfx::B2IPoint b2IPointFromAwtPoint( const awt::Point& rPoint ) { return ::basegfx::B2IPoint( rPoint.X, rPoint.Y ); } ::basegfx::B2IRange b2IRectangleFromAwtRectangle( const awt::Rectangle& rRect ) { return ::basegfx::B2IRange( rRect.X, rRect.Y, rRect.X + rRect.Width, rRect.Y + rRect.Height ); } } // namespace bgfxtools } // namespace canvas