Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/form/tbxform.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 <sal/config.h>
21
22
#include <comphelper/propertyvalue.hxx>
23
#include <svl/intitem.hxx>
24
#include <svl/eitem.hxx>
25
#include <svl/stritem.hxx>
26
#include <tools/debug.hxx>
27
#include <vcl/toolbox.hxx>
28
#include <vcl/settings.hxx>
29
30
#include <svx/dialmgr.hxx>
31
#include <svx/labelitemwindow.hxx>
32
#include <svx/svxids.hrc>
33
#include <svx/strings.hrc>
34
#include <tbxform.hxx>
35
36
using namespace ::com::sun::star::uno;
37
using namespace ::com::sun::star::beans;
38
39
SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window* pParent, SfxToolBoxControl* pController)
40
0
    : RecordItemWindow(pParent)
41
0
    , m_pController(pController)
42
0
{
43
0
    m_xWidget->set_width_chars(6);
44
0
    SetSizePixel(m_xWidget->get_preferred_size());
45
0
}
Unexecuted instantiation: SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window*, SfxToolBoxControl*)
Unexecuted instantiation: SvxFmAbsRecWin::SvxFmAbsRecWin(vcl::Window*, SfxToolBoxControl*)
46
47
void SvxFmAbsRecWin::PositionFired(sal_Int64 nRecord)
48
0
{
49
0
    SfxInt32Item aPositionParam( TypedWhichId<SfxInt32Item>(FN_PARAM_1), static_cast<sal_Int32>(nRecord) );
50
51
0
    Any a;
52
0
    aPositionParam.QueryValue( a );
53
0
    Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"Position"_ustr, a) };
54
0
    m_pController->Dispatch( u".uno:AbsoluteRecord"_ustr,
55
0
                             aArgs );
56
0
    m_pController->updateStatus();
57
0
}
58
59
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item );
60
61
SvxFmTbxCtlAbsRec::SvxFmTbxCtlAbsRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
62
0
    :SfxToolBoxControl( nSlotId, nId, rTbx )
63
0
{
64
0
}
65
66
67
SvxFmTbxCtlAbsRec::~SvxFmTbxCtlAbsRec()
68
0
{
69
0
}
70
71
void SvxFmTbxCtlAbsRec::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
72
0
{
73
0
    ToolBoxItemId       nId = GetId();
74
0
    ToolBox*            pToolBox = &GetToolBox();
75
0
    SvxFmAbsRecWin*     pWin = static_cast<SvxFmAbsRecWin*>( pToolBox->GetItemWindow(nId) );
76
77
0
    assert(pWin && "Control not found!");
78
79
0
    if (pState)
80
0
    {
81
0
        const SfxInt32Item* pItem = dynamic_cast< const SfxInt32Item* >( pState );
82
0
        DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" );
83
0
        pWin->set_text(OUString::number(pItem ? pItem->GetValue() : -1));
84
0
    }
85
86
0
    bool bEnable = SfxItemState::DISABLED != eState && pState;
87
0
    if (!bEnable)
88
0
        pWin->set_text(OUString());
89
90
91
    // enabling/disabling of the window
92
0
    pToolBox->EnableItem(nId, bEnable);
93
0
    SfxToolBoxControl::StateChangedAtToolBoxControl( nSID, eState,pState );
94
0
}
95
96
VclPtr<InterimItemWindow> SvxFmTbxCtlAbsRec::CreateItemWindow( vcl::Window* pParent )
97
0
{
98
0
    return VclPtrInstance<SvxFmAbsRecWin>(pParent, this);
99
0
}
100
101
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecText, SfxBoolItem );
102
103
SvxFmTbxCtlRecText::SvxFmTbxCtlRecText( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
104
0
    :SfxToolBoxControl( nSlotId, nId, rTbx )
105
0
{
106
0
    rTbx.SetItemWindowNonInteractive(nId, true);
107
0
}
108
109
SvxFmTbxCtlRecText::~SvxFmTbxCtlRecText()
110
0
{
111
0
}
112
113
VclPtr<InterimItemWindow> SvxFmTbxCtlRecText::CreateItemWindow( vcl::Window* pParent )
114
0
{
115
0
    OUString aText(SvxResId(RID_STR_REC_TEXT));
116
0
    VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
117
118
0
    xFixedText->Show();
119
120
0
    return xFixedText;
121
0
}
122
123
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecFromText, SfxBoolItem );
124
125
SvxFmTbxCtlRecFromText::SvxFmTbxCtlRecFromText( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
126
0
    :SfxToolBoxControl( nSlotId, nId, rTbx )
127
0
{
128
0
    rTbx.SetItemWindowNonInteractive(nId, true);
129
0
}
130
131
SvxFmTbxCtlRecFromText::~SvxFmTbxCtlRecFromText()
132
0
{
133
0
}
134
135
VclPtr<InterimItemWindow> SvxFmTbxCtlRecFromText::CreateItemWindow( vcl::Window* pParent )
136
0
{
137
0
    OUString aText(SvxResId(RID_STR_REC_FROM_TEXT));
138
0
    VclPtrInstance<LabelItemWindow> xFixedText(pParent, aText);
139
140
0
    xFixedText->Show();
141
142
0
    return xFixedText;
143
0
}
144
145
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecTotal, SfxStringItem );
146
147
SvxFmTbxCtlRecTotal::SvxFmTbxCtlRecTotal( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
148
0
    : SfxToolBoxControl( nSlotId, nId, rTbx )
149
0
{
150
0
    rTbx.SetItemWindowNonInteractive(nId, true);
151
0
}
152
153
SvxFmTbxCtlRecTotal::~SvxFmTbxCtlRecTotal()
154
0
{
155
0
}
156
157
VclPtr<InterimItemWindow> SvxFmTbxCtlRecTotal::CreateItemWindow( vcl::Window* pParent )
158
0
{
159
0
    m_xFixedText.reset(VclPtr<LabelItemWindow>::Create(pParent, "123456"));
160
0
    m_xFixedText->set_label(u""_ustr);
161
162
0
    m_xFixedText->Show();
163
164
0
    return m_xFixedText;
165
0
}
166
167
void SvxFmTbxCtlRecTotal::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
168
0
{
169
    // setting the FixedText
170
0
    if (GetSlotId() != SID_FM_RECORD_TOTAL)
171
0
        return;
172
173
0
    OUString aText;
174
0
    if (pState)
175
0
        aText = static_cast<const SfxStringItem*>(pState)->GetValue();
176
0
    else
177
0
        aText = "?";
178
179
0
    m_xFixedText->set_label(aText);
180
181
0
    SfxToolBoxControl::StateChangedAtToolBoxControl( nSID, eState,pState );
182
0
}
183
184
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxNextRec, SfxBoolItem );
185
186
187
SvxFmTbxNextRec::SvxFmTbxNextRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
188
0
    :SfxToolBoxControl( nSlotId, nId, rTbx )
189
0
{
190
0
    rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
191
192
0
    AllSettings aSettings = rTbx.GetSettings();
193
0
    MouseSettings aMouseSettings = aSettings.GetMouseSettings();
194
0
    aMouseSettings.SetButtonRepeat(aMouseSettings.GetButtonRepeat() / 4);
195
0
    aSettings.SetMouseSettings(aMouseSettings);
196
0
    rTbx.SetSettings(aSettings, true);
197
0
}
198
199
SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxPrevRec, SfxBoolItem );
200
201
202
SvxFmTbxPrevRec::SvxFmTbxPrevRec( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx )
203
0
    :SfxToolBoxControl( nSlotId, nId, rTbx )
204
0
{
205
0
    rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | ToolBoxItemBits::REPEAT);
206
0
}
207
208
209
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */