LibreOffice Module toolkit (master) 1
hatchwindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/embed/XHatchWindowController.hpp>
21#include <com/sun/star/lang/IllegalArgumentException.hpp>
22
23#include "hatchwindow.hxx"
24#include "ipwin.hxx"
25
29#include <osl/diagnose.h>
30#include <vcl/svapp.hxx>
31
32using namespace ::com::sun::star;
33
35: pHatchWindow(nullptr)
36{
37}
38
40{
41}
42
43void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
44 const awt::Rectangle& aBounds,
45 const awt::Size& aSize )
46{
47 SolarMutexGuard aGuard;
48
49 VclPtr<vcl::Window> pParent;
50 VCLXWindow* pParentComponent = dynamic_cast<VCLXWindow*>( xParent.get() );
51
52 if ( pParentComponent )
53 pParent = pParentComponent->GetWindow();
54
55 OSL_ENSURE( pParent, "No parent window is provided!" );
56 if ( !pParent )
57 throw lang::IllegalArgumentException(); // TODO
58
60 pHatchWindow->setPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
61 aHatchBorderSize = aSize;
62 pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
63
64 SetWindow( pHatchWindow );
65 pHatchWindow->SetComponentInterface( this );
66
67 //pHatchWindow->Show();
68}
69
71{
72 if ( !m_xController.is() )
73 return;
74
75 awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
76
77 try {
78 awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect );
79 aRect = VCLRectangle( aUnoResultRect );
80 }
81 catch( uno::Exception& )
82 {
83 OSL_FAIL( "Can't adjust rectangle size!" );
84 }
85}
86
88{
89 if ( m_xController.is() )
90 {
91 awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
92
93 try {
94 m_xController->requestPositioning( aUnoRequestRect );
95 }
96 catch( uno::Exception& )
97 {
98 OSL_FAIL( "Can't request resizing!" );
99 }
100 }
101}
102
104{
105 if ( m_xController.is() )
106 {
107 // TODO: communicate with controller
108 }
109}
110
111
112css::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize()
113{
114 return aHatchBorderSize;
115}
116
117void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const css::awt::Size& _hatchbordersize )
118{
119 if ( pHatchWindow )
120 {
121 aHatchBorderSize = _hatchbordersize;
122 pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
123 }
124}
125
126void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
127{
129}
130
132{
135}
136
137void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
138{
139 VCLXWindow::addEventListener( xListener );
140}
141
142void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
143{
145}
146
148{
149 if ( m_xController.is() )
150 m_xController->activated();
151}
152
154{
155 if ( m_xController.is() )
156 m_xController->deactivated();
157}
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL dispose() override
virtual css::awt::Size SAL_CALL getHatchBorderSize() override
void initializeWindow(const css::uno::Reference< css::awt::XWindowPeer > &xParent, const css::awt::Rectangle &aBounds, const css::awt::Size &aSize)
Definition: hatchwindow.cxx:43
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void QueryObjAreaPixel(tools::Rectangle &)
Definition: hatchwindow.cxx:70
virtual void SAL_CALL setHatchBorderSize(const css::awt::Size &_hatchbordersize) override
VclPtr< SvResizeWindow > pHatchWindow
Definition: hatchwindow.hxx:32
css::uno::Reference< css::embed::XHatchWindowController > m_xController
Definition: hatchwindow.hxx:30
void InplaceDeactivate()
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
css::awt::Size aHatchBorderSize
Definition: hatchwindow.hxx:31
virtual ~VCLXHatchWindow() override
Definition: hatchwindow.cxx:39
void RequestObjAreaPixel(const tools::Rectangle &)
Definition: hatchwindow.cxx:87
virtual void SAL_CALL setController(const css::uno::Reference< css::embed::XHatchWindowController > &xController) override
vcl::Window * GetWindow() const
Definition: vclxwindow.hxx:131
void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &rxListener) override
Definition: vclxwindow.cxx:954
void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &rxListener) override
Definition: vclxwindow.cxx:946
void SAL_CALL dispose() override
Definition: vclxwindow.cxx:907
void clear()
static VclPtr< reference_type > Create(Arg &&... arg)
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
Definition: convert.hxx:49
inline ::tools::Rectangle VCLRectangle(const css::awt::Rectangle &rAWTRect)
Definition: convert.hxx:54
Reference< XController > xController