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>
21 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include "hatchwindow.hxx"
26 #include <toolkit/helper/convert.hxx>
27 #include <cppuhelper/queryinterface.hxx>
28 #include <cppuhelper/typeprovider.hxx>
29 #include <osl/diagnose.h>
30 #include <vcl/svapp.hxx>
32 using namespace ::com::sun::star
;
34 VCLXHatchWindow::VCLXHatchWindow()
35 : pHatchWindow(nullptr)
39 VCLXHatchWindow::~VCLXHatchWindow()
43 void VCLXHatchWindow::initializeWindow( const uno::Reference
< awt::XWindowPeer
>& xParent
,
44 const awt::Rectangle
& aBounds
,
45 const awt::Size
& aSize
)
47 SolarMutexGuard aGuard
;
49 VclPtr
<vcl::Window
> pParent
;
50 VCLXWindow
* pParentComponent
= dynamic_cast<VCLXWindow
*>( xParent
.get() );
52 if ( pParentComponent
)
53 pParent
= pParentComponent
->GetWindow();
55 OSL_ENSURE( pParent
, "No parent window is provided!" );
57 throw lang::IllegalArgumentException(); // TODO
59 pHatchWindow
= VclPtr
<SvResizeWindow
>::Create( pParent
, this );
60 pHatchWindow
->setPosSizePixel( aBounds
.X
, aBounds
.Y
, aBounds
.Width
, aBounds
.Height
);
61 aHatchBorderSize
= aSize
;
62 pHatchWindow
->SetHatchBorderPixel( Size( aSize
.Width
, aSize
.Height
) );
64 SetWindow( pHatchWindow
);
65 pHatchWindow
->SetComponentInterface( this );
67 //pHatchWindow->Show();
70 void VCLXHatchWindow::QueryObjAreaPixel( tools::Rectangle
& aRect
)
72 if ( !m_xController
.is() )
75 awt::Rectangle aUnoRequestRect
= AWTRectangle( aRect
);
78 awt::Rectangle aUnoResultRect
= m_xController
->calcAdjustedRectangle( aUnoRequestRect
);
79 aRect
= VCLRectangle( aUnoResultRect
);
81 catch( uno::Exception
& )
83 OSL_FAIL( "Can't adjust rectangle size!" );
87 void VCLXHatchWindow::RequestObjAreaPixel( const tools::Rectangle
& aRect
)
89 if ( m_xController
.is() )
91 awt::Rectangle aUnoRequestRect
= AWTRectangle( aRect
);
94 m_xController
->requestPositioning( aUnoRequestRect
);
96 catch( uno::Exception
& )
98 OSL_FAIL( "Can't request resizing!" );
103 void VCLXHatchWindow::InplaceDeactivate()
105 if ( m_xController
.is() )
107 // TODO: communicate with controller
112 css::awt::Size SAL_CALL
VCLXHatchWindow::getHatchBorderSize()
114 return aHatchBorderSize
;
117 void SAL_CALL
VCLXHatchWindow::setHatchBorderSize( const css::awt::Size
& _hatchbordersize
)
121 aHatchBorderSize
= _hatchbordersize
;
122 pHatchWindow
->SetHatchBorderPixel( Size( aHatchBorderSize
.Width
, aHatchBorderSize
.Height
) );
126 void SAL_CALL
VCLXHatchWindow::setController( const uno::Reference
< embed::XHatchWindowController
>& xController
)
128 m_xController
= xController
;
131 void SAL_CALL
VCLXHatchWindow::dispose()
133 pHatchWindow
.clear();
134 VCLXWindow::dispose();
137 void SAL_CALL
VCLXHatchWindow::addEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
139 VCLXWindow::addEventListener( xListener
);
142 void SAL_CALL
VCLXHatchWindow::removeEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
144 VCLXWindow::removeEventListener( xListener
);
147 void VCLXHatchWindow::Activated()
149 if ( m_xController
.is() )
150 m_xController
->activated();
153 void VCLXHatchWindow::Deactivated()
155 if ( m_xController
.is() )
156 m_xController
->deactivated();
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */