Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/toolkit/source/awt/vclxcontainer.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 <awt/vclxcontainer.hxx>
21
#include <toolkit/helper/vclunohelper.hxx>
22
#include <toolkit/helper/listenermultiplexer.hxx>
23
24
#include <vcl/svapp.hxx>
25
#include <vcl/window.hxx>
26
#include <vcl/tabpage.hxx>
27
#include <tools/debug.hxx>
28
#include <tools/mapunit.hxx>
29
#include <helper/scrollabledialog.hxx>
30
#include <helper/property.hxx>
31
32
void VCLXContainer::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds )
33
0
{
34
0
    VCLXWindow::ImplGetPropertyIds( rIds );
35
0
}
36
37
VCLXContainer::VCLXContainer()
38
23.5k
{
39
23.5k
}
40
41
VCLXContainer::~VCLXContainer()
42
18.6k
{
43
18.6k
}
44
45
46
// css::awt::XVclContainer
47
void VCLXContainer::addVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener )
48
0
{
49
0
    SolarMutexGuard aGuard;
50
51
0
    if (!IsDisposed())
52
0
        GetContainerListeners().addInterface( rxListener );
53
0
}
54
55
void VCLXContainer::removeVclContainerListener( const css::uno::Reference< css::awt::XVclContainerListener >& rxListener )
56
0
{
57
0
    SolarMutexGuard aGuard;
58
59
0
    if (!IsDisposed())
60
0
        GetContainerListeners().removeInterface( rxListener );
61
0
}
62
63
css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > VCLXContainer::getWindows(  )
64
0
{
65
0
    SolarMutexGuard aGuard;
66
67
    // Request container interface from all children
68
0
    css::uno::Sequence< css::uno::Reference< css::awt::XWindow > > aSeq;
69
0
    VclPtr<vcl::Window> pWindow = GetWindow();
70
0
    if ( pWindow )
71
0
    {
72
0
        sal_uInt16 nChildren = pWindow->GetChildCount();
73
0
        if ( nChildren )
74
0
        {
75
0
            aSeq = css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >( nChildren );
76
0
            css::uno::Reference< css::awt::XWindow > * pChildRefs = aSeq.getArray();
77
0
            for ( sal_uInt16 n = 0; n < nChildren; n++ )
78
0
            {
79
0
                vcl::Window* pChild = pWindow->GetChild( n );
80
0
                css::uno::Reference< css::awt::XWindowPeer >  xWP = pChild->GetComponentInterface();
81
0
                pChildRefs[n].set(xWP, css::uno::UNO_QUERY);
82
0
            }
83
0
        }
84
0
    }
85
0
    return aSeq;
86
0
}
87
88
89
// css::awt::XVclContainerPeer
90
void VCLXContainer::enableDialogControl( sal_Bool bEnable )
91
0
{
92
0
    SolarMutexGuard aGuard;
93
94
0
    VclPtr<vcl::Window> pWindow = GetWindow();
95
0
    if ( pWindow )
96
0
    {
97
0
        WinBits nStyle = pWindow->GetStyle();
98
0
        if ( bEnable )
99
0
            nStyle |= WB_DIALOGCONTROL;
100
0
        else
101
0
            nStyle &= (~WB_DIALOGCONTROL);
102
0
        pWindow->SetStyle( nStyle );
103
0
    }
104
0
}
105
106
void VCLXContainer::setTabOrder( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components, const css::uno::Sequence< css::uno::Any >& Tabs, sal_Bool bGroupControl )
107
0
{
108
0
    SolarMutexGuard aGuard;
109
110
0
    sal_uInt32 nCount = Components.getLength();
111
0
    DBG_ASSERT( nCount == static_cast<sal_uInt32>(Tabs.getLength()), "setTabOrder: TabCount != ComponentCount" );
112
0
    const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray();
113
0
    const css::uno::Any* pTabs = Tabs.getConstArray();
114
115
0
    vcl::Window* pPrevWin = nullptr;
116
0
    for ( sal_uInt32 n = 0; n < nCount; n++ )
117
0
    {
118
        // css::style::TabStop
119
0
        VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( pComps[n] );
120
        // May be NULL if a css::uno::Sequence is originated from TabController and is missing a peer!
121
0
        if ( pWin )
122
0
        {
123
            // Order windows before manipulating their style, because elements such as the
124
            // RadioButton considers the PREV-window in StateChanged.
125
0
            if ( pPrevWin )
126
0
                pWin->SetZOrder( pPrevWin, ZOrderFlags::Behind );
127
128
0
            WinBits nStyle = pWin->GetStyle();
129
0
            nStyle &= ~(WB_TABSTOP|WB_NOTABSTOP|WB_GROUP);
130
0
            if ( pTabs[n].getValueTypeClass() == css::uno::TypeClass_BOOLEAN )
131
0
            {
132
0
                bool bTab = false;
133
0
                pTabs[n] >>= bTab;
134
0
                nStyle |= ( bTab ? WB_TABSTOP : WB_NOTABSTOP );
135
0
            }
136
0
            pWin->SetStyle( nStyle );
137
138
0
            if ( bGroupControl )
139
0
            {
140
0
                if ( n == 0 )
141
0
                    pWin->SetDialogControlStart( true );
142
0
                else
143
0
                    pWin->SetDialogControlStart( false );
144
0
            }
145
146
0
            pPrevWin = pWin;
147
0
        }
148
0
    }
149
0
}
150
151
void VCLXContainer::setGroup( const css::uno::Sequence< css::uno::Reference< css::awt::XWindow > >& Components )
152
0
{
153
0
    SolarMutexGuard aGuard;
154
155
0
    sal_uInt32 nCount = Components.getLength();
156
0
    const css::uno::Reference< css::awt::XWindow > * pComps = Components.getConstArray();
157
158
0
    vcl::Window* pPrevWin = nullptr;
159
0
    vcl::Window* pPrevRadio = nullptr;
160
0
    for ( sal_uInt32 n = 0; n < nCount; n++ )
161
0
    {
162
0
        VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( pComps[n] );
163
0
        if ( pWin )
164
0
        {
165
0
            vcl::Window* pSortBehind = pPrevWin;
166
            // #57096# Sort all radios consecutively
167
0
            bool bNewPrevWin = true;
168
0
            if ( pWin->GetType() == WindowType::RADIOBUTTON )
169
0
            {
170
0
                if ( pPrevRadio )
171
0
                {
172
                    // This RadioButton was sorted before PrevWin
173
0
                    bNewPrevWin = ( pPrevWin == pPrevRadio );
174
0
                    pSortBehind = pPrevRadio;
175
0
                }
176
0
                pPrevRadio = pWin;
177
0
            }
178
179
            // Z-Order
180
0
            if ( pSortBehind )
181
0
                pWin->SetZOrder( pSortBehind, ZOrderFlags::Behind );
182
183
0
            WinBits nStyle = pWin->GetStyle();
184
0
            if ( n == 0 )
185
0
                nStyle |= WB_GROUP;
186
0
            else
187
0
                nStyle &= (~WB_GROUP);
188
0
            pWin->SetStyle( nStyle );
189
190
            // Add WB_GROUP after the last group
191
0
            if ( n == ( nCount - 1 ) )
192
0
            {
193
0
                vcl::Window* pBehindLast = pWin->GetWindow( GetWindowType::Next );
194
0
                if ( pBehindLast )
195
0
                {
196
0
                    WinBits nLastStyle = pBehindLast->GetStyle();
197
0
                    nLastStyle |= WB_GROUP;
198
0
                    pBehindLast->SetStyle( nLastStyle );
199
0
                }
200
0
            }
201
202
0
            if ( bNewPrevWin )
203
0
                pPrevWin = pWin;
204
0
        }
205
0
    }
206
0
}
207
208
void SAL_CALL VCLXContainer::setProperty(
209
    const OUString& PropertyName,
210
    const css::uno::Any& Value )
211
0
{
212
0
    SolarMutexGuard aGuard;
213
214
0
    sal_uInt16 nPropType = GetPropertyId( PropertyName );
215
0
    switch ( nPropType )
216
0
    {
217
0
        case BASEPROPERTY_SCROLLHEIGHT:
218
0
        case BASEPROPERTY_SCROLLWIDTH:
219
0
        case BASEPROPERTY_SCROLLTOP:
220
0
        case BASEPROPERTY_SCROLLLEFT:
221
0
        {
222
0
            sal_Int32 nVal =0;
223
0
            Value >>= nVal;
224
0
            Size aSize( nVal, nVal );
225
0
            VclPtr<vcl::Window> pWindow = GetWindow();
226
0
            MapMode aMode( MapUnit::MapAppFont );
227
0
            toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() );
228
0
            TabPage* pScrollTabPage = dynamic_cast< TabPage* >( pWindow.get() );
229
0
            if ( pWindow && (pScrollable || pScrollTabPage) )
230
0
            {
231
0
                aSize = pWindow->LogicToPixel( aSize, aMode );
232
0
                switch ( nPropType )
233
0
                {
234
0
                    case BASEPROPERTY_SCROLLHEIGHT:
235
0
                        pScrollable ? pScrollable->SetScrollHeight( aSize.Height() ) : (void)0;
236
0
                        pScrollTabPage ? pScrollTabPage->SetScrollHeight( aSize.Height() ) : (void)0;
237
0
                        break;
238
0
                    case BASEPROPERTY_SCROLLWIDTH:
239
0
                        pScrollable ? pScrollable->SetScrollWidth( aSize.Width() ) : (void)0;
240
0
                        pScrollTabPage ? pScrollTabPage->SetScrollWidth( aSize.Width() ) : (void)0;
241
0
                        break;
242
0
                    case BASEPROPERTY_SCROLLTOP:
243
0
                        pScrollable ? pScrollable->SetScrollTop( aSize.Height() ) : (void)0;
244
0
                        pScrollTabPage ? pScrollTabPage->SetScrollTop( aSize.Height() ) : (void)0;
245
0
                        break;
246
0
                    case BASEPROPERTY_SCROLLLEFT:
247
0
                        pScrollable ? pScrollable->SetScrollLeft( aSize.Width() ) : (void)0;
248
0
                        pScrollTabPage ? pScrollTabPage->SetScrollLeft( aSize.Width() ) : (void)0;
249
0
                        break;
250
0
                    default:
251
0
                        break;
252
0
                }
253
0
                break;
254
0
            }
255
0
            break;
256
0
        }
257
258
0
        default:
259
0
        {
260
0
            VCLXWindow::setProperty( PropertyName, Value );
261
0
        }
262
0
    }
263
0
}
264
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */