1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/XHatchWindowController.hpp>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "hatchwindow.hxx"
29cdf0e10cSrcweir #include "ipwin.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
32cdf0e10cSrcweir #include <vos/mutex.hxx>
33cdf0e10cSrcweir #include <vcl/svapp.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir
VCLXHatchWindow()37cdf0e10cSrcweir VCLXHatchWindow::VCLXHatchWindow()
38cdf0e10cSrcweir : VCLXWindow()
39cdf0e10cSrcweir , pHatchWindow(0)
40cdf0e10cSrcweir {
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
~VCLXHatchWindow()43cdf0e10cSrcweir VCLXHatchWindow::~VCLXHatchWindow()
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
initializeWindow(const uno::Reference<awt::XWindowPeer> & xParent,const awt::Rectangle & aBounds,const awt::Size & aSize)47cdf0e10cSrcweir void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
48cdf0e10cSrcweir const awt::Rectangle& aBounds,
49cdf0e10cSrcweir const awt::Size& aSize )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
52cdf0e10cSrcweir
53cdf0e10cSrcweir Window* pParent = NULL;
54cdf0e10cSrcweir VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent );
55cdf0e10cSrcweir
56cdf0e10cSrcweir if ( pParentComponent )
57cdf0e10cSrcweir pParent = pParentComponent->GetWindow();
58cdf0e10cSrcweir
59cdf0e10cSrcweir OSL_ENSURE( pParent, "No parent window is provided!\n" );
60cdf0e10cSrcweir if ( !pParent )
61cdf0e10cSrcweir throw lang::IllegalArgumentException(); // TODO
62cdf0e10cSrcweir
63cdf0e10cSrcweir pHatchWindow = new SvResizeWindow( pParent, this );
64cdf0e10cSrcweir pHatchWindow->SetPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
65cdf0e10cSrcweir aHatchBorderSize = aSize;
66cdf0e10cSrcweir pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
67cdf0e10cSrcweir
68cdf0e10cSrcweir SetWindow( pHatchWindow );
69cdf0e10cSrcweir pHatchWindow->SetComponentInterface( this );
70cdf0e10cSrcweir
71cdf0e10cSrcweir //pHatchWindow->Show();
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
QueryObjAreaPixel(Rectangle & aRect)74cdf0e10cSrcweir void VCLXHatchWindow::QueryObjAreaPixel( Rectangle & aRect )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir if ( m_xController.is() )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
79cdf0e10cSrcweir
80cdf0e10cSrcweir try {
81cdf0e10cSrcweir awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect );
82cdf0e10cSrcweir aRect = VCLRectangle( aUnoResultRect );
83cdf0e10cSrcweir }
84cdf0e10cSrcweir catch( uno::Exception& )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir OSL_ENSURE( sal_False, "Can't adjust rectangle size!\n" );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir }
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
RequestObjAreaPixel(const Rectangle & aRect)91cdf0e10cSrcweir void VCLXHatchWindow::RequestObjAreaPixel( const Rectangle & aRect )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir if ( m_xController.is() )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
96cdf0e10cSrcweir
97cdf0e10cSrcweir try {
98cdf0e10cSrcweir m_xController->requestPositioning( aUnoRequestRect );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir catch( uno::Exception& )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir OSL_ENSURE( sal_False, "Can't request resizing!\n" );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
InplaceDeactivate()107cdf0e10cSrcweir void VCLXHatchWindow::InplaceDeactivate()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir if ( m_xController.is() )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir // TODO: communicate with controller
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir
queryInterface(const uno::Type & rType)116cdf0e10cSrcweir uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType )
117cdf0e10cSrcweir throw( uno::RuntimeException )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir // Attention:
120cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface.
121cdf0e10cSrcweir
122cdf0e10cSrcweir uno::Any aReturn( ::cppu::queryInterface( rType,
123cdf0e10cSrcweir static_cast< embed::XHatchWindow* >( this ) ) );
124cdf0e10cSrcweir
125cdf0e10cSrcweir if ( aReturn.hasValue() == sal_True )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir return aReturn ;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir return VCLXWindow::queryInterface( rType ) ;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
acquire()133cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::acquire()
134cdf0e10cSrcweir throw()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir VCLXWindow::acquire();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir
release()139cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::release()
140cdf0e10cSrcweir throw()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir VCLXWindow::release();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
getTypes()145cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL VCLXHatchWindow::getTypes()
146cdf0e10cSrcweir throw( uno::RuntimeException )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir static ::cppu::OTypeCollection* pTypeCollection = NULL ;
149cdf0e10cSrcweir
150cdf0e10cSrcweir if ( pTypeCollection == NULL )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
153cdf0e10cSrcweir
154cdf0e10cSrcweir if ( pTypeCollection == NULL )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir static ::cppu::OTypeCollection aTypeCollection(
157cdf0e10cSrcweir ::getCppuType(( const uno::Reference< embed::XHatchWindow >* )NULL ),
158cdf0e10cSrcweir VCLXHatchWindow::getTypes() );
159cdf0e10cSrcweir
160cdf0e10cSrcweir pTypeCollection = &aTypeCollection ;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir return pTypeCollection->getTypes() ;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
getImplementationId()167cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL VCLXHatchWindow::getImplementationId()
168cdf0e10cSrcweir throw( uno::RuntimeException )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir static ::cppu::OImplementationId* pID = NULL ;
171cdf0e10cSrcweir
172cdf0e10cSrcweir if ( pID == NULL )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
175cdf0e10cSrcweir
176cdf0e10cSrcweir if ( pID == NULL )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir static ::cppu::OImplementationId aID( sal_False ) ;
179cdf0e10cSrcweir pID = &aID ;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
183cdf0e10cSrcweir return pID->getImplementationId() ;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
getHatchBorderSize()186cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir return aHatchBorderSize;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
setHatchBorderSize(const::com::sun::star::awt::Size & _hatchbordersize)191cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size& _hatchbordersize ) throw (::com::sun::star::uno::RuntimeException)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir if ( pHatchWindow )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir aHatchBorderSize = _hatchbordersize;
196cdf0e10cSrcweir pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
setController(const uno::Reference<embed::XHatchWindowController> & xController)200cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
201cdf0e10cSrcweir throw (uno::RuntimeException)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir m_xController = xController;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
dispose()206cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::dispose()
207cdf0e10cSrcweir throw (uno::RuntimeException)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir pHatchWindow = 0;
210cdf0e10cSrcweir VCLXWindow::dispose();
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
addEventListener(const uno::Reference<lang::XEventListener> & xListener)213cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
214cdf0e10cSrcweir throw (uno::RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir VCLXWindow::addEventListener( xListener );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)219cdf0e10cSrcweir void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
220cdf0e10cSrcweir throw (uno::RuntimeException)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir VCLXWindow::removeEventListener( xListener );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
Activated()225cdf0e10cSrcweir void VCLXHatchWindow::Activated()
226cdf0e10cSrcweir {
227cdf0e10cSrcweir if ( m_xController.is() )
228cdf0e10cSrcweir m_xController->activated();
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
Deactivated()231cdf0e10cSrcweir void VCLXHatchWindow::Deactivated()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir if ( m_xController.is() )
234cdf0e10cSrcweir m_xController->deactivated();
235cdf0e10cSrcweir }
236