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 <awt/vclxregion.hxx>
21 #include <toolkit/helper/vclunohelper.hxx>
22 #include <toolkit/helper/convert.hxx>
26 VCLXRegion::VCLXRegion()
30 VCLXRegion::~VCLXRegion()
34 css::awt::Rectangle
VCLXRegion::getBounds()
36 std::scoped_lock
aGuard( maMutex
);
38 return AWTRectangle( maRegion
.GetBoundRect() );
41 void VCLXRegion::clear()
43 std::scoped_lock
aGuard( maMutex
);
48 void VCLXRegion::move( sal_Int32 nHorzMove
, sal_Int32 nVertMove
)
50 std::scoped_lock
aGuard( maMutex
);
52 maRegion
.Move( nHorzMove
, nVertMove
);
55 void VCLXRegion::unionRectangle( const css::awt::Rectangle
& rRect
)
57 std::scoped_lock
aGuard( maMutex
);
59 maRegion
.Union( VCLRectangle( rRect
) );
62 void VCLXRegion::intersectRectangle( const css::awt::Rectangle
& rRect
)
64 std::scoped_lock
aGuard( maMutex
);
66 maRegion
.Intersect( VCLRectangle( rRect
) );
69 void VCLXRegion::excludeRectangle( const css::awt::Rectangle
& rRect
)
71 std::scoped_lock
aGuard( maMutex
);
73 maRegion
.Exclude( VCLRectangle( rRect
) );
76 void VCLXRegion::xOrRectangle( const css::awt::Rectangle
& rRect
)
78 std::scoped_lock
aGuard( maMutex
);
80 maRegion
.XOr( VCLRectangle( rRect
) );
83 void VCLXRegion::unionRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
85 std::scoped_lock
aGuard( maMutex
);
88 maRegion
.Union( VCLUnoHelper::GetRegion( rxRegion
) );
91 void VCLXRegion::intersectRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
93 std::scoped_lock
aGuard( maMutex
);
96 maRegion
.Intersect( VCLUnoHelper::GetRegion( rxRegion
) );
99 void VCLXRegion::excludeRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
101 std::scoped_lock
aGuard( maMutex
);
104 maRegion
.Exclude( VCLUnoHelper::GetRegion( rxRegion
) );
107 void VCLXRegion::xOrRegion( const css::uno::Reference
< css::awt::XRegion
>& rxRegion
)
109 std::scoped_lock
aGuard( maMutex
);
112 maRegion
.XOr( VCLUnoHelper::GetRegion( rxRegion
) );
115 css::uno::Sequence
< css::awt::Rectangle
> VCLXRegion::getRectangles()
117 std::scoped_lock
aGuard( maMutex
);
119 RectangleVector aRectangles
;
120 maRegion
.GetRegionRectangles(aRectangles
);
122 // sal_uLong nRects = maRegion.GetRectCount();
123 css::uno::Sequence
< css::awt::Rectangle
> aRects(aRectangles
.size());
126 for(const auto& rRect
: aRectangles
)
128 aRects
.getArray()[a
++] = AWTRectangle(rRect
);
133 //RegionHandle h = maRegion.BeginEnumRects();
134 //while ( maRegion.GetEnumRects( h, aRect ) )
135 // aRects.getArray()[nR++] = AWTRectangle( aRect );
136 //maRegion.EndEnumRects( h );
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */