Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/toolkit/morebtn.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 <tools/mapunit.hxx>
21
#include <vcl/toolkit/morebtn.hxx>
22
#include <vcl/stdtext.hxx>
23
24
struct ImplMoreButtonData
25
{
26
    OUString                             maMoreText;
27
    OUString                             maLessText;
28
};
29
30
void MoreButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
31
0
{
32
0
    mpMBData.reset(new ImplMoreButtonData);
33
0
    mbState      = false;
34
35
0
    PushButton::ImplInit( pParent, nStyle );
36
37
0
    mpMBData->maMoreText = GetStandardText( StandardButtonType::More );
38
0
    mpMBData->maLessText = GetStandardText( StandardButtonType::Less );
39
40
0
    ShowState();
41
42
0
    SetSymbolAlign(SymbolAlign::RIGHT);
43
0
    SetImageAlign(ImageAlign::Right); //Resolves: fdo#31849 ensure button remains vertically centered
44
0
    SetSmallSymbol();
45
46
0
    if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
47
0
    {
48
0
        nStyle |= WB_CENTER;
49
0
        SetStyle( nStyle );
50
0
    }
51
0
}
52
53
void MoreButton::ShowState()
54
0
{
55
0
    if ( mbState )
56
0
    {
57
0
        SetSymbol( SymbolType::PAGEUP );
58
0
        SetText( mpMBData->maLessText );
59
0
    }
60
0
    else
61
0
    {
62
0
        SetSymbol( SymbolType::PAGEDOWN );
63
0
        SetText( mpMBData->maMoreText );
64
0
    }
65
0
}
66
67
MoreButton::MoreButton( vcl::Window* pParent, WinBits nStyle ) :
68
0
    PushButton( WindowType::MOREBUTTON )
69
0
{
70
0
    ImplInit( pParent, nStyle );
71
0
}
Unexecuted instantiation: MoreButton::MoreButton(vcl::Window*, long)
Unexecuted instantiation: MoreButton::MoreButton(vcl::Window*, long)
72
73
MoreButton::~MoreButton()
74
0
{
75
0
    disposeOnce();
76
0
}
77
78
void MoreButton::dispose()
79
0
{
80
0
    mpMBData.reset();
81
0
    PushButton::dispose();
82
0
}
83
84
void MoreButton::Click()
85
0
{
86
0
    vcl::Window*     pParent = GetParent();
87
0
    Size        aSize( pParent->GetSizePixel() );
88
0
    tools::Long nDeltaPixel = LogicToPixel(Size(0, 0), MapMode(MapUnit::MapPixel)).Height();
89
90
    // Change status
91
0
    mbState = !mbState;
92
0
    ShowState();
93
94
    // Update the windows according to the status
95
0
    if ( mbState )
96
0
    {
97
        // Adapt dialogbox
98
0
        Point aPos( pParent->GetPosPixel() );
99
0
        tools::Rectangle aDeskRect( pParent->ImplGetFrameWindow()->GetDesktopRectPixel() );
100
101
0
        aSize.AdjustHeight(nDeltaPixel );
102
0
        if ( (aPos.Y()+aSize.Height()) > aDeskRect.Bottom() )
103
0
        {
104
0
            aPos.setY( aDeskRect.Bottom()-aSize.Height() );
105
106
0
            if ( aPos.Y() < aDeskRect.Top() )
107
0
                aPos.setY( aDeskRect.Top() );
108
109
0
            pParent->SetPosSizePixel( aPos, aSize );
110
0
        }
111
0
        else
112
0
            pParent->SetSizePixel( aSize );
113
0
    }
114
0
    else
115
0
    {
116
        // Adapt Dialogbox
117
0
        aSize.AdjustHeight( -nDeltaPixel );
118
0
        pParent->SetSizePixel( aSize );
119
0
    }
120
    // Call Click handler here, so that we can initialize the Controls
121
0
    PushButton::Click();
122
0
}
123
124
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */