1b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b0724fc6SAndrew Rist * distributed with this work for additional information
6b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance
9b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at
10b0724fc6SAndrew Rist *
11b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b0724fc6SAndrew Rist *
13b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b0724fc6SAndrew Rist * software distributed under the License is distributed on an
15b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the
17b0724fc6SAndrew Rist * specific language governing permissions and limitations
18b0724fc6SAndrew Rist * under the License.
19b0724fc6SAndrew Rist *
20b0724fc6SAndrew Rist *************************************************************/
21b0724fc6SAndrew Rist
22b0724fc6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <toolkit/awt/vclxregion.hxx>
29cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
30cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
31cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
32cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
33cdf0e10cSrcweir #include <rtl/memory.h>
34cdf0e10cSrcweir #include <rtl/uuid.h>
35cdf0e10cSrcweir #include <vcl/svapp.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir // ----------------------------------------------------
38cdf0e10cSrcweir // class VCLXRegion
39cdf0e10cSrcweir // ----------------------------------------------------
VCLXRegion()40cdf0e10cSrcweir VCLXRegion::VCLXRegion()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir
~VCLXRegion()44cdf0e10cSrcweir VCLXRegion::~VCLXRegion()
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir
48cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)49cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXRegion::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
52cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XRegion*, this ),
53cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
54cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
55cdf0e10cSrcweir return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel
59cdf0e10cSrcweir IMPL_XUNOTUNNEL( VCLXRegion )
60cdf0e10cSrcweir
61cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START(VCLXRegion)62cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXRegion )
63cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion>* ) NULL )
64cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
65cdf0e10cSrcweir
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir ::com::sun::star::awt::Rectangle VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
71cdf0e10cSrcweir
72cdf0e10cSrcweir return AWTRectangle( maRegion.GetBoundRect() );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
clear()75cdf0e10cSrcweir void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
78cdf0e10cSrcweir
79cdf0e10cSrcweir maRegion.SetEmpty();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
move(sal_Int32 nHorzMove,sal_Int32 nVertMove)82cdf0e10cSrcweir void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) throw(::com::sun::star::uno::RuntimeException)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
85cdf0e10cSrcweir
86cdf0e10cSrcweir maRegion.Move( nHorzMove, nVertMove );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
unionRectangle(const::com::sun::star::awt::Rectangle & rRect)89cdf0e10cSrcweir void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
92cdf0e10cSrcweir
93cdf0e10cSrcweir maRegion.Union( VCLRectangle( rRect ) );
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
intersectRectangle(const::com::sun::star::awt::Rectangle & rRect)96cdf0e10cSrcweir void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
99cdf0e10cSrcweir
100cdf0e10cSrcweir maRegion.Intersect( VCLRectangle( rRect ) );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
excludeRectangle(const::com::sun::star::awt::Rectangle & rRect)103cdf0e10cSrcweir void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
106cdf0e10cSrcweir
107cdf0e10cSrcweir maRegion.Exclude( VCLRectangle( rRect ) );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
xOrRectangle(const::com::sun::star::awt::Rectangle & rRect)110cdf0e10cSrcweir void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
113cdf0e10cSrcweir
114cdf0e10cSrcweir maRegion.XOr( VCLRectangle( rRect ) );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
unionRegion(const::com::sun::star::uno::Reference<::com::sun::star::awt::XRegion> & rxRegion)117cdf0e10cSrcweir void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
120cdf0e10cSrcweir
121cdf0e10cSrcweir if ( rxRegion.is() )
122cdf0e10cSrcweir maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
intersectRegion(const::com::sun::star::uno::Reference<::com::sun::star::awt::XRegion> & rxRegion)125cdf0e10cSrcweir void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
128cdf0e10cSrcweir
129cdf0e10cSrcweir if ( rxRegion.is() )
130cdf0e10cSrcweir maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
excludeRegion(const::com::sun::star::uno::Reference<::com::sun::star::awt::XRegion> & rxRegion)133cdf0e10cSrcweir void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
136cdf0e10cSrcweir
137cdf0e10cSrcweir if ( rxRegion.is() )
138cdf0e10cSrcweir maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
xOrRegion(const::com::sun::star::uno::Reference<::com::sun::star::awt::XRegion> & rxRegion)141cdf0e10cSrcweir void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
144cdf0e10cSrcweir
145cdf0e10cSrcweir if ( rxRegion.is() )
146cdf0e10cSrcweir maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
getRectangles()149cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
152cdf0e10cSrcweir
153*e6f63103SArmin Le Grand RectangleVector aRectangles;
154*e6f63103SArmin Le Grand maRegion.GetRegionRectangles(aRectangles);
155*e6f63103SArmin Le Grand
156*e6f63103SArmin Le Grand // sal_uLong nRects = maRegion.GetRectCount();
157*e6f63103SArmin Le Grand ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects(aRectangles.size());
158*e6f63103SArmin Le Grand sal_uInt32 a(0);
159*e6f63103SArmin Le Grand
160*e6f63103SArmin Le Grand for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
161*e6f63103SArmin Le Grand {
162*e6f63103SArmin Le Grand aRects.getArray()[a++] = AWTRectangle(*aRectIter);
163*e6f63103SArmin Le Grand }
164*e6f63103SArmin Le Grand
165*e6f63103SArmin Le Grand //Rectangle aRect;
166*e6f63103SArmin Le Grand //sal_uInt32 nR = 0;
167*e6f63103SArmin Le Grand //RegionHandle h = maRegion.BeginEnumRects();
168*e6f63103SArmin Le Grand //while ( maRegion.GetEnumRects( h, aRect ) )
169*e6f63103SArmin Le Grand // aRects.getArray()[nR++] = AWTRectangle( aRect );
170*e6f63103SArmin Le Grand //maRegion.EndEnumRects( h );
171cdf0e10cSrcweir
172cdf0e10cSrcweir return aRects;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176cdf0e10cSrcweir
177