update dev300-m58
[ooovba.git] / toolkit / source / awt / vclxregion.cxx
blob35cd4f388e963a1cba414afe964217086b2dd926
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxregion.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
35 #include <toolkit/awt/vclxregion.hxx>
36 #include <toolkit/helper/macros.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <toolkit/helper/convert.hxx>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <rtl/memory.h>
41 #include <rtl/uuid.h>
42 #include <vcl/svapp.hxx>
44 // ----------------------------------------------------
45 // class VCLXRegion
46 // ----------------------------------------------------
47 VCLXRegion::VCLXRegion()
51 VCLXRegion::~VCLXRegion()
55 // ::com::sun::star::uno::XInterface
56 ::com::sun::star::uno::Any VCLXRegion::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
58 ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
59 SAL_STATIC_CAST( ::com::sun::star::awt::XRegion*, this ),
60 SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
61 SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
62 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
65 // ::com::sun::star::lang::XUnoTunnel
66 IMPL_XUNOTUNNEL( VCLXRegion )
68 // ::com::sun::star::lang::XTypeProvider
69 IMPL_XTYPEPROVIDER_START( VCLXRegion )
70 getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion>* ) NULL )
71 IMPL_XTYPEPROVIDER_END
75 ::com::sun::star::awt::Rectangle VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException)
77 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
79 return AWTRectangle( maRegion.GetBoundRect() );
82 void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException)
84 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
86 maRegion.SetEmpty();
89 void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) throw(::com::sun::star::uno::RuntimeException)
91 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
93 maRegion.Move( nHorzMove, nVertMove );
96 void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
98 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
100 maRegion.Union( VCLRectangle( rRect ) );
103 void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
105 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
107 maRegion.Intersect( VCLRectangle( rRect ) );
110 void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
112 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
114 maRegion.Exclude( VCLRectangle( rRect ) );
117 void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
119 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
121 maRegion.XOr( VCLRectangle( rRect ) );
124 void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
126 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
128 if ( rxRegion.is() )
129 maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
132 void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
134 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
136 if ( rxRegion.is() )
137 maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
140 void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
142 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
144 if ( rxRegion.is() )
145 maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
148 void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
150 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
152 if ( rxRegion.is() )
153 maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
156 ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException)
158 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
160 ULONG nRects = maRegion.GetRectCount();
161 ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects( nRects );
163 Rectangle aRect;
164 sal_uInt32 nR = 0;
165 RegionHandle h = maRegion.BeginEnumRects();
166 while ( maRegion.GetNextEnumRect( h, aRect ) )
167 aRects.getArray()[nR++] = AWTRectangle( aRect );
168 maRegion.EndEnumRects( h );
170 return aRects;