1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/embed/XHatchWindowController.hpp>
22 #include "hatchwindow.hxx"
25 #include <toolkit/helper/convert.hxx>
26 #include <osl/mutex.hxx>
27 #include <vcl/svapp.hxx>
29 using namespace ::com::sun::star
;
31 VCLXHatchWindow::VCLXHatchWindow()
37 VCLXHatchWindow::~VCLXHatchWindow()
41 void VCLXHatchWindow::initializeWindow( const uno::Reference
< awt::XWindowPeer
>& xParent
,
42 const awt::Rectangle
& aBounds
,
43 const awt::Size
& aSize
)
45 SolarMutexGuard aGuard
;
47 Window
* pParent
= NULL
;
48 VCLXWindow
* pParentComponent
= VCLXWindow::GetImplementation( xParent
);
50 if ( pParentComponent
)
51 pParent
= pParentComponent
->GetWindow();
53 OSL_ENSURE( pParent
, "No parent window is provided!\n" );
55 throw lang::IllegalArgumentException(); // TODO
57 pHatchWindow
= new SvResizeWindow( pParent
, this );
58 pHatchWindow
->setPosSizePixel( aBounds
.X
, aBounds
.Y
, aBounds
.Width
, aBounds
.Height
);
59 aHatchBorderSize
= aSize
;
60 pHatchWindow
->SetHatchBorderPixel( Size( aSize
.Width
, aSize
.Height
) );
62 SetWindow( pHatchWindow
);
63 pHatchWindow
->SetComponentInterface( this );
65 //pHatchWindow->Show();
68 void VCLXHatchWindow::QueryObjAreaPixel( Rectangle
& aRect
)
70 if ( m_xController
.is() )
72 awt::Rectangle aUnoRequestRect
= AWTRectangle( aRect
);
75 awt::Rectangle aUnoResultRect
= m_xController
->calcAdjustedRectangle( aUnoRequestRect
);
76 aRect
= VCLRectangle( aUnoResultRect
);
78 catch( uno::Exception
& )
80 OSL_FAIL( "Can't adjust rectangle size!\n" );
85 void VCLXHatchWindow::RequestObjAreaPixel( const Rectangle
& aRect
)
87 if ( m_xController
.is() )
89 awt::Rectangle aUnoRequestRect
= AWTRectangle( aRect
);
92 m_xController
->requestPositioning( aUnoRequestRect
);
94 catch( uno::Exception
& )
96 OSL_FAIL( "Can't request resizing!\n" );
101 void VCLXHatchWindow::InplaceDeactivate()
103 if ( m_xController
.is() )
105 // TODO: communicate with controller
110 uno::Any SAL_CALL
VCLXHatchWindow::queryInterface( const uno::Type
& rType
)
111 throw( uno::RuntimeException
)
114 // Don't use mutex or guard in this method!!! Is a method of XInterface.
116 uno::Any
aReturn( ::cppu::queryInterface( rType
,
117 static_cast< embed::XHatchWindow
* >( this ) ) );
119 if ( aReturn
.hasValue() == sal_True
)
124 return VCLXWindow::queryInterface( rType
) ;
127 void SAL_CALL
VCLXHatchWindow::acquire()
130 VCLXWindow::acquire();
133 void SAL_CALL
VCLXHatchWindow::release()
136 VCLXWindow::release();
139 uno::Sequence
< uno::Type
> SAL_CALL
VCLXHatchWindow::getTypes()
140 throw( uno::RuntimeException
)
142 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
144 if ( pTypeCollection
== NULL
)
146 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() ) ;
148 if ( pTypeCollection
== NULL
)
150 static ::cppu::OTypeCollection
aTypeCollection(
151 ::getCppuType(( const uno::Reference
< embed::XHatchWindow
>* )NULL
),
152 VCLXHatchWindow::getTypes() );
154 pTypeCollection
= &aTypeCollection
;
158 return pTypeCollection
->getTypes() ;
161 uno::Sequence
< sal_Int8
> SAL_CALL
VCLXHatchWindow::getImplementationId()
162 throw( uno::RuntimeException
)
164 static ::cppu::OImplementationId
* pID
= NULL
;
168 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() ) ;
172 static ::cppu::OImplementationId
aID( sal_False
) ;
177 return pID
->getImplementationId() ;
180 ::com::sun::star::awt::Size SAL_CALL
VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException
)
182 return aHatchBorderSize
;
185 void SAL_CALL
VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size
& _hatchbordersize
) throw (::com::sun::star::uno::RuntimeException
)
189 aHatchBorderSize
= _hatchbordersize
;
190 pHatchWindow
->SetHatchBorderPixel( Size( aHatchBorderSize
.Width
, aHatchBorderSize
.Height
) );
194 void SAL_CALL
VCLXHatchWindow::setController( const uno::Reference
< embed::XHatchWindowController
>& xController
)
195 throw (uno::RuntimeException
)
197 m_xController
= xController
;
200 void SAL_CALL
VCLXHatchWindow::dispose()
201 throw (uno::RuntimeException
)
204 VCLXWindow::dispose();
207 void SAL_CALL
VCLXHatchWindow::addEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
208 throw (uno::RuntimeException
)
210 VCLXWindow::addEventListener( xListener
);
213 void SAL_CALL
VCLXHatchWindow::removeEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
214 throw (uno::RuntimeException
)
216 VCLXWindow::removeEventListener( xListener
);
219 void VCLXHatchWindow::Activated()
221 if ( m_xController
.is() )
222 m_xController
->activated();
225 void VCLXHatchWindow::Deactivated()
227 if ( m_xController
.is() )
228 m_xController
->deactivated();
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */