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
)
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 IMPL_IMPLEMENTATION_ID( VCLXRegion
)
55 // css::lang::XTypeProvider
56 css::uno::Sequence
< css::uno::Type
> VCLXRegion::getTypes()
58 static const css::uno::Sequence
< css::uno::Type
> aTypeList
{
59 cppu::UnoType
<css::lang::XTypeProvider
>::get(),
60 cppu::UnoType
<css::awt::XRegion
>::get()
66 css::awt::Rectangle
VCLXRegion::getBounds()
68 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
70 return AWTRectangle( maRegion
.GetBoundRect() );
73 void VCLXRegion::clear()
75 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
80 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
)
82 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
84 maRegion
.Move( nHorzMove
, nVertMove
);
87 void VCLXRegion::unionRectangle( const css::awt::Rectangle
& rRect
)
89 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
91 maRegion
.Union( VCLRectangle( rRect
) );
94 void VCLXRegion::intersectRectangle( const css::awt::Rectangle
& rRect
)
96 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
98 maRegion
.Intersect( VCLRectangle( rRect
) );
101 void VCLXRegion::excludeRectangle( const css::awt::Rectangle
& rRect
)
103 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
105 maRegion
.Exclude( VCLRectangle( rRect
) );
108 void VCLXRegion::xOrRectangle( const css::awt::Rectangle
& rRect
)
110 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
112 maRegion
.XOr( VCLRectangle( rRect
) );
115 void VCLXRegion::unionRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
117 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
120 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
123 void VCLXRegion::intersectRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
125 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
128 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
131 void VCLXRegion::excludeRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
133 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
136 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
139 void VCLXRegion::xOrRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
141 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
144 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
147 css::uno::Sequence
< css::awt::Rectangle
> VCLXRegion::getRectangles()
149 ::osl::Guard
< ::osl::Mutex
> aGuard( GetMutex() );
151 RectangleVector aRectangles
;
152 maRegion
.GetRegionRectangles(aRectangles
);
154 // sal_uLong nRects = maRegion.GetRectCount();
155 css::uno::Sequence
< css::awt::Rectangle
> aRects(aRectangles
.size());
158 for(const auto& rRect
: aRectangles
)
160 aRects
.getArray()[a
++] = AWTRectangle(rRect
);
165 //RegionHandle h = maRegion.BeginEnumRects();
166 //while ( maRegion.GetEnumRects( h, aRect ) )
167 // aRects.getArray()[nR++] = AWTRectangle( aRect );
168 //maRegion.EndEnumRects( h );
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */