Update git submodules
[LibreOffice.git] / toolkit / source / awt / vclxregion.cxx
blobc30538b27695ee3d3e166a70bb18f3030b4c59ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <awt/vclxregion.hxx>
21 #include <toolkit/helper/vclunohelper.hxx>
22 #include <vcl/unohelp.hxx>
25 VCLXRegion::VCLXRegion()
29 VCLXRegion::~VCLXRegion()
33 css::awt::Rectangle VCLXRegion::getBounds()
35 std::scoped_lock aGuard( maMutex );
37 return vcl::unohelper::ConvertToAWTRect(maRegion.GetBoundRect());
40 void VCLXRegion::clear()
42 std::scoped_lock aGuard( maMutex );
44 maRegion.SetEmpty();
47 void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove )
49 std::scoped_lock aGuard( maMutex );
51 maRegion.Move( nHorzMove, nVertMove );
54 void VCLXRegion::unionRectangle( const css::awt::Rectangle& rRect )
56 std::scoped_lock aGuard( maMutex );
58 maRegion.Union(vcl::unohelper::ConvertToVCLRect(rRect));
61 void VCLXRegion::intersectRectangle( const css::awt::Rectangle& rRect )
63 std::scoped_lock aGuard( maMutex );
65 maRegion.Intersect(vcl::unohelper::ConvertToVCLRect(rRect));
68 void VCLXRegion::excludeRectangle( const css::awt::Rectangle& rRect )
70 std::scoped_lock aGuard( maMutex );
72 maRegion.Exclude(vcl::unohelper::ConvertToVCLRect(rRect));
75 void VCLXRegion::xOrRectangle( const css::awt::Rectangle& rRect )
77 std::scoped_lock aGuard( maMutex );
79 maRegion.XOr(vcl::unohelper::ConvertToVCLRect(rRect));
82 void VCLXRegion::unionRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
84 std::scoped_lock aGuard( maMutex );
86 if ( rxRegion.is() )
87 maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
90 void VCLXRegion::intersectRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
92 std::scoped_lock aGuard( maMutex );
94 if ( rxRegion.is() )
95 maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
98 void VCLXRegion::excludeRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
100 std::scoped_lock aGuard( maMutex );
102 if ( rxRegion.is() )
103 maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
106 void VCLXRegion::xOrRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
108 std::scoped_lock aGuard( maMutex );
110 if ( rxRegion.is() )
111 maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
114 css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles()
116 std::scoped_lock aGuard( maMutex );
118 RectangleVector aRectangles;
119 maRegion.GetRegionRectangles(aRectangles);
121 // sal_uLong nRects = maRegion.GetRectCount();
122 css::uno::Sequence< css::awt::Rectangle > aRects(aRectangles.size());
123 sal_uInt32 a(0);
125 for(const auto& rRect : aRectangles)
127 aRects.getArray()[a++] = vcl::unohelper::ConvertToAWTRect(rRect);
130 //Rectangle aRect;
131 //sal_uInt32 nR = 0;
132 //RegionHandle h = maRegion.BeginEnumRects();
133 //while ( maRegion.GetEnumRects( h, aRect ) )
134 // aRects.getArray()[nR++] = vcl::unohelper::ConvertToAWTRect( aRect );
135 //maRegion.EndEnumRects( h );
137 return aRects;
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */