Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / toolkit / source / awt / vclxregion.cxx
blobe7b6d9da4d922a39cba1776bb528b74dc4c9a6ba
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 <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>
26 #include <rtl/uuid.h>
27 #include <vcl/svapp.hxx>
30 // class VCLXRegion
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 // 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()
61 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
63 return AWTRectangle( maRegion.GetBoundRect() );
66 void VCLXRegion::clear()
68 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
70 maRegion.SetEmpty();
73 void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove )
75 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
77 maRegion.Move( nHorzMove, nVertMove );
80 void VCLXRegion::unionRectangle( const css::awt::Rectangle& rRect )
82 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
84 maRegion.Union( VCLRectangle( rRect ) );
87 void VCLXRegion::intersectRectangle( const css::awt::Rectangle& rRect )
89 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
91 maRegion.Intersect( VCLRectangle( rRect ) );
94 void VCLXRegion::excludeRectangle( const css::awt::Rectangle& rRect )
96 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
98 maRegion.Exclude( VCLRectangle( rRect ) );
101 void VCLXRegion::xOrRectangle( const css::awt::Rectangle& rRect )
103 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
105 maRegion.XOr( VCLRectangle( rRect ) );
108 void VCLXRegion::unionRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
110 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
112 if ( rxRegion.is() )
113 maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
116 void VCLXRegion::intersectRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
118 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
120 if ( rxRegion.is() )
121 maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
124 void VCLXRegion::excludeRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
126 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
128 if ( rxRegion.is() )
129 maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
132 void VCLXRegion::xOrRegion( const css::uno::Reference< css::awt::XRegion >& rxRegion )
134 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
136 if ( rxRegion.is() )
137 maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
140 css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles()
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());
149 sal_uInt32 a(0);
151 for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
153 aRects.getArray()[a++] = AWTRectangle(*aRectIter);
156 //Rectangle aRect;
157 //sal_uInt32 nR = 0;
158 //RegionHandle h = maRegion.BeginEnumRects();
159 //while ( maRegion.GetEnumRects( h, aRect ) )
160 // aRects.getArray()[nR++] = AWTRectangle( aRect );
161 //maRegion.EndEnumRects( h );
163 return aRects;
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */