1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <toolkit/awt/vclxregion.hxx>
21 #include <toolkit/helper/macros.hxx>
22 #include <toolkit/helper/vclunohelper.hxx>
23 #include <toolkit/helper/convert.hxx>
24 #include <cppuhelper/typeprovider.hxx>
26 #include <vcl/svapp.hxx>
28 // ----------------------------------------------------
30 // ----------------------------------------------------
31 VCLXRegion::VCLXRegion()
35 VCLXRegion::~VCLXRegion()
39 // ::com::sun::star::uno::XInterface
40 ::com::sun::star::uno::Any
VCLXRegion::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
42 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
43 (static_cast< ::com::sun::star::awt::XRegion
* >(this)),
44 (static_cast< ::com::sun::star::lang::XUnoTunnel
* >(this)),
45 (static_cast< ::com::sun::star::lang::XTypeProvider
* >(this)) );
46 return (aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
));
49 // ::com::sun::star::lang::XUnoTunnel
50 IMPL_XUNOTUNNEL( VCLXRegion
)
52 // ::com::sun::star::lang::XTypeProvider
53 IMPL_XTYPEPROVIDER_START( VCLXRegion
)
54 getCppuType( ( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>* ) NULL
)
55 IMPL_XTYPEPROVIDER_END
59 ::com::sun::star::awt::Rectangle
VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException
)
61 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
63 return AWTRectangle( maRegion
.GetBoundRect() );
66 void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException
)
68 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
73 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
) throw(::com::sun::star::uno::RuntimeException
)
75 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
77 maRegion
.Move( nHorzMove
, nVertMove
);
80 void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
82 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
84 maRegion
.Union( VCLRectangle( rRect
) );
87 void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
89 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
91 maRegion
.Intersect( VCLRectangle( rRect
) );
94 void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
96 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
98 maRegion
.Exclude( VCLRectangle( rRect
) );
101 void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
)
103 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
105 maRegion
.XOr( VCLRectangle( rRect
) );
108 void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
110 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
113 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
116 void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
)
118 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
121 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
124 void VCLXRegion::excludeRegion( 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() );
129 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
132 void VCLXRegion::xOrRegion( 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() );
137 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
140 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException
)
142 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
144 sal_uLong nRects
= maRegion
.GetRectCount();
145 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> aRects( nRects
);
149 RegionHandle h
= maRegion
.BeginEnumRects();
150 while ( maRegion
.GetNextEnumRect( h
, aRect
) )
151 aRects
.getArray()[nR
++] = AWTRectangle( aRect
);
152 maRegion
.EndEnumRects( h
);
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */