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 // css::uno::XInterface
41 css::uno::Any
VCLXRegion::queryInterface( const css::uno::Type
& rType
) throw(css::uno::RuntimeException
, std::exception
)
43 css::uno::Any aRet
= ::cppu::queryInterface( rType
,
44 (static_cast< css::awt::XRegion
* >(this)),
45 (static_cast< css::lang::XUnoTunnel
* >(this)),
46 (static_cast< css::lang::XTypeProvider
* >(this)) );
47 return (aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
));
50 // css::lang::XUnoTunnel
51 IMPL_XUNOTUNNEL( VCLXRegion
)
53 // css::lang::XTypeProvider
54 IMPL_XTYPEPROVIDER_START( VCLXRegion
)
55 cppu::UnoType
<css::awt::XRegion
>::get()
56 IMPL_XTYPEPROVIDER_END
59 css::awt::Rectangle
VCLXRegion::getBounds() throw(css::uno::RuntimeException
, std::exception
)
61 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
63 return AWTRectangle( maRegion
.GetBoundRect() );
66 void VCLXRegion::clear() throw(css::uno::RuntimeException
, std::exception
)
68 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
73 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
) throw(css::uno::RuntimeException
, std::exception
)
75 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
77 maRegion
.Move( nHorzMove
, nVertMove
);
80 void VCLXRegion::unionRectangle( const css::awt::Rectangle
& rRect
) throw(css::uno::RuntimeException
, std::exception
)
82 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
84 maRegion
.Union( VCLRectangle( rRect
) );
87 void VCLXRegion::intersectRectangle( const css::awt::Rectangle
& rRect
) throw(css::uno::RuntimeException
, std::exception
)
89 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
91 maRegion
.Intersect( VCLRectangle( rRect
) );
94 void VCLXRegion::excludeRectangle( const css::awt::Rectangle
& rRect
) throw(css::uno::RuntimeException
, std::exception
)
96 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
98 maRegion
.Exclude( VCLRectangle( rRect
) );
101 void VCLXRegion::xOrRectangle( const css::awt::Rectangle
& rRect
) throw(css::uno::RuntimeException
, std::exception
)
103 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
105 maRegion
.XOr( VCLRectangle( rRect
) );
108 void VCLXRegion::unionRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
) throw(css::uno::RuntimeException
, std::exception
)
110 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
113 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
116 void VCLXRegion::intersectRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
) throw(css::uno::RuntimeException
, std::exception
)
118 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
121 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
124 void VCLXRegion::excludeRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
) throw(css::uno::RuntimeException
, std::exception
)
126 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
129 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
132 void VCLXRegion::xOrRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
) throw(css::uno::RuntimeException
, std::exception
)
134 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
137 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
140 css::uno::Sequence
< css::awt::Rectangle
> VCLXRegion::getRectangles() throw(css::uno::RuntimeException
, std::exception
)
142 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
144 RectangleVector aRectangles
;
145 maRegion
.GetRegionRectangles(aRectangles
);
147 // sal_uLong nRects = maRegion.GetRectCount();
148 css::uno::Sequence
< css::awt::Rectangle
> aRects(aRectangles
.size());
151 for(RectangleVector::const_iterator
aRectIter(aRectangles
.begin()); aRectIter
!= aRectangles
.end(); ++aRectIter
)
153 aRects
.getArray()[a
++] = AWTRectangle(*aRectIter
);
158 //RegionHandle h = maRegion.BeginEnumRects();
159 //while ( maRegion.GetEnumRects( h, aRect ) )
160 // aRects.getArray()[nR++] = AWTRectangle( aRect );
161 //maRegion.EndEnumRects( h );
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */