merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / hatchwindow / hatchwindow.cxx
blobe3107b62854d25436e805807222c4e0ee9fcfaa8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hatchwindow.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <com/sun/star/embed/XHatchWindowController.hpp>
35 #include "hatchwindow.hxx"
36 #include "ipwin.hxx"
38 #include <toolkit/helper/convert.hxx>
40 using namespace ::com::sun::star;
42 VCLXHatchWindow::VCLXHatchWindow()
43 : VCLXWindow()
44 , pHatchWindow(0)
48 VCLXHatchWindow::~VCLXHatchWindow()
52 void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
53 const awt::Rectangle& aBounds,
54 const awt::Size& aSize )
56 Window* pParent = NULL;
57 VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent );
59 if ( pParentComponent )
60 pParent = pParentComponent->GetWindow();
62 OSL_ENSURE( pParent, "No parent window is provided!\n" );
63 if ( !pParent )
64 throw lang::IllegalArgumentException(); // TODO
66 pHatchWindow = new SvResizeWindow( pParent, this );
67 pHatchWindow->SetPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
68 aHatchBorderSize = aSize;
69 pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
71 SetWindow( pHatchWindow );
72 pHatchWindow->SetComponentInterface( this );
74 //pHatchWindow->Show();
77 void VCLXHatchWindow::QueryObjAreaPixel( Rectangle & aRect )
79 if ( m_xController.is() )
81 awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
83 try {
84 awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect );
85 aRect = VCLRectangle( aUnoResultRect );
87 catch( uno::Exception& )
89 OSL_ENSURE( sal_False, "Can't adjust rectangle size!\n" );
94 void VCLXHatchWindow::RequestObjAreaPixel( const Rectangle & aRect )
96 if ( m_xController.is() )
98 awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
100 try {
101 m_xController->requestPositioning( aUnoRequestRect );
103 catch( uno::Exception& )
105 OSL_ENSURE( sal_False, "Can't request resizing!\n" );
110 void VCLXHatchWindow::InplaceDeactivate()
112 if ( m_xController.is() )
114 // TODO: communicate with controller
119 uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType )
120 throw( uno::RuntimeException )
122 // Attention:
123 // Don't use mutex or guard in this method!!! Is a method of XInterface.
125 uno::Any aReturn( ::cppu::queryInterface( rType,
126 static_cast< embed::XHatchWindow* >( this ) ) );
128 if ( aReturn.hasValue() == sal_True )
130 return aReturn ;
133 return VCLXWindow::queryInterface( rType ) ;
136 void SAL_CALL VCLXHatchWindow::acquire()
137 throw()
139 VCLXWindow::acquire();
142 void SAL_CALL VCLXHatchWindow::release()
143 throw()
145 VCLXWindow::release();
148 uno::Sequence< uno::Type > SAL_CALL VCLXHatchWindow::getTypes()
149 throw( uno::RuntimeException )
151 static ::cppu::OTypeCollection* pTypeCollection = NULL ;
153 if ( pTypeCollection == NULL )
155 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
157 if ( pTypeCollection == NULL )
159 static ::cppu::OTypeCollection aTypeCollection(
160 ::getCppuType(( const uno::Reference< embed::XHatchWindow >* )NULL ),
161 VCLXHatchWindow::getTypes() );
163 pTypeCollection = &aTypeCollection ;
167 return pTypeCollection->getTypes() ;
170 uno::Sequence< sal_Int8 > SAL_CALL VCLXHatchWindow::getImplementationId()
171 throw( uno::RuntimeException )
173 static ::cppu::OImplementationId* pID = NULL ;
175 if ( pID == NULL )
177 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
179 if ( pID == NULL )
181 static ::cppu::OImplementationId aID( sal_False ) ;
182 pID = &aID ;
186 return pID->getImplementationId() ;
189 ::com::sun::star::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException)
191 return aHatchBorderSize;
194 void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size& _hatchbordersize ) throw (::com::sun::star::uno::RuntimeException)
196 if ( pHatchWindow )
198 aHatchBorderSize = _hatchbordersize;
199 pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
203 void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
204 throw (uno::RuntimeException)
206 m_xController = xController;
209 void SAL_CALL VCLXHatchWindow::dispose()
210 throw (uno::RuntimeException)
212 pHatchWindow = 0;
213 VCLXWindow::dispose();
216 void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
217 throw (uno::RuntimeException)
219 VCLXWindow::addEventListener( xListener );
222 void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
223 throw (uno::RuntimeException)
225 VCLXWindow::removeEventListener( xListener );
228 void VCLXHatchWindow::Activated()
230 if ( m_xController.is() )
231 m_xController->activated();
234 void VCLXHatchWindow::Deactivated()
236 if ( m_xController.is() )
237 m_xController->deactivated();