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 <com/sun/star/embed/XHatchWindowController.hpp>
30 : :
31 : : #include "hatchwindow.hxx"
32 : : #include "ipwin.hxx"
33 : :
34 : : #include <toolkit/helper/convert.hxx>
35 : : #include <osl/mutex.hxx>
36 : : #include <vcl/svapp.hxx>
37 : :
38 : : using namespace ::com::sun::star;
39 : :
40 : 2 : VCLXHatchWindow::VCLXHatchWindow()
41 : : : VCLXWindow()
42 [ + - ]: 2 : , pHatchWindow(0)
43 : : {
44 : 2 : }
45 : :
46 [ + - ]: 2 : VCLXHatchWindow::~VCLXHatchWindow()
47 : : {
48 [ - + ]: 4 : }
49 : :
50 : 2 : void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
51 : : const awt::Rectangle& aBounds,
52 : : const awt::Size& aSize )
53 : : {
54 [ + - ]: 2 : SolarMutexGuard aGuard;
55 : :
56 : 2 : Window* pParent = NULL;
57 : 2 : VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent );
58 : :
59 [ + - ]: 2 : if ( pParentComponent )
60 : 2 : pParent = pParentComponent->GetWindow();
61 : :
62 : : OSL_ENSURE( pParent, "No parent window is provided!\n" );
63 [ - + ]: 2 : if ( !pParent )
64 [ # # ]: 0 : throw lang::IllegalArgumentException(); // TODO
65 : :
66 [ + - ][ + - ]: 2 : pHatchWindow = new SvResizeWindow( pParent, this );
67 [ + - ]: 2 : pHatchWindow->SetPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
68 : 2 : aHatchBorderSize = aSize;
69 [ + - ]: 2 : pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
70 : :
71 [ + - ]: 2 : SetWindow( pHatchWindow );
72 [ + - ][ + - ]: 2 : pHatchWindow->SetComponentInterface( this );
[ + - ]
73 : :
74 : : //pHatchWindow->Show();
75 : 2 : }
76 : :
77 : 0 : void VCLXHatchWindow::QueryObjAreaPixel( Rectangle & aRect )
78 : : {
79 [ # # ]: 0 : if ( m_xController.is() )
80 : : {
81 [ # # ]: 0 : awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
82 : :
83 : : try {
84 [ # # ][ # # ]: 0 : awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect );
85 [ # # ]: 0 : aRect = VCLRectangle( aUnoResultRect );
86 : : }
87 [ # # ]: 0 : catch( uno::Exception& )
88 : : {
89 : : OSL_FAIL( "Can't adjust rectangle size!\n" );
90 : : }
91 : : }
92 [ # # ]: 0 : }
93 : :
94 : 0 : void VCLXHatchWindow::RequestObjAreaPixel( const Rectangle & aRect )
95 : : {
96 [ # # ]: 0 : if ( m_xController.is() )
97 : : {
98 [ # # ]: 0 : awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
99 : :
100 : : try {
101 [ # # ][ # # ]: 0 : m_xController->requestPositioning( aUnoRequestRect );
102 : : }
103 [ # # ]: 0 : catch( uno::Exception& )
104 : : {
105 : : OSL_FAIL( "Can't request resizing!\n" );
106 : : }
107 : : }
108 [ # # ]: 0 : }
109 : :
110 : 0 : void VCLXHatchWindow::InplaceDeactivate()
111 : : {
112 : 0 : if ( m_xController.is() )
113 : : {
114 : : // TODO: communicate with controller
115 : : }
116 : 0 : }
117 : :
118 : :
119 : 16 : uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType )
120 : : throw( uno::RuntimeException )
121 : : {
122 : : // Attention:
123 : : // Don't use mutex or guard in this method!!! Is a method of XInterface.
124 : :
125 : : uno::Any aReturn( ::cppu::queryInterface( rType,
126 [ + - ]: 16 : static_cast< embed::XHatchWindow* >( this ) ) );
127 : :
128 [ + + ]: 16 : if ( aReturn.hasValue() == sal_True )
129 : : {
130 : 4 : return aReturn ;
131 : : }
132 : :
133 [ + - ]: 16 : return VCLXWindow::queryInterface( rType ) ;
134 : : }
135 : :
136 : 76 : void SAL_CALL VCLXHatchWindow::acquire()
137 : : throw()
138 : : {
139 : 76 : VCLXWindow::acquire();
140 : 76 : }
141 : :
142 : 76 : void SAL_CALL VCLXHatchWindow::release()
143 : : throw()
144 : : {
145 : 76 : VCLXWindow::release();
146 : 76 : }
147 : :
148 : 0 : uno::Sequence< uno::Type > SAL_CALL VCLXHatchWindow::getTypes()
149 : : throw( uno::RuntimeException )
150 : : {
151 : : static ::cppu::OTypeCollection* pTypeCollection = NULL ;
152 : :
153 [ # # ]: 0 : if ( pTypeCollection == NULL )
154 : : {
155 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
156 : :
157 [ # # ]: 0 : if ( pTypeCollection == NULL )
158 : : {
159 : : static ::cppu::OTypeCollection aTypeCollection(
160 [ # # ]: 0 : ::getCppuType(( const uno::Reference< embed::XHatchWindow >* )NULL ),
161 [ # # ][ # # ]: 0 : VCLXHatchWindow::getTypes() );
[ # # ][ # # ]
[ # # ][ # # ]
162 : :
163 : 0 : pTypeCollection = &aTypeCollection ;
164 [ # # ]: 0 : }
165 : : }
166 : :
167 : 0 : return pTypeCollection->getTypes() ;
168 : : }
169 : :
170 : 0 : uno::Sequence< sal_Int8 > SAL_CALL VCLXHatchWindow::getImplementationId()
171 : : throw( uno::RuntimeException )
172 : : {
173 : : static ::cppu::OImplementationId* pID = NULL ;
174 : :
175 [ # # ]: 0 : if ( pID == NULL )
176 : : {
177 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
178 : :
179 [ # # ]: 0 : if ( pID == NULL )
180 : : {
181 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aID( sal_False ) ;
182 : 0 : pID = &aID ;
183 [ # # ]: 0 : }
184 : : }
185 : :
186 : 0 : return pID->getImplementationId() ;
187 : : }
188 : :
189 : 0 : ::com::sun::star::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException)
190 : : {
191 : 0 : return aHatchBorderSize;
192 : : }
193 : :
194 : 4 : void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size& _hatchbordersize ) throw (::com::sun::star::uno::RuntimeException)
195 : : {
196 [ + - ]: 4 : if ( pHatchWindow )
197 : : {
198 : 4 : aHatchBorderSize = _hatchbordersize;
199 [ + - ]: 4 : pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
200 : : }
201 : 4 : }
202 : :
203 : 2 : void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
204 : : throw (uno::RuntimeException)
205 : : {
206 : 2 : m_xController = xController;
207 : 2 : }
208 : :
209 : 4 : void SAL_CALL VCLXHatchWindow::dispose()
210 : : throw (uno::RuntimeException)
211 : : {
212 : 4 : pHatchWindow = 0;
213 : 4 : VCLXWindow::dispose();
214 : 4 : }
215 : :
216 : 0 : void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
217 : : throw (uno::RuntimeException)
218 : : {
219 : 0 : VCLXWindow::addEventListener( xListener );
220 : 0 : }
221 : :
222 : 0 : void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
223 : : throw (uno::RuntimeException)
224 : : {
225 : 0 : VCLXWindow::removeEventListener( xListener );
226 : 0 : }
227 : :
228 : 2 : void VCLXHatchWindow::Activated()
229 : : {
230 [ + - ]: 2 : if ( m_xController.is() )
231 : 2 : m_xController->activated();
232 : 2 : }
233 : :
234 : 0 : void VCLXHatchWindow::Deactivated()
235 : : {
236 [ # # ]: 0 : if ( m_xController.is() )
237 : 0 : m_xController->deactivated();
238 : 0 : }
239 : :
240 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|