Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <toolkit/awt/vclxregion.hxx>
30 : : #include <toolkit/helper/macros.hxx>
31 : : #include <toolkit/helper/vclunohelper.hxx>
32 : : #include <toolkit/helper/convert.hxx>
33 : : #include <cppuhelper/typeprovider.hxx>
34 : : #include <rtl/memory.h>
35 : : #include <rtl/uuid.h>
36 : : #include <vcl/svapp.hxx>
37 : :
38 : : // ----------------------------------------------------
39 : : // class VCLXRegion
40 : : // ----------------------------------------------------
41 [ + - ][ + - ]: 2 : VCLXRegion::VCLXRegion()
42 : : {
43 : 2 : }
44 : :
45 [ + - ][ + - ]: 2 : VCLXRegion::~VCLXRegion()
[ + - ]
46 : : {
47 [ - + ]: 4 : }
48 : :
49 : : // ::com::sun::star::uno::XInterface
50 : 2 : ::com::sun::star::uno::Any VCLXRegion::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
51 : : {
52 : : ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
53 : : (static_cast< ::com::sun::star::awt::XRegion* >(this)),
54 : : (static_cast< ::com::sun::star::lang::XUnoTunnel* >(this)),
55 [ + - ]: 2 : (static_cast< ::com::sun::star::lang::XTypeProvider* >(this)) );
56 [ - + ][ + - ]: 2 : return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
57 : : }
58 : :
59 : : // ::com::sun::star::lang::XUnoTunnel
60 [ # # ][ # # ]: 0 : IMPL_XUNOTUNNEL( VCLXRegion )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
61 : :
62 : : // ::com::sun::star::lang::XTypeProvider
63 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_START( VCLXRegion )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
64 [ # # ]: 0 : getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion>* ) NULL )
65 [ # # ][ # # ]: 0 : IMPL_XTYPEPROVIDER_END
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
66 : :
67 : :
68 : :
69 : 0 : ::com::sun::star::awt::Rectangle VCLXRegion::getBounds() throw(::com::sun::star::uno::RuntimeException)
70 : : {
71 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
72 : :
73 [ # # ][ # # ]: 0 : return AWTRectangle( maRegion.GetBoundRect() );
[ # # ]
74 : : }
75 : :
76 : 0 : void VCLXRegion::clear() throw(::com::sun::star::uno::RuntimeException)
77 : : {
78 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
79 : :
80 [ # # ][ # # ]: 0 : maRegion.SetEmpty();
81 : 0 : }
82 : :
83 : 0 : void VCLXRegion::move( sal_Int32 nHorzMove, sal_Int32 nVertMove ) throw(::com::sun::star::uno::RuntimeException)
84 : : {
85 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
86 : :
87 [ # # ][ # # ]: 0 : maRegion.Move( nHorzMove, nVertMove );
88 : 0 : }
89 : :
90 : 0 : void VCLXRegion::unionRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
91 : : {
92 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
93 : :
94 [ # # ][ # # ]: 0 : maRegion.Union( VCLRectangle( rRect ) );
[ # # ]
95 : 0 : }
96 : :
97 : 0 : void VCLXRegion::intersectRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
98 : : {
99 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
100 : :
101 [ # # ][ # # ]: 0 : maRegion.Intersect( VCLRectangle( rRect ) );
[ # # ]
102 : 0 : }
103 : :
104 : 0 : void VCLXRegion::excludeRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
105 : : {
106 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
107 : :
108 [ # # ][ # # ]: 0 : maRegion.Exclude( VCLRectangle( rRect ) );
[ # # ]
109 : 0 : }
110 : :
111 : 0 : void VCLXRegion::xOrRectangle( const ::com::sun::star::awt::Rectangle& rRect ) throw(::com::sun::star::uno::RuntimeException)
112 : : {
113 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
114 : :
115 [ # # ][ # # ]: 0 : maRegion.XOr( VCLRectangle( rRect ) );
[ # # ]
116 : 0 : }
117 : :
118 : 0 : void VCLXRegion::unionRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
119 : : {
120 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
121 : :
122 [ # # ]: 0 : if ( rxRegion.is() )
123 [ # # ][ # # ]: 0 : maRegion.Union( VCLUnoHelper::GetRegion( rxRegion ) );
[ # # ][ # # ]
124 : 0 : }
125 : :
126 : 0 : void VCLXRegion::intersectRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
127 : : {
128 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
129 : :
130 [ # # ]: 0 : if ( rxRegion.is() )
131 [ # # ][ # # ]: 0 : maRegion.Intersect( VCLUnoHelper::GetRegion( rxRegion ) );
[ # # ][ # # ]
132 : 0 : }
133 : :
134 : 0 : void VCLXRegion::excludeRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
135 : : {
136 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
137 : :
138 [ # # ]: 0 : if ( rxRegion.is() )
139 [ # # ][ # # ]: 0 : maRegion.Exclude( VCLUnoHelper::GetRegion( rxRegion ) );
[ # # ][ # # ]
140 : 0 : }
141 : :
142 : 0 : void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) throw(::com::sun::star::uno::RuntimeException)
143 : : {
144 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
145 : :
146 [ # # ]: 0 : if ( rxRegion.is() )
147 [ # # ][ # # ]: 0 : maRegion.XOr( VCLUnoHelper::GetRegion( rxRegion ) );
[ # # ][ # # ]
148 : 0 : }
149 : :
150 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > VCLXRegion::getRectangles() throw(::com::sun::star::uno::RuntimeException)
151 : : {
152 [ # # ]: 0 : ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
153 : :
154 [ # # ]: 0 : sal_uLong nRects = maRegion.GetRectCount();
155 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects( nRects );
156 : :
157 [ # # ]: 0 : Rectangle aRect;
158 : 0 : sal_uInt32 nR = 0;
159 [ # # ]: 0 : RegionHandle h = maRegion.BeginEnumRects();
160 [ # # ][ # # ]: 0 : while ( maRegion.GetNextEnumRect( h, aRect ) )
161 [ # # ][ # # ]: 0 : aRects.getArray()[nR++] = AWTRectangle( aRect );
162 [ # # ]: 0 : maRegion.EndEnumRects( h );
163 : :
164 [ # # ]: 0 : return aRects;
165 : : }
166 : :
167 : :
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|