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>
25 #include <cppuhelper/queryinterface.hxx>
27 #include <vcl/svapp.hxx>
32 VCLXRegion::VCLXRegion()
36 VCLXRegion::~VCLXRegion()
40 // ::com::sun::star::uno::XInterface
41 ::com::sun::star::uno::Any
VCLXRegion::queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
43 ::com::sun::star::uno::Any aRet
= ::cppu::queryInterface( rType
,
44 (static_cast< ::com::sun::star::awt::XRegion
* >(this)),
45 (static_cast< ::com::sun::star::lang::XUnoTunnel
* >(this)),
46 (static_cast< ::com::sun::star::lang::XTypeProvider
* >(this)) );
47 return (aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
));
50 // ::com::sun::star::lang::XUnoTunnel
51 IMPL_XUNOTUNNEL( VCLXRegion
)
53 // ::com::sun::star::lang::XTypeProvider
54 IMPL_XTYPEPROVIDER_START( VCLXRegion
)
55 cppu::UnoType
<com::sun::star::awt::XRegion
>::get()
56 IMPL_XTYPEPROVIDER_END
60 ::com::sun::star::awt::Rectangle
VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
62 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
64 return AWTRectangle( maRegion
.GetBoundRect() );
67 void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
69 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
74 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
76 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
78 maRegion
.Move( nHorzMove
, nVertMove
);
81 void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
83 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
85 maRegion
.Union( VCLRectangle( rRect
) );
88 void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
90 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
92 maRegion
.Intersect( VCLRectangle( rRect
) );
95 void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
97 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
99 maRegion
.Exclude( VCLRectangle( rRect
) );
102 void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle
& rRect
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
104 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
106 maRegion
.XOr( VCLRectangle( rRect
) );
109 void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
111 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
114 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
117 void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
119 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
122 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
125 void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
127 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
130 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
133 void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XRegion
>& rxRegion
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
135 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
138 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
141 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
143 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
145 RectangleVector aRectangles
;
146 maRegion
.GetRegionRectangles(aRectangles
);
148 // sal_uLong nRects = maRegion.GetRectCount();
149 ::com::sun::star::uno::Sequence
< ::com::sun::star::awt::Rectangle
> aRects(aRectangles
.size());
152 for(RectangleVector::const_iterator
aRectIter(aRectangles
.begin()); aRectIter
!= aRectangles
.end(); ++aRectIter
)
154 aRects
.getArray()[a
++] = AWTRectangle(*aRectIter
);
159 //RegionHandle h = maRegion.BeginEnumRects();
160 //while ( maRegion.GetEnumRects( h, aRect ) )
161 // aRects.getArray()[nR++] = AWTRectangle( aRect );
162 //maRegion.EndEnumRects( h );
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */