1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
31 #include <toolkit/awt/vclxregion.hxx>
32 #include <toolkit/helper/macros.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <toolkit/helper/convert.hxx>
35 #include <cppuhelper/typeprovider.hxx>
36 #include <rtl/memory.h>
38 #include <vcl/svapp.hxx>
40 // ----------------------------------------------------
42 // ----------------------------------------------------
43 VCLXRegion::VCLXRegion()
47 VCLXRegion::~VCLXRegion()
51 // ::com::sun::star::uno::XInterface
52 ::com::sun::star::uno::Any
VCLXRegion::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
54 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
55 (static_cast< ::com::sun::star::awt::XRegion
* >(this)),
56 (static_cast< ::com::sun::star::lang::XUnoTunnel
* >(this)),
57 (static_cast< ::com::sun::star::lang::XTypeProvider
* >(this)) );
58 return (aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
));
61 // ::com::sun::star::lang::XUnoTunnel
62 IMPL_XUNOTUNNEL( VCLXRegion
)
64 // ::com::sun::star::lang::XTypeProvider
65 IMPL_XTYPEPROVIDER_START( VCLXRegion
)
66 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>* ) NULL
)
67 IMPL_XTYPEPROVIDER_END
71 ::com::sun::star::awt::Rectangle
VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException
)
73 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
75 return AWTRectangle( maRegion
.GetBoundRect() );
78 void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException
)
80 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
85 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
) throw(::com::sun::star::uno::RuntimeException
)
87 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
89 maRegion
.Move( nHorzMove
, nVertMove
);
92 void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
94 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
96 maRegion
.Union( VCLRectangle( rRect
) );
99 void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
101 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
103 maRegion
.Intersect( VCLRectangle( rRect
) );
106 void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
108 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
110 maRegion
.Exclude( VCLRectangle( rRect
) );
113 void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
115 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
117 maRegion
.XOr( VCLRectangle( rRect
) );
120 void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
122 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
125 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
128 void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
130 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
133 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
136 void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
138 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
141 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
144 void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
146 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
149 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
152 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException
)
154 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
156 sal_uLong nRects
= maRegion
.GetRectCount();
157 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> aRects( nRects
);
161 RegionHandle h
= maRegion
.BeginEnumRects();
162 while ( maRegion
.GetNextEnumRect( h
, aRect
) )
163 aRects
.getArray()[nR
++] = AWTRectangle( aRect
);
164 maRegion
.EndEnumRects( h
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */