Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/framework/source/helper/dockingareadefaultacceptor.cxx
Line
Count
Source
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 <helper/dockingareadefaultacceptor.hxx>
21
22
#include <com/sun/star/awt/XDevice.hpp>
23
#include <com/sun/star/awt/PosSize.hpp>
24
25
#include <vcl/svapp.hxx>
26
27
namespace framework{
28
29
using namespace ::com::sun::star::frame;
30
using namespace ::com::sun::star::lang;
31
using namespace ::com::sun::star::uno;
32
using namespace ::cppu;
33
34
//  constructor
35
36
DockingAreaDefaultAcceptor::DockingAreaDefaultAcceptor( const   css::uno::Reference< XFrame >&      xOwner  )
37
11.0k
        :   m_xOwner        ( xOwner    )
38
11.0k
{
39
11.0k
}
40
41
//  destructor
42
43
DockingAreaDefaultAcceptor::~DockingAreaDefaultAcceptor()
44
6.21k
{
45
6.21k
}
46
47
//  XDockingAreaAcceptor
48
css::uno::Reference< css::awt::XWindow > SAL_CALL DockingAreaDefaultAcceptor::getContainerWindow()
49
17.2k
{
50
17.2k
    SolarMutexGuard g;
51
52
    // Try to "lock" the frame for access to taskscontainer.
53
17.2k
    css::uno::Reference< XFrame > xFrame( m_xOwner );
54
    //TODO: check xFrame for null?
55
17.2k
    css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
56
57
17.2k
    return xContainerWindow;
58
17.2k
}
59
60
sal_Bool SAL_CALL DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css::awt::Rectangle& RequestedSpace )
61
0
{
62
    // Try to "lock" the frame for access to taskscontainer.
63
0
    css::uno::Reference< XFrame > xFrame( m_xOwner );
64
65
0
    if ( !xFrame.is() )
66
0
        return false;
67
68
0
    css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
69
0
    css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
70
71
0
    if ( !xContainerWindow.is() || !xComponentWindow.is() )
72
0
        return false;
73
74
0
    css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
75
    // Convert relative size to output size.
76
0
    css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
77
0
    css::awt::DeviceInfo aInfo       = xDevice->getInfo();
78
0
    css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
79
0
                                        aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
80
81
0
    css::awt::Size aMinSize( 0, 0 ); // = xLayoutConstraints->getMinimumSize();
82
83
    // Check if request border space would decrease component window size below minimum size
84
0
    if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) ||
85
0
        (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height  )       )
86
0
        return false;
87
88
0
    return true;
89
0
}
90
91
void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle& BorderSpace )
92
0
{
93
0
    SolarMutexGuard g;
94
95
    // Try to "lock" the frame for access to taskscontainer.
96
0
    css::uno::Reference< XFrame > xFrame( m_xOwner );
97
0
    if ( !xFrame.is() )
98
0
        return;
99
100
0
    css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() );
101
0
    css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() );
102
103
0
    if ( !(xContainerWindow.is() && xComponentWindow.is()) )
104
0
        return;
105
106
0
    css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
107
    // Convert relative size to output size.
108
0
    css::awt::Rectangle  aRectangle  = xContainerWindow->getPosSize();
109
0
    css::awt::DeviceInfo aInfo       = xDevice->getInfo();
110
0
    css::awt::Size       aSize       (  aRectangle.Width  - aInfo.LeftInset - aInfo.RightInset  ,
111
0
                                        aRectangle.Height - aInfo.TopInset  - aInfo.BottomInset );
112
0
    css::awt::Size aMinSize( 0, 0 );// = xLayoutConstraints->getMinimumSize();
113
114
    // Check if request border space would decrease component window size below minimum size
115
0
    sal_Int32 nWidth     = aSize.Width - BorderSpace.X - BorderSpace.Width;
116
0
    sal_Int32 nHeight    = aSize.Height - BorderSpace.Y - BorderSpace.Height;
117
118
0
    if (( nWidth > aMinSize.Width ) && ( nHeight > aMinSize.Height ))
119
0
    {
120
        // Resize our component window.
121
0
        xComponentWindow->setPosSize( BorderSpace.X, BorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE );
122
0
    }
123
0
}
124
125
} // namespace framework
126
127
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */