Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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 <rtl/uuid.h>
26 : #include <vcl/svapp.hxx>
27 :
28 :
29 : // class VCLXRegion
30 :
31 0 : VCLXRegion::VCLXRegion()
32 : {
33 0 : }
34 :
35 0 : VCLXRegion::~VCLXRegion()
36 : {
37 0 : }
38 :
39 : // ::com::sun::star::uno::XInterface
40 0 : ::com::sun::star::uno::Any VCLXRegion::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
41 : {
42 : ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
43 : (static_cast< ::com::sun::star::awt::XRegion* >(this)),
44 : (static_cast< ::com::sun::star::lang::XUnoTunnel* >(this)),
45 0 : (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
46 0 : return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
47 : }
48 :
49 : // ::com::sun::star::lang::XUnoTunnel
50 0 : IMPL_XUNOTUNNEL( VCLXRegion )
51 :
52 : // ::com::sun::star::lang::XTypeProvider
53 0 : IMPL_XTYPEPROVIDER_START( VCLXRegion )
54 0 : getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion>* ) NULL )
55 0 : IMPL_XTYPEPROVIDER_END
56 :
57 :
58 :
59 0 : ::com::sun::star::awt::Rectangle VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException, std::exception)
60 : {
61 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
62 :
63 0 : return AWTRectangle( maRegion.GetBoundRect() );
64 : }
65 :
66 0 : void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException, std::exception)
67 : {
68 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
69 :
70 0 : maRegion.SetEmpty();
71 0 : }
72 :
73 0 : void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) throw(::com::sun::star::uno::RuntimeException, std::exception)
74 : {
75 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
76 :
77 0 : maRegion.Move( nHorzMove, nVertMove );
78 0 : }
79 :
80 0 : void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
81 : {
82 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
83 :
84 0 : maRegion.Union( VCLRectangle( rRect ) );
85 0 : }
86 :
87 0 : void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
88 : {
89 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
90 :
91 0 : maRegion.Intersect( VCLRectangle( rRect ) );
92 0 : }
93 :
94 0 : void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
95 : {
96 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
97 :
98 0 : maRegion.Exclude( VCLRectangle( rRect ) );
99 0 : }
100 :
101 0 : void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException, std::exception)
102 : {
103 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
104 :
105 0 : maRegion.XOr( VCLRectangle( rRect ) );
106 0 : }
107 :
108 0 : void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException, std::exception)
109 : {
110 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
111 :
112 0 : if ( rxRegion.is() )
113 0 : maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
114 0 : }
115 :
116 0 : void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException, std::exception)
117 : {
118 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
119 :
120 0 : if ( rxRegion.is() )
121 0 : maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
122 0 : }
123 :
124 0 : void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException, std::exception)
125 : {
126 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
127 :
128 0 : if ( rxRegion.is() )
129 0 : maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
130 0 : }
131 :
132 0 : void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException, std::exception)
133 : {
134 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
135 :
136 0 : if ( rxRegion.is() )
137 0 : maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
138 0 : }
139 :
140 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException, std::exception)
141 : {
142 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
143 :
144 0 : RectangleVector aRectangles;
145 0 : maRegion.GetRegionRectangles(aRectangles);
146 :
147 : // sal_uLong nRects = maRegion.GetRectCount();
148 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects(aRectangles.size());
149 0 : sal_uInt32 a(0);
150 :
151 0 : for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
152 : {
153 0 : aRects.getArray()[a++] = AWTRectangle(*aRectIter);
154 : }
155 :
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 );
162 :
163 0 : return aRects;
164 : }
165 :
166 :
167 :
168 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|