Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/app/salvtables.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 <limits>
23
#include <string_view>
24
25
#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
26
#include <com/sun/star/awt/XWindow.hpp>
27
#include <com/sun/star/awt/XVclWindowPeer.hpp>
28
#include <colorpicker.hxx>
29
#include <o3tl/safeint.hxx>
30
#include <o3tl/sorted_vector.hxx>
31
#include <o3tl/string_view.hxx>
32
#include <officecfg/Office/Common.hxx>
33
#include <SvHeaderTabListBox.hxx>
34
#include <ivctrl.hxx>
35
#include <salframe.hxx>
36
#include <salinst.hxx>
37
#include <salvd.hxx>
38
#include <salprn.hxx>
39
#include <saltimer.hxx>
40
#include <salsession.hxx>
41
#include <salsys.hxx>
42
#include <salbmp.hxx>
43
#include <salobj.hxx>
44
#include <salmenu.hxx>
45
#include <strings.hrc>
46
#include <svdata.hxx>
47
#include <svimpbox.hxx>
48
#include <svtabbx.hxx>
49
#include <messagedialog.hxx>
50
#include <treeglue.hxx>
51
#include <unotools/accessiblerelationsethelper.hxx>
52
#include <unotools/configmgr.hxx>
53
#include <unotools/fontdefs.hxx>
54
#include <utility>
55
#include <tools/helpers.hxx>
56
#include <vcl/builder.hxx>
57
#include <vcl/dndlistenercontainer.hxx>
58
#include <vcl/toolkit/combobox.hxx>
59
#include <vcl/toolkit/dialog.hxx>
60
#include <vcl/toolkit/fixed.hxx>
61
#include <vcl/toolkit/fmtfield.hxx>
62
#include <vcl/headbar.hxx>
63
#include <vcl/layout.hxx>
64
#include <vcl/notebookbar/NotebookBarAddonsItem.hxx>
65
#include <vcl/toolkit/MenuButton.hxx>
66
#include <vcl/ptrstyle.hxx>
67
#include <slider.hxx>
68
#include <vcl/rendercontext/GetDefaultFontFlags.hxx>
69
#include <vcl/sysdata.hxx>
70
#include <vcl/toolkit/svlbitm.hxx>
71
#include <vcl/tabctrl.hxx>
72
#include <vcl/tabpage.hxx>
73
#include <vcl/toolbox.hxx>
74
#include <vcl/toolkit/treelistentry.hxx>
75
#include <vcl/toolkit/throbber.hxx>
76
#include <vcl/toolkit/unowrap.hxx>
77
#include <vcl/weld/Paned.hxx>
78
#include <vcl/weld/SizeGroup.hxx>
79
#include <vcl/weld/weldutils.hxx>
80
#include <vcl/toolkit/vclmedit.hxx>
81
#include <vcl/toolkit/viewdataentry.hxx>
82
#include <vcl/virdev.hxx>
83
#include <bitmaps.hlst>
84
#include <listbox.hxx>
85
#include <window.h>
86
#include <wizdlg.hxx>
87
#include <salvtables.hxx>
88
#include <comphelper/lok.hxx>
89
90
0
SalTimer::~SalTimer() {}
91
92
void SalBitmap::DropScaledCache()
93
1.86M
{
94
1.86M
    if (ImplSVData* pSVData = ImplGetSVData())
95
1.86M
    {
96
1.86M
        auto& rCache = pSVData->maGDIData.maScaleCache;
97
98
1.86M
        rCache.remove_if([this](const lru_scale_cache::key_value_pair_t& rKeyValuePair) {
99
0
            return rKeyValuePair.first.mpBitmap == this;
100
0
        });
101
1.86M
    }
102
1.86M
}
103
104
925k
SalBitmap::~SalBitmap() { DropScaledCache(); }
105
106
0
SalSystem::~SalSystem() {}
107
108
0
SalPrinter::~SalPrinter() {}
109
110
bool SalPrinter::StartJob(const OUString*, const OUString&, const OUString&, ImplJobSetup*,
111
                          vcl::PrinterController&)
112
0
{
113
0
    return false;
114
0
}
115
116
0
SalInfoPrinter::~SalInfoPrinter() {}
117
118
1.10M
SalVirtualDevice::~SalVirtualDevice() {}
119
120
0
SalObject::~SalObject() {}
121
122
0
SalMenu::~SalMenu() {}
123
124
0
void SalMenu::GetSystemMenuData(SystemMenuData&) {}
125
126
bool SalMenu::ShowNativePopupMenu(FloatingWindow*, const tools::Rectangle&, FloatWinPopupFlags)
127
0
{
128
0
    return false;
129
0
}
130
131
0
void SalMenu::ShowCloseButton(bool) {}
132
133
0
bool SalMenu::AddMenuBarButton(const SalMenuButtonItem&) { return false; }
134
135
0
void SalMenu::RemoveMenuBarButton(sal_uInt16) {}
136
137
tools::Rectangle SalMenu::GetMenuBarButtonRectPixel(sal_uInt16, SalFrame*)
138
0
{
139
0
    return tools::Rectangle();
140
0
}
141
142
0
int SalMenu::GetMenuBarHeight() const { return 0; }
143
144
0
SalMenuItem::~SalMenuItem() {}
145
146
class SalFlashAttention
147
{
148
private:
149
    VclPtr<vcl::Window> m_xWidget;
150
    Timer m_aFlashTimer;
151
    Color m_aOrigControlBackground;
152
    Wallpaper m_aOrigBackground;
153
    bool m_bOrigControlBackground;
154
    int m_nFlashCount;
155
156
    void SetFlash()
157
0
    {
158
0
        Color aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
159
0
        m_xWidget->SetControlBackground(aColor);
160
0
    }
161
162
    void ClearFlash()
163
0
    {
164
0
        if (m_bOrigControlBackground)
165
0
            m_xWidget->SetControlBackground(m_aOrigControlBackground);
166
0
        else
167
0
            m_xWidget->SetControlBackground();
168
0
    }
169
170
    void Flash()
171
0
    {
172
0
        constexpr int FlashesWanted = 1;
173
174
0
        if (m_nFlashCount % 2 == 0)
175
0
            ClearFlash();
176
0
        else
177
0
            SetFlash();
178
179
0
        if (m_nFlashCount == FlashesWanted * 2)
180
0
            return;
181
182
0
        ++m_nFlashCount;
183
184
0
        m_aFlashTimer.Start();
185
0
    }
186
187
    DECL_LINK(FlashTimeout, Timer*, void);
188
189
public:
190
    SalFlashAttention(VclPtr<vcl::Window> xWidget)
191
0
        : m_xWidget(std::move(xWidget))
192
0
        , m_aFlashTimer("SalFlashAttention")
193
0
        , m_bOrigControlBackground(false)
194
0
        , m_nFlashCount(1)
195
0
    {
196
0
        m_aFlashTimer.SetTimeout(150);
197
0
        m_aFlashTimer.SetInvokeHandler(LINK(this, SalFlashAttention, FlashTimeout));
198
0
    }
199
200
    void Start()
201
0
    {
202
0
        m_bOrigControlBackground = m_xWidget->IsControlBackground();
203
0
        if (m_bOrigControlBackground)
204
0
            m_aOrigControlBackground = m_xWidget->GetControlBackground();
205
0
        m_aFlashTimer.Start();
206
0
    }
207
208
0
    ~SalFlashAttention() { ClearFlash(); }
209
};
210
211
0
IMPL_LINK_NOARG(SalFlashAttention, FlashTimeout, Timer*, void) { Flash(); }
212
213
void SalInstanceWidget::ensure_event_listener()
214
0
{
215
0
    if (!m_bEventListener)
216
0
    {
217
0
        m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener));
218
0
        m_bEventListener = true;
219
0
    }
220
0
}
221
222
// we want the ability to mark key events as handled, so use this variant
223
// for those, we get all keystrokes in this case, so we will need to filter
224
// them later
225
void SalInstanceWidget::ensure_key_listener()
226
0
{
227
0
    if (!m_bKeyEventListener)
228
0
    {
229
0
        Application::AddKeyListener(LINK(this, SalInstanceWidget, KeyEventListener));
230
0
        m_bKeyEventListener = true;
231
0
    }
232
0
}
233
234
// we want the ability to know about mouse events that happen in our children
235
// so use this variant, we will need to filter them later
236
void SalInstanceWidget::ensure_mouse_listener()
237
0
{
238
0
    if (!m_bMouseEventListener)
239
0
    {
240
0
        m_xWidget->AddChildEventListener(LINK(this, SalInstanceWidget, MouseEventListener));
241
0
        m_bMouseEventListener = true;
242
0
    }
243
0
}
244
245
void SalInstanceWidget::set_background(const Color& rColor)
246
0
{
247
0
    m_xWidget->SetControlBackground(rColor);
248
0
    m_xWidget->SetBackground(m_xWidget->GetControlBackground());
249
0
    if (m_xWidget->GetStyle() & WB_CLIPCHILDREN)
250
0
    {
251
        // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under"
252
        // transparent children of the widget e.g. expander in sidebar panel header
253
0
        m_xWidget->SetStyle(m_xWidget->GetStyle() & ~WB_CLIPCHILDREN);
254
        // and toggle mbClipChildren on instead otherwise the bg won't fill e.g.
255
        // deck titlebar header when its width is stretched
256
0
        WindowImpl* pImpl = m_xWidget->ImplGetWindowImpl();
257
0
        pImpl->mbClipChildren = true;
258
0
    }
259
0
}
260
261
void SalInstanceWidget::set_background()
262
0
{
263
0
    m_xWidget->SetControlBackground();
264
0
    m_xWidget->SetBackground();
265
0
}
266
267
SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder,
268
                                     bool bTakeOwnership)
269
117
    : m_xWidget(pWidget)
270
117
    , m_pBuilder(pBuilder)
271
117
    , m_bTakeOwnership(bTakeOwnership)
272
117
    , m_bEventListener(false)
273
117
    , m_bKeyEventListener(false)
274
117
    , m_bMouseEventListener(false)
275
117
    , m_nFreezeCount(0)
276
117
{
277
117
    m_xWidget->SetCommandHdl(LINK(this, SalInstanceWidget, CommandHdl));
278
117
}
SalInstanceWidget::SalInstanceWidget(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
269
117
    : m_xWidget(pWidget)
270
117
    , m_pBuilder(pBuilder)
271
117
    , m_bTakeOwnership(bTakeOwnership)
272
117
    , m_bEventListener(false)
273
117
    , m_bKeyEventListener(false)
274
117
    , m_bMouseEventListener(false)
275
117
    , m_nFreezeCount(0)
276
117
{
277
117
    m_xWidget->SetCommandHdl(LINK(this, SalInstanceWidget, CommandHdl));
278
117
}
Unexecuted instantiation: SalInstanceWidget::SalInstanceWidget(vcl::Window*, SalInstanceBuilder*, bool)
279
280
0
void SalInstanceWidget::set_sensitive(bool sensitive) { m_xWidget->Enable(sensitive); }
281
282
0
bool SalInstanceWidget::get_sensitive() const { return m_xWidget->IsEnabled(); }
283
284
0
bool SalInstanceWidget::get_visible() const { return m_xWidget->IsVisible(); }
285
286
0
bool SalInstanceWidget::is_visible() const { return m_xWidget->IsReallyVisible(); }
287
288
void SalInstanceWidget::set_can_focus(bool bCanFocus)
289
0
{
290
0
    auto nStyle = m_xWidget->GetStyle() & ~(WB_TABSTOP | WB_NOTABSTOP);
291
0
    if (bCanFocus)
292
0
        nStyle |= WB_TABSTOP;
293
0
    else
294
0
        nStyle |= WB_NOTABSTOP;
295
0
    m_xWidget->SetStyle(nStyle);
296
0
}
297
298
void SalInstanceWidget::grab_focus()
299
0
{
300
0
    if (has_focus())
301
0
        return;
302
0
    m_xWidget->GrabFocus();
303
0
}
304
305
0
bool SalInstanceWidget::has_focus() const { return m_xWidget->HasFocus(); }
306
307
0
bool SalInstanceWidget::has_child_focus() const { return m_xWidget->HasChildPathFocus(true); }
308
309
0
void SalInstanceWidget::show() { m_xWidget->Show(); }
310
311
0
void SalInstanceWidget::hide() { m_xWidget->Hide(); }
312
313
void SalInstanceWidget::set_size_request(int nWidth, int nHeight)
314
0
{
315
0
    m_xWidget->set_width_request(nWidth);
316
0
    m_xWidget->set_height_request(nHeight);
317
0
}
318
319
Size SalInstanceWidget::get_size_request() const
320
0
{
321
0
    return Size(m_xWidget->get_width_request(), m_xWidget->get_height_request());
322
0
}
323
324
0
Size SalInstanceWidget::get_preferred_size() const { return m_xWidget->get_preferred_size(); }
325
326
float SalInstanceWidget::get_approximate_digit_width() const
327
0
{
328
0
    return m_xWidget->approximate_digit_width();
329
0
}
330
331
0
int SalInstanceWidget::get_text_height() const { return m_xWidget->GetTextHeight(); }
332
333
Size SalInstanceWidget::get_pixel_size(const OUString& rText) const
334
0
{
335
    //TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway
336
0
    return Size(m_xWidget->GetTextWidth(rText), m_xWidget->GetTextHeight());
337
0
}
338
339
0
vcl::Font SalInstanceWidget::get_font() { return m_xWidget->GetPointFont(*m_xWidget->GetOutDev()); }
340
341
0
OUString SalInstanceWidget::get_buildable_name() const { return m_xWidget->get_id(); }
342
343
0
void SalInstanceWidget::set_buildable_name(const OUString& rId) { return m_xWidget->set_id(rId); }
344
345
0
void SalInstanceWidget::set_help_id(const OUString& rId) { return m_xWidget->SetHelpId(rId); }
346
347
0
OUString SalInstanceWidget::get_help_id() const { return m_xWidget->GetHelpId(); }
348
349
0
void SalInstanceWidget::set_hexpand(bool bExpand) { m_xWidget->set_hexpand(bExpand); }
350
351
0
void SalInstanceWidget::set_vexpand(bool bExpand) { m_xWidget->set_vexpand(bExpand); }
352
353
0
void SalInstanceWidget::set_margin_top(int nMargin) { m_xWidget->set_margin_top(nMargin); }
354
355
0
void SalInstanceWidget::set_margin_bottom(int nMargin) { m_xWidget->set_margin_bottom(nMargin); }
356
357
0
void SalInstanceWidget::set_margin_start(int nMargin) { m_xWidget->set_margin_start(nMargin); }
358
359
0
void SalInstanceWidget::set_margin_end(int nMargin) { m_xWidget->set_margin_end(nMargin); }
360
361
0
int SalInstanceWidget::get_margin_start() const { return m_xWidget->get_margin_start(); }
362
363
0
int SalInstanceWidget::get_margin_end() const { return m_xWidget->get_margin_end(); }
364
365
void SalInstanceWidget::set_accessible_name(const OUString& rName)
366
0
{
367
0
    m_xWidget->SetAccessibleName(rName);
368
0
}
369
370
void SalInstanceWidget::set_accessible_description(const OUString& rDescription)
371
0
{
372
0
    m_xWidget->SetAccessibleDescription(rDescription);
373
0
}
374
375
0
OUString SalInstanceWidget::get_accessible_name() const { return m_xWidget->GetAccessibleName(); }
376
377
OUString SalInstanceWidget::get_accessible_description() const
378
0
{
379
0
    return m_xWidget->GetAccessibleDescription();
380
0
}
381
382
0
OUString SalInstanceWidget::get_accessible_id() const { return m_xWidget->get_id(); }
383
384
void SalInstanceWidget::set_accessible_relation_labeled_by(weld::Widget* pLabel)
385
0
{
386
0
    if (vcl::Window* pOldLabel = m_xWidget->GetAccessibleRelationLabeledBy())
387
0
        pOldLabel->SetAccessibleRelationLabelFor(nullptr);
388
0
    vcl::Window* pA11yLabel
389
0
        = pLabel ? dynamic_cast<SalInstanceWidget&>(*pLabel).getWidget() : nullptr;
390
0
    m_xWidget->SetAccessibleRelationLabeledBy(pA11yLabel);
391
0
    if (pA11yLabel)
392
0
        pA11yLabel->SetAccessibleRelationLabelFor(m_xWidget);
393
0
}
394
395
void SalInstanceWidget::set_tooltip_text(const OUString& rTip)
396
0
{
397
0
    m_xWidget->SetQuickHelpText(rTip);
398
0
}
399
400
0
OUString SalInstanceWidget::get_tooltip_text() const { return m_xWidget->GetQuickHelpText(); }
401
402
void SalInstanceWidget::set_cursor_data(void* pData)
403
0
{
404
0
    vcl::Cursor* pCursor = static_cast<vcl::Cursor*>(pData);
405
0
    if (!pCursor)
406
0
        return;
407
408
0
    m_xWidget->SetCursor(pCursor);
409
0
}
410
411
void SalInstanceWidget::connect_focus_in(const Link<Widget&, void>& rLink)
412
0
{
413
0
    ensure_event_listener();
414
0
    weld::Widget::connect_focus_in(rLink);
415
0
}
416
417
void SalInstanceWidget::connect_mnemonic_activate(const Link<Widget&, bool>& rLink)
418
0
{
419
0
    m_xWidget->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget, MnemonicActivateHdl));
420
0
    weld::Widget::connect_mnemonic_activate(rLink);
421
0
}
422
423
void SalInstanceWidget::connect_focus_out(const Link<Widget&, void>& rLink)
424
0
{
425
0
    ensure_event_listener();
426
0
    weld::Widget::connect_focus_out(rLink);
427
0
}
428
429
void SalInstanceWidget::connect_size_allocate(const Link<const Size&, void>& rLink)
430
0
{
431
0
    ensure_event_listener();
432
0
    weld::Widget::connect_size_allocate(rLink);
433
0
}
434
435
void SalInstanceWidget::connect_mouse_press(const Link<const MouseEvent&, bool>& rLink)
436
0
{
437
0
    ensure_mouse_listener();
438
0
    weld::Widget::connect_mouse_press(rLink);
439
0
}
440
441
void SalInstanceWidget::connect_mouse_move(const Link<const MouseEvent&, bool>& rLink)
442
0
{
443
0
    ensure_mouse_listener();
444
0
    weld::Widget::connect_mouse_move(rLink);
445
0
}
446
447
void SalInstanceWidget::connect_mouse_release(const Link<const MouseEvent&, bool>& rLink)
448
0
{
449
0
    ensure_mouse_listener();
450
0
    weld::Widget::connect_mouse_release(rLink);
451
0
}
452
453
void SalInstanceWidget::connect_key_press(const Link<const KeyEvent&, bool>& rLink)
454
0
{
455
0
    ensure_key_listener();
456
0
    weld::Widget::connect_key_press(rLink);
457
0
}
458
459
void SalInstanceWidget::connect_key_release(const Link<const KeyEvent&, bool>& rLink)
460
0
{
461
0
    ensure_key_listener();
462
0
    weld::Widget::connect_key_release(rLink);
463
0
}
464
465
IMPL_LINK(SalInstanceWidget, SettingsChangedHdl, VclWindowEvent&, rEvent, void)
466
0
{
467
0
    if (rEvent.GetId() != VclEventId::WindowDataChanged)
468
0
        return;
469
470
0
    DataChangedEvent* pData = static_cast<DataChangedEvent*>(rEvent.GetData());
471
0
    if (pData->GetType() == DataChangedEventType::SETTINGS)
472
0
        m_aStyleUpdatedHdl.Call(*this);
473
0
}
474
475
void SalInstanceWidget::connect_style_updated(const Link<Widget&, void>& rLink)
476
0
{
477
0
    if (m_aStyleUpdatedHdl.IsSet())
478
0
        m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, SettingsChangedHdl));
479
0
    weld::Widget::connect_style_updated(rLink);
480
0
    if (m_aStyleUpdatedHdl.IsSet())
481
0
        m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, SettingsChangedHdl));
482
0
}
483
484
bool SalInstanceWidget::get_extents_relative_to(const Widget& rRelative, int& x, int& y, int& width,
485
                                                int& height) const
486
0
{
487
0
    tools::Rectangle aRect(m_xWidget->GetWindowExtentsRelative(
488
0
        *dynamic_cast<const SalInstanceWidget&>(rRelative).getWidget()));
489
0
    x = aRect.Left();
490
0
    y = aRect.Top();
491
0
    width = aRect.GetWidth();
492
0
    height = aRect.GetHeight();
493
0
    return true;
494
0
}
495
496
0
void SalInstanceWidget::grab_mouse() { m_xWidget->CaptureMouse(); }
497
498
0
bool SalInstanceWidget::has_mouse_grab() const { return m_xWidget->IsMouseCaptured(); }
499
500
0
void SalInstanceWidget::release_mouse() { m_xWidget->ReleaseMouse(); }
501
502
0
bool SalInstanceWidget::get_direction() const { return m_xWidget->IsRTLEnabled(); }
503
504
0
void SalInstanceWidget::set_direction(bool bRTL) { m_xWidget->EnableRTL(bRTL); }
505
506
void SalInstanceWidget::freeze()
507
0
{
508
0
    if (m_nFreezeCount == 0)
509
0
        m_xWidget->SetUpdateMode(false);
510
0
    ++m_nFreezeCount;
511
0
}
512
513
void SalInstanceWidget::thaw()
514
0
{
515
0
    --m_nFreezeCount;
516
0
    if (m_nFreezeCount == 0)
517
0
        m_xWidget->SetUpdateMode(true);
518
0
}
519
520
void SalInstanceWidget::set_busy_cursor(bool bBusy)
521
0
{
522
0
    if (!m_xWidget)
523
0
    {
524
0
        return;
525
0
    }
526
527
0
    if (bBusy)
528
0
        m_xWidget->EnterWait();
529
0
    else
530
0
        m_xWidget->LeaveWait();
531
0
}
532
533
0
void SalInstanceWidget::queue_resize() { m_xWidget->queue_resize(); }
534
535
SalInstanceWidget::~SalInstanceWidget()
536
117
{
537
117
    m_xWidget->SetCommandHdl(Link<const CommandEvent&, bool>());
538
117
    if (m_aStyleUpdatedHdl.IsSet())
539
0
        m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, SettingsChangedHdl));
540
117
    if (m_aMnemonicActivateHdl.IsSet())
541
0
        m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&, bool>());
542
117
    if (m_bMouseEventListener)
543
0
        m_xWidget->RemoveChildEventListener(LINK(this, SalInstanceWidget, MouseEventListener));
544
117
    if (m_bKeyEventListener)
545
0
        Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener));
546
117
    if (m_bEventListener)
547
0
        m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener));
548
117
    if (m_bTakeOwnership)
549
0
        m_xWidget.disposeAndClear();
550
117
}
551
552
0
vcl::Window* SalInstanceWidget::getWidget() const { return m_xWidget; }
553
554
OUString SalInstanceWidget::strip_mnemonic(const OUString& rLabel) const
555
0
{
556
0
    return rLabel.replaceFirst("~", "");
557
0
}
558
559
OUString SalInstanceWidget::escape_ui_str(const OUString& rLabel) const
560
0
{
561
0
    return rLabel.replaceAll("~", "~~");
562
0
}
563
564
ScopedVclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const
565
0
{
566
    // create with (annoying) separate alpha layer that LibreOffice itself uses
567
0
    return VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(),
568
0
                                         DeviceFormat::WITH_ALPHA);
569
0
}
570
571
void SalInstanceWidget::call_attention_to()
572
0
{
573
0
    m_xFlashAttention.reset(new SalFlashAttention(m_xWidget));
574
0
    m_xFlashAttention->Start();
575
0
}
576
577
css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_drop_target()
578
0
{
579
0
    return m_xWidget->GetDropTarget();
580
0
}
581
582
css::uno::Reference<css::datatransfer::clipboard::XClipboard>
583
SalInstanceWidget::get_clipboard() const
584
0
{
585
0
    return m_xWidget->GetClipboard();
586
0
}
587
588
void SalInstanceWidget::set_stack_background()
589
0
{
590
0
    set_background(m_xWidget->GetSettings().GetStyleSettings().GetFieldColor());
591
0
}
592
593
void SalInstanceWidget::set_title_background()
594
0
{
595
0
    set_background(m_xWidget->GetSettings().GetStyleSettings().GetShadowColor());
596
0
}
597
598
void SalInstanceWidget::set_toolbar_background()
599
0
{
600
0
    m_xWidget->SetBackground();
601
0
    m_xWidget->SetPaintTransparent(true);
602
0
}
603
604
void SalInstanceWidget::set_highlight_background()
605
0
{
606
0
    set_background(m_xWidget->GetSettings().GetStyleSettings().GetHighlightColor());
607
0
}
608
609
0
SystemWindow* SalInstanceWidget::getSystemWindow() { return m_xWidget->GetSystemWindow(); }
610
611
void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent)
612
0
{
613
0
    if (rEvent.GetId() == VclEventId::WindowGetFocus)
614
0
        signal_focus_in();
615
0
    else if (rEvent.GetId() == VclEventId::WindowLoseFocus)
616
0
        signal_focus_out();
617
0
    else if (rEvent.GetId() == VclEventId::WindowResize)
618
0
        signal_size_allocate(m_xWidget->GetSizePixel());
619
0
}
620
621
namespace
622
{
623
MouseEvent TransformEvent(const MouseEvent& rEvent, const vcl::Window* pParent,
624
                          const vcl::Window* pChild)
625
0
{
626
0
    return MouseEvent(
627
0
        pParent->ScreenToOutputPixel(pChild->OutputToScreenPixel(rEvent.GetPosPixel())),
628
0
        rEvent.GetClicks(), rEvent.GetMode(), rEvent.GetButtons(), rEvent.GetModifier());
629
0
}
630
}
631
632
void SalInstanceWidget::HandleMouseEventListener(VclWindowEvent& rWinEvent)
633
0
{
634
0
    if (rWinEvent.GetId() == VclEventId::WindowMouseButtonDown)
635
0
    {
636
0
        if (m_xWidget == rWinEvent.GetWindow())
637
0
        {
638
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
639
0
            signal_mouse_press(*pMouseEvent);
640
0
        }
641
0
        else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow()))
642
0
        {
643
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
644
0
            const MouseEvent aTransformedEvent(
645
0
                TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow()));
646
0
            signal_mouse_press(aTransformedEvent);
647
0
        }
648
0
    }
649
0
    else if (rWinEvent.GetId() == VclEventId::WindowMouseButtonUp)
650
0
    {
651
0
        if (m_xWidget == rWinEvent.GetWindow())
652
0
        {
653
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
654
0
            signal_mouse_release(*pMouseEvent);
655
0
        }
656
0
        else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow()))
657
0
        {
658
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
659
0
            const MouseEvent aTransformedEvent(
660
0
                TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow()));
661
0
            signal_mouse_release(aTransformedEvent);
662
0
        }
663
0
    }
664
0
    else if (rWinEvent.GetId() == VclEventId::WindowMouseMove)
665
0
    {
666
0
        if (m_xWidget == rWinEvent.GetWindow())
667
0
        {
668
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
669
0
            signal_mouse_motion(*pMouseEvent);
670
0
        }
671
0
        else if (m_xWidget->ImplIsChild(rWinEvent.GetWindow()))
672
0
        {
673
0
            const MouseEvent* pMouseEvent = static_cast<const MouseEvent*>(rWinEvent.GetData());
674
0
            const MouseEvent aTransformedEvent(
675
0
                TransformEvent(*pMouseEvent, m_xWidget, rWinEvent.GetWindow()));
676
0
            signal_mouse_motion(aTransformedEvent);
677
0
        }
678
0
    }
679
0
}
680
681
bool SalInstanceWidget::HandleKeyEventListener(VclWindowEvent& rEvent)
682
0
{
683
    // we get all key events here, ignore them unless we have focus
684
0
    if (!m_xWidget->HasChildPathFocus())
685
0
        return false;
686
0
    if (rEvent.GetId() == VclEventId::WindowKeyInput)
687
0
    {
688
0
        const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData());
689
0
        return signal_key_press(*pKeyEvent);
690
0
    }
691
0
    else if (rEvent.GetId() == VclEventId::WindowKeyUp)
692
0
    {
693
0
        const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData());
694
0
        return signal_key_release(*pKeyEvent);
695
0
    }
696
0
    return false;
697
0
}
698
699
IMPL_LINK(SalInstanceWidget, EventListener, VclWindowEvent&, rEvent, void)
700
0
{
701
0
    HandleEventListener(rEvent);
702
0
}
703
704
IMPL_LINK(SalInstanceWidget, CommandHdl, const CommandEvent&, rEvent, bool)
705
0
{
706
0
    return signal_command(rEvent);
707
0
}
708
709
IMPL_LINK(SalInstanceWidget, KeyEventListener, VclWindowEvent&, rEvent, bool)
710
0
{
711
0
    return HandleKeyEventListener(rEvent);
712
0
}
713
714
IMPL_LINK(SalInstanceWidget, MouseEventListener, VclWindowEvent&, rEvent, void)
715
0
{
716
0
    HandleMouseEventListener(rEvent);
717
0
}
718
719
IMPL_LINK_NOARG(SalInstanceWidget, MnemonicActivateHdl, vcl::Window&, bool)
720
0
{
721
0
    return signal_mnemonic_activate();
722
0
}
723
724
namespace
725
{
726
Image createImage(const OUString& rImage)
727
0
{
728
0
    if (rImage.isEmpty())
729
0
        return Image();
730
0
    if (rImage.lastIndexOf('.') != rImage.getLength() - 4)
731
0
    {
732
0
        assert((rImage == "dialog-warning" || rImage == "dialog-error"
733
0
                || rImage == "dialog-information")
734
0
               && "unknown stock image");
735
0
        if (rImage == "dialog-warning")
736
0
            return Image(StockImage::Yes, IMG_WARN);
737
0
        else if (rImage == "dialog-error")
738
0
            return Image(StockImage::Yes, IMG_ERROR);
739
0
        else if (rImage == "dialog-information")
740
0
            return Image(StockImage::Yes, IMG_INFO);
741
0
    }
742
0
    return Image(StockImage::Yes, rImage);
743
0
}
744
745
Image createImage(const VirtualDevice& rDevice)
746
0
{
747
0
    return Image(rDevice.GetBitmap(Point(), rDevice.GetOutputSizePixel()));
748
0
}
749
750
sal_uInt16 insert_to_menu(sal_uInt16 nLastId, PopupMenu* pMenu, int pos, const OUString& rId,
751
                          const OUString& rStr, const OUString* pIconName,
752
                          const VirtualDevice* pImageSurface,
753
                          const css::uno::Reference<css::graphic::XGraphic>& rImage,
754
                          TriState eCheckRadioFalse)
755
0
{
756
0
    const sal_uInt16 nNewid = nLastId + 1;
757
758
0
    MenuItemBits nBits;
759
0
    if (eCheckRadioFalse == TRISTATE_TRUE)
760
0
        nBits = MenuItemBits::CHECKABLE;
761
0
    else if (eCheckRadioFalse == TRISTATE_FALSE)
762
0
        nBits = MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK;
763
0
    else
764
0
        nBits = MenuItemBits::NONE;
765
766
0
    pMenu->InsertItem(nNewid, rStr, nBits, rId, pos == -1 ? MENU_APPEND : pos);
767
0
    if (pIconName)
768
0
    {
769
0
        pMenu->SetItemImage(nNewid, createImage(*pIconName));
770
0
    }
771
0
    else if (pImageSurface)
772
0
    {
773
0
        pMenu->SetItemImage(nNewid, createImage(*pImageSurface));
774
0
    }
775
0
    else if (rImage)
776
0
    {
777
0
        pMenu->SetItemImage(nNewid, Image(rImage));
778
0
    }
779
0
    return nNewid;
780
0
}
781
}
782
783
SalInstanceMenu::SalInstanceMenu(PopupMenu* pMenu, bool bTakeOwnership)
784
0
    : m_xMenu(pMenu)
785
0
    , m_bTakeOwnership(bTakeOwnership)
786
0
{
787
0
    const auto nCount = m_xMenu->GetItemCount();
788
0
    m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0;
789
0
    m_xMenu->SetSelectHdl(LINK(this, SalInstanceMenu, SelectMenuHdl));
790
0
}
791
OUString SalInstanceMenu::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
792
                                        weld::Placement ePlace)
793
0
{
794
0
    SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent);
795
0
    assert(pVclWidget);
796
0
    PopupMenuFlags eFlags = PopupMenuFlags::NoMouseUpClose;
797
0
    if (ePlace == weld::Placement::Under)
798
0
        eFlags = eFlags | PopupMenuFlags::ExecuteDown;
799
0
    else
800
0
        eFlags = eFlags | PopupMenuFlags::ExecuteRight;
801
0
    m_xMenu->Execute(pVclWidget->getWidget(), rRect, eFlags);
802
0
    return m_xMenu->GetCurItemIdent();
803
0
}
804
void SalInstanceMenu::set_sensitive(const OUString& rIdent, bool bSensitive)
805
0
{
806
0
    m_xMenu->EnableItem(rIdent, bSensitive);
807
0
}
808
bool SalInstanceMenu::get_sensitive(const OUString& rIdent) const
809
0
{
810
0
    return m_xMenu->IsItemEnabled(m_xMenu->GetItemId(rIdent));
811
0
}
812
void SalInstanceMenu::set_active(const OUString& rIdent, bool bActive)
813
0
{
814
0
    m_xMenu->CheckItem(rIdent, bActive);
815
0
}
816
bool SalInstanceMenu::get_active(const OUString& rIdent) const
817
0
{
818
0
    return m_xMenu->IsItemChecked(m_xMenu->GetItemId(rIdent));
819
0
}
820
void SalInstanceMenu::set_label(const OUString& rIdent, const OUString& rLabel)
821
0
{
822
0
    m_xMenu->SetItemText(m_xMenu->GetItemId(rIdent), rLabel);
823
0
}
824
OUString SalInstanceMenu::get_label(const OUString& rIdent) const
825
0
{
826
0
    return m_xMenu->GetItemText(m_xMenu->GetItemId(rIdent));
827
0
}
828
829
void SalInstanceMenu::set_tooltip_text(const OUString& rIdent, const OUString& rTip)
830
0
{
831
0
    m_xMenu->SetTipHelpText(m_xMenu->GetItemId(rIdent), rTip);
832
0
}
833
834
void SalInstanceMenu::set_visible(const OUString& rIdent, bool bShow)
835
0
{
836
0
    m_xMenu->ShowItem(m_xMenu->GetItemId(rIdent), bShow);
837
0
}
838
0
void SalInstanceMenu::clear() { m_xMenu->Clear(); }
839
void SalInstanceMenu::insert(int pos, const OUString& rId, const OUString& rStr,
840
                             const OUString* pIconName, VirtualDevice* pImageSurface,
841
                             const css::uno::Reference<css::graphic::XGraphic>& rImage,
842
                             TriState eCheckRadioFalse)
843
0
{
844
0
    m_nLastId = insert_to_menu(m_nLastId, m_xMenu, pos, rId, rStr, pIconName, pImageSurface, rImage,
845
0
                               eCheckRadioFalse);
846
0
}
847
void SalInstanceMenu::insert_separator(int pos, const OUString& rId)
848
0
{
849
0
    auto nInsertPos = pos == -1 ? MENU_APPEND : pos;
850
0
    m_xMenu->InsertSeparator(rId, nInsertPos);
851
0
}
852
853
// Defines the help id of the item in a given position
854
void SalInstanceMenu::set_item_help_id(const OUString& rIdent, const OUString& rHelpId)
855
0
{
856
0
    m_xMenu->SetHelpId(m_xMenu->GetItemId(rIdent), rHelpId);
857
0
}
858
859
void SalInstanceMenu::remove(const OUString& rId)
860
0
{
861
0
    m_xMenu->RemoveItem(m_xMenu->GetItemPos(m_xMenu->GetItemId(rId)));
862
0
}
863
0
int SalInstanceMenu::n_children() const { return m_xMenu->GetItemCount(); }
864
OUString SalInstanceMenu::get_id(int pos) const
865
0
{
866
0
    return m_xMenu->GetItemIdent(m_xMenu->GetItemId(pos));
867
0
}
868
0
PopupMenu* SalInstanceMenu::getMenu() const { return m_xMenu.get(); }
869
SalInstanceMenu::~SalInstanceMenu()
870
0
{
871
0
    m_xMenu->SetSelectHdl(Link<::Menu*, bool>());
872
0
    if (m_bTakeOwnership)
873
0
        m_xMenu.disposeAndClear();
874
0
}
875
876
IMPL_LINK_NOARG(SalInstanceMenu, SelectMenuHdl, ::Menu*, bool)
877
0
{
878
0
    signal_activate(m_xMenu->GetCurItemIdent());
879
    /* tdf#131333 Menu::Select depends on a false here to allow
880
       propagating a submenu's selected id to its parent menu to become its
881
       selected id.
882
883
       without this, while gen menus already have propagated this to its parent
884
       in MenuFloatingWindow::EndExecute, SalMenus as used under kf5/macOS
885
       won't propagate the selected id
886
    */
887
0
    return false;
888
0
}
889
890
SalInstanceToolbar::SalInstanceToolbar(ToolBox* pToolBox, SalInstanceBuilder* pBuilder,
891
                                       bool bTakeOwnership)
892
0
    : SalInstanceWidget(pToolBox, pBuilder, bTakeOwnership)
893
0
    , m_xToolBox(pToolBox)
894
0
{
895
0
    m_xToolBox->SetSelectHdl(LINK(this, SalInstanceToolbar, ClickHdl));
896
0
    m_xToolBox->SetDropdownClickHdl(LINK(this, SalInstanceToolbar, DropdownClick));
897
0
}
Unexecuted instantiation: SalInstanceToolbar::SalInstanceToolbar(ToolBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceToolbar::SalInstanceToolbar(ToolBox*, SalInstanceBuilder*, bool)
898
899
void SalInstanceToolbar::set_item_sensitive(const OUString& rIdent, bool bSensitive)
900
0
{
901
0
    m_xToolBox->EnableItem(m_xToolBox->GetItemId(rIdent), bSensitive);
902
0
}
903
904
bool SalInstanceToolbar::get_item_sensitive(const OUString& rIdent) const
905
0
{
906
0
    return m_xToolBox->IsItemEnabled(m_xToolBox->GetItemId(rIdent));
907
0
}
908
909
void SalInstanceToolbar::set_item_visible(const OUString& rIdent, bool bVisible)
910
0
{
911
0
    m_xToolBox->ShowItem(m_xToolBox->GetItemId(rIdent), bVisible);
912
0
}
913
914
void SalInstanceToolbar::set_item_help_id(const OUString& rIdent, const OUString& rHelpId)
915
0
{
916
0
    m_xToolBox->SetHelpId(m_xToolBox->GetItemId(rIdent), rHelpId);
917
0
}
918
919
bool SalInstanceToolbar::get_item_visible(const OUString& rIdent) const
920
0
{
921
0
    return m_xToolBox->IsItemVisible(m_xToolBox->GetItemId(rIdent));
922
0
}
923
924
void SalInstanceToolbar::set_item_active(const OUString& rIdent, bool bActive)
925
0
{
926
0
    ToolBoxItemId nItemId = m_xToolBox->GetItemId(rIdent);
927
0
    m_xToolBox->CheckItem(nItemId, bActive);
928
0
}
929
930
bool SalInstanceToolbar::get_item_active(const OUString& rIdent) const
931
0
{
932
0
    return m_xToolBox->IsItemChecked(m_xToolBox->GetItemId(rIdent));
933
0
}
934
935
void SalInstanceToolbar::set_menu_item_active(const OUString& rIdent, bool bActive)
936
0
{
937
0
    ToolBoxItemId nItemId = m_xToolBox->GetItemId(rIdent);
938
0
    assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN);
939
940
0
    if (bActive)
941
0
    {
942
0
        m_sStartShowIdent = m_xToolBox->GetItemCommand(nItemId);
943
0
        signal_toggle_menu(m_sStartShowIdent);
944
0
    }
945
946
0
    auto pFloat = m_aFloats[nItemId];
947
0
    if (pFloat)
948
0
    {
949
0
        if (bActive)
950
0
            vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat,
951
0
                                                             FloatWinPopupFlags::GrabFocus);
952
0
        else
953
0
            vcl::Window::GetDockingManager()->EndPopupMode(pFloat);
954
0
    }
955
0
    auto pPopup = m_aMenus[nItemId];
956
0
    if (pPopup)
957
0
    {
958
0
        if (bActive)
959
0
        {
960
0
            MenuFlags nMenuFlags = pPopup->GetMenuFlags();
961
0
            if (officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get())
962
0
                nMenuFlags &= ~MenuFlags::HideDisabledEntries;
963
0
            else
964
0
                nMenuFlags |= MenuFlags::HideDisabledEntries;
965
0
            pPopup->SetMenuFlags(nMenuFlags);
966
0
            tools::Rectangle aRect = m_xToolBox->GetItemRect(nItemId);
967
0
            pPopup->Execute(m_xToolBox, aRect, PopupMenuFlags::ExecuteDown);
968
0
        }
969
0
        else
970
0
            pPopup->EndExecute();
971
0
    }
972
973
0
    m_sStartShowIdent.clear();
974
0
}
975
976
bool SalInstanceToolbar::get_menu_item_active(const OUString& rIdent) const
977
0
{
978
0
    ToolBoxItemId nItemId = m_xToolBox->GetItemId(rIdent);
979
0
    assert(m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN);
980
981
0
    if (rIdent == m_sStartShowIdent)
982
0
        return true;
983
984
0
    auto aFloat = m_aFloats.find(nItemId);
985
0
    if (aFloat != m_aFloats.end())
986
0
    {
987
0
        return vcl::Window::GetDockingManager()->IsInPopupMode(aFloat->second);
988
0
    }
989
990
0
    auto aPopup = m_aMenus.find(nItemId);
991
0
    if (aPopup != m_aMenus.end())
992
0
    {
993
0
        return PopupMenu::GetActivePopupMenu() == aPopup->second;
994
0
    }
995
996
0
    return false;
997
0
}
998
999
void SalInstanceToolbar::set_item_popover(const OUString& rIdent, weld::Widget* pPopover)
1000
0
{
1001
0
    SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover);
1002
1003
0
    vcl::Window* pFloat = pPopoverWidget ? pPopoverWidget->getWidget() : nullptr;
1004
0
    if (pFloat)
1005
0
    {
1006
0
        pFloat->AddEventListener(LINK(this, SalInstanceToolbar, MenuToggleListener));
1007
0
        pFloat->EnableDocking();
1008
0
    }
1009
1010
0
    ToolBoxItemId nId = m_xToolBox->GetItemId(rIdent);
1011
0
    auto xOldFloat = m_aFloats[nId];
1012
0
    if (xOldFloat)
1013
0
    {
1014
0
        xOldFloat->RemoveEventListener(LINK(this, SalInstanceToolbar, MenuToggleListener));
1015
0
    }
1016
0
    m_aFloats[nId] = pFloat;
1017
0
    m_aMenus[nId] = nullptr;
1018
0
}
1019
1020
void SalInstanceToolbar::set_item_menu(const OUString& rIdent, weld::Menu* pMenu)
1021
0
{
1022
0
    SalInstanceMenu* pInstanceMenu = dynamic_cast<SalInstanceMenu*>(pMenu);
1023
1024
0
    PopupMenu* pPopup = pInstanceMenu ? pInstanceMenu->getMenu() : nullptr;
1025
1026
0
    ToolBoxItemId nId = m_xToolBox->GetItemId(rIdent);
1027
0
    m_aMenus[nId] = pPopup;
1028
0
    m_aFloats[nId] = nullptr;
1029
0
}
1030
1031
void SalInstanceToolbar::insert_item(int pos, const OUString& rId)
1032
0
{
1033
0
    ToolBoxItemId nId(pos);
1034
0
    m_xToolBox->InsertItem(nId, OUString(), rId, ToolBoxItemBits::ICON_ONLY);
1035
0
}
1036
1037
void SalInstanceToolbar::insert_separator(int pos, const OUString& /*rId*/)
1038
0
{
1039
0
    auto nInsertPos = pos == -1 ? ToolBox::APPEND : pos;
1040
0
    m_xToolBox->InsertSeparator(nInsertPos, 5);
1041
0
}
1042
1043
0
int SalInstanceToolbar::get_n_items() const { return m_xToolBox->GetItemCount(); }
1044
1045
OUString SalInstanceToolbar::get_item_ident(int nIndex) const
1046
0
{
1047
0
    return m_xToolBox->GetItemCommand(m_xToolBox->GetItemId(nIndex));
1048
0
}
1049
1050
void SalInstanceToolbar::set_item_ident(int nIndex, const OUString& rIdent)
1051
0
{
1052
0
    return m_xToolBox->SetItemCommand(m_xToolBox->GetItemId(nIndex), rIdent);
1053
0
}
1054
1055
void SalInstanceToolbar::set_item_label(int nIndex, const OUString& rLabel)
1056
0
{
1057
0
    m_xToolBox->SetItemText(m_xToolBox->GetItemId(nIndex), rLabel);
1058
0
}
1059
1060
void SalInstanceToolbar::set_item_label(const OUString& rIdent, const OUString& rLabel)
1061
0
{
1062
0
    m_xToolBox->SetItemText(m_xToolBox->GetItemId(rIdent), rLabel);
1063
0
}
1064
1065
void SalInstanceToolbar::set_item_icon_name(const OUString& rIdent, const OUString& rIconName)
1066
0
{
1067
0
    m_xToolBox->SetItemImage(m_xToolBox->GetItemId(rIdent), Image(StockImage::Yes, rIconName));
1068
0
}
1069
1070
void SalInstanceToolbar::set_item_image_mirrored(const OUString& rIdent, bool bMirrored)
1071
0
{
1072
0
    m_xToolBox->SetItemImageMirrorMode(m_xToolBox->GetItemId(rIdent), bMirrored);
1073
0
}
1074
1075
void SalInstanceToolbar::set_item_image(const OUString& rIdent,
1076
                                        const css::uno::Reference<css::graphic::XGraphic>& rIcon)
1077
0
{
1078
0
    m_xToolBox->SetItemImage(m_xToolBox->GetItemId(rIdent), Image(rIcon));
1079
0
}
1080
1081
void SalInstanceToolbar::set_item_image(const OUString& rIdent, VirtualDevice* pDevice)
1082
0
{
1083
0
    if (pDevice)
1084
0
        m_xToolBox->SetItemImage(m_xToolBox->GetItemId(rIdent), createImage(*pDevice));
1085
0
    else
1086
0
        m_xToolBox->SetItemImage(m_xToolBox->GetItemId(rIdent), Image());
1087
0
}
1088
1089
void SalInstanceToolbar::set_item_image(int nIndex,
1090
                                        const css::uno::Reference<css::graphic::XGraphic>& rIcon)
1091
0
{
1092
0
    m_xToolBox->SetItemImage(m_xToolBox->GetItemId(nIndex), Image(rIcon));
1093
0
}
1094
1095
void SalInstanceToolbar::set_item_tooltip_text(int nIndex, const OUString& rTip)
1096
0
{
1097
0
    m_xToolBox->SetQuickHelpText(m_xToolBox->GetItemId(nIndex), rTip);
1098
0
}
1099
1100
void SalInstanceToolbar::set_item_tooltip_text(const OUString& rIdent, const OUString& rTip)
1101
0
{
1102
0
    m_xToolBox->SetQuickHelpText(m_xToolBox->GetItemId(rIdent), rTip);
1103
0
}
1104
1105
void SalInstanceToolbar::set_item_accessible_name(int nIndex, const OUString& rName)
1106
0
{
1107
0
    m_xToolBox->SetAccessibleName(m_xToolBox->GetItemId(nIndex), rName);
1108
0
}
1109
1110
void SalInstanceToolbar::set_item_accessible_name(const OUString& rIdent, const OUString& rName)
1111
0
{
1112
0
    m_xToolBox->SetAccessibleName(m_xToolBox->GetItemId(rIdent), rName);
1113
0
}
1114
1115
OUString SalInstanceToolbar::get_item_tooltip_text(const OUString& rIdent) const
1116
0
{
1117
0
    return m_xToolBox->GetQuickHelpText(m_xToolBox->GetItemId(rIdent));
1118
0
}
1119
1120
0
vcl::ImageType SalInstanceToolbar::get_icon_size() const { return m_xToolBox->GetImageSize(); }
1121
1122
void SalInstanceToolbar::set_icon_size(vcl::ImageType eType)
1123
0
{
1124
0
    ToolBoxButtonSize eButtonSize = ToolBoxButtonSize::DontCare;
1125
0
    switch (eType)
1126
0
    {
1127
0
        case vcl::ImageType::Size16:
1128
0
            eButtonSize = ToolBoxButtonSize::Small;
1129
0
            break;
1130
0
        case vcl::ImageType::Size26:
1131
0
            eButtonSize = ToolBoxButtonSize::Large;
1132
0
            break;
1133
0
        case vcl::ImageType::Size32:
1134
0
            eButtonSize = ToolBoxButtonSize::Size32;
1135
0
            break;
1136
0
    }
1137
0
    if (m_xToolBox->GetToolboxButtonSize() != eButtonSize)
1138
0
    {
1139
0
        m_xToolBox->SetToolboxButtonSize(eButtonSize);
1140
0
        m_xToolBox->queue_resize();
1141
0
    }
1142
0
}
1143
1144
0
sal_uInt16 SalInstanceToolbar::get_modifier_state() const { return m_xToolBox->GetModifier(); }
1145
1146
int SalInstanceToolbar::get_drop_index(const Point& rPoint) const
1147
0
{
1148
0
    auto nRet = m_xToolBox->GetItemPos(rPoint);
1149
0
    if (nRet == ToolBox::ITEM_NOTFOUND)
1150
0
        return 0;
1151
0
    return nRet;
1152
0
}
1153
1154
SalInstanceToolbar::~SalInstanceToolbar()
1155
0
{
1156
0
    m_xToolBox->SetDropdownClickHdl(Link<ToolBox*, void>());
1157
0
    m_xToolBox->SetSelectHdl(Link<ToolBox*, void>());
1158
0
}
1159
1160
IMPL_LINK_NOARG(SalInstanceToolbar, ClickHdl, ToolBox*, void)
1161
0
{
1162
0
    ToolBoxItemId nItemId = m_xToolBox->GetCurItemId();
1163
0
    signal_clicked(m_xToolBox->GetItemCommand(nItemId));
1164
0
}
1165
1166
IMPL_LINK_NOARG(SalInstanceToolbar, DropdownClick, ToolBox*, void)
1167
0
{
1168
0
    ToolBoxItemId nItemId = m_xToolBox->GetCurItemId();
1169
0
    set_menu_item_active(m_xToolBox->GetItemCommand(nItemId), true);
1170
0
}
1171
1172
IMPL_LINK(SalInstanceToolbar, MenuToggleListener, VclWindowEvent&, rEvent, void)
1173
0
{
1174
0
    if (rEvent.GetId() == VclEventId::WindowEndPopupMode)
1175
0
    {
1176
0
        for (const auto& rFloat : m_aFloats)
1177
0
        {
1178
0
            if (rEvent.GetWindow() == rFloat.second)
1179
0
            {
1180
0
                ToolBoxItemId nItemId = rFloat.first;
1181
0
                signal_toggle_menu(m_xToolBox->GetItemCommand(nItemId));
1182
0
                break;
1183
0
            }
1184
0
        }
1185
0
    }
1186
0
}
1187
1188
namespace
1189
{
1190
class SalInstanceSizeGroup : public weld::SizeGroup
1191
{
1192
private:
1193
    std::shared_ptr<VclSizeGroup> m_xGroup;
1194
1195
public:
1196
    SalInstanceSizeGroup(VclSizeGroupMode eMode)
1197
0
        : m_xGroup(std::make_shared<VclSizeGroup>())
1198
0
    {
1199
0
        m_xGroup->set_mode(eMode);
1200
0
    }
1201
1202
    virtual void add_widget(weld::Widget* pWidget) override
1203
0
    {
1204
0
        SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget);
1205
0
        assert(pVclWidget && pVclWidget->getWidget());
1206
0
        pVclWidget->getWidget()->add_to_size_group(m_xGroup);
1207
0
    }
1208
};
1209
}
1210
1211
void SalInstanceContainer::connect_container_focus_changed(const Link<Container&, void>& rLink)
1212
0
{
1213
0
    ensure_event_listener();
1214
0
    weld::Container::connect_container_focus_changed(rLink);
1215
0
}
1216
1217
void SalInstanceContainer::HandleEventListener(VclWindowEvent& rEvent)
1218
0
{
1219
0
    if (rEvent.GetId() == VclEventId::WindowActivate
1220
0
        || rEvent.GetId() == VclEventId::WindowDeactivate)
1221
0
    {
1222
0
        signal_container_focus_changed();
1223
0
        return;
1224
0
    }
1225
0
    SalInstanceWidget::HandleEventListener(rEvent);
1226
0
}
1227
1228
SalInstanceContainer::SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
1229
                                           bool bTakeOwnership)
1230
117
    : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership)
1231
117
    , m_xContainer(pContainer)
1232
117
{
1233
117
}
SalInstanceContainer::SalInstanceContainer(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
1230
117
    : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership)
1231
117
    , m_xContainer(pContainer)
1232
117
{
1233
117
}
Unexecuted instantiation: SalInstanceContainer::SalInstanceContainer(vcl::Window*, SalInstanceBuilder*, bool)
1234
1235
void SalInstanceContainer::move(weld::Widget* pWidget, weld::Container* pNewParent)
1236
0
{
1237
0
    SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget);
1238
0
    assert(pVclWidget);
1239
0
    SalInstanceContainer* pNewVclParent = dynamic_cast<SalInstanceContainer*>(pNewParent);
1240
0
    assert(!pNewParent || pNewVclParent);
1241
0
    vcl::Window* pVclWindow = pVclWidget->getWidget();
1242
0
    if (pNewVclParent)
1243
0
    {
1244
0
        vcl::Window* pNew = pNewVclParent->getWidget();
1245
0
        if (!pNew->isDisposed())
1246
0
            pVclWindow->SetParent(pNewVclParent->getWidget());
1247
0
        else
1248
0
            SAL_WARN("vcl", "ignoring move because new parent is already disposed");
1249
0
    }
1250
0
    else
1251
0
    {
1252
0
        pVclWindow->Hide();
1253
0
        pVclWindow->SetParent(ImplGetDefaultWindow());
1254
0
    }
1255
0
}
1256
1257
void SalInstanceContainer::child_grab_focus()
1258
0
{
1259
0
    m_xContainer->GrabFocus();
1260
0
    if (vcl::Window* pFirstChild = m_xContainer->ImplGetDlgWindow(0, GetDlgWindowType::First))
1261
0
        pFirstChild->ImplControlFocus();
1262
0
}
1263
1264
css::uno::Reference<css::awt::XWindow> SalInstanceContainer::CreateChildFrame()
1265
0
{
1266
0
    auto xPage = VclPtr<VclBin>::Create(m_xContainer.get());
1267
0
    xPage->set_expand(true);
1268
0
    xPage->Show();
1269
0
    return css::uno::Reference<css::awt::XWindow>(xPage->GetComponentInterface(),
1270
0
                                                  css::uno::UNO_QUERY);
1271
0
}
1272
1273
std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const
1274
0
{
1275
0
    vcl::Window* pParent = m_xWidget->GetParent();
1276
0
    if (!pParent)
1277
0
        return nullptr;
1278
0
    return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false);
1279
0
}
1280
1281
void SalInstanceWidget::DoRecursivePaint(vcl::Window* pWindow, const Point& rRenderLogicPos,
1282
                                         OutputDevice& rOutput)
1283
0
{
1284
0
    rOutput.Push();
1285
0
    bool bOldMapModeEnabled = pWindow->IsMapModeEnabled();
1286
1287
0
    if (pWindow->GetMapMode().GetMapUnit() != rOutput.GetMapMode().GetMapUnit())
1288
0
    {
1289
        // This is needed for e.g. the scrollbar in writer comments in margins that has its map unit in pixels
1290
        // as seen with bin/run gtktiledviewer --enable-tiled-annotations on a document containing a comment
1291
        // long enough to need a scrollbar
1292
0
        pWindow->EnableMapMode();
1293
0
        MapMode aMapMode = pWindow->GetMapMode();
1294
0
        aMapMode.SetMapUnit(rOutput.GetMapMode().GetMapUnit());
1295
0
        aMapMode.SetScaleX(rOutput.GetMapMode().GetScaleX());
1296
0
        aMapMode.SetScaleY(rOutput.GetMapMode().GetScaleY());
1297
0
        pWindow->SetMapMode(aMapMode);
1298
0
    }
1299
1300
0
    VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::WITHOUT_ALPHA));
1301
0
    Size aChildSizePixel(pWindow->GetSizePixel());
1302
0
    xOutput->SetOutputSizePixel(aChildSizePixel);
1303
1304
0
    MapMode aMapMode(xOutput->GetMapMode());
1305
0
    aMapMode.SetMapUnit(rOutput.GetMapMode().GetMapUnit());
1306
0
    aMapMode.SetScaleX(rOutput.GetMapMode().GetScaleX());
1307
0
    aMapMode.SetScaleY(rOutput.GetMapMode().GetScaleY());
1308
0
    xOutput->SetMapMode(aMapMode);
1309
1310
0
    Size aTempLogicSize(xOutput->PixelToLogic(aChildSizePixel));
1311
0
    Size aRenderLogicSize(rOutput.PixelToLogic(aChildSizePixel));
1312
1313
0
    switch (rOutput.GetOutDevType())
1314
0
    {
1315
0
        case OUTDEV_WINDOW:
1316
0
        case OUTDEV_VIRDEV:
1317
0
            xOutput->DrawOutDev(Point(), aTempLogicSize, rRenderLogicPos, aRenderLogicSize,
1318
0
                                rOutput);
1319
0
            break;
1320
0
        case OUTDEV_PRINTER:
1321
0
        case OUTDEV_PDF:
1322
0
            xOutput->SetBackground(rOutput.GetBackground());
1323
0
            xOutput->Erase();
1324
0
            break;
1325
0
    }
1326
1327
    //set ReallyVisible to match Visible, we restore the original state after Paint
1328
0
    WindowImpl* pImpl = pWindow->ImplGetWindowImpl();
1329
0
    bool bRVisible = pImpl->mbReallyVisible;
1330
0
    pImpl->mbReallyVisible = pWindow->IsVisible();
1331
1332
0
    pWindow->ApplySettings(*xOutput);
1333
0
    pWindow->Paint(*xOutput, tools::Rectangle(Point(), pWindow->PixelToLogic(aChildSizePixel)));
1334
1335
0
    pImpl->mbReallyVisible = bRVisible;
1336
1337
0
    switch (rOutput.GetOutDevType())
1338
0
    {
1339
0
        case OUTDEV_WINDOW:
1340
0
        case OUTDEV_VIRDEV:
1341
0
            rOutput.DrawOutDev(rRenderLogicPos, aRenderLogicSize, Point(), aTempLogicSize,
1342
0
                               *xOutput);
1343
0
            break;
1344
0
        case OUTDEV_PRINTER:
1345
0
        case OUTDEV_PDF:
1346
0
            rOutput.DrawBitmap(rRenderLogicPos, aRenderLogicSize,
1347
0
                               xOutput->GetBitmap(Point(), aTempLogicSize));
1348
0
            break;
1349
0
    }
1350
1351
0
    bool bHasMirroredGraphics = pWindow->GetOutDev()->HasMirroredGraphics();
1352
1353
0
    xOutput.disposeAndClear();
1354
1355
0
    pWindow->EnableMapMode(bOldMapModeEnabled);
1356
0
    rOutput.Pop();
1357
1358
0
    for (vcl::Window* pChild = pWindow->GetWindow(GetWindowType::FirstChild); pChild;
1359
0
         pChild = pChild->GetWindow(GetWindowType::Next))
1360
0
    {
1361
0
        if (!pChild->IsVisible())
1362
0
            continue;
1363
1364
0
        tools::Long nDeltaX
1365
0
            = pChild->GetOutDev()->GetDeviceOriginX() - pWindow->GetOutDev()->GetDeviceOriginX();
1366
0
        if (bHasMirroredGraphics)
1367
0
            nDeltaX = pWindow->GetOutDev()->GetOutputWidthPixel() - nDeltaX
1368
0
                      - pChild->GetOutDev()->GetOutputWidthPixel();
1369
1370
0
        tools::Long nDeltaY
1371
0
            = pChild->GetOutDev()->GetDeviceOriginY() - pWindow->GetOutDev()->GetDeviceOriginY();
1372
1373
0
        Point aPos(rRenderLogicPos);
1374
0
        aPos += Point(nDeltaX, nDeltaY);
1375
1376
0
        DoRecursivePaint(pChild, aPos, rOutput);
1377
0
    }
1378
0
}
1379
1380
void SalInstanceWidget::draw(OutputDevice& rOutput, const Point& rPos, const Size& rSizePixel)
1381
0
{
1382
0
    Size aOrigSize(m_xWidget->GetSizePixel());
1383
0
    bool bChangeSize = aOrigSize != rSizePixel;
1384
0
    if (bChangeSize)
1385
0
        m_xWidget->SetSizePixel(rSizePixel);
1386
1387
0
    DoRecursivePaint(m_xWidget, rPos, rOutput);
1388
1389
0
    if (bChangeSize)
1390
0
        m_xWidget->SetSizePixel(aOrigSize);
1391
0
}
1392
1393
SalInstanceBox::SalInstanceBox(VclBox* pContainer, SalInstanceBuilder* pBuilder,
1394
                               bool bTakeOwnership)
1395
0
    : SalInstanceContainer(pContainer, pBuilder, bTakeOwnership)
1396
0
    , m_xBox(pContainer)
1397
0
{
1398
0
}
Unexecuted instantiation: SalInstanceBox::SalInstanceBox(VclBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceBox::SalInstanceBox(VclBox*, SalInstanceBuilder*, bool)
1399
void SalInstanceBox::reorder_child(weld::Widget* pWidget, int nNewPosition)
1400
0
{
1401
0
    SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget);
1402
0
    assert(pVclWidget);
1403
0
    pVclWidget->getWidget()->reorderWithinParent(nNewPosition);
1404
0
}
1405
1406
0
void SalInstanceBox::sort_native_button_order() { ::sort_native_button_order(*m_xBox); }
1407
1408
SalInstanceGrid::SalInstanceGrid(VclGrid* pGrid, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1409
0
    : SalInstanceContainer(pGrid, pBuilder, bTakeOwnership)
1410
0
{
1411
0
}
Unexecuted instantiation: SalInstanceGrid::SalInstanceGrid(VclGrid*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceGrid::SalInstanceGrid(VclGrid*, SalInstanceBuilder*, bool)
1412
1413
void SalInstanceGrid::set_child_left_attach(weld::Widget& rWidget, int nAttach)
1414
0
{
1415
0
    vcl::Window* pChild = dynamic_cast<SalInstanceWidget&>(rWidget).getWidget();
1416
0
    assert(pChild && pChild->GetParent() == getWidget() && "widget is not a grid child");
1417
0
    pChild->set_grid_left_attach(nAttach);
1418
0
}
1419
1420
int SalInstanceGrid::get_child_left_attach(weld::Widget& rWidget) const
1421
0
{
1422
0
    vcl::Window* pChild = dynamic_cast<SalInstanceWidget&>(rWidget).getWidget();
1423
0
    assert(pChild && pChild->GetParent() == getWidget() && "widget is not a grid child");
1424
0
    return pChild->get_grid_left_attach();
1425
0
}
1426
1427
void SalInstanceGrid::set_child_column_span(weld::Widget& rWidget, int nCols)
1428
0
{
1429
0
    vcl::Window* pChild = dynamic_cast<SalInstanceWidget&>(rWidget).getWidget();
1430
0
    assert(pChild && pChild->GetParent() == getWidget() && "widget is not a grid child");
1431
0
    pChild->set_grid_width(nCols);
1432
0
}
1433
1434
void SalInstanceGrid::set_child_top_attach(weld::Widget& rWidget, int nAttach)
1435
0
{
1436
0
    vcl::Window* pChild = dynamic_cast<SalInstanceWidget&>(rWidget).getWidget();
1437
0
    assert(pChild && pChild->GetParent() == getWidget() && "widget is not a grid child");
1438
0
    pChild->set_grid_top_attach(nAttach);
1439
0
}
1440
1441
int SalInstanceGrid::get_child_top_attach(weld::Widget& rWidget) const
1442
0
{
1443
0
    vcl::Window* pChild = dynamic_cast<SalInstanceWidget&>(rWidget).getWidget();
1444
0
    assert(pChild && pChild->GetParent() == getWidget() && "widget is not a grid child");
1445
0
    return pChild->get_grid_top_attach();
1446
0
}
1447
1448
namespace
1449
{
1450
void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft,
1451
                     weld::ScreenShotCollection& rControlDataCollection)
1452
0
{
1453
0
    if (!rCurrent.IsVisible())
1454
0
        return;
1455
1456
0
    const Point aCurrentPos(rCurrent.GetPosPixel());
1457
0
    const Size aCurrentSize(rCurrent.GetSizePixel());
1458
0
    const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(),
1459
0
                                            rTopLeft.getY() + aCurrentPos.Y());
1460
0
    const basegfx::B2IRange aCurrentRange(
1461
0
        aCurrentTopLeft,
1462
0
        aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height()));
1463
1464
0
    if (!aCurrentRange.isEmpty())
1465
0
    {
1466
0
        rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange);
1467
0
    }
1468
1469
0
    for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++)
1470
0
    {
1471
0
        vcl::Window* pChild = rCurrent.GetChild(a);
1472
0
        if (nullptr != pChild)
1473
0
        {
1474
0
            CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection);
1475
0
        }
1476
0
    }
1477
0
}
1478
}
1479
1480
void SalInstanceWindow::override_child_help(vcl::Window* pParent)
1481
0
{
1482
0
    for (vcl::Window* pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild;
1483
0
         pChild = pChild->GetWindow(GetWindowType::Next))
1484
0
        override_child_help(pChild);
1485
0
    pParent->SetHelpHdl(LINK(this, SalInstanceWindow, HelpHdl));
1486
0
}
1487
1488
void SalInstanceWindow::clear_child_help(vcl::Window* pParent)
1489
0
{
1490
0
    for (vcl::Window* pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild;
1491
0
         pChild = pChild->GetWindow(GetWindowType::Next))
1492
0
        clear_child_help(pChild);
1493
0
    pParent->SetHelpHdl(Link<vcl::Window&, bool>());
1494
0
}
1495
1496
SalInstanceWindow::SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder,
1497
                                     bool bTakeOwnership)
1498
117
    : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership)
1499
117
    , m_xWindow(pWindow)
1500
117
{
1501
    // tdf#129745 only override child help for the normal case, not for
1502
    // m_pBuilder of null which is the toplevel application frame case.
1503
117
    if (m_pBuilder)
1504
0
        override_child_help(m_xWindow);
1505
117
}
Unexecuted instantiation: SalInstanceWindow::SalInstanceWindow(vcl::Window*, SalInstanceBuilder*, bool)
SalInstanceWindow::SalInstanceWindow(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
1498
117
    : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership)
1499
117
    , m_xWindow(pWindow)
1500
117
{
1501
    // tdf#129745 only override child help for the normal case, not for
1502
    // m_pBuilder of null which is the toplevel application frame case.
1503
117
    if (m_pBuilder)
1504
0
        override_child_help(m_xWindow);
1505
117
}
1506
1507
0
void SalInstanceWindow::set_title(const OUString& rTitle) { m_xWindow->SetText(rTitle); }
1508
1509
0
OUString SalInstanceWindow::get_title() const { return m_xWindow->GetText(); }
1510
1511
css::uno::Reference<css::awt::XWindow> SalInstanceWindow::GetXWindow()
1512
171
{
1513
171
    css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(),
1514
171
                                                   css::uno::UNO_QUERY);
1515
171
    return xWindow;
1516
171
}
1517
1518
namespace
1519
{
1520
void resize_to_request(vcl::Window* pWindow)
1521
0
{
1522
0
    if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWindow))
1523
0
    {
1524
0
        pSysWin->setOptimalLayoutSize(true);
1525
0
        return;
1526
0
    }
1527
0
    if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(pWindow))
1528
0
    {
1529
0
        pDockWin->setOptimalLayoutSize();
1530
0
        return;
1531
0
    }
1532
0
    assert(false && "must be system or docking window");
1533
0
}
1534
}
1535
1536
0
void SalInstanceWindow::resize_to_request() { ::resize_to_request(m_xWindow.get()); }
1537
1538
0
void SalInstanceWindow::window_move(int x, int y) { m_xWindow->SetPosPixel(Point(x, y)); }
1539
1540
0
Size SalInstanceWindow::get_size() const { return m_xWindow->GetSizePixel(); }
1541
1542
0
Point SalInstanceWindow::get_position() const { return m_xWindow->GetPosPixel(); }
1543
1544
0
bool SalInstanceWindow::get_resizable() const { return m_xWindow->GetStyle() & WB_SIZEABLE; }
1545
1546
0
bool SalInstanceWindow::has_toplevel_focus() const { return m_xWindow->HasChildPathFocus(); }
1547
1548
void SalInstanceWindow::present()
1549
0
{
1550
0
    m_xWindow->ToTop(ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask);
1551
0
}
1552
1553
void SalInstanceWindow::set_window_state(const vcl::WindowData& rState)
1554
0
{
1555
0
    SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get());
1556
0
    assert(pSysWin);
1557
0
    pSysWin->SetWindowState(rState);
1558
0
}
1559
1560
vcl::WindowData SalInstanceWindow::get_window_state(vcl::WindowDataMask nMask) const
1561
0
{
1562
0
    SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get());
1563
0
    assert(pSysWin);
1564
0
    return pSysWin->GetWindowState(nMask);
1565
0
}
1566
1567
0
SystemEnvData SalInstanceWindow::get_system_data() const { return *m_xWindow->GetSystemData(); }
1568
1569
VclPtr<VirtualDevice> SalInstanceWindow::screenshot()
1570
0
{
1571
0
    SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(m_xWindow.get());
1572
0
    assert(pSysWin);
1573
0
    return pSysWin->createScreenshot();
1574
0
}
1575
1576
weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data()
1577
0
{
1578
0
    weld::ScreenShotCollection aRet;
1579
1580
    // collect all children. Choose start pos to be negative
1581
    // of target dialog's position to get all positions relative to (0,0)
1582
0
    const Point aParentPos(m_xWindow->GetPosPixel());
1583
0
    const basegfx::B2IPoint aTopLeft(-aParentPos.X(), -aParentPos.Y());
1584
0
    CollectChildren(*m_xWindow, aTopLeft, aRet);
1585
1586
0
    return aRet;
1587
0
}
1588
1589
SalInstanceWindow::~SalInstanceWindow()
1590
117
{
1591
    // tdf#129745 only undo overriding child help for the normal case, not for
1592
    // m_pBuilder of null which is the toplevel application frame case.
1593
117
    if (m_pBuilder)
1594
0
        clear_child_help(m_xWindow);
1595
117
}
1596
1597
IMPL_LINK_NOARG(SalInstanceWindow, HelpHdl, vcl::Window&, bool)
1598
0
{
1599
0
    help();
1600
0
    return false;
1601
0
}
1602
1603
typedef std::set<VclPtr<vcl::Window>> winset;
1604
1605
namespace
1606
{
1607
void hideUnless(const vcl::Window* pTop, const winset& rVisibleWidgets,
1608
                std::vector<VclPtr<vcl::Window>>& rWasVisibleWidgets)
1609
0
{
1610
0
    for (vcl::Window* pChild = pTop->GetWindow(GetWindowType::FirstChild); pChild;
1611
0
         pChild = pChild->GetWindow(GetWindowType::Next))
1612
0
    {
1613
0
        if (!pChild->IsVisible())
1614
0
            continue;
1615
0
        if (rVisibleWidgets.find(pChild) == rVisibleWidgets.end())
1616
0
        {
1617
0
            rWasVisibleWidgets.emplace_back(pChild);
1618
0
            pChild->Hide();
1619
0
        }
1620
0
        else if (isContainerWindow(pChild))
1621
0
        {
1622
0
            hideUnless(pChild, rVisibleWidgets, rWasVisibleWidgets);
1623
0
        }
1624
0
    }
1625
0
}
1626
}
1627
1628
SalInstanceDialog::SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder,
1629
                                     bool bTakeOwnership)
1630
0
    : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership)
1631
0
    , m_xDialog(pDialog)
1632
0
    , m_nOldEditWidthReq(0)
1633
0
    , m_nOldBorderWidth(0)
1634
0
{
1635
0
}
Unexecuted instantiation: SalInstanceDialog::SalInstanceDialog(Dialog*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceDialog::SalInstanceDialog(Dialog*, SalInstanceBuilder*, bool)
1636
1637
bool SalInstanceDialog::runAsync(std::shared_ptr<weld::DialogController> const& rxOwner,
1638
                                 const std::function<void(sal_Int32)>& rEndDialogFn)
1639
0
{
1640
0
    VclAbstractDialog::AsyncContext aCtx;
1641
0
    aCtx.mxOwnerDialogController = rxOwner;
1642
0
    aCtx.maEndDialogFn = rEndDialogFn;
1643
0
    VclButtonBox* pActionArea = m_xDialog->get_action_area();
1644
0
    if (pActionArea)
1645
0
        sort_native_button_order(*pActionArea);
1646
0
    return m_xDialog->StartExecuteAsync(aCtx);
1647
0
}
1648
1649
bool SalInstanceDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
1650
                                 const std::function<void(sal_Int32)>& rEndDialogFn)
1651
0
{
1652
0
    assert(rxSelf.get() == this);
1653
0
    VclAbstractDialog::AsyncContext aCtx;
1654
    // In order to store a shared_ptr to ourself, we have to have been constructed by make_shared,
1655
    // which is that rxSelf enforces.
1656
0
    aCtx.mxOwnerSelf = rxSelf;
1657
0
    aCtx.maEndDialogFn = rEndDialogFn;
1658
0
    VclButtonBox* pActionArea = m_xDialog->get_action_area();
1659
0
    if (pActionArea)
1660
0
        sort_native_button_order(*pActionArea);
1661
0
    return m_xDialog->StartExecuteAsync(aCtx);
1662
0
}
1663
1664
void SalInstanceDialog::collapse(weld::Widget& rEdit, weld::Widget* pButton)
1665
0
{
1666
0
    SalInstanceWidget& rVclEdit = dynamic_cast<SalInstanceWidget&>(rEdit);
1667
0
    SalInstanceWidget* pVclButton = dynamic_cast<SalInstanceWidget*>(pButton);
1668
1669
0
    vcl::Window* pRefEdit = rVclEdit.getWidget();
1670
0
    vcl::Window* pRefBtn = pVclButton ? pVclButton->getWidget() : nullptr;
1671
1672
0
    auto nOldEditWidth = pRefEdit->GetSizePixel().Width();
1673
0
    m_nOldEditWidthReq = pRefEdit->get_width_request();
1674
1675
    //We want just pRefBtn and pRefEdit to be shown
1676
    //mark widgets we want to be visible, starting with pRefEdit
1677
    //and all its direct parents.
1678
0
    winset aVisibleWidgets;
1679
0
    vcl::Window* pContentArea = m_xDialog->get_content_area();
1680
0
    for (vcl::Window* pCandidate = pRefEdit;
1681
0
         pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible());
1682
0
         pCandidate = pCandidate->GetWindow(GetWindowType::RealParent))
1683
0
    {
1684
0
        aVisibleWidgets.insert(pCandidate);
1685
0
    }
1686
    //same again with pRefBtn, except stop if there's a
1687
    //shared parent in the existing widgets
1688
0
    for (vcl::Window* pCandidate = pRefBtn;
1689
0
         pCandidate && (pCandidate != pContentArea && pCandidate->IsVisible());
1690
0
         pCandidate = pCandidate->GetWindow(GetWindowType::RealParent))
1691
0
    {
1692
0
        if (aVisibleWidgets.insert(pCandidate).second)
1693
0
            break;
1694
0
    }
1695
1696
    //hide everything except the aVisibleWidgets
1697
0
    hideUnless(pContentArea, aVisibleWidgets, m_aHiddenWidgets);
1698
1699
    // the insert function case has an initially hidden edit widget, so it has
1700
    // not start size, so take larger of actual size and size request
1701
0
    pRefEdit->set_width_request(std::max(nOldEditWidth, m_nOldEditWidthReq));
1702
0
    m_nOldBorderWidth = m_xDialog->get_border_width();
1703
0
    m_xDialog->set_border_width(0);
1704
0
    if (vcl::Window* pActionArea = m_xDialog->get_action_area())
1705
0
        pActionArea->Hide();
1706
0
    m_xDialog->setOptimalLayoutSize(true);
1707
0
    m_xRefEdit = pRefEdit;
1708
0
}
1709
1710
void SalInstanceDialog::undo_collapse()
1711
0
{
1712
    // All others: Show();
1713
0
    for (VclPtr<vcl::Window> const& pWindow : m_aHiddenWidgets)
1714
0
    {
1715
0
        pWindow->Show();
1716
0
    }
1717
0
    m_aHiddenWidgets.clear();
1718
1719
0
    m_xRefEdit->set_width_request(m_nOldEditWidthReq);
1720
0
    m_xRefEdit.reset();
1721
0
    m_xDialog->set_border_width(m_nOldBorderWidth);
1722
0
    if (vcl::Window* pActionArea = m_xDialog->get_action_area())
1723
0
        pActionArea->Show();
1724
0
    m_xDialog->setOptimalLayoutSize(true);
1725
0
}
1726
1727
void SalInstanceDialog::SetInstallLOKNotifierHdl(
1728
    const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink)
1729
0
{
1730
0
    m_xDialog->SetInstallLOKNotifierHdl(rLink);
1731
0
}
1732
1733
int SalInstanceDialog::run()
1734
0
{
1735
0
    VclButtonBox* pActionArea = m_xDialog->get_action_area();
1736
0
    if (pActionArea)
1737
0
        sort_native_button_order(*pActionArea);
1738
0
    return m_xDialog->Execute();
1739
0
}
1740
1741
0
void SalInstanceDialog::response(int nResponse) { m_xDialog->EndDialog(nResponse); }
1742
1743
void SalInstanceDialog::add_button(const OUString& rText, int nResponse, const OUString& rHelpId)
1744
0
{
1745
0
    VclButtonBox* pBox = m_xDialog->get_action_area();
1746
0
    VclPtr<PushButton> xButton(
1747
0
        VclPtr<PushButton>::Create(pBox, WB_CLIPCHILDREN | WB_CENTER | WB_VCENTER));
1748
0
    xButton->SetText(rText);
1749
0
    xButton->SetHelpId(rHelpId);
1750
1751
0
    switch (nResponse)
1752
0
    {
1753
0
        case RET_OK:
1754
0
            xButton->set_id(u"ok"_ustr);
1755
0
            break;
1756
0
        case RET_CLOSE:
1757
0
            xButton->set_id(u"close"_ustr);
1758
0
            break;
1759
0
        case RET_CANCEL:
1760
0
            xButton->set_id(u"cancel"_ustr);
1761
0
            break;
1762
0
        case RET_YES:
1763
0
            xButton->set_id(u"yes"_ustr);
1764
0
            break;
1765
0
        case RET_NO:
1766
0
            xButton->set_id(u"no"_ustr);
1767
0
            break;
1768
0
    }
1769
1770
0
    xButton->Show();
1771
0
    m_xDialog->add_button(xButton, nResponse, true);
1772
0
}
1773
1774
void SalInstanceDialog::set_modal(bool bModal)
1775
0
{
1776
0
    if (get_modal() == bModal)
1777
0
        return;
1778
0
    m_xDialog->SetModalInputMode(bModal);
1779
0
}
1780
1781
0
bool SalInstanceDialog::get_modal() const { return m_xDialog->IsModalInputMode(); }
1782
1783
void SalInstanceDialog::set_centered_on_parent(bool /*bTrackGeometryRequests*/)
1784
0
{
1785
0
    if (vcl::Window* pParent = m_xWidget->GetParent())
1786
0
    {
1787
0
        Size aParentGeometry(pParent->GetSizePixel());
1788
0
        Size aGeometry(m_xWidget->get_preferred_size());
1789
0
        auto nX = (aParentGeometry.Width() - aGeometry.Width()) / 2;
1790
0
        auto nY = (aParentGeometry.Height() - aGeometry.Height()) / 2;
1791
0
        m_xWidget->SetPosPixel(Point(nX, nY));
1792
0
    }
1793
0
}
1794
1795
void SalInstanceDialog::set_default_response(int nResponse)
1796
0
{
1797
0
    m_xDialog->set_default_response(nResponse);
1798
0
}
1799
1800
std::unique_ptr<weld::Container> SalInstanceDialog::weld_content_area()
1801
0
{
1802
0
    return std::make_unique<SalInstanceContainer>(m_xDialog->get_content_area(), m_pBuilder, false);
1803
0
}
1804
1805
void SalInstanceDialog::implResetDefault(const vcl::Window* _pWindow)
1806
0
{
1807
0
    vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild);
1808
0
    while (pChildLoop)
1809
0
    {
1810
        // does the window participate in the tabbing order?
1811
0
        if (pChildLoop->GetStyle() & WB_DIALOGCONTROL)
1812
0
            implResetDefault(pChildLoop);
1813
1814
        // is it a button?
1815
0
        WindowType eType = pChildLoop->GetType();
1816
0
        if ((WindowType::PUSHBUTTON == eType) || (WindowType::OKBUTTON == eType)
1817
0
            || (WindowType::CANCELBUTTON == eType) || (WindowType::HELPBUTTON == eType)
1818
0
            || (WindowType::IMAGEBUTTON == eType) || (WindowType::MENUBUTTON == eType)
1819
0
            || (WindowType::MOREBUTTON == eType))
1820
0
        {
1821
0
            pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON);
1822
0
        }
1823
1824
        // the next one ...
1825
0
        pChildLoop = pChildLoop->GetWindow(GetWindowType::Next);
1826
0
    }
1827
0
}
1828
1829
0
void SalInstanceDialog::recursively_unset_default_buttons() { implResetDefault(m_xDialog.get()); }
1830
1831
void SalInstanceDialog::change_default_button(weld::Button* pOld, weld::Button* pNew)
1832
0
{
1833
0
    SalInstanceButton* pVclNew = dynamic_cast<SalInstanceButton*>(pNew);
1834
0
    vcl::Window* pWidgetNew = pVclNew ? pVclNew->getWidget() : nullptr;
1835
0
    SalInstanceButton* pVclOld = dynamic_cast<SalInstanceButton*>(pOld);
1836
0
    vcl::Window* pWidgetOld = pVclOld ? pVclOld->getWidget() : nullptr;
1837
0
    if (pWidgetOld)
1838
0
        pWidgetOld->set_property(u"has-default"_ustr, OUString::boolean(false));
1839
0
    else
1840
0
        recursively_unset_default_buttons();
1841
0
    if (pWidgetNew)
1842
0
        pWidgetNew->set_property(u"has-default"_ustr, OUString::boolean(true));
1843
0
}
1844
1845
bool SalInstanceDialog::is_default_button(const weld::Button* pCandidate) const
1846
0
{
1847
0
    const SalInstanceWidget* pVclCandidate = dynamic_cast<const SalInstanceWidget*>(pCandidate);
1848
0
    vcl::Window* pWidget = pVclCandidate ? pVclCandidate->getWidget() : nullptr;
1849
0
    return pWidget && pWidget->GetStyle() & WB_DEFBUTTON;
1850
0
}
1851
1852
SalInstanceMessageDialog::SalInstanceMessageDialog(::MessageDialog* pDialog,
1853
                                                   SalInstanceBuilder* pBuilder,
1854
                                                   bool bTakeOwnership)
1855
0
    : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership)
1856
0
    , m_xMessageDialog(pDialog)
1857
0
{
1858
0
}
Unexecuted instantiation: SalInstanceMessageDialog::SalInstanceMessageDialog(MessageDialog*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceMessageDialog::SalInstanceMessageDialog(MessageDialog*, SalInstanceBuilder*, bool)
1859
1860
void SalInstanceMessageDialog::set_primary_text(const OUString& rText)
1861
0
{
1862
0
    m_xMessageDialog->set_primary_text(rText);
1863
0
}
1864
1865
OUString SalInstanceMessageDialog::get_primary_text() const
1866
0
{
1867
0
    return m_xMessageDialog->get_primary_text();
1868
0
}
1869
1870
void SalInstanceMessageDialog::set_secondary_text(const OUString& rText)
1871
0
{
1872
0
    m_xMessageDialog->set_secondary_text(rText);
1873
0
}
1874
1875
OUString SalInstanceMessageDialog::get_secondary_text() const
1876
0
{
1877
0
    return m_xMessageDialog->get_secondary_text();
1878
0
}
1879
1880
std::unique_ptr<weld::Container> SalInstanceMessageDialog::weld_message_area()
1881
0
{
1882
0
    return std::make_unique<SalInstanceContainer>(m_xMessageDialog->get_message_area(), m_pBuilder,
1883
0
                                                  false);
1884
0
}
1885
1886
int SalInstanceAssistant::find_page(std::u16string_view rIdent) const
1887
0
{
1888
0
    for (size_t i = 0; i < m_aAddedPages.size(); ++i)
1889
0
    {
1890
0
        if (m_aAddedPages[i]->get_id() == rIdent)
1891
0
            return i;
1892
0
    }
1893
0
    return -1;
1894
0
}
1895
1896
int SalInstanceAssistant::find_id(int nId) const
1897
0
{
1898
0
    for (size_t i = 0; i < m_aIds.size(); ++i)
1899
0
    {
1900
0
        if (nId == m_aIds[i])
1901
0
            return i;
1902
0
    }
1903
0
    return -1;
1904
0
}
1905
1906
SalInstanceAssistant::SalInstanceAssistant(vcl::RoadmapWizard* pDialog,
1907
                                           SalInstanceBuilder* pBuilder, bool bTakeOwnership)
1908
0
    : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership)
1909
0
    , m_xWizard(pDialog)
1910
0
    , m_aUpdateRoadmapIdle("SalInstanceAssistant m_aUpdateRoadmapIdle")
1911
0
{
1912
0
    m_xWizard->SetItemSelectHdl(LINK(this, SalInstanceAssistant, OnRoadmapItemSelected));
1913
1914
0
    m_aUpdateRoadmapIdle.SetInvokeHandler(LINK(this, SalInstanceAssistant, UpdateRoadmap_Hdl));
1915
0
    m_aUpdateRoadmapIdle.SetPriority(TaskPriority::HIGHEST);
1916
0
}
Unexecuted instantiation: SalInstanceAssistant::SalInstanceAssistant(vcl::RoadmapWizard*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceAssistant::SalInstanceAssistant(vcl::RoadmapWizard*, SalInstanceBuilder*, bool)
1917
1918
0
int SalInstanceAssistant::get_current_page() const { return find_id(m_xWizard->GetCurLevel()); }
1919
1920
0
int SalInstanceAssistant::get_n_pages() const { return m_aAddedPages.size(); }
1921
1922
OUString SalInstanceAssistant::get_page_ident(int nPage) const
1923
0
{
1924
0
    return m_aAddedPages[nPage]->get_id();
1925
0
}
1926
1927
OUString SalInstanceAssistant::get_current_page_ident() const
1928
0
{
1929
0
    return get_page_ident(get_current_page());
1930
0
}
1931
1932
void SalInstanceAssistant::do_set_current_page(int nPage)
1933
0
{
1934
    // take the first shown page as the size for all pages
1935
0
    if (m_xWizard->GetPageSizePixel().Width() == 0)
1936
0
    {
1937
0
        Size aFinalSize;
1938
0
        for (int i = 0, nPages = get_n_pages(); i < nPages; ++i)
1939
0
        {
1940
0
            TabPage* pPage = m_xWizard->GetPage(m_aIds[i]);
1941
0
            assert(pPage);
1942
0
            Size aPageSize(pPage->get_preferred_size());
1943
0
            if (aPageSize.Width() > aFinalSize.Width())
1944
0
                aFinalSize.setWidth(aPageSize.Width());
1945
0
            if (aPageSize.Height() > aFinalSize.Height())
1946
0
                aFinalSize.setHeight(aPageSize.Height());
1947
0
        }
1948
0
        m_xWizard->SetPageSizePixel(aFinalSize);
1949
0
    }
1950
1951
0
    m_xWizard->ShowPage(m_aIds[nPage]);
1952
0
}
1953
1954
void SalInstanceAssistant::do_set_current_page(const OUString& rIdent)
1955
0
{
1956
0
    int nIndex = find_page(rIdent);
1957
0
    if (nIndex == -1)
1958
0
        return;
1959
0
    do_set_current_page(nIndex);
1960
0
}
1961
1962
void SalInstanceAssistant::do_set_page_index(const OUString& rIdent, int nNewIndex)
1963
0
{
1964
0
    int nOldIndex = find_page(rIdent);
1965
1966
0
    if (nOldIndex == -1)
1967
0
        return;
1968
1969
0
    if (nOldIndex == nNewIndex)
1970
0
        return;
1971
1972
0
    auto entry = std::move(m_aAddedPages[nOldIndex]);
1973
0
    m_aAddedPages.erase(m_aAddedPages.begin() + nOldIndex);
1974
0
    m_aAddedPages.insert(m_aAddedPages.begin() + nNewIndex, std::move(entry));
1975
1976
0
    int nId = m_aIds[nOldIndex];
1977
0
    m_aIds.erase(m_aIds.begin() + nOldIndex);
1978
0
    m_aIds.insert(m_aIds.begin() + nNewIndex, nId);
1979
1980
0
    m_aUpdateRoadmapIdle.Start();
1981
0
}
1982
1983
weld::Container* SalInstanceAssistant::append_page(const OUString& rIdent)
1984
0
{
1985
0
    VclPtrInstance<TabPage> xPage(m_xWizard);
1986
0
    VclPtrInstance<VclGrid> xGrid(xPage);
1987
0
    xPage->set_id(rIdent);
1988
0
    xPage->Show();
1989
0
    xGrid->set_hexpand(true);
1990
0
    xGrid->set_vexpand(true);
1991
0
    xGrid->Show();
1992
0
    m_xWizard->AddPage(xPage);
1993
0
    m_aIds.push_back(m_aAddedPages.size());
1994
0
    m_xWizard->SetPage(m_aIds.back(), xPage);
1995
0
    m_aAddedPages.push_back(xPage);
1996
0
    m_aAddedGrids.push_back(xGrid);
1997
1998
0
    m_aUpdateRoadmapIdle.Start();
1999
2000
0
    m_aPages.emplace_back(new SalInstanceContainer(xGrid, m_pBuilder, false));
2001
0
    return m_aPages.back().get();
2002
0
}
2003
2004
OUString SalInstanceAssistant::get_page_title(const OUString& rIdent) const
2005
0
{
2006
0
    int nIndex = find_page(rIdent);
2007
0
    if (nIndex == -1)
2008
0
        return OUString();
2009
0
    return m_aAddedPages[nIndex]->GetText();
2010
0
}
2011
2012
void SalInstanceAssistant::do_set_page_title(const OUString& rIdent, const OUString& rTitle)
2013
0
{
2014
0
    int nIndex = find_page(rIdent);
2015
0
    if (nIndex == -1)
2016
0
        return;
2017
0
    if (m_aAddedPages[nIndex]->GetText() != rTitle)
2018
0
    {
2019
0
        m_aAddedPages[nIndex]->SetText(rTitle);
2020
0
        m_aUpdateRoadmapIdle.Start();
2021
0
    }
2022
0
}
2023
2024
void SalInstanceAssistant::do_set_page_sensitive(const OUString& rIdent, bool bSensitive)
2025
0
{
2026
0
    int nIndex = find_page(rIdent);
2027
0
    if (nIndex == -1)
2028
0
        return;
2029
0
    if (m_aAddedPages[nIndex]->IsEnabled() != bSensitive)
2030
0
    {
2031
0
        m_aAddedPages[nIndex]->Enable(bSensitive);
2032
0
        m_aUpdateRoadmapIdle.Start();
2033
0
    }
2034
0
}
2035
2036
void SalInstanceAssistant::set_page_side_help_id(const OUString& rHelpId)
2037
0
{
2038
0
    m_xWizard->SetRoadmapHelpId(rHelpId);
2039
0
}
2040
2041
void SalInstanceAssistant::set_page_side_image(const OUString& rImage)
2042
0
{
2043
0
    m_xWizard->SetRoadmapBitmap(createImage(rImage).GetBitmap());
2044
0
}
2045
2046
SalInstanceAssistant::~SalInstanceAssistant()
2047
0
{
2048
0
    for (auto& rGrid : m_aAddedGrids)
2049
0
        rGrid.disposeAndClear();
2050
0
    for (auto& rPage : m_aAddedPages)
2051
0
        rPage.disposeAndClear();
2052
0
}
2053
2054
IMPL_LINK_NOARG(SalInstanceAssistant, OnRoadmapItemSelected, LinkParamNone*, void)
2055
0
{
2056
0
    auto nCurItemId = m_xWizard->GetCurrentRoadmapItemID();
2057
0
    int nPageIndex(find_id(nCurItemId));
2058
0
    if (!signal_jump_page(get_page_ident(nPageIndex)) && nCurItemId != m_xWizard->GetCurLevel())
2059
0
        m_xWizard->SelectRoadmapItemByID(m_xWizard->GetCurLevel());
2060
0
}
2061
2062
IMPL_LINK_NOARG(SalInstanceAssistant, UpdateRoadmap_Hdl, Timer*, void)
2063
0
{
2064
0
    disable_notify_events();
2065
2066
0
    m_xWizard->DeleteRoadmapItems();
2067
2068
0
    int nPos = 0;
2069
0
    for (size_t i = 0; i < m_aAddedPages.size(); ++i)
2070
0
    {
2071
0
        const OUString aLabel = m_aAddedPages[i]->GetText();
2072
0
        bool bSensitive = m_aAddedPages[i]->IsEnabled();
2073
0
        if (aLabel.isEmpty())
2074
0
            continue;
2075
0
        m_xWizard->InsertRoadmapItem(nPos++, aLabel, m_aIds[i], bSensitive);
2076
0
    }
2077
2078
0
    m_xWizard->SelectRoadmapItemByID(m_aIds[get_current_page()], false);
2079
2080
0
    m_xWizard->ShowRoadmap(nPos != 0);
2081
2082
0
    enable_notify_events();
2083
0
}
2084
2085
SalInstanceFrame::SalInstanceFrame(VclFrame* pFrame, SalInstanceBuilder* pBuilder,
2086
                                   bool bTakeOwnership)
2087
0
    : SalInstanceContainer(pFrame, pBuilder, bTakeOwnership)
2088
0
    , m_xFrame(pFrame)
2089
0
{
2090
0
}
Unexecuted instantiation: SalInstanceFrame::SalInstanceFrame(VclFrame*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceFrame::SalInstanceFrame(VclFrame*, SalInstanceBuilder*, bool)
2091
2092
0
void SalInstanceFrame::set_label(const OUString& rText) { m_xFrame->set_label(rText); }
2093
2094
0
OUString SalInstanceFrame::get_label() const { return m_xFrame->get_label(); }
2095
2096
namespace
2097
{
2098
class SalInstancePaned : public SalInstanceContainer, public virtual weld::Paned
2099
{
2100
private:
2101
    VclPtr<VclPaned> m_xPaned;
2102
2103
public:
2104
    SalInstancePaned(VclPaned* pPaned, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
2105
0
        : SalInstanceContainer(pPaned, pBuilder, bTakeOwnership)
2106
0
        , m_xPaned(pPaned)
2107
0
    {
2108
0
    }
2109
2110
0
    virtual void set_position(int nPos) override { m_xPaned->set_position(nPos); }
2111
2112
0
    virtual int get_position() const override { return m_xPaned->get_position(); }
2113
};
2114
}
2115
2116
void SalInstanceScrolledWindow::customize_scrollbars(ScrollBar& rScrollBar,
2117
                                                     const Color& rButtonTextColor,
2118
                                                     const Color& rBackgroundColor,
2119
                                                     const Color& rShadowColor,
2120
                                                     const Color& rFaceColor)
2121
0
{
2122
0
    rScrollBar.EnableNativeWidget(false);
2123
0
    AllSettings aSettings = rScrollBar.GetSettings();
2124
0
    StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2125
0
    aStyleSettings.SetButtonTextColor(rButtonTextColor);
2126
0
    aStyleSettings.SetCheckedColor(rBackgroundColor); // background
2127
0
    aStyleSettings.SetShadowColor(rShadowColor);
2128
0
    aStyleSettings.SetFaceColor(rFaceColor);
2129
0
    aSettings.SetStyleSettings(aStyleSettings);
2130
0
    rScrollBar.SetSettings(aSettings);
2131
0
}
2132
2133
SalInstanceScrolledWindow::SalInstanceScrolledWindow(VclScrolledWindow* pScrolledWindow,
2134
                                                     SalInstanceBuilder* pBuilder,
2135
                                                     bool bTakeOwnership,
2136
                                                     bool bUserManagedScrolling)
2137
0
    : SalInstanceContainer(pScrolledWindow, pBuilder, bTakeOwnership)
2138
0
    , m_xScrolledWindow(pScrolledWindow)
2139
0
    , m_bUserManagedScrolling(bUserManagedScrolling)
2140
0
{
2141
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2142
0
    m_aOrigVScrollHdl = rVertScrollBar.GetScrollHdl();
2143
0
    rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceScrolledWindow, VscrollHdl));
2144
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2145
0
    m_aOrigHScrollHdl = rHorzScrollBar.GetScrollHdl();
2146
0
    rHorzScrollBar.SetScrollHdl(LINK(this, SalInstanceScrolledWindow, HscrollHdl));
2147
0
    m_xScrolledWindow->setUserManagedScrolling(m_bUserManagedScrolling);
2148
0
}
Unexecuted instantiation: SalInstanceScrolledWindow::SalInstanceScrolledWindow(VclScrolledWindow*, SalInstanceBuilder*, bool, bool)
Unexecuted instantiation: SalInstanceScrolledWindow::SalInstanceScrolledWindow(VclScrolledWindow*, SalInstanceBuilder*, bool, bool)
2149
2150
void SalInstanceScrolledWindow::hadjustment_configure(int value, int upper, int step_increment,
2151
                                                      int page_increment, int page_size)
2152
0
{
2153
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2154
0
    rHorzScrollBar.SetRangeMin(0);
2155
0
    rHorzScrollBar.SetRangeMax(upper);
2156
0
    rHorzScrollBar.SetLineSize(step_increment);
2157
0
    rHorzScrollBar.SetPageSize(page_increment);
2158
0
    rHorzScrollBar.SetThumbPos(value);
2159
0
    rHorzScrollBar.SetVisibleSize(page_size);
2160
0
}
2161
2162
int SalInstanceScrolledWindow::hadjustment_get_value() const
2163
0
{
2164
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2165
0
    return rHorzScrollBar.GetThumbPos();
2166
0
}
2167
2168
void SalInstanceScrolledWindow::hadjustment_set_value(int value)
2169
0
{
2170
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2171
0
    rHorzScrollBar.SetThumbPos(value);
2172
0
    if (!m_bUserManagedScrolling)
2173
0
        m_aOrigHScrollHdl.Call(&rHorzScrollBar);
2174
0
}
2175
2176
int SalInstanceScrolledWindow::hadjustment_get_upper() const
2177
0
{
2178
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2179
0
    return rHorzScrollBar.GetRangeMax();
2180
0
}
2181
2182
void SalInstanceScrolledWindow::hadjustment_set_upper(int upper)
2183
0
{
2184
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2185
0
    rHorzScrollBar.SetRangeMax(upper);
2186
0
}
2187
2188
int SalInstanceScrolledWindow::hadjustment_get_page_size() const
2189
0
{
2190
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2191
0
    return rHorzScrollBar.GetVisibleSize();
2192
0
}
2193
2194
void SalInstanceScrolledWindow::hadjustment_set_page_size(int size)
2195
0
{
2196
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2197
0
    return rHorzScrollBar.SetVisibleSize(size);
2198
0
}
2199
2200
void SalInstanceScrolledWindow::hadjustment_set_page_increment(int size)
2201
0
{
2202
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2203
0
    return rHorzScrollBar.SetPageSize(size);
2204
0
}
2205
2206
void SalInstanceScrolledWindow::hadjustment_set_step_increment(int size)
2207
0
{
2208
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2209
0
    return rHorzScrollBar.SetLineSize(size);
2210
0
}
2211
2212
void SalInstanceScrolledWindow::set_hpolicy(VclPolicyType eHPolicy)
2213
0
{
2214
0
    WinBits nWinBits = m_xScrolledWindow->GetStyle() & ~(WB_AUTOHSCROLL | WB_HSCROLL);
2215
0
    if (eHPolicy == VclPolicyType::ALWAYS)
2216
0
        nWinBits |= WB_HSCROLL;
2217
0
    else if (eHPolicy == VclPolicyType::AUTOMATIC)
2218
0
        nWinBits |= WB_AUTOHSCROLL;
2219
0
    m_xScrolledWindow->SetStyle(nWinBits);
2220
0
    m_xScrolledWindow->queue_resize();
2221
0
}
2222
2223
VclPolicyType SalInstanceScrolledWindow::get_hpolicy() const
2224
0
{
2225
0
    WinBits nWinBits = m_xScrolledWindow->GetStyle();
2226
0
    if (nWinBits & WB_AUTOHSCROLL)
2227
0
        return VclPolicyType::AUTOMATIC;
2228
0
    else if (nWinBits & WB_HSCROLL)
2229
0
        return VclPolicyType::ALWAYS;
2230
0
    return VclPolicyType::NEVER;
2231
0
}
2232
2233
void SalInstanceScrolledWindow::vadjustment_configure(int value, int upper, int step_increment,
2234
                                                      int page_increment, int page_size)
2235
0
{
2236
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2237
0
    rVertScrollBar.SetRangeMin(0);
2238
0
    rVertScrollBar.SetRangeMax(upper);
2239
0
    rVertScrollBar.SetLineSize(step_increment);
2240
0
    rVertScrollBar.SetPageSize(page_increment);
2241
0
    rVertScrollBar.SetThumbPos(value);
2242
0
    rVertScrollBar.SetVisibleSize(page_size);
2243
0
}
2244
2245
int SalInstanceScrolledWindow::vadjustment_get_value() const
2246
0
{
2247
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2248
0
    return rVertScrollBar.GetThumbPos();
2249
0
}
2250
2251
void SalInstanceScrolledWindow::vadjustment_set_value(int value)
2252
0
{
2253
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2254
0
    rVertScrollBar.SetThumbPos(value);
2255
0
    if (!m_bUserManagedScrolling)
2256
0
        m_aOrigVScrollHdl.Call(&rVertScrollBar);
2257
0
}
2258
2259
int SalInstanceScrolledWindow::vadjustment_get_upper() const
2260
0
{
2261
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2262
0
    return rVertScrollBar.GetRangeMax();
2263
0
}
2264
2265
void SalInstanceScrolledWindow::vadjustment_set_upper(int upper)
2266
0
{
2267
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2268
0
    rVertScrollBar.SetRangeMax(upper);
2269
0
}
2270
2271
int SalInstanceScrolledWindow::vadjustment_get_page_size() const
2272
0
{
2273
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2274
0
    return rVertScrollBar.GetVisibleSize();
2275
0
}
2276
2277
void SalInstanceScrolledWindow::vadjustment_set_page_size(int size)
2278
0
{
2279
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2280
0
    return rVertScrollBar.SetVisibleSize(size);
2281
0
}
2282
2283
void SalInstanceScrolledWindow::vadjustment_set_page_increment(int size)
2284
0
{
2285
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2286
0
    return rVertScrollBar.SetPageSize(size);
2287
0
}
2288
2289
void SalInstanceScrolledWindow::vadjustment_set_step_increment(int size)
2290
0
{
2291
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2292
0
    return rVertScrollBar.SetLineSize(size);
2293
0
}
2294
2295
void SalInstanceScrolledWindow::set_vpolicy(VclPolicyType eVPolicy)
2296
0
{
2297
0
    WinBits nWinBits = m_xScrolledWindow->GetStyle() & ~(WB_AUTOVSCROLL | WB_VSCROLL);
2298
0
    if (eVPolicy == VclPolicyType::ALWAYS)
2299
0
        nWinBits |= WB_VSCROLL;
2300
0
    else if (eVPolicy == VclPolicyType::AUTOMATIC)
2301
0
        nWinBits |= WB_AUTOVSCROLL;
2302
0
    m_xScrolledWindow->SetStyle(nWinBits);
2303
0
    m_xScrolledWindow->queue_resize();
2304
0
}
2305
2306
VclPolicyType SalInstanceScrolledWindow::get_vpolicy() const
2307
0
{
2308
0
    WinBits nWinBits = m_xScrolledWindow->GetStyle();
2309
0
    if (nWinBits & WB_AUTOVSCROLL)
2310
0
        return VclPolicyType::AUTOMATIC;
2311
0
    else if (nWinBits & WB_VSCROLL)
2312
0
        return VclPolicyType::ALWAYS;
2313
0
    return VclPolicyType::NEVER;
2314
0
}
2315
2316
int SalInstanceScrolledWindow::get_scroll_thickness() const
2317
0
{
2318
0
    return m_xScrolledWindow->getVertScrollBar().get_preferred_size().Width();
2319
0
}
2320
2321
void SalInstanceScrolledWindow::set_scroll_thickness(int nThickness)
2322
0
{
2323
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2324
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2325
0
    rHorzScrollBar.set_height_request(nThickness);
2326
0
    rVertScrollBar.set_width_request(nThickness);
2327
0
}
2328
2329
void SalInstanceScrolledWindow::customize_scrollbars(const Color& rBackgroundColor,
2330
                                                     const Color& rShadowColor,
2331
                                                     const Color& rFaceColor)
2332
0
{
2333
0
    ScrollBar& rHorzScrollBar = m_xScrolledWindow->getHorzScrollBar();
2334
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2335
0
    customize_scrollbars(rHorzScrollBar, Color(0, 0, 0), rBackgroundColor, rShadowColor,
2336
0
                         rFaceColor);
2337
0
    customize_scrollbars(rVertScrollBar, Color(0, 0, 0), rBackgroundColor, rShadowColor,
2338
0
                         rFaceColor);
2339
0
}
2340
2341
SalInstanceScrolledWindow::~SalInstanceScrolledWindow()
2342
0
{
2343
0
    ScrollBar& rVertScrollBar = m_xScrolledWindow->getVertScrollBar();
2344
0
    rVertScrollBar.SetScrollHdl(m_aOrigVScrollHdl);
2345
0
}
2346
2347
IMPL_LINK(SalInstanceScrolledWindow, VscrollHdl, ScrollBar*, pScrollBar, void)
2348
0
{
2349
0
    signal_vadjustment_value_changed();
2350
0
    if (!m_bUserManagedScrolling)
2351
0
        m_aOrigVScrollHdl.Call(pScrollBar);
2352
0
}
2353
2354
IMPL_LINK_NOARG(SalInstanceScrolledWindow, HscrollHdl, ScrollBar*, void)
2355
0
{
2356
0
    signal_hadjustment_value_changed();
2357
0
    if (!m_bUserManagedScrolling)
2358
0
        m_aOrigHScrollHdl.Call(&m_xScrolledWindow->getHorzScrollBar());
2359
0
}
2360
2361
namespace
2362
{
2363
class SalInstanceScrollbar : public SalInstanceWidget, public virtual weld::Scrollbar
2364
{
2365
private:
2366
    VclPtr<ScrollBar> m_xScrollBar;
2367
2368
    DECL_LINK(ScrollHdl, ScrollBar*, void);
2369
2370
public:
2371
    SalInstanceScrollbar(ScrollBar* pScrollbar, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
2372
0
        : SalInstanceWidget(pScrollbar, pBuilder, bTakeOwnership)
2373
0
        , m_xScrollBar(pScrollbar)
2374
0
    {
2375
0
        m_xScrollBar->SetScrollHdl(LINK(this, SalInstanceScrollbar, ScrollHdl));
2376
0
        m_xScrollBar->EnableDrag();
2377
0
    }
2378
2379
0
    virtual int adjustment_get_value() const override { return m_xScrollBar->GetThumbPos(); }
2380
2381
0
    virtual void adjustment_set_value(int value) override { m_xScrollBar->SetThumbPos(value); }
2382
2383
0
    virtual int adjustment_get_upper() const override { return m_xScrollBar->GetRangeMax(); }
2384
2385
0
    virtual void adjustment_set_upper(int upper) override { m_xScrollBar->SetRangeMax(upper); }
2386
2387
0
    virtual int adjustment_get_lower() const override { return m_xScrollBar->GetRangeMin(); }
2388
2389
0
    virtual void adjustment_set_lower(int lower) override { m_xScrollBar->SetRangeMin(lower); }
2390
2391
0
    virtual int adjustment_get_page_size() const override { return m_xScrollBar->GetVisibleSize(); }
2392
2393
0
    virtual void adjustment_set_page_size(int size) override { m_xScrollBar->SetVisibleSize(size); }
2394
2395
    virtual int adjustment_get_page_increment() const override
2396
0
    {
2397
0
        return m_xScrollBar->GetPageSize();
2398
0
    }
2399
2400
    virtual void adjustment_set_page_increment(int size) override
2401
0
    {
2402
0
        m_xScrollBar->SetPageSize(size);
2403
0
    }
2404
2405
    virtual int adjustment_get_step_increment() const override
2406
0
    {
2407
0
        return m_xScrollBar->GetLineSize();
2408
0
    }
2409
2410
    virtual void adjustment_set_step_increment(int size) override
2411
0
    {
2412
0
        m_xScrollBar->SetLineSize(size);
2413
0
    }
2414
2415
0
    virtual ScrollType get_scroll_type() const override { return m_xScrollBar->GetType(); }
2416
2417
    virtual int get_scroll_thickness() const override
2418
0
    {
2419
0
        if (m_xScrollBar->GetStyle() & WB_HORZ)
2420
0
            return m_xScrollBar->get_preferred_size().Height();
2421
0
        return m_xScrollBar->get_preferred_size().Width();
2422
0
    }
2423
2424
    virtual void set_scroll_thickness(int nThickness) override
2425
0
    {
2426
0
        if (m_xScrollBar->GetStyle() & WB_HORZ)
2427
0
            m_xScrollBar->set_height_request(nThickness);
2428
0
        else
2429
0
            m_xScrollBar->set_width_request(nThickness);
2430
0
    }
2431
2432
0
    virtual void set_scroll_swap_arrows(bool bSwap) override { m_xScrollBar->SetSwapArrows(bSwap); }
2433
};
2434
}
2435
2436
IMPL_LINK_NOARG(SalInstanceScrollbar, ScrollHdl, ScrollBar*, void)
2437
0
{
2438
0
    signal_adjustment_value_changed();
2439
0
}
2440
2441
SalInstanceNotebook::SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder,
2442
                                         bool bTakeOwnership)
2443
0
    : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership)
2444
0
    , m_xNotebook(pNotebook)
2445
0
{
2446
0
    m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl));
2447
0
    m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook, DeactivatePageHdl));
2448
0
}
Unexecuted instantiation: SalInstanceNotebook::SalInstanceNotebook(TabControl*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceNotebook::SalInstanceNotebook(TabControl*, SalInstanceBuilder*, bool)
2449
2450
int SalInstanceNotebook::get_current_page() const
2451
0
{
2452
0
    return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
2453
0
}
2454
2455
OUString SalInstanceNotebook::get_page_ident(int nPage) const
2456
0
{
2457
0
    return m_xNotebook->GetPageName(m_xNotebook->GetPageId(nPage));
2458
0
}
2459
2460
OUString SalInstanceNotebook::get_current_page_ident() const
2461
0
{
2462
0
    return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId());
2463
0
}
2464
2465
int SalInstanceNotebook::get_page_index(const OUString& rIdent) const
2466
0
{
2467
0
    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
2468
0
    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
2469
0
    if (nPageIndex == TAB_PAGE_NOTFOUND)
2470
0
        return -1;
2471
0
    return nPageIndex;
2472
0
}
2473
2474
weld::Container* SalInstanceNotebook::get_page(const OUString& rIdent) const
2475
0
{
2476
0
    int nPageIndex = get_page_index(rIdent);
2477
0
    if (nPageIndex == -1)
2478
0
        return nullptr;
2479
0
    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
2480
0
    TabPage* pPage = m_xNotebook->GetTabPage(nPageId);
2481
0
    vcl::Window* pChild = pPage->GetChild(0);
2482
0
    auto it = m_aPages.find(rIdent);
2483
0
    if (it != m_aPages.end())
2484
0
        return it->second.get();
2485
0
    auto pNew = std::make_shared<SalInstanceContainer>(pChild, m_pBuilder, false);
2486
0
    m_aPages[rIdent] = pNew;
2487
0
    return pNew.get();
2488
0
}
2489
2490
void SalInstanceNotebook::set_current_page(int nPage)
2491
0
{
2492
0
    m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage));
2493
0
}
2494
2495
void SalInstanceNotebook::set_current_page(const OUString& rIdent)
2496
0
{
2497
0
    m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(rIdent));
2498
0
}
2499
2500
void SalInstanceNotebook::remove_page(const OUString& rIdent)
2501
0
{
2502
0
    sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent);
2503
0
    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId);
2504
0
    if (nPageIndex == TAB_PAGE_NOTFOUND)
2505
0
        return;
2506
2507
0
    m_xNotebook->RemovePage(nPageId);
2508
0
    m_aPages.erase(rIdent);
2509
2510
0
    auto iter = m_aAddedPages.find(rIdent);
2511
0
    if (iter != m_aAddedPages.end())
2512
0
    {
2513
0
        iter->second.second.disposeAndClear();
2514
0
        iter->second.first.disposeAndClear();
2515
0
        m_aAddedPages.erase(iter);
2516
0
    }
2517
0
}
2518
2519
void SalInstanceNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, int nPos,
2520
                                      const OUString* /* pIconName */)
2521
0
{
2522
0
    sal_uInt16 nPageCount = m_xNotebook->GetPageCount();
2523
0
    sal_uInt16 nLastPageId = nPageCount ? m_xNotebook->GetPageId(nPageCount - 1) : 0;
2524
0
    sal_uInt16 nNewPageId = nLastPageId + 1;
2525
0
    while (m_xNotebook->GetPagePos(nNewPageId) != TAB_PAGE_NOTFOUND)
2526
0
        ++nNewPageId;
2527
0
    m_xNotebook->InsertPage(nNewPageId, rLabel, nPos == -1 ? TAB_APPEND : nPos);
2528
0
    VclPtrInstance<TabPage> xPage(m_xNotebook);
2529
0
    VclPtrInstance<VclGrid> xGrid(xPage);
2530
0
    xPage->Show();
2531
0
    xGrid->set_hexpand(true);
2532
0
    xGrid->set_vexpand(true);
2533
0
    xGrid->Show();
2534
0
    m_xNotebook->SetTabPage(nNewPageId, xPage);
2535
0
    m_xNotebook->SetPageName(nNewPageId, rIdent);
2536
0
    m_aAddedPages.try_emplace(rIdent, xPage, xGrid);
2537
0
}
2538
2539
0
int SalInstanceNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); }
2540
2541
OUString SalInstanceNotebook::get_tab_label_text(const OUString& rIdent) const
2542
0
{
2543
0
    return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent));
2544
0
}
2545
2546
void SalInstanceNotebook::set_tab_label_text(const OUString& rIdent, const OUString& rText)
2547
0
{
2548
0
    return m_xNotebook->SetPageText(m_xNotebook->GetPageId(rIdent), rText);
2549
0
}
2550
2551
void SalInstanceNotebook::set_show_tabs(bool bShow)
2552
0
{
2553
0
    m_xNotebook->set_property(u"show-tabs"_ustr, OUString::boolean(bShow));
2554
0
}
2555
2556
SalInstanceNotebook::~SalInstanceNotebook()
2557
0
{
2558
0
    for (auto& rItem : m_aAddedPages)
2559
0
    {
2560
0
        rItem.second.second.disposeAndClear();
2561
0
        rItem.second.first.disposeAndClear();
2562
0
    }
2563
0
    m_xNotebook->SetActivatePageHdl(Link<TabControl*, void>());
2564
0
    m_xNotebook->SetDeactivatePageHdl(Link<TabControl*, bool>());
2565
0
}
2566
2567
IMPL_LINK_NOARG(SalInstanceNotebook, DeactivatePageHdl, TabControl*, bool)
2568
0
{
2569
0
    return !m_aLeavePageHdl.IsSet() || m_aLeavePageHdl.Call(get_current_page_ident());
2570
0
}
2571
2572
IMPL_LINK_NOARG(SalInstanceNotebook, ActivatePageHdl, TabControl*, void)
2573
0
{
2574
0
    m_aEnterPageHdl.Call(get_current_page_ident());
2575
0
}
2576
2577
SalInstanceVerticalNotebook::SalInstanceVerticalNotebook(VerticalTabControl* pNotebook,
2578
                                                         SalInstanceBuilder* pBuilder,
2579
                                                         bool bTakeOwnership)
2580
0
    : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership)
2581
0
    , m_xNotebook(pNotebook)
2582
0
{
2583
0
    m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl));
2584
0
    m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl));
2585
0
}
Unexecuted instantiation: SalInstanceVerticalNotebook::SalInstanceVerticalNotebook(VerticalTabControl*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceVerticalNotebook::SalInstanceVerticalNotebook(VerticalTabControl*, SalInstanceBuilder*, bool)
2586
2587
int SalInstanceVerticalNotebook::get_current_page() const
2588
0
{
2589
0
    return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
2590
0
}
2591
2592
OUString SalInstanceVerticalNotebook::get_page_ident(int nPage) const
2593
0
{
2594
0
    return m_xNotebook->GetPageId(nPage);
2595
0
}
2596
2597
OUString SalInstanceVerticalNotebook::get_current_page_ident() const
2598
0
{
2599
0
    return m_xNotebook->GetCurPageId();
2600
0
}
2601
2602
int SalInstanceVerticalNotebook::get_page_index(const OUString& rIdent) const
2603
0
{
2604
0
    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent);
2605
0
    if (nPageIndex == TAB_PAGE_NOTFOUND)
2606
0
        return -1;
2607
0
    return nPageIndex;
2608
0
}
2609
2610
weld::Container* SalInstanceVerticalNotebook::get_page(const OUString& rIdent) const
2611
0
{
2612
0
    int nPageIndex = get_page_index(rIdent);
2613
0
    if (nPageIndex == -1)
2614
0
        return nullptr;
2615
0
    auto pChild = m_xNotebook->GetPage(rIdent);
2616
0
    auto it = m_aPages.find(rIdent);
2617
0
    if (it != m_aPages.end())
2618
0
        return it->second.get();
2619
0
    auto pNew = std::make_shared<SalInstanceContainer>(pChild, m_pBuilder, false);
2620
0
    m_aPages[rIdent] = pNew;
2621
0
    return pNew.get();
2622
0
}
2623
2624
void SalInstanceVerticalNotebook::set_current_page(int nPage)
2625
0
{
2626
0
    m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage));
2627
0
}
2628
2629
void SalInstanceVerticalNotebook::set_current_page(const OUString& rIdent)
2630
0
{
2631
0
    m_xNotebook->SetCurPageId(rIdent);
2632
0
}
2633
2634
void SalInstanceVerticalNotebook::remove_page(const OUString& rIdent)
2635
0
{
2636
0
    sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent);
2637
0
    if (nPageIndex == TAB_PAGE_NOTFOUND)
2638
0
        return;
2639
0
    m_xNotebook->RemovePage(rIdent);
2640
0
    m_aPages.erase(rIdent);
2641
0
}
2642
2643
void SalInstanceVerticalNotebook::insert_page(const OUString& rIdent, const OUString& rLabel,
2644
                                              int nPos, const OUString* pIconName)
2645
0
{
2646
0
    VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent());
2647
0
    xGrid->set_hexpand(true);
2648
0
    xGrid->set_vexpand(true);
2649
0
    Image aImage = pIconName ? Image(StockImage::Yes, *pIconName) : Image();
2650
0
    m_xNotebook->InsertPage(rIdent, rLabel, aImage, u""_ustr, xGrid, nPos);
2651
0
}
2652
2653
0
int SalInstanceVerticalNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); }
2654
2655
void SalInstanceVerticalNotebook::set_tab_label_text(const OUString& rIdent, const OUString& rText)
2656
0
{
2657
0
    return m_xNotebook->SetPageText(rIdent, rText);
2658
0
}
2659
2660
OUString SalInstanceVerticalNotebook::get_tab_label_text(const OUString& rIdent) const
2661
0
{
2662
0
    return m_xNotebook->GetPageText(rIdent);
2663
0
}
2664
2665
void SalInstanceVerticalNotebook::set_show_tabs(bool /*bShow*/)
2666
0
{
2667
    // if someone needs this they will have to implement it in VerticalTabControl
2668
0
    assert(false && "not implemented");
2669
0
}
2670
2671
SalInstanceVerticalNotebook::~SalInstanceVerticalNotebook()
2672
0
{
2673
0
    m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>());
2674
0
    m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>());
2675
0
}
2676
2677
IMPL_LINK_NOARG(SalInstanceVerticalNotebook, DeactivatePageHdl, VerticalTabControl*, bool)
2678
0
{
2679
0
    return !m_aLeavePageHdl.IsSet() || m_aLeavePageHdl.Call(get_current_page_ident());
2680
0
}
2681
2682
IMPL_LINK_NOARG(SalInstanceVerticalNotebook, ActivatePageHdl, VerticalTabControl*, void)
2683
0
{
2684
0
    m_aEnterPageHdl.Call(get_current_page_ident());
2685
0
}
2686
2687
SalInstanceButton::SalInstanceButton(::Button* pButton, SalInstanceBuilder* pBuilder,
2688
                                     bool bTakeOwnership)
2689
0
    : SalInstanceWidget(pButton, pBuilder, bTakeOwnership)
2690
0
    , m_xButton(pButton)
2691
0
    , m_aOldClickHdl(pButton->GetClickHdl())
2692
0
{
2693
0
    m_xButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl));
2694
0
}
Unexecuted instantiation: SalInstanceButton::SalInstanceButton(Button*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceButton::SalInstanceButton(Button*, SalInstanceBuilder*, bool)
2695
2696
0
void SalInstanceButton::set_label(const OUString& rText) { m_xButton->SetText(rText); }
2697
2698
void SalInstanceButton::set_image(VirtualDevice* pDevice)
2699
0
{
2700
0
    m_xButton->SetImageAlign(ImageAlign::Left);
2701
0
    if (pDevice)
2702
0
        m_xButton->SetModeImage(createImage(*pDevice));
2703
0
    else
2704
0
        m_xButton->SetModeImage(Image());
2705
0
}
2706
2707
void SalInstanceButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
2708
0
{
2709
0
    m_xButton->SetImageAlign(ImageAlign::Left);
2710
0
    m_xButton->SetModeImage(Image(rImage));
2711
0
}
2712
2713
void SalInstanceButton::set_from_icon_name(const OUString& rIconName)
2714
0
{
2715
0
    m_xButton->SetModeImage(Image(StockImage::Yes, rIconName));
2716
0
}
2717
2718
static void set_label_wrap(Control& rWidget, bool wrap)
2719
0
{
2720
0
    WinBits nBits = rWidget.GetStyle();
2721
0
    nBits &= ~WB_WORDBREAK;
2722
0
    if (wrap)
2723
0
        nBits |= WB_WORDBREAK;
2724
0
    rWidget.SetStyle(nBits);
2725
0
    rWidget.queue_resize();
2726
0
}
2727
2728
void SalInstanceButton::set_font(const vcl::Font& rFont)
2729
0
{
2730
0
    m_xButton->SetControlFont(rFont);
2731
0
    m_xButton->Invalidate();
2732
0
}
2733
2734
void SalInstanceButton::set_custom_button(VirtualDevice* pDevice)
2735
0
{
2736
0
    if (pDevice)
2737
0
        m_xButton->SetCustomButtonImage(createImage(*pDevice));
2738
0
    else
2739
0
        m_xButton->SetCustomButtonImage(Image());
2740
0
    m_xButton->Invalidate();
2741
0
}
2742
2743
0
OUString SalInstanceButton::get_label() const { return m_xButton->GetText(); }
2744
2745
0
SalInstanceButton::~SalInstanceButton() { m_xButton->SetClickHdl(Link<::Button*, void>()); }
2746
2747
IMPL_LINK(SalInstanceButton, ClickHdl, ::Button*, pButton, void)
2748
0
{
2749
    //if there's no handler set, disengage our intercept and
2750
    //run the click again to get default behaviour for cancel/ok
2751
    //etc buttons.
2752
0
    if (!m_aClickHdl.IsSet())
2753
0
    {
2754
0
        pButton->SetClickHdl(m_aOldClickHdl);
2755
0
        pButton->Click();
2756
0
        pButton->SetClickHdl(LINK(this, SalInstanceButton, ClickHdl));
2757
0
        return;
2758
0
    }
2759
0
    signal_clicked();
2760
0
}
2761
2762
std::unique_ptr<weld::Button> SalInstanceDialog::weld_button_for_response(int nResponse)
2763
0
{
2764
0
    PushButton* pButton = dynamic_cast<PushButton*>(m_xDialog->get_widget_for_response(nResponse));
2765
0
    return pButton ? std::make_unique<SalInstanceButton>(pButton, nullptr, false) : nullptr;
2766
0
}
2767
2768
std::unique_ptr<weld::Button> SalInstanceAssistant::weld_button_for_response(int nResponse)
2769
0
{
2770
0
    PushButton* pButton = nullptr;
2771
0
    if (nResponse == RET_YES)
2772
0
        pButton = m_xWizard->m_pNextPage;
2773
0
    else if (nResponse == RET_NO)
2774
0
        pButton = m_xWizard->m_pPrevPage;
2775
0
    else if (nResponse == RET_OK)
2776
0
        pButton = m_xWizard->m_pFinish;
2777
0
    else if (nResponse == RET_CANCEL)
2778
0
        pButton = m_xWizard->m_pCancel;
2779
0
    else if (nResponse == RET_HELP)
2780
0
        pButton = m_xWizard->m_pHelp;
2781
0
    if (pButton)
2782
0
        return std::make_unique<SalInstanceButton>(pButton, nullptr, false);
2783
0
    return nullptr;
2784
0
}
2785
2786
SalInstanceMenuButton::SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder,
2787
                                             bool bTakeOwnership)
2788
0
    : SalInstanceButton(pButton, pBuilder, bTakeOwnership)
2789
0
    , m_xMenuButton(pButton)
2790
0
    , m_nLastId(0)
2791
0
{
2792
0
    m_xMenuButton->SetActivateHdl(LINK(this, SalInstanceMenuButton, ActivateHdl));
2793
0
    m_xMenuButton->SetSelectHdl(LINK(this, SalInstanceMenuButton, MenuSelectHdl));
2794
0
    if (PopupMenu* pMenu = m_xMenuButton->GetPopupMenu())
2795
0
    {
2796
0
        pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
2797
0
        const auto nCount = pMenu->GetItemCount();
2798
0
        m_nLastId = nCount ? pMenu->GetItemId(nCount - 1) : 0;
2799
0
    }
2800
0
}
Unexecuted instantiation: SalInstanceMenuButton::SalInstanceMenuButton(MenuButton*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceMenuButton::SalInstanceMenuButton(MenuButton*, SalInstanceBuilder*, bool)
2801
2802
void SalInstanceMenuButton::do_set_active(bool active)
2803
0
{
2804
0
    if (active == get_active())
2805
0
        return;
2806
0
    if (active)
2807
0
        m_xMenuButton->ExecuteMenu();
2808
0
    else
2809
0
        m_xMenuButton->CancelMenu();
2810
0
}
2811
2812
0
bool SalInstanceMenuButton::get_active() const { return m_xMenuButton->InPopupMode(); }
2813
2814
void SalInstanceMenuButton::insert_item(int pos, const OUString& rId, const OUString& rStr,
2815
                                        const OUString* pIconName, VirtualDevice* pImageSurface,
2816
                                        TriState eCheckRadioFalse)
2817
0
{
2818
0
    m_nLastId = insert_to_menu(m_nLastId, m_xMenuButton->GetPopupMenu(), pos, rId, rStr, pIconName,
2819
0
                               pImageSurface, nullptr, eCheckRadioFalse);
2820
0
}
2821
2822
void SalInstanceMenuButton::insert_separator(int pos, const OUString& rId)
2823
0
{
2824
0
    auto nInsertPos = pos == -1 ? MENU_APPEND : pos;
2825
0
    m_xMenuButton->GetPopupMenu()->InsertSeparator(rId, nInsertPos);
2826
0
}
2827
2828
void SalInstanceMenuButton::set_item_sensitive(const OUString& rIdent, bool bSensitive)
2829
0
{
2830
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2831
0
    pMenu->EnableItem(rIdent, bSensitive);
2832
0
}
2833
2834
void SalInstanceMenuButton::remove_item(const OUString& rId)
2835
0
{
2836
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2837
0
    pMenu->RemoveItem(pMenu->GetItemPos(pMenu->GetItemId(rId)));
2838
0
}
2839
2840
void SalInstanceMenuButton::clear()
2841
0
{
2842
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2843
0
    pMenu->Clear();
2844
0
}
2845
2846
void SalInstanceMenuButton::set_item_active(const OUString& rIdent, bool bActive)
2847
0
{
2848
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2849
0
    pMenu->CheckItem(rIdent, bActive);
2850
0
}
2851
2852
void SalInstanceMenuButton::set_item_label(const OUString& rIdent, const OUString& rText)
2853
0
{
2854
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2855
0
    pMenu->SetItemText(pMenu->GetItemId(rIdent), rText);
2856
0
}
2857
2858
OUString SalInstanceMenuButton::get_item_label(const OUString& rIdent) const
2859
0
{
2860
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2861
0
    return pMenu->GetItemText(pMenu->GetItemId(rIdent));
2862
0
}
2863
2864
void SalInstanceMenuButton::set_item_visible(const OUString& rIdent, bool bShow)
2865
0
{
2866
0
    PopupMenu* pMenu = m_xMenuButton->GetPopupMenu();
2867
0
    pMenu->ShowItem(pMenu->GetItemId(rIdent), bShow);
2868
0
}
2869
2870
void SalInstanceMenuButton::set_popover(weld::Widget* pPopover)
2871
0
{
2872
0
    SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover);
2873
0
    m_xMenuButton->SetPopover(pPopoverWidget ? pPopoverWidget->getWidget() : nullptr);
2874
0
}
2875
2876
SalInstanceMenuButton::~SalInstanceMenuButton()
2877
0
{
2878
0
    m_xMenuButton->SetSelectHdl(Link<::MenuButton*, void>());
2879
0
    m_xMenuButton->SetActivateHdl(Link<::MenuButton*, void>());
2880
0
}
2881
2882
IMPL_LINK_NOARG(SalInstanceMenuButton, MenuSelectHdl, ::MenuButton*, void)
2883
0
{
2884
0
    signal_selected(m_xMenuButton->GetCurItemIdent());
2885
0
}
2886
2887
0
IMPL_LINK_NOARG(SalInstanceMenuButton, ActivateHdl, ::MenuButton*, void) { signal_toggled(); }
2888
2889
IMPL_LINK(SalInstanceLinkButton, ClickHdl, FixedHyperlink&, rButton, void)
2890
0
{
2891
0
    bool bConsumed = signal_activate_link();
2892
0
    if (!bConsumed)
2893
0
        m_aOrigClickHdl.Call(rButton);
2894
0
}
2895
2896
0
void SalInstanceLinkButton::set_label_wrap(bool bWrap) { ::set_label_wrap(*m_xButton, bWrap); }
2897
2898
SalInstanceRadioButton::SalInstanceRadioButton(::RadioButton* pButton, SalInstanceBuilder* pBuilder,
2899
                                               bool bTakeOwnership)
2900
0
    : SalInstanceButton(pButton, pBuilder, bTakeOwnership)
2901
0
    , m_xRadioButton(pButton)
2902
0
{
2903
0
    m_xRadioButton->SetToggleHdl(LINK(this, SalInstanceRadioButton, ToggleHdl));
2904
0
}
Unexecuted instantiation: SalInstanceRadioButton::SalInstanceRadioButton(RadioButton*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceRadioButton::SalInstanceRadioButton(RadioButton*, SalInstanceBuilder*, bool)
2905
2906
0
void SalInstanceRadioButton::do_set_active(bool active) { m_xRadioButton->Check(active); }
2907
2908
0
bool SalInstanceRadioButton::get_active() const { return m_xRadioButton->IsChecked(); }
2909
2910
void SalInstanceRadioButton::set_image(VirtualDevice* pDevice)
2911
0
{
2912
0
    m_xRadioButton->SetImageAlign(ImageAlign::Center);
2913
0
    if (pDevice)
2914
0
        m_xRadioButton->SetModeImage(createImage(*pDevice));
2915
0
    else
2916
0
        m_xRadioButton->SetModeImage(Image());
2917
0
}
2918
2919
void SalInstanceRadioButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
2920
0
{
2921
0
    m_xRadioButton->SetImageAlign(ImageAlign::Center);
2922
0
    m_xRadioButton->SetModeImage(Image(rImage));
2923
0
}
2924
2925
void SalInstanceRadioButton::set_from_icon_name(const OUString& rIconName)
2926
0
{
2927
0
    m_xRadioButton->SetModeRadioImage(Image(StockImage::Yes, rIconName));
2928
0
}
2929
2930
void SalInstanceRadioButton::set_label_wrap(bool bWrap)
2931
0
{
2932
0
    ::set_label_wrap(*m_xRadioButton, bWrap);
2933
0
}
2934
2935
SalInstanceRadioButton::~SalInstanceRadioButton()
2936
0
{
2937
0
    m_xRadioButton->SetToggleHdl(Link<::RadioButton&, void>());
2938
0
}
2939
2940
0
IMPL_LINK_NOARG(SalInstanceRadioButton, ToggleHdl, ::RadioButton&, void) { signal_toggled(); }
2941
2942
IMPL_LINK(SalInstanceToggleButton, ToggleListener, VclWindowEvent&, rEvent, void)
2943
0
{
2944
0
    if (rEvent.GetId() == VclEventId::PushbuttonToggle)
2945
0
        signal_toggled();
2946
0
}
2947
2948
SalInstanceCheckButton::SalInstanceCheckButton(CheckBox* pButton, SalInstanceBuilder* pBuilder,
2949
                                               bool bTakeOwnership)
2950
0
    : SalInstanceButton(pButton, pBuilder, bTakeOwnership)
2951
0
    , m_xCheckButton(pButton)
2952
0
{
2953
0
    m_xCheckButton->SetToggleHdl(LINK(this, SalInstanceCheckButton, ToggleHdl));
2954
0
}
Unexecuted instantiation: SalInstanceCheckButton::SalInstanceCheckButton(CheckBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceCheckButton::SalInstanceCheckButton(CheckBox*, SalInstanceBuilder*, bool)
2955
2956
void SalInstanceCheckButton::do_set_state(TriState eState)
2957
0
{
2958
0
    m_xCheckButton->EnableTriState(eState == TRISTATE_INDET);
2959
0
    m_xCheckButton->SetState(eState);
2960
0
}
2961
2962
0
TriState SalInstanceCheckButton::get_state() const { return m_xCheckButton->GetState(); }
2963
2964
void SalInstanceCheckButton::set_label_wrap(bool bWrap)
2965
0
{
2966
0
    ::set_label_wrap(*m_xCheckButton, bWrap);
2967
0
}
2968
2969
SalInstanceCheckButton::~SalInstanceCheckButton()
2970
0
{
2971
0
    m_xCheckButton->SetToggleHdl(Link<CheckBox&, void>());
2972
0
}
2973
2974
IMPL_LINK_NOARG(SalInstanceCheckButton, ToggleHdl, CheckBox&, void)
2975
0
{
2976
0
    m_xCheckButton->EnableTriState(false);
2977
0
    signal_toggled();
2978
0
}
2979
2980
namespace
2981
{
2982
class SalInstanceScale : public SalInstanceWidget, public virtual weld::Scale
2983
{
2984
private:
2985
    VclPtr<Slider> m_xScale;
2986
2987
    DECL_LINK(SlideHdl, Slider*, void);
2988
2989
public:
2990
    SalInstanceScale(Slider* pScale, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
2991
0
        : SalInstanceWidget(pScale, pBuilder, bTakeOwnership)
2992
0
        , m_xScale(pScale)
2993
0
    {
2994
0
        m_xScale->SetSlideHdl(LINK(this, SalInstanceScale, SlideHdl));
2995
0
    }
2996
2997
0
    virtual void set_value(int value) override { m_xScale->SetThumbPos(value); }
2998
2999
    virtual void set_range(int min, int max) override
3000
0
    {
3001
0
        m_xScale->SetRangeMin(min);
3002
0
        m_xScale->SetRangeMax(max);
3003
0
    }
3004
3005
0
    virtual int get_value() const override { return m_xScale->GetThumbPos(); }
3006
3007
    virtual void set_increments(int step, int page) override
3008
0
    {
3009
0
        m_xScale->SetLineSize(step);
3010
0
        m_xScale->SetPageSize(page);
3011
0
    }
3012
3013
    virtual void get_increments(int& step, int& page) const override
3014
0
    {
3015
0
        step = m_xScale->GetLineSize();
3016
0
        page = m_xScale->GetPageSize();
3017
0
    }
3018
3019
0
    virtual ~SalInstanceScale() override { m_xScale->SetSlideHdl(Link<Slider*, void>()); }
3020
};
3021
}
3022
3023
0
IMPL_LINK_NOARG(SalInstanceScale, SlideHdl, Slider*, void) { signal_value_changed(); }
3024
3025
namespace
3026
{
3027
class SalInstanceSpinner : public SalInstanceWidget, public virtual weld::Spinner
3028
{
3029
private:
3030
    VclPtr<Throbber> m_xThrobber;
3031
3032
public:
3033
    SalInstanceSpinner(Throbber* pThrobber, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
3034
0
        : SalInstanceWidget(pThrobber, pBuilder, bTakeOwnership)
3035
0
        , m_xThrobber(pThrobber)
3036
0
    {
3037
0
    }
3038
3039
0
    virtual void start() override { m_xThrobber->start(); }
3040
3041
0
    virtual void stop() override { m_xThrobber->stop(); }
3042
};
3043
3044
class SalInstanceProgressBar : public SalInstanceWidget, public virtual weld::ProgressBar
3045
{
3046
private:
3047
    VclPtr<::ProgressBar> m_xProgressBar;
3048
3049
public:
3050
    SalInstanceProgressBar(::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder,
3051
                           bool bTakeOwnership)
3052
0
        : SalInstanceWidget(pProgressBar, pBuilder, bTakeOwnership)
3053
0
        , m_xProgressBar(pProgressBar)
3054
0
    {
3055
0
    }
3056
3057
0
    virtual void set_percentage(int value) override { m_xProgressBar->SetValue(value); }
3058
3059
0
    virtual OUString get_text() const override { return m_xProgressBar->GetText(); }
3060
3061
0
    virtual void set_text(const OUString& rText) override { m_xProgressBar->SetText(rText); }
3062
};
3063
}
3064
3065
0
IMPL_LINK_NOARG(SalInstanceCalendar, SelectHdl, ::Calendar*, void) { signal_selected(); }
3066
3067
0
IMPL_LINK_NOARG(SalInstanceCalendar, ActivateHdl, ::Calendar*, void) { signal_activated(); }
3068
3069
SalInstanceImage::SalInstanceImage(FixedImage* pImage, SalInstanceBuilder* pBuilder,
3070
                                   bool bTakeOwnership)
3071
0
    : SalInstanceWidget(pImage, pBuilder, bTakeOwnership)
3072
0
    , m_xImage(pImage)
3073
0
{
3074
0
}
Unexecuted instantiation: SalInstanceImage::SalInstanceImage(FixedImage*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceImage::SalInstanceImage(FixedImage*, SalInstanceBuilder*, bool)
3075
3076
void SalInstanceImage::set_from_icon_name(const OUString& rIconName)
3077
0
{
3078
0
    m_xImage->SetImage(::Image(StockImage::Yes, rIconName));
3079
0
}
3080
3081
void SalInstanceImage::set_image(VirtualDevice* pDevice)
3082
0
{
3083
0
    if (pDevice)
3084
0
        m_xImage->SetImage(createImage(*pDevice));
3085
0
    else
3086
0
        m_xImage->SetImage(::Image());
3087
0
}
3088
3089
void SalInstanceImage::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
3090
0
{
3091
0
    m_xImage->SetImage(::Image(rImage));
3092
0
}
3093
3094
WeldTextFilter::WeldTextFilter(Link<OUString&, bool>& rInsertTextHdl)
3095
0
    : TextFilter(OUString())
3096
0
    , m_rInsertTextHdl(rInsertTextHdl)
3097
0
{
3098
0
}
3099
3100
OUString WeldTextFilter::filter(const OUString& rText)
3101
0
{
3102
0
    if (!m_rInsertTextHdl.IsSet())
3103
0
        return rText;
3104
0
    OUString sText(rText);
3105
0
    const bool bContinue = m_rInsertTextHdl.Call(sText);
3106
0
    if (!bContinue)
3107
0
        return OUString();
3108
0
    return sText;
3109
0
}
3110
3111
SalInstanceTextWidget::SalInstanceTextWidget(Edit* pEntry, SalInstanceBuilder* pBuilder,
3112
                                             bool bTakeOwnership)
3113
0
    : SalInstanceWidget(pEntry, pBuilder, bTakeOwnership)
3114
0
    , m_pEntry(pEntry)
3115
0
{
3116
0
}
3117
3118
SalInstanceTextWidget::~SalInstanceTextWidget()
3119
0
{
3120
0
    if (m_pEntry->isDisposed())
3121
0
        return;
3122
3123
0
    if (m_aCursorPositionHdl.IsSet())
3124
0
        m_pEntry->RemoveEventListener(LINK(this, SalInstanceTextWidget, CursorListener));
3125
0
}
3126
3127
IMPL_LINK(SalInstanceTextWidget, CursorListener, VclWindowEvent&, rEvent, void)
3128
0
{
3129
0
    if (rEvent.GetId() == VclEventId::EditSelectionChanged
3130
0
        || rEvent.GetId() == VclEventId::EditCaretChanged)
3131
0
        signal_cursor_position();
3132
0
}
3133
3134
void SalInstanceTextWidget::connect_cursor_position(const Link<TextWidget&, void>& rLink)
3135
0
{
3136
0
    assert(!m_aCursorPositionHdl.IsSet());
3137
0
    m_pEntry->AddEventListener(LINK(this, SalInstanceTextWidget, CursorListener));
3138
0
    weld::TextWidget::connect_cursor_position(rLink);
3139
0
}
3140
3141
0
void SalInstanceTextWidget::do_set_text(const OUString& rText) { m_pEntry->SetText(rText); }
3142
3143
0
OUString SalInstanceTextWidget::get_text() const { return m_pEntry->GetText(); }
3144
3145
void SalInstanceTextWidget::do_set_position(int nCursorPos)
3146
0
{
3147
0
    m_pEntry->SetSelection(Selection(nCursorPos, nCursorPos));
3148
0
}
3149
3150
0
int SalInstanceTextWidget::get_position() const { return m_pEntry->GetSelection().Max(); }
3151
3152
void SalInstanceTextWidget::do_select_region(int nStartPos, int nEndPos)
3153
0
{
3154
0
    tools::Long nStart = nStartPos < 0 ? SELECTION_MAX : nStartPos;
3155
0
    tools::Long nEnd = nEndPos < 0 ? SELECTION_MAX : nEndPos;
3156
0
    m_pEntry->SetSelection(Selection(nStart, nEnd));
3157
0
}
3158
3159
bool SalInstanceTextWidget::get_selection_bounds(int& rStartPos, int& rEndPos)
3160
0
{
3161
0
    const Selection& rSelection = m_pEntry->GetSelection();
3162
0
    rStartPos = rSelection.Min();
3163
0
    rEndPos = rSelection.Max();
3164
0
    return rSelection.Len();
3165
0
}
3166
3167
void SalInstanceTextWidget::do_replace_selection(const OUString& rText)
3168
0
{
3169
0
    m_pEntry->ReplaceSelected(rText);
3170
0
}
3171
3172
0
void SalInstanceTextWidget::set_editable(bool bEditable) { m_pEntry->SetReadOnly(!bEditable); }
3173
3174
0
bool SalInstanceTextWidget::get_editable() const { return !m_pEntry->IsReadOnly(); }
3175
3176
void SalInstanceTextWidget::set_font_color(const Color& rColor)
3177
0
{
3178
0
    if (rColor == COL_AUTO)
3179
0
        m_pEntry->SetControlForeground();
3180
0
    else
3181
0
        m_pEntry->SetControlForeground(rColor);
3182
0
}
3183
3184
SalInstanceEntry::SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
3185
0
    : SalInstanceTextWidget(pEntry, pBuilder, bTakeOwnership)
3186
0
    , m_xEntry(pEntry)
3187
0
    , m_aTextFilter(m_aInsertTextHdl)
3188
0
{
3189
0
    m_xEntry->SetModifyHdl(LINK(this, SalInstanceEntry, ChangeHdl));
3190
0
    m_xEntry->SetActivateHdl(LINK(this, SalInstanceEntry, ActivateHdl));
3191
0
    m_xEntry->SetTextFilter(&m_aTextFilter);
3192
0
}
Unexecuted instantiation: SalInstanceEntry::SalInstanceEntry(Edit*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceEntry::SalInstanceEntry(Edit*, SalInstanceBuilder*, bool)
3193
3194
0
void SalInstanceEntry::set_width_chars(int nChars) { m_xEntry->SetWidthInChars(nChars); }
3195
3196
0
int SalInstanceEntry::get_width_chars() const { return m_xEntry->GetWidthInChars(); }
3197
3198
0
void SalInstanceEntry::set_max_length(int nChars) { m_xEntry->SetMaxTextLen(nChars); }
3199
3200
void SalInstanceEntry::set_visibility(bool bVisible)
3201
0
{
3202
0
    m_xEntry->set_property(u"visibility"_ustr, OUString::boolean(bVisible));
3203
0
}
3204
3205
0
void SalInstanceEntry::set_overwrite_mode(bool bOn) { m_xEntry->SetInsertMode(!bOn); }
3206
3207
0
bool SalInstanceEntry::get_overwrite_mode() const { return !m_xEntry->IsInsertMode(); }
3208
3209
namespace
3210
{
3211
void set_message_type(Edit* pEntry, weld::EntryMessageType eType)
3212
0
{
3213
0
    switch (eType)
3214
0
    {
3215
0
        case weld::EntryMessageType::Normal:
3216
0
        case weld::EntryMessageType::Info:
3217
0
            pEntry->SetForceControlBackground(false);
3218
0
            pEntry->SetControlForeground();
3219
0
            pEntry->SetControlBackground();
3220
0
            if (eType == weld::EntryMessageType::Normal)
3221
0
                pEntry->SetEntryMessageType(0);
3222
0
            else
3223
0
                pEntry->SetEntryMessageType(1);
3224
0
            break;
3225
0
        case weld::EntryMessageType::Warning:
3226
            // tdf#114603: enable setting the background to a different color;
3227
            // relevant for GTK; see also #i75179#
3228
0
            pEntry->SetForceControlBackground(true);
3229
0
            pEntry->SetControlForeground(COL_BLACK);
3230
0
            pEntry->SetControlBackground(0xffffa6); // "light yellow 3"
3231
0
            pEntry->SetEntryMessageType(2);
3232
0
            break;
3233
0
        case weld::EntryMessageType::Error:
3234
            // tdf#114603: enable setting the background to a different color;
3235
            // relevant for GTK; see also #i75179#
3236
0
            pEntry->SetForceControlBackground(true);
3237
0
            pEntry->SetControlForeground(COL_BLACK); // contrast of 5.87 to the red background
3238
0
            pEntry->SetControlBackground(0xffa6a6); // "light red 3"
3239
0
            pEntry->SetEntryMessageType(3);
3240
0
            break;
3241
0
    }
3242
0
}
3243
}
3244
3245
void SalInstanceEntry::set_message_type(weld::EntryMessageType eType)
3246
0
{
3247
0
    ::set_message_type(m_xEntry, eType);
3248
0
}
3249
3250
void SalInstanceEntry::set_font(const vcl::Font& rFont)
3251
0
{
3252
0
    m_xEntry->SetControlFont(rFont);
3253
0
    m_xEntry->Invalidate();
3254
0
}
3255
3256
void SalInstanceEntry::set_placeholder_text(const OUString& rText)
3257
0
{
3258
0
    m_xEntry->SetPlaceholderText(rText);
3259
0
}
3260
3261
0
Edit& SalInstanceEntry::getEntry() { return *m_xEntry; }
3262
3263
0
void SalInstanceEntry::fire_signal_changed() { signal_changed(); }
3264
3265
void SalInstanceEntry::cut_clipboard()
3266
0
{
3267
0
    m_xEntry->Cut();
3268
0
    m_xEntry->Modify();
3269
0
}
3270
3271
0
void SalInstanceEntry::copy_clipboard() { m_xEntry->Copy(); }
3272
3273
void SalInstanceEntry::paste_clipboard()
3274
0
{
3275
0
    m_xEntry->Paste();
3276
0
    m_xEntry->Modify();
3277
0
}
3278
3279
namespace
3280
{
3281
void set_alignment(Edit& rEntry, TxtAlign eXAlign)
3282
0
{
3283
0
    WinBits nAlign(0);
3284
0
    switch (eXAlign)
3285
0
    {
3286
0
        case TxtAlign::Left:
3287
0
            nAlign = WB_LEFT;
3288
0
            break;
3289
0
        case TxtAlign::Center:
3290
0
            nAlign = WB_CENTER;
3291
0
            break;
3292
0
        case TxtAlign::Right:
3293
0
            nAlign = WB_RIGHT;
3294
0
            break;
3295
0
    }
3296
0
    WinBits nBits = rEntry.GetStyle();
3297
0
    nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
3298
0
    rEntry.SetStyle(nBits | nAlign);
3299
0
}
3300
}
3301
3302
0
void SalInstanceEntry::set_alignment(TxtAlign eXAlign) { ::set_alignment(*m_xEntry, eXAlign); }
3303
3304
SalInstanceEntry::~SalInstanceEntry()
3305
0
{
3306
0
    m_xEntry->SetTextFilter(nullptr);
3307
0
    m_xEntry->SetActivateHdl(Link<Edit&, bool>());
3308
0
    m_xEntry->SetModifyHdl(Link<Edit&, void>());
3309
0
}
3310
3311
0
IMPL_LINK_NOARG(SalInstanceEntry, ChangeHdl, Edit&, void) { signal_changed(); }
3312
3313
0
IMPL_LINK_NOARG(SalInstanceEntry, ActivateHdl, Edit&, bool) { return m_aActivateHdl.Call(*this); }
3314
3315
static SalInstanceTreeView* g_DragSource;
3316
3317
namespace
3318
{
3319
// tdf#131581 if the TreeView is hidden then there are possibly additional
3320
// optimizations available
3321
class UpdateGuardIfHidden
3322
{
3323
private:
3324
    SvTabListBox& m_rTreeView;
3325
    bool m_bOrigUpdate;
3326
    bool m_bOrigEnableInvalidate;
3327
3328
public:
3329
    UpdateGuardIfHidden(SvTabListBox& rTreeView)
3330
0
        : m_rTreeView(rTreeView)
3331
        // tdf#136962 only do SetUpdateMode(false) optimization if the widget is currently hidden
3332
0
        , m_bOrigUpdate(!m_rTreeView.IsVisible() && m_rTreeView.IsUpdateMode())
3333
        // tdf#137432 only do EnableInvalidate(false) optimization if the widget is currently hidden
3334
0
        , m_bOrigEnableInvalidate(!m_rTreeView.IsVisible()
3335
0
                                  && m_rTreeView.GetModel()->IsEnableInvalidate())
3336
0
    {
3337
0
        if (m_bOrigUpdate)
3338
0
            m_rTreeView.SetUpdateMode(false);
3339
0
        if (m_bOrigEnableInvalidate)
3340
0
            m_rTreeView.GetModel()->EnableInvalidate(false);
3341
0
    }
3342
3343
    ~UpdateGuardIfHidden()
3344
0
    {
3345
0
        if (m_bOrigEnableInvalidate)
3346
0
            m_rTreeView.GetModel()->EnableInvalidate(true);
3347
0
        if (m_bOrigUpdate)
3348
0
            m_rTreeView.SetUpdateMode(true);
3349
0
    }
3350
};
3351
}
3352
3353
SalInstanceItemView::SalInstanceItemView(SvTreeListBox* pTreeListBox, SalInstanceBuilder* pBuilder,
3354
                                         bool bTakeOwnership)
3355
0
    : SalInstanceWidget(pTreeListBox, pBuilder, bTakeOwnership)
3356
0
    , m_pTreeListBox(pTreeListBox)
3357
0
{
3358
0
    m_pTreeListBox->SetDoubleClickHdl(LINK(this, SalInstanceItemView, DoubleClickHdl));
3359
0
}
3360
3361
SalInstanceItemView::~SalInstanceItemView()
3362
0
{
3363
0
    m_pTreeListBox->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
3364
0
}
3365
3366
std::unique_ptr<weld::TreeIter>
3367
SalInstanceItemView::make_iterator(const weld::TreeIter* pOrig) const
3368
0
{
3369
0
    return std::unique_ptr<weld::TreeIter>(
3370
0
        new SalInstanceTreeIter(*this, static_cast<const SalInstanceTreeIter*>(pOrig)));
3371
0
}
3372
3373
bool SalInstanceItemView::get_iter_first(weld::TreeIter& rIter) const
3374
0
{
3375
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
3376
0
    SvTreeListEntry* pFirst = m_pTreeListBox->GetEntry(0);
3377
0
    if (!pFirst)
3378
0
        return false;
3379
3380
0
    rVclIter.iter = pFirst;
3381
0
    return true;
3382
0
}
3383
3384
bool SalInstanceItemView::iter_next_sibling(weld::TreeIter& rIter) const
3385
0
{
3386
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
3387
0
    SvTreeListEntry* pSibling = rVclIter.iter->NextSibling();
3388
0
    if (!pSibling)
3389
0
        return false;
3390
3391
0
    rVclIter.iter = pSibling;
3392
0
    return true;
3393
0
}
3394
3395
int SalInstanceItemView::get_iter_index_in_parent(const weld::TreeIter& rIter) const
3396
0
{
3397
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3398
0
    return SvTreeList::GetRelPos(rVclIter.iter);
3399
0
}
3400
3401
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_iterator(int nPos) const
3402
0
{
3403
0
    if (SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry(nPos))
3404
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3405
3406
0
    return {};
3407
0
}
3408
3409
IMPL_LINK_NOARG(SalInstanceItemView, DoubleClickHdl, SvTreeListBox*, bool)
3410
0
{
3411
0
    if (SvTreeListEntry* pCurEntry = m_pTreeListBox->GetCurEntry())
3412
0
        return !signal_item_activated(SalInstanceTreeIter(*this, pCurEntry));
3413
3414
0
    return false;
3415
0
}
3416
3417
OUString SalInstanceItemView::get_id(const weld::TreeIter& rIter) const
3418
0
{
3419
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3420
0
    const OUString* pStr = rVclIter.iter->GetUserData();
3421
0
    if (pStr)
3422
0
        return *pStr;
3423
0
    return OUString();
3424
0
}
3425
3426
void SalInstanceItemView::set_id(const weld::TreeIter& rIter, const OUString& rId)
3427
0
{
3428
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3429
0
    m_aUserData.emplace_back(std::make_unique<OUString>(rId));
3430
0
    rVclIter.iter->SetUserData(m_aUserData.back().get());
3431
0
}
3432
3433
OUString SalInstanceItemView::get_selected_text() const
3434
0
{
3435
0
    assert(m_pTreeListBox->IsUpdateMode() && "don't request selection when frozen");
3436
0
    if (SvTreeListEntry* pEntry = m_pTreeListBox->FirstSelected())
3437
0
        return SvTabListBox::GetEntryText(pEntry, 0);
3438
0
    return OUString();
3439
0
}
3440
3441
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_selected() const
3442
0
{
3443
0
    SvTreeListEntry* pEntry = m_pTreeListBox->FirstSelected();
3444
0
    if (pEntry)
3445
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3446
3447
0
    return {};
3448
0
}
3449
3450
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_cursor() const
3451
0
{
3452
0
    SvTreeListEntry* pEntry = m_pTreeListBox->GetCurEntry();
3453
0
    if (pEntry)
3454
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3455
3456
0
    return {};
3457
0
}
3458
3459
void SalInstanceItemView::do_select_all()
3460
0
{
3461
0
    assert(m_pTreeListBox->IsUpdateMode()
3462
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3463
0
              "freeze");
3464
0
    m_pTreeListBox->SelectAll(true);
3465
0
}
3466
3467
void SalInstanceItemView::do_unselect_all()
3468
0
{
3469
0
    assert(m_pTreeListBox->IsUpdateMode()
3470
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3471
0
              "freeze");
3472
0
    m_pTreeListBox->SelectAll(false);
3473
0
}
3474
3475
int SalInstanceItemView::n_children() const
3476
0
{
3477
0
    return m_pTreeListBox->GetModel()->GetChildList(nullptr).size();
3478
0
}
3479
3480
void SalInstanceItemView::do_set_cursor(const weld::TreeIter& rIter)
3481
0
{
3482
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3483
0
    m_pTreeListBox->SetCurEntry(rVclIter.iter);
3484
0
}
3485
3486
void SalInstanceItemView::do_select(const weld::TreeIter& rIter)
3487
0
{
3488
0
    assert(m_pTreeListBox->IsUpdateMode()
3489
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3490
0
              "freeze");
3491
3492
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3493
0
    m_pTreeListBox->Select(rVclIter.iter, true);
3494
0
    m_pTreeListBox->MakeVisible(rVclIter.iter);
3495
0
}
3496
3497
void SalInstanceItemView::do_unselect(const weld::TreeIter& rIter)
3498
0
{
3499
0
    assert(m_pTreeListBox->IsUpdateMode()
3500
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3501
0
              "freeze");
3502
3503
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3504
0
    m_pTreeListBox->Select(rVclIter.iter, false);
3505
0
}
3506
3507
void SalInstanceItemView::do_remove(const weld::TreeIter& rIter)
3508
0
{
3509
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3510
0
    m_pTreeListBox->RemoveEntry(rVclIter.iter);
3511
0
}
3512
3513
void SalInstanceItemView::do_clear()
3514
0
{
3515
0
    m_pTreeListBox->Clear();
3516
0
    m_aUserData.clear();
3517
0
}
3518
3519
// Each row has a cell for the expander image, (and an optional cell for a
3520
// checkbutton if enable_toggle_buttons has been called) which precede
3521
// index 0
3522
int SalInstanceTreeView::to_internal_model(int col) const
3523
0
{
3524
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3525
0
        ++col; // skip checkbutton column
3526
0
    ++col; //skip expander column
3527
0
    return col;
3528
0
}
3529
3530
int SalInstanceTreeView::to_external_model(int col) const
3531
0
{
3532
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3533
0
        --col; // skip checkbutton column
3534
0
    --col; //skip expander column
3535
0
    return col;
3536
0
}
3537
3538
SvTreeListEntry& SalInstanceTreeView::InsertDummyEntry(SvTreeListEntry* pParent)
3539
0
{
3540
0
    return m_xTreeView->InsertEntry(u"<dummy>"_ustr, pParent, 0);
3541
0
}
3542
3543
bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const
3544
0
{
3545
0
    return o3tl::trim(m_xTreeView->GetEntryText(pEntry)) == u"<dummy>";
3546
0
}
3547
3548
SvTreeListEntry* SalInstanceTreeView::GetPlaceHolderChild(const SvTreeListEntry* pEntry) const
3549
0
{
3550
0
    if (pEntry->HasChildren())
3551
0
    {
3552
0
        auto pChild = m_xTreeView->FirstChild(pEntry);
3553
0
        assert(pChild);
3554
0
        if (IsDummyEntry(pChild))
3555
0
            return pChild;
3556
0
    }
3557
0
    return nullptr;
3558
0
}
3559
3560
void SalInstanceTreeView::set_font_color(SvTreeListEntry* pEntry, const Color& rColor)
3561
0
{
3562
0
    if (rColor == COL_AUTO)
3563
0
        pEntry->SetTextColor(std::optional<Color>());
3564
0
    else
3565
0
        pEntry->SetTextColor(rColor);
3566
0
}
3567
3568
void SalInstanceTreeView::AddStringItem(SvTreeListEntry& rEntry, const OUString& rStr, int nCol)
3569
0
{
3570
0
    auto xCell = std::make_unique<SvLBoxString>(rStr);
3571
0
    if (m_aCustomRenders.contains(nCol))
3572
0
        xCell->SetCustomRender();
3573
0
    rEntry.AddItem(std::move(xCell));
3574
0
}
3575
3576
void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
3577
                                    const OUString* pId, const OUString* pIconName,
3578
                                    const VirtualDevice* pImageSurface, bool bChildrenOnDemand,
3579
                                    weld::TreeIter* pRet, bool bIsSeparator)
3580
0
{
3581
0
    const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
3582
0
    SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr;
3583
0
    auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
3584
0
    OUString* pUserData;
3585
0
    if (pId)
3586
0
    {
3587
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
3588
0
        pUserData = m_aUserData.back().get();
3589
0
    }
3590
0
    else
3591
0
        pUserData = nullptr;
3592
3593
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
3594
0
    if (bIsSeparator)
3595
0
        pEntry->SetSeparator();
3596
3597
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3598
0
        AddStringItem(*pEntry, u""_ustr, -1);
3599
3600
0
    if (pIconName || pImageSurface)
3601
0
    {
3602
0
        Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
3603
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage));
3604
0
    }
3605
0
    else
3606
0
    {
3607
0
        Image aDummy;
3608
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
3609
0
    }
3610
0
    if (pStr)
3611
0
        AddStringItem(*pEntry, *pStr, pEntry->ItemCount());
3612
0
    pEntry->SetUserData(pUserData);
3613
0
    m_xTreeView->Insert(pEntry, nInsertPos, iter);
3614
3615
0
    if (pRet)
3616
0
    {
3617
0
        SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
3618
0
        pVclRetIter->iter = pEntry;
3619
0
    }
3620
3621
0
    if (bChildrenOnDemand)
3622
0
    {
3623
0
        SvTreeListEntry& rPlaceHolder = InsertDummyEntry(pEntry);
3624
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rPlaceHolder);
3625
0
        rViewData.SetSelectable(false);
3626
0
    }
3627
3628
0
    if (bIsSeparator)
3629
0
    {
3630
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pEntry);
3631
0
        rViewData.SetSelectable(false);
3632
0
    }
3633
0
}
3634
3635
void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry& rEntry)
3636
0
{
3637
0
    SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rEntry);
3638
0
    m_xTreeView->InitViewData(rViewData, rEntry);
3639
0
    m_xTreeView->CheckBoxInserted(rEntry);
3640
0
}
3641
3642
void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry* pEntry)
3643
0
{
3644
0
    if (!m_xTreeView->GetModel()->IsEnableInvalidate())
3645
0
        return;
3646
0
    m_xTreeView->ModelHasEntryInvalidated(pEntry);
3647
0
}
3648
3649
void SalInstanceTreeView::set_toggle(SvTreeListEntry& rEntry, TriState eState, int col)
3650
0
{
3651
0
    assert(col >= 0 && o3tl::make_unsigned(col) < rEntry.ItemCount());
3652
    // if it's the placeholder to allow a blank column, replace it now
3653
0
    if (rEntry.GetItem(col).GetType() != SvLBoxItemType::Button)
3654
0
    {
3655
0
        SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
3656
0
        rEntry.ReplaceItem(std::make_unique<SvLBoxButton>(rData), 0);
3657
0
        update_checkbutton_column_width(rEntry);
3658
0
    }
3659
0
    SvLBoxItem& rItem = rEntry.GetItem(col);
3660
0
    assert(dynamic_cast<SvLBoxButton*>(&rItem));
3661
0
    switch (eState)
3662
0
    {
3663
0
        case TRISTATE_TRUE:
3664
0
            static_cast<SvLBoxButton&>(rItem).SetStateChecked();
3665
0
            break;
3666
0
        case TRISTATE_FALSE:
3667
0
            static_cast<SvLBoxButton&>(rItem).SetStateUnchecked();
3668
0
            break;
3669
0
        case TRISTATE_INDET:
3670
0
            static_cast<SvLBoxButton&>(rItem).SetStateTristate();
3671
0
            break;
3672
0
    }
3673
3674
0
    InvalidateModelEntry(&rEntry);
3675
0
}
3676
3677
TriState SalInstanceTreeView::do_get_toggle(SvTreeListEntry* pEntry, int col)
3678
0
{
3679
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
3680
0
        return TRISTATE_FALSE;
3681
3682
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
3683
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
3684
0
    assert(dynamic_cast<SvLBoxButton*>(&rItem));
3685
0
    SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem);
3686
0
    if (rToggle.IsStateTristate())
3687
0
        return TRISTATE_INDET;
3688
0
    else if (rToggle.IsStateChecked())
3689
0
        return TRISTATE_TRUE;
3690
0
    return TRISTATE_FALSE;
3691
0
}
3692
3693
TriState SalInstanceTreeView::get_toggle(SvTreeListEntry* pEntry, int col) const
3694
0
{
3695
0
    if (col == -1)
3696
0
    {
3697
0
        assert(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
3698
0
        return do_get_toggle(pEntry, 0);
3699
0
    }
3700
0
    col = to_internal_model(col);
3701
0
    return do_get_toggle(pEntry, col);
3702
0
}
3703
3704
bool SalInstanceTreeView::get_text_emphasis(SvTreeListEntry* pEntry, int col) const
3705
0
{
3706
0
    col = to_internal_model(col);
3707
3708
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
3709
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
3710
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
3711
0
    return static_cast<SvLBoxString&>(rItem).IsEmphasized();
3712
0
}
3713
3714
void SalInstanceTreeView::set_header_item_width(const std::vector<int>& rWidths)
3715
0
{
3716
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3717
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3718
0
    {
3719
0
        for (size_t i = 0; i < rWidths.size(); ++i)
3720
0
            pHeaderBar->SetItemSize(pHeaderBar->GetItemId(i), rWidths[i]);
3721
0
    }
3722
0
}
3723
3724
SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder,
3725
                                         bool bTakeOwnership)
3726
0
    : SalInstanceItemView(pTreeView, pBuilder, bTakeOwnership)
3727
0
    , m_xTreeView(pTreeView)
3728
0
    , m_aCheckButtonData(*pTreeView, false)
3729
0
    , m_aRadioButtonData(*pTreeView, true)
3730
0
    , m_bTogglesAsRadio(false)
3731
0
    , m_nSortColumn(-1)
3732
0
{
3733
0
    m_xTreeView->SetNodeDefaultImages();
3734
0
    m_xTreeView->SetForceMakeVisible(true);
3735
0
    m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
3736
0
    m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
3737
0
    m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl));
3738
0
    m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, CustomRenderHdl));
3739
0
    m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, CustomMeasureHdl));
3740
0
    const std::vector<tools::Long> aTabPositions{ 0 };
3741
0
    m_xTreeView->SetTabs(aTabPositions);
3742
    // by default, 1st one is editable, others not; override with set_column_editables
3743
0
    m_xTreeView->SetTabEditable(0, true);
3744
3745
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3746
3747
0
    if (pHeaderBox)
3748
0
    {
3749
0
        if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
3750
0
        {
3751
            //make the last entry fill available space
3752
0
            pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1),
3753
0
                                    HEADERBAR_FULLSIZE);
3754
0
            pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
3755
0
            pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl));
3756
0
        }
3757
0
    }
3758
0
    else
3759
0
    {
3760
0
        LclTabListBox& rLclTabListBox = static_cast<LclTabListBox&>(*m_xTreeView);
3761
0
        rLclTabListBox.SetModelChangedHdl(LINK(this, SalInstanceTreeView, ModelChangedHdl));
3762
0
        rLclTabListBox.SetStartDragHdl(LINK(this, SalInstanceTreeView, StartDragHdl));
3763
0
        rLclTabListBox.SetEndDragHdl(LINK(this, SalInstanceTreeView, FinishDragHdl));
3764
0
    }
3765
0
    m_xTreeView->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
3766
0
    m_xTreeView->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
3767
3768
0
    m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
3769
0
    m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
3770
0
}
Unexecuted instantiation: SalInstanceTreeView::SalInstanceTreeView(SvTabListBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceTreeView::SalInstanceTreeView(SvTabListBox*, SalInstanceBuilder*, bool)
3771
3772
void SalInstanceTreeView::connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink)
3773
0
{
3774
0
    weld::TreeView::connect_query_tooltip(rLink);
3775
0
    m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl));
3776
0
}
3777
3778
void SalInstanceTreeView::columns_autosize()
3779
0
{
3780
0
    std::vector<tools::Long> aWidths;
3781
0
    m_xTreeView->getPreferredDimensions(aWidths);
3782
0
    if (aWidths.size() > 2)
3783
0
    {
3784
0
        std::vector<int> aColWidths;
3785
0
        aColWidths.push_back(aWidths[1] + aWidths[0]);
3786
0
        aColWidths.insert(aColWidths.end(), aWidths.begin() + 2, aWidths.end());
3787
3788
        // take column headers into account
3789
0
        if (VclPtr<SvHeaderTabListBox> pTabListBox
3790
0
            = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3791
0
        {
3792
0
            if (VclPtr<HeaderBar> pHeaderBar = pTabListBox->GetHeaderBar())
3793
0
            {
3794
0
                const size_t nCount
3795
0
                    = std::min(aColWidths.size(), size_t(pHeaderBar->GetItemCount()));
3796
0
                for (size_t i = 0; i < nCount; ++i)
3797
0
                {
3798
0
                    const OUString sHeaderText = pHeaderBar->GetItemText(pHeaderBar->GetItemId(i));
3799
0
                    constexpr int PADDING = 6;
3800
0
                    const int nHeaderColWidth = pHeaderBar->GetTextWidth(sHeaderText) + PADDING;
3801
0
                    aColWidths[i] = std::max(aColWidths.at(i), nHeaderColWidth);
3802
0
                }
3803
0
            }
3804
0
        }
3805
3806
0
        set_column_fixed_widths(aColWidths);
3807
0
    }
3808
0
}
3809
3810
void SalInstanceTreeView::freeze()
3811
0
{
3812
0
    bool bIsFirstFreeze = IsFirstFreeze();
3813
0
    SalInstanceWidget::freeze();
3814
0
    if (bIsFirstFreeze)
3815
0
    {
3816
0
        m_xTreeView->SetUpdateMode(false);
3817
0
        m_xTreeView->GetModel()->EnableInvalidate(false);
3818
0
    }
3819
0
}
3820
3821
void SalInstanceTreeView::thaw()
3822
0
{
3823
0
    bool bIsLastThaw = IsLastThaw();
3824
0
    if (bIsLastThaw)
3825
0
    {
3826
0
        m_xTreeView->GetModel()->EnableInvalidate(true);
3827
0
        m_xTreeView->SetUpdateMode(true);
3828
0
    }
3829
0
    SalInstanceWidget::thaw();
3830
0
}
3831
3832
void SalInstanceTreeView::set_column_fixed_widths(const std::vector<int>& rWidths)
3833
0
{
3834
0
    std::vector<tools::Long> aTabPositions{ 0 };
3835
0
    for (size_t i = 0; i < rWidths.size(); ++i)
3836
0
        aTabPositions.push_back(aTabPositions[i]
3837
0
                                + (m_xTreeView->GetTabVisible(i) ? rWidths[i] : 0));
3838
0
    m_xTreeView->SetTabs(aTabPositions);
3839
0
    set_header_item_width(rWidths);
3840
    // call Resize to recalculate based on the new tabs
3841
0
    m_xTreeView->Resize();
3842
0
}
3843
3844
void SalInstanceTreeView::set_column_editables(const std::vector<bool>& rEditables)
3845
0
{
3846
0
    size_t nTabCount = rEditables.size();
3847
0
    for (size_t i = 0; i < nTabCount; ++i)
3848
0
        m_xTreeView->SetTabEditable(i, rEditables[i]);
3849
0
}
3850
3851
0
void SalInstanceTreeView::set_centered_column(int nCol) { m_xTreeView->SetTabAlignCenter(nCol); }
3852
3853
int SalInstanceTreeView::get_column_width(int nColumn) const
3854
0
{
3855
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3856
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3857
0
        return pHeaderBar->GetItemSize(pHeaderBar->GetItemId(nColumn));
3858
    // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
3859
    // So the first text column's width is Tab(2)-Tab(1).
3860
0
    auto nWidthPixel
3861
0
        = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1);
3862
0
    nWidthPixel -= SV_TAB_BORDER;
3863
0
    return nWidthPixel;
3864
0
}
3865
3866
OUString SalInstanceTreeView::get_column_title(int nColumn) const
3867
0
{
3868
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3869
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3870
0
    {
3871
0
        return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn));
3872
0
    }
3873
0
    return OUString();
3874
0
}
3875
3876
void SalInstanceTreeView::set_column_title(int nColumn, const OUString& rTitle)
3877
0
{
3878
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3879
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3880
0
    {
3881
0
        return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle);
3882
0
    }
3883
0
}
3884
3885
bool SalInstanceTreeView::get_column_visible(int nColumn) const
3886
0
{
3887
0
    return m_xTreeView->GetTabVisible(nColumn);
3888
0
}
3889
3890
void SalInstanceTreeView::set_column_visible(int nColumn, const bool bVisible)
3891
0
{
3892
0
    tools::Long width = bVisible ? m_xTreeView->GetEntryWidth() : 0;
3893
0
    m_xTreeView->SetTabWidth(nColumn, width);
3894
3895
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3896
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3897
0
    {
3898
0
        sal_uInt16 nItemId = pHeaderBar->GetItemId(nColumn);
3899
0
        pHeaderBar->SetItemVisible(nItemId, bVisible);
3900
0
        pHeaderBar->SetItemSize(nItemId, width);
3901
0
    }
3902
3903
    // Set flag for columns_autosize() to respect the visibility
3904
0
    m_xTreeView->SetTabVisible(nColumn, bVisible);
3905
3906
    // call Resize to recalculate based on the new tab positions
3907
0
    m_xTreeView->Resize();
3908
0
}
3909
3910
void SalInstanceTreeView::set_column_custom_renderer(int nColumn, bool bEnable)
3911
0
{
3912
0
    assert(n_children() == 0 && "tree must be empty");
3913
0
    if (bEnable)
3914
0
        m_aCustomRenders.insert(nColumn);
3915
0
    else
3916
0
        m_aCustomRenders.erase(nColumn);
3917
0
}
3918
3919
void SalInstanceTreeView::queue_draw()
3920
0
{
3921
    // invalidate the entries
3922
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
3923
0
        m_xTreeView->InvalidateEntry(*pEntry);
3924
0
}
3925
3926
void SalInstanceTreeView::show()
3927
0
{
3928
0
    if (SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3929
0
        pHeaderBox->GetParent()->Show();
3930
0
    SalInstanceWidget::show();
3931
0
}
3932
3933
void SalInstanceTreeView::hide()
3934
0
{
3935
0
    if (SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3936
0
        pHeaderBox->GetParent()->Hide();
3937
0
    SalInstanceWidget::hide();
3938
0
}
3939
3940
void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
3941
                                    const OUString* pId, const OUString* pIconName,
3942
                                    VirtualDevice* pImageSurface, bool bChildrenOnDemand,
3943
                                    weld::TreeIter* pRet)
3944
0
{
3945
0
    do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet, false);
3946
0
}
3947
3948
void SalInstanceTreeView::do_insert_separator(int pos, const OUString& /*rId*/)
3949
0
{
3950
0
    OUString sSep(VclResId(STR_SEPARATOR));
3951
0
    do_insert(nullptr, pos, &sSep, nullptr, nullptr, nullptr, false, nullptr, true);
3952
0
}
3953
3954
void SalInstanceTreeView::bulk_insert_for_each(
3955
    int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
3956
    const weld::TreeIter* pParent, const std::vector<int>* pFixedWidths, bool bGoingToSetText, bool)
3957
0
{
3958
0
    const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
3959
0
    SvTreeListEntry* pVclParent = pVclIter ? pVclIter->iter : nullptr;
3960
3961
0
    freeze();
3962
0
    if (!pVclParent)
3963
0
        clear();
3964
0
    else
3965
0
    {
3966
0
        while (SvTreeListEntry* pChild = m_xTreeView->FirstChild(pVclParent))
3967
0
            m_xTreeView->RemoveEntry(pChild);
3968
0
    }
3969
0
    SalInstanceTreeIter aVclIter(*this, static_cast<SvTreeListEntry*>(nullptr));
3970
3971
0
    m_xTreeView->m_nTreeFlags |= SvTreeFlags::MANINS;
3972
3973
0
    if (pFixedWidths)
3974
0
        set_header_item_width(*pFixedWidths);
3975
3976
0
    bool bHasAutoCheckButton(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
3977
0
    size_t nExtraCols = bHasAutoCheckButton ? 2 : 1;
3978
3979
0
    Image aDummy;
3980
0
    for (int i = 0; i < nSourceCount; ++i)
3981
0
    {
3982
0
        aVclIter.iter = new SvTreeListEntry;
3983
0
        if (bHasAutoCheckButton)
3984
0
            AddStringItem(*aVclIter.iter, u""_ustr, -1);
3985
0
        aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
3986
0
        if (bGoingToSetText)
3987
0
            AddStringItem(*aVclIter.iter, u""_ustr, aVclIter.iter->ItemCount());
3988
0
        m_xTreeView->Insert(aVclIter.iter, TREELIST_APPEND, pVclParent);
3989
0
        func(aVclIter, i);
3990
0
        m_xTreeView->CalcEntryHeight(*aVclIter.iter);
3991
3992
0
        if (!pFixedWidths)
3993
0
            continue;
3994
3995
0
        size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
3996
0
        for (size_t j = 0; j < nFixedWidths; ++j)
3997
0
        {
3998
0
            SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols);
3999
0
            SvViewDataItem& rViewDataItem = m_xTreeView->GetViewDataItem(*aVclIter.iter, rItem);
4000
0
            rViewDataItem.mnWidth = (*pFixedWidths)[j];
4001
0
        }
4002
0
    }
4003
4004
0
    m_xTreeView->m_nTreeFlags &= ~SvTreeFlags::MANINS;
4005
4006
0
    thaw();
4007
0
}
4008
4009
void SalInstanceTreeView::set_font_color(const weld::TreeIter& rIter, const Color& rColor)
4010
0
{
4011
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4012
0
    set_font_color(rVclIter.iter, rColor);
4013
0
}
4014
4015
int SalInstanceTreeView::find_text(const OUString& rText) const
4016
0
{
4017
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
4018
0
    {
4019
0
        if (SvTabListBox::GetEntryText(pEntry, 0) == rText)
4020
0
            return SvTreeList::GetRelPos(pEntry);
4021
0
    }
4022
0
    return -1;
4023
0
}
4024
4025
int SalInstanceTreeView::find_id(const OUString& rId) const
4026
0
{
4027
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
4028
0
    {
4029
0
        const OUString* pId = pEntry->GetUserData();
4030
0
        if (!pId)
4031
0
            continue;
4032
0
        if (rId == *pId)
4033
0
            return SvTreeList::GetRelPos(pEntry);
4034
0
    }
4035
0
    return -1;
4036
0
}
4037
4038
void SalInstanceTreeView::swap(int pos1, int pos2)
4039
0
{
4040
0
    int min = std::min(pos1, pos2);
4041
0
    int max = std::max(pos1, pos2);
4042
0
    SvTreeList* pModel = m_xTreeView->GetModel();
4043
0
    SvTreeListEntry* pEntry1 = pModel->GetEntry(nullptr, min);
4044
0
    SvTreeListEntry* pEntry2 = pModel->GetEntry(nullptr, max);
4045
0
    pModel->Move(pEntry1, pEntry2);
4046
0
}
4047
4048
int SalInstanceTreeView::do_iter_n_children(const weld::TreeIter& rIter) const
4049
0
{
4050
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4051
0
    return m_xTreeView->GetModel()->GetChildList(rVclIter.iter).size();
4052
0
}
4053
4054
void SalInstanceTreeView::do_set_cursor(int pos)
4055
0
{
4056
0
    if (pos == -1)
4057
0
        m_xTreeView->SetCurEntry(nullptr);
4058
0
    else
4059
0
    {
4060
0
        SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
4061
0
        m_xTreeView->SetCurEntry(pEntry);
4062
0
    }
4063
0
}
4064
4065
std::vector<int> SalInstanceTreeView::get_selected_rows() const
4066
0
{
4067
0
    std::vector<int> aRows;
4068
4069
0
    aRows.reserve(m_xTreeView->GetSelectionCount());
4070
0
    for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry;
4071
0
         pEntry = m_xTreeView->NextSelected(pEntry))
4072
0
        aRows.push_back(SvTreeList::GetRelPos(pEntry));
4073
4074
0
    return aRows;
4075
0
}
4076
4077
void SalInstanceTreeView::set_text(SvTreeListEntry& rEntry, const OUString& rText, int col)
4078
0
{
4079
0
    if (col == -1)
4080
0
    {
4081
0
        m_xTreeView->SetEntryText(rEntry, rText);
4082
0
        return;
4083
0
    }
4084
4085
0
    col = to_internal_model(col);
4086
4087
    // blank out missing entries
4088
0
    for (int i = rEntry.ItemCount(); i < col; ++i)
4089
0
        AddStringItem(rEntry, u""_ustr, i - 1);
4090
4091
0
    if (static_cast<size_t>(col) == rEntry.ItemCount())
4092
0
    {
4093
0
        AddStringItem(rEntry, rText, col - 1);
4094
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rEntry);
4095
0
        m_xTreeView->InitViewData(rViewData, rEntry);
4096
0
    }
4097
0
    else
4098
0
    {
4099
0
        assert(col >= 0 && o3tl::make_unsigned(col) < rEntry.ItemCount());
4100
0
        SvLBoxItem& rItem = rEntry.GetItem(col);
4101
0
        assert(dynamic_cast<SvLBoxString*>(&rItem));
4102
0
        static_cast<SvLBoxString&>(rItem).SetText(rText);
4103
0
    }
4104
4105
0
    InvalidateModelEntry(&rEntry);
4106
0
}
4107
4108
void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col)
4109
0
{
4110
0
    if (col == -1)
4111
0
    {
4112
0
        auto nFlags = pEntry->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT;
4113
0
        if (!bSensitive)
4114
0
            nFlags = nFlags | SvTLEntryFlags::SEMITRANSPARENT;
4115
0
        pEntry->SetFlags(nFlags);
4116
0
        const sal_uInt16 nCount = pEntry->ItemCount();
4117
0
        for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur)
4118
0
        {
4119
0
            SvLBoxItem& rItem = pEntry->GetItem(nCur);
4120
0
            if (rItem.GetType() == SvLBoxItemType::String
4121
0
                || rItem.GetType() == SvLBoxItemType::Button
4122
0
                || rItem.GetType() == SvLBoxItemType::ContextBmp)
4123
0
            {
4124
0
                rItem.Enable(bSensitive);
4125
0
                InvalidateModelEntry(pEntry);
4126
0
            }
4127
0
        }
4128
0
        return;
4129
0
    }
4130
4131
0
    col = to_internal_model(col);
4132
4133
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4134
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4135
0
    rItem.Enable(bSensitive);
4136
4137
0
    InvalidateModelEntry(pEntry);
4138
0
}
4139
4140
bool SalInstanceTreeView::do_get_sensitive(SvTreeListEntry* pEntry, int col)
4141
0
{
4142
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
4143
0
        return false;
4144
4145
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4146
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4147
0
    return rItem.isEnable();
4148
0
}
4149
4150
bool SalInstanceTreeView::get_sensitive(SvTreeListEntry* pEntry, int col) const
4151
0
{
4152
0
    col = to_internal_model(col);
4153
0
    return do_get_sensitive(pEntry, col);
4154
0
}
4155
4156
void SalInstanceTreeView::set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col)
4157
0
{
4158
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4159
0
    set_sensitive(rVclIter.iter, bSensitive, col);
4160
0
}
4161
4162
bool SalInstanceTreeView::get_sensitive(const weld::TreeIter& rIter, int col) const
4163
0
{
4164
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4165
0
    return get_sensitive(rVclIter.iter, col);
4166
0
}
4167
4168
TriState SalInstanceTreeView::get_toggle(const weld::TreeIter& rIter, int col) const
4169
0
{
4170
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4171
0
    return get_toggle(rVclIter.iter, col);
4172
0
}
4173
4174
void SalInstanceTreeView::enable_toggle_buttons()
4175
0
{
4176
0
    assert(n_children() == 0 && "tree must be empty");
4177
4178
0
    SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
4179
0
    m_xTreeView->EnableCheckButton(rData);
4180
0
}
4181
4182
void SalInstanceTreeView::set_toggle_button_type(weld::ColumnToggleType eType)
4183
0
{
4184
0
    assert(n_children() == 0 && "tree must be empty");
4185
0
    m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio;
4186
4187
    // Update type of check buttons to use for the special toggle button column, if active
4188
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
4189
0
        enable_toggle_buttons();
4190
0
}
4191
4192
void SalInstanceTreeView::do_set_toggle(const weld::TreeIter& rIter, TriState eState, int col)
4193
0
{
4194
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4195
0
    assert(rVclIter.iter && "Invalid iter");
4196
0
    SvTreeListEntry& rEntry = *rVclIter.iter;
4197
4198
0
    if (col == -1)
4199
0
    {
4200
0
        assert(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
4201
0
        set_toggle(rEntry, eState, 0);
4202
0
        return;
4203
0
    }
4204
4205
0
    col = to_internal_model(col);
4206
4207
    // blank out missing entries
4208
0
    for (int i = rEntry.ItemCount(); i < col; ++i)
4209
0
        AddStringItem(rEntry, u""_ustr, i - 1);
4210
4211
0
    if (static_cast<size_t>(col) == rEntry.ItemCount())
4212
0
    {
4213
0
        SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
4214
0
        rEntry.AddItem(std::make_unique<SvLBoxButton>(rData));
4215
0
        update_checkbutton_column_width(rEntry);
4216
0
    }
4217
4218
0
    set_toggle(rEntry, eState, col);
4219
0
}
4220
4221
void SalInstanceTreeView::set_clicks_to_toggle(int nToggleBehavior)
4222
0
{
4223
0
    m_xTreeView->SetClicksToToggle(nToggleBehavior);
4224
0
}
4225
4226
void SalInstanceTreeView::set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel)
4227
0
{
4228
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4229
0
    rVclIter.iter->SetExtraIndent(nIndentLevel);
4230
0
}
4231
4232
void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col)
4233
0
{
4234
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4235
0
    SvTreeListEntry* pEntry = rVclIter.iter;
4236
4237
0
    if (col == -1)
4238
0
    {
4239
0
        for (size_t nCur = 0; nCur < pEntry->ItemCount(); ++nCur)
4240
0
        {
4241
0
            SvLBoxItem& rItem = pEntry->GetItem(nCur);
4242
0
            if (rItem.GetType() == SvLBoxItemType::String)
4243
0
            {
4244
0
                static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
4245
0
                InvalidateModelEntry(pEntry);
4246
0
            }
4247
0
        }
4248
0
        return;
4249
0
    }
4250
4251
0
    col = to_internal_model(col);
4252
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4253
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4254
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4255
0
    static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
4256
4257
0
    InvalidateModelEntry(pEntry);
4258
0
}
4259
4260
bool SalInstanceTreeView::get_text_emphasis(const weld::TreeIter& rIter, int col) const
4261
0
{
4262
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4263
0
    return get_text_emphasis(rVclIter.iter, col);
4264
0
}
4265
4266
void SalInstanceTreeView::set_text_align(SvTreeListEntry* pEntry, TxtAlign eAlign, int col)
4267
0
{
4268
0
    col = to_internal_model(col);
4269
4270
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4271
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4272
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4273
0
    static_cast<SvLBoxString&>(rItem).Align(eAlign);
4274
4275
0
    InvalidateModelEntry(pEntry);
4276
0
}
4277
4278
void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, TxtAlign eAlign, int col)
4279
0
{
4280
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4281
0
    set_text_align(rVclIter.iter, eAlign, col);
4282
0
}
4283
4284
void SalInstanceTreeView::connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
4285
                                          const Link<const IterColText&, bool>& rEndLink)
4286
0
{
4287
0
    m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet());
4288
0
    weld::TreeView::connect_editing(rStartLink, rEndLink);
4289
0
}
4290
4291
void SalInstanceTreeView::start_editing(const weld::TreeIter& rIter)
4292
0
{
4293
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4294
0
    m_xTreeView->EditEntry(rVclIter.iter);
4295
0
}
4296
4297
0
void SalInstanceTreeView::end_editing() { m_xTreeView->EndEditing(); }
4298
4299
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, const Image& rImage, int col)
4300
0
{
4301
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4302
0
    SvTreeListEntry* pEntry = rVclIter.iter;
4303
0
    assert(pEntry);
4304
4305
0
    if (col == -1 || col == 0)
4306
0
    {
4307
0
        m_xTreeView->SetExpandedEntryBmp(*pEntry, rImage);
4308
0
        m_xTreeView->SetCollapsedEntryBmp(*pEntry, rImage);
4309
0
        return;
4310
0
    }
4311
4312
0
    col = to_internal_model(col);
4313
4314
    // blank out missing entries
4315
0
    for (int i = pEntry->ItemCount(); i < col; ++i)
4316
0
        AddStringItem(*pEntry, u""_ustr, i - 1);
4317
4318
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
4319
0
    {
4320
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage));
4321
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pEntry);
4322
0
        m_xTreeView->InitViewData(rViewData, *pEntry);
4323
0
    }
4324
0
    else
4325
0
    {
4326
0
        assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4327
0
        SvLBoxItem& rItem = pEntry->GetItem(col);
4328
0
        assert(dynamic_cast<SvLBoxContextBmp*>(&rItem));
4329
0
        static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage);
4330
0
        static_cast<SvLBoxContextBmp&>(rItem).SetBitmap2(rImage);
4331
0
    }
4332
4333
0
    m_xTreeView->CalcEntryHeight(*pEntry);
4334
0
    InvalidateModelEntry(pEntry);
4335
0
}
4336
4337
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, const OUString& rImage, int col)
4338
0
{
4339
0
    set_image(rIter, createImage(rImage), col);
4340
0
}
4341
4342
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter,
4343
                                    const css::uno::Reference<css::graphic::XGraphic>& rImage,
4344
                                    int col)
4345
0
{
4346
0
    set_image(rIter, Image(rImage), col);
4347
0
}
4348
4349
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, VirtualDevice& rImage, int col)
4350
0
{
4351
0
    set_image(rIter, createImage(rImage), col);
4352
0
}
4353
4354
void SalInstanceTreeView::copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const
4355
0
{
4356
0
    const SalInstanceTreeIter& rVclSource(static_cast<const SalInstanceTreeIter&>(rSource));
4357
0
    SalInstanceTreeIter& rVclDest(static_cast<SalInstanceTreeIter&>(rDest));
4358
0
    rVclDest.iter = rVclSource.iter;
4359
0
}
4360
4361
bool SalInstanceTreeView::iter_previous_sibling(weld::TreeIter& rIter) const
4362
0
{
4363
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4364
0
    SvTreeListEntry* pSibling = rVclIter.iter->PrevSibling();
4365
0
    if (!pSibling)
4366
0
        return false;
4367
4368
0
    rVclIter.iter = pSibling;
4369
0
    return true;
4370
0
}
4371
4372
bool SalInstanceTreeView::do_iter_children(weld::TreeIter& rIter) const
4373
0
{
4374
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4375
0
    SvTreeListEntry* pChild = m_xTreeView->FirstChild(rVclIter.iter);
4376
0
    if (!pChild)
4377
0
        return false;
4378
4379
0
    rVclIter.iter = pChild;
4380
0
    return true;
4381
0
}
4382
4383
bool SalInstanceTreeView::iter_parent(weld::TreeIter& rIter) const
4384
0
{
4385
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4386
0
    SvTreeListEntry* pParent = m_xTreeView->GetParent(rVclIter.iter);
4387
0
    if (!pParent)
4388
0
        return false;
4389
4390
0
    rVclIter.iter = pParent;
4391
0
    return true;
4392
0
}
4393
4394
void SalInstanceTreeView::do_select(const weld::TreeIter& rIter)
4395
0
{
4396
0
    assert(m_xTreeView->IsUpdateMode()
4397
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4398
0
              "freeze");
4399
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4400
0
    m_xTreeView->Select(rVclIter.iter, true);
4401
0
}
4402
4403
void SalInstanceTreeView::do_scroll_to_row(const weld::TreeIter& rIter)
4404
0
{
4405
0
    assert(m_xTreeView->IsUpdateMode()
4406
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4407
0
              "freeze");
4408
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4409
0
    m_xTreeView->MakeVisible(rVclIter.iter);
4410
0
}
4411
4412
void SalInstanceTreeView::do_unselect(const weld::TreeIter& rIter)
4413
0
{
4414
0
    assert(m_xTreeView->IsUpdateMode() && "don't unselect when frozen");
4415
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4416
0
    m_xTreeView->Select(rVclIter.iter, false);
4417
0
}
4418
4419
int SalInstanceTreeView::get_iter_depth(const weld::TreeIter& rIter) const
4420
0
{
4421
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4422
0
    return m_xTreeView->GetModel()->GetDepth(rVclIter.iter);
4423
0
}
4424
4425
bool SalInstanceTreeView::get_row_expanded(const weld::TreeIter& rIter) const
4426
0
{
4427
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4428
0
    return m_xTreeView->IsExpanded(rVclIter.iter);
4429
0
}
4430
4431
bool SalInstanceTreeView::get_children_on_demand(const weld::TreeIter& rIter) const
4432
0
{
4433
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4434
0
    assert(rVclIter.iter && "Invalid iter");
4435
0
    if (m_aExpandingPlaceHolderParents.contains(rVclIter.iter))
4436
0
        return true;
4437
0
    return GetPlaceHolderChild(rVclIter.iter) != nullptr;
4438
0
}
4439
4440
void SalInstanceTreeView::do_set_children_on_demand(const weld::TreeIter& rIter,
4441
                                                    bool bChildrenOnDemand)
4442
0
{
4443
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4444
4445
0
    SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(rVclIter.iter);
4446
4447
0
    if (bChildrenOnDemand && !pPlaceHolder)
4448
0
    {
4449
0
        pPlaceHolder = &InsertDummyEntry(rVclIter.iter);
4450
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pPlaceHolder);
4451
0
        rViewData.SetSelectable(false);
4452
0
    }
4453
0
    else if (!bChildrenOnDemand && pPlaceHolder)
4454
0
        m_xTreeView->RemoveEntry(pPlaceHolder);
4455
0
}
4456
4457
void SalInstanceTreeView::expand_row(const weld::TreeIter& rIter)
4458
0
{
4459
0
    assert(m_xTreeView->IsUpdateMode() && "don't expand when frozen");
4460
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4461
0
    assert(rVclIter.iter);
4462
0
    if (!m_xTreeView->IsExpanded(rVclIter.iter) && ExpandRow(rVclIter))
4463
0
        m_xTreeView->Expand(*rVclIter.iter);
4464
0
}
4465
4466
void SalInstanceTreeView::collapse_row(const weld::TreeIter& rIter)
4467
0
{
4468
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4469
0
    if (m_xTreeView->IsExpanded(rVclIter.iter) && signal_collapsing(rIter))
4470
0
        m_xTreeView->Collapse(rVclIter.iter);
4471
0
}
4472
4473
OUString SalInstanceTreeView::get_text(const weld::TreeIter& rIter, int col) const
4474
0
{
4475
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4476
4477
0
    if (col == -1)
4478
0
        return SvTabListBox::GetEntryText(rVclIter.iter, 0);
4479
4480
0
    col = to_internal_model(col);
4481
4482
0
    if (static_cast<size_t>(col) == rVclIter.iter->ItemCount())
4483
0
        return OUString();
4484
4485
0
    assert(col >= 0 && o3tl::make_unsigned(col) < rVclIter.iter->ItemCount());
4486
0
    SvLBoxItem& rItem = rVclIter.iter->GetItem(col);
4487
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4488
0
    return static_cast<SvLBoxString&>(rItem).GetText();
4489
0
}
4490
4491
void SalInstanceTreeView::set_text(const weld::TreeIter& rIter, const OUString& rText, int col)
4492
0
{
4493
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4494
0
    assert(rVclIter.iter && "Invalid iter");
4495
0
    set_text(*rVclIter.iter, rText, col);
4496
0
}
4497
4498
void SalInstanceTreeView::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
4499
                                             sal_uInt8 eDNDConstants)
4500
0
{
4501
0
    m_xTreeView->SetDragHelper(rHelper, eDNDConstants);
4502
0
}
4503
4504
void SalInstanceTreeView::set_selection_mode(SelectionMode eMode)
4505
0
{
4506
0
    m_xTreeView->SetSelectionMode(eMode);
4507
0
}
4508
4509
void SalInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>& func)
4510
0
{
4511
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4512
4513
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->First());
4514
0
    bool bContinue = aVclIter.iter;
4515
0
    while (bContinue)
4516
0
    {
4517
0
        if (func(aVclIter))
4518
0
            return;
4519
0
        bContinue = iter_next(aVclIter);
4520
0
    }
4521
0
}
4522
4523
void SalInstanceTreeView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
4524
0
{
4525
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4526
4527
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->FirstSelected());
4528
0
    while (aVclIter.iter)
4529
0
    {
4530
0
        if (func(aVclIter))
4531
0
            return;
4532
0
        aVclIter.iter = m_xTreeView->NextSelected(aVclIter.iter);
4533
0
    }
4534
0
}
4535
4536
void SalInstanceTreeView::visible_foreach(const std::function<bool(weld::TreeIter&)>& func)
4537
0
{
4538
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4539
4540
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->GetFirstEntryInView());
4541
0
    while (aVclIter.iter)
4542
0
    {
4543
0
        if (func(aVclIter))
4544
0
            return;
4545
0
        aVclIter.iter = m_xTreeView->GetNextEntryInView(aVclIter.iter);
4546
0
    }
4547
0
}
4548
4549
void SalInstanceTreeView::connect_visible_range_changed(const Link<weld::TreeView&, void>& rLink)
4550
0
{
4551
0
    m_xTreeView->SetCustomEntryRenderer(true);
4552
0
    weld::TreeView::connect_visible_range_changed(rLink);
4553
0
    m_xTreeView->SetScrolledHdl(LINK(this, SalInstanceTreeView, VisibleRangeChangedHdl));
4554
0
}
4555
4556
void SalInstanceTreeView::do_remove_selection()
4557
0
{
4558
0
    SvTreeListEntry* pSelected = m_xTreeView->FirstSelected();
4559
0
    while (pSelected)
4560
0
    {
4561
0
        SvTreeListEntry* pNextSelected = m_xTreeView->NextSelected(pSelected);
4562
0
        m_xTreeView->RemoveEntry(pSelected);
4563
0
        pSelected = pNextSelected;
4564
0
    }
4565
0
}
4566
4567
bool SalInstanceTreeView::is_selected(const weld::TreeIter& rIter) const
4568
0
{
4569
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4570
0
    return m_xTreeView->IsSelected(rVclIter.iter);
4571
0
}
4572
4573
int SalInstanceTreeView::iter_compare(const weld::TreeIter& a, const weld::TreeIter& b) const
4574
0
{
4575
0
    const SalInstanceTreeIter& rVclIterA = static_cast<const SalInstanceTreeIter&>(a);
4576
0
    const SalInstanceTreeIter& rVclIterB = static_cast<const SalInstanceTreeIter&>(b);
4577
0
    const SvTreeList* pModel = m_xTreeView->GetModel();
4578
0
    auto nAbsPosA = pModel->GetAbsPos(rVclIterA.iter);
4579
0
    auto nAbsPosB = pModel->GetAbsPos(rVclIterB.iter);
4580
0
    if (nAbsPosA < nAbsPosB)
4581
0
        return -1;
4582
0
    if (nAbsPosA > nAbsPosB)
4583
0
        return 1;
4584
0
    return 0;
4585
0
}
4586
4587
void SalInstanceTreeView::move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent,
4588
                                       int nIndexInNewParent)
4589
0
{
4590
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNode);
4591
0
    const SalInstanceTreeIter* pVclParentIter = static_cast<const SalInstanceTreeIter*>(pNewParent);
4592
0
    m_xTreeView->GetModel()->Move(rVclIter.iter, pVclParentIter ? pVclParentIter->iter : nullptr,
4593
0
                                  nIndexInNewParent);
4594
0
}
4595
4596
0
int SalInstanceTreeView::count_selected_rows() const { return m_xTreeView->GetSelectionCount(); }
4597
4598
int SalInstanceTreeView::get_height_rows(int nRows) const
4599
0
{
4600
0
    int nHeight = m_xTreeView->GetEntryHeight() * nRows;
4601
4602
0
    sal_Int32 nLeftBorder(0), nTopBorder(0), nRightBorder(0), nBottomBorder(0);
4603
0
    m_xTreeView->GetBorder(nLeftBorder, nTopBorder, nRightBorder, nBottomBorder);
4604
0
    nHeight += nTopBorder + nBottomBorder;
4605
4606
0
    return nHeight;
4607
0
}
4608
4609
void SalInstanceTreeView::make_sorted()
4610
0
{
4611
0
    assert(m_xTreeView->IsUpdateMode() && "don't sort when frozen");
4612
0
    m_xTreeView->SetStyle(m_xTreeView->GetStyle() | WB_SORT);
4613
0
    m_xTreeView->GetModel()->SetCompareHdl(LINK(this, SalInstanceTreeView, CompareHdl));
4614
0
    set_sort_order(true);
4615
0
}
4616
4617
void SalInstanceTreeView::set_sort_func(
4618
    const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func)
4619
0
{
4620
0
    weld::TreeView::set_sort_func(func);
4621
0
    SvTreeList* pListModel = m_xTreeView->GetModel();
4622
0
    pListModel->Resort();
4623
0
}
4624
4625
void SalInstanceTreeView::make_unsorted()
4626
0
{
4627
0
    m_xTreeView->SetStyle(m_xTreeView->GetStyle() & ~WB_SORT);
4628
0
}
4629
4630
void SalInstanceTreeView::set_sort_order(bool bAscending)
4631
0
{
4632
0
    SvTreeList* pListModel = m_xTreeView->GetModel();
4633
0
    pListModel->SetSortMode(bAscending ? SvSortMode::Ascending : SvSortMode::Descending);
4634
0
    pListModel->Resort();
4635
0
}
4636
4637
bool SalInstanceTreeView::get_sort_order() const
4638
0
{
4639
0
    return m_xTreeView->GetModel()->GetSortMode() == SvSortMode::Ascending;
4640
0
}
4641
4642
void SalInstanceTreeView::set_sort_indicator(TriState eState, int col)
4643
0
{
4644
0
    assert(col >= 0 && "cannot sort on expander column");
4645
4646
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4647
0
    HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr;
4648
0
    if (!pHeaderBar)
4649
0
        return;
4650
4651
0
    sal_uInt16 nTextId = pHeaderBar->GetItemId(col);
4652
0
    HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId);
4653
0
    nBits &= ~HeaderBarItemBits::UPARROW;
4654
0
    nBits &= ~HeaderBarItemBits::DOWNARROW;
4655
0
    if (eState != TRISTATE_INDET)
4656
0
    {
4657
0
        if (eState == TRISTATE_TRUE)
4658
0
            nBits |= HeaderBarItemBits::DOWNARROW;
4659
0
        else
4660
0
            nBits |= HeaderBarItemBits::UPARROW;
4661
0
    }
4662
0
    pHeaderBar->SetItemBits(nTextId, nBits);
4663
0
}
4664
4665
TriState SalInstanceTreeView::get_sort_indicator(int col) const
4666
0
{
4667
0
    assert(col >= 0 && "cannot sort on expander column");
4668
4669
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4670
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
4671
0
    {
4672
0
        sal_uInt16 nTextId = pHeaderBar->GetItemId(col);
4673
0
        HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId);
4674
0
        if (nBits & HeaderBarItemBits::DOWNARROW)
4675
0
            return TRISTATE_TRUE;
4676
0
        if (nBits & HeaderBarItemBits::UPARROW)
4677
0
            return TRISTATE_FALSE;
4678
0
    }
4679
4680
0
    return TRISTATE_INDET;
4681
0
}
4682
4683
0
int SalInstanceTreeView::get_sort_column() const { return m_nSortColumn; }
4684
4685
void SalInstanceTreeView::set_sort_column(int nColumn)
4686
0
{
4687
0
    if (nColumn == -1)
4688
0
    {
4689
0
        make_unsorted();
4690
0
        m_nSortColumn = -1;
4691
0
        return;
4692
0
    }
4693
4694
0
    if (nColumn != m_nSortColumn)
4695
0
    {
4696
0
        m_nSortColumn = nColumn;
4697
0
        m_xTreeView->GetModel()->Resort();
4698
0
    }
4699
0
}
4700
4701
0
SvTabListBox& SalInstanceTreeView::getTreeView() { return *m_xTreeView; }
4702
4703
std::unique_ptr<weld::TreeIter>
4704
SalInstanceTreeView::get_dest_row_at_pos(const Point& rPos, bool bDnDMode, bool bAutoScroll)
4705
0
{
4706
0
    LclTabListBox* pTreeView
4707
0
        = !bDnDMode ? dynamic_cast<LclTabListBox*>(m_xTreeView.get()) : nullptr;
4708
0
    SvTreeListEntry* pTarget = pTreeView ? pTreeView->GetTargetAtPoint(rPos, false, bAutoScroll)
4709
0
                                         : m_xTreeView->GetDropTarget(rPos);
4710
4711
0
    if (pTarget)
4712
0
        return std::make_unique<SalInstanceTreeIter>(*this, pTarget);
4713
4714
0
    return {};
4715
0
}
4716
4717
0
void SalInstanceTreeView::unset_drag_dest_row() { m_xTreeView->UnsetDropTarget(); }
4718
4719
tools::Rectangle SalInstanceTreeView::get_row_area(const weld::TreeIter& rIter) const
4720
0
{
4721
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4722
0
    assert(rVclIter.iter && "invalid iter");
4723
0
    return m_xTreeView->GetBoundingRect(*rVclIter.iter);
4724
0
}
4725
4726
0
weld::TreeView* SalInstanceTreeView::get_drag_source() const { return g_DragSource; }
4727
4728
int SalInstanceTreeView::vadjustment_get_value() const
4729
0
{
4730
0
    int nValue = -1;
4731
0
    const SvTreeListEntry* pEntry = m_xTreeView->GetFirstEntryInView();
4732
0
    if (pEntry)
4733
0
        nValue = m_xTreeView->GetAbsPos(pEntry);
4734
0
    return nValue;
4735
0
}
4736
4737
void SalInstanceTreeView::vadjustment_set_value(int nValue)
4738
0
{
4739
0
    if (nValue == -1)
4740
0
        return;
4741
0
    bool bUpdate = m_xTreeView->IsUpdateMode();
4742
0
    if (bUpdate)
4743
0
        m_xTreeView->SetUpdateMode(false);
4744
0
    m_xTreeView->ScrollToAbsPos(nValue);
4745
0
    if (bUpdate)
4746
0
        m_xTreeView->SetUpdateMode(true);
4747
0
}
4748
4749
void SalInstanceTreeView::set_show_expanders(bool bShow)
4750
0
{
4751
0
    m_xTreeView->set_property(u"show-expanders"_ustr, OUString::boolean(bShow));
4752
0
}
4753
4754
0
bool SalInstanceTreeView::changed_by_hover() const { return m_xTreeView->IsSelectDueToHover(); }
4755
4756
SalInstanceTreeView::~SalInstanceTreeView()
4757
0
{
4758
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4759
0
    if (pHeaderBox)
4760
0
    {
4761
0
        if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
4762
0
        {
4763
0
            pHeaderBar->SetSelectHdl(Link<HeaderBar*, void>());
4764
0
            pHeaderBar->SetEndDragHdl(Link<HeaderBar*, void>());
4765
0
        }
4766
0
    }
4767
0
    else
4768
0
    {
4769
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetEndDragHdl(Link<SvTreeListBox*, void>());
4770
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetStartDragHdl(Link<SvTreeListBox*, bool>());
4771
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetModelChangedHdl(Link<SvTreeListBox*, void>());
4772
0
    }
4773
0
    if (g_DragSource == this)
4774
0
        g_DragSource = nullptr;
4775
0
    m_xTreeView->SetExpandingHdl(Link<SvTreeListBox*, bool>());
4776
0
    m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>());
4777
0
    m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>());
4778
0
    m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>());
4779
0
    m_xTreeView->SetTooltipHdl({});
4780
0
    m_xTreeView->SetCustomRenderHdl(Link<svtree_render_args, void>());
4781
0
    m_xTreeView->SetCustomMeasureHdl(Link<svtree_measure_args, Size>());
4782
0
}
4783
4784
IMPL_LINK(SalInstanceTreeView, TooltipHdl, SvTreeListEntry&, rEntry, OUString)
4785
0
{
4786
0
    return signal_query_tooltip(SalInstanceTreeIter(*this, &rEntry));
4787
0
}
4788
4789
IMPL_LINK(SalInstanceTreeView, CustomRenderHdl, svtree_render_args, payload, void)
4790
0
{
4791
0
    vcl::RenderContext& rRenderDevice = std::get<0>(payload);
4792
0
    const tools::Rectangle& rRect = std::get<1>(payload);
4793
0
    const SvTreeListEntry& rEntry = std::get<2>(payload);
4794
0
    const OUString* pId = rEntry.GetUserData();
4795
0
    if (!pId)
4796
0
        return;
4797
0
    signal_custom_render(rRenderDevice, rRect, m_xTreeView->IsSelected(&rEntry), *pId);
4798
0
}
4799
4800
IMPL_LINK(SalInstanceTreeView, CustomMeasureHdl, svtree_measure_args, payload, Size)
4801
0
{
4802
0
    vcl::RenderContext& rRenderDevice = payload.first;
4803
0
    const SvTreeListEntry& rEntry = payload.second;
4804
0
    const OUString* pId = rEntry.GetUserData();
4805
0
    if (!pId)
4806
0
        return Size();
4807
0
    return signal_custom_get_size(rRenderDevice, *pId);
4808
0
}
4809
4810
IMPL_LINK(SalInstanceTreeView, CompareHdl, const SvSortData&, rSortData, sal_Int32)
4811
0
{
4812
0
    const SvTreeListEntry* pLHS = rSortData.pLeft;
4813
0
    const SvTreeListEntry* pRHS = rSortData.pRight;
4814
0
    assert(pLHS && pRHS);
4815
4816
0
    if (m_aCustomSort)
4817
0
        return m_aCustomSort(SalInstanceTreeIter(*this, const_cast<SvTreeListEntry*>(pLHS)),
4818
0
                             SalInstanceTreeIter(*this, const_cast<SvTreeListEntry*>(pRHS)));
4819
4820
0
    const SvLBoxString* pLeftTextItem;
4821
0
    const SvLBoxString* pRightTextItem;
4822
4823
0
    if (m_nSortColumn != -1)
4824
0
    {
4825
0
        size_t col = to_internal_model(m_nSortColumn);
4826
4827
0
        if (col < pLHS->ItemCount())
4828
0
        {
4829
0
            const SvLBoxString& rLeftTextItem
4830
0
                = static_cast<const SvLBoxString&>(pLHS->GetItem(col));
4831
0
            pLeftTextItem = &rLeftTextItem;
4832
0
        }
4833
0
        else
4834
0
            pLeftTextItem = nullptr;
4835
0
        if (col < pRHS->ItemCount())
4836
0
        {
4837
0
            const SvLBoxString& rRightTextItem
4838
0
                = static_cast<const SvLBoxString&>(pRHS->GetItem(col));
4839
0
            pRightTextItem = &rRightTextItem;
4840
0
        }
4841
0
        else
4842
0
            pRightTextItem = nullptr;
4843
0
    }
4844
0
    else
4845
0
    {
4846
0
        pLeftTextItem
4847
0
            = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SvLBoxItemType::String));
4848
0
        pRightTextItem
4849
0
            = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SvLBoxItemType::String));
4850
0
    }
4851
4852
0
    return m_xTreeView->DefaultCompare(pLeftTextItem, pRightTextItem);
4853
0
}
4854
4855
IMPL_LINK_NOARG(SalInstanceTreeView, VisibleRangeChangedHdl, SvTreeListBox*, void)
4856
0
{
4857
0
    signal_visible_range_changed();
4858
0
}
4859
4860
IMPL_LINK_NOARG(SalInstanceTreeView, ModelChangedHdl, SvTreeListBox*, void)
4861
0
{
4862
0
    signal_model_changed();
4863
0
}
4864
4865
IMPL_LINK_NOARG(SalInstanceTreeView, StartDragHdl, SvTreeListBox*, bool)
4866
0
{
4867
0
    bool bUnsetDragIcon(false); // ignored for vcl
4868
0
    if (m_aDragBeginHdl.Call(bUnsetDragIcon))
4869
0
        return true;
4870
0
    g_DragSource = this;
4871
0
    return false;
4872
0
}
4873
4874
IMPL_STATIC_LINK_NOARG(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void)
4875
0
{
4876
0
    g_DragSource = nullptr;
4877
0
}
4878
4879
IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)
4880
0
{
4881
0
    SvTreeListEntry* pEntry = pData->GetActEntry();
4882
0
    SvLBoxButton* pBox = pData->GetActBox();
4883
4884
    // tdf#122874 Select the row, calling SelectHdl, before handling
4885
    // the toggle
4886
0
    if (!m_xTreeView->IsSelected(pEntry))
4887
0
    {
4888
0
        m_xTreeView->SelectAll(false);
4889
0
        m_xTreeView->Select(pEntry, true);
4890
0
    }
4891
4892
    // additionally set the cursor into the row the toggled element is in
4893
0
    m_xTreeView->m_pImpl->m_pCursor = pEntry;
4894
4895
0
    for (int i = 0, nCount = pEntry->ItemCount(); i < nCount; ++i)
4896
0
    {
4897
0
        SvLBoxItem& rItem = pEntry->GetItem(i);
4898
0
        if (&rItem == pBox)
4899
0
        {
4900
0
            int nCol = to_external_model(i);
4901
0
            signal_toggled(iter_col(SalInstanceTreeIter(*this, pEntry), nCol));
4902
0
            break;
4903
0
        }
4904
0
    }
4905
0
}
4906
4907
IMPL_LINK_NOARG(SalInstanceTreeView, SelectHdl, SvTreeListBox*, void)
4908
0
{
4909
0
    signal_selection_changed();
4910
0
}
4911
4912
IMPL_LINK_NOARG(SalInstanceTreeView, DeSelectHdl, SvTreeListBox*, void)
4913
0
{
4914
0
    if (m_xTreeView->GetSelectionMode() == SelectionMode::Single
4915
0
        && !m_xTreeView->GetHoverSelection())
4916
0
        return;
4917
0
    signal_selection_changed();
4918
0
}
4919
4920
IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void)
4921
0
{
4922
0
    std::vector<tools::Long> aTabPositions{ 0 };
4923
0
    for (int i = 0; i < pHeaderBar->GetItemCount() - 1; ++i)
4924
0
        aTabPositions.push_back(aTabPositions[i]
4925
0
                                + pHeaderBar->GetItemSize(pHeaderBar->GetItemId(i)));
4926
0
    m_xTreeView->SetTabs(aTabPositions);
4927
0
}
4928
4929
IMPL_LINK(SalInstanceTreeView, HeaderBarClickedHdl, HeaderBar*, pHeaderBar, void)
4930
0
{
4931
0
    sal_uInt16 nId = pHeaderBar->GetCurItemId();
4932
0
    if (!(pHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE))
4933
0
        return;
4934
0
    signal_column_header_clicked(pHeaderBar->GetItemPos(nId));
4935
0
}
4936
4937
IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool)
4938
0
{
4939
0
    SvTreeListEntry* pEntry = m_xTreeView->GetHdlEntry();
4940
0
    SalInstanceTreeIter aIter(*this, pEntry);
4941
4942
0
    if (m_xTreeView->IsExpanded(pEntry))
4943
0
    {
4944
        //collapsing;
4945
0
        return signal_collapsing(aIter);
4946
0
    }
4947
4948
    // expanding
4949
0
    return ExpandRow(aIter);
4950
0
}
4951
4952
bool SalInstanceTreeView::ExpandRow(const SalInstanceTreeIter& rIter)
4953
0
{
4954
0
    SvTreeListEntry* pEntry = rIter.iter;
4955
    // if there's a preexisting placeholder child, required to make this
4956
    // potentially expandable in the first place, now we remove it
4957
0
    SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry);
4958
0
    if (pPlaceHolder)
4959
0
    {
4960
0
        m_aExpandingPlaceHolderParents.insert(pEntry);
4961
0
        m_xTreeView->RemoveEntry(pPlaceHolder);
4962
0
    }
4963
4964
0
    bool bRet = signal_expanding(rIter);
4965
4966
0
    if (pPlaceHolder)
4967
0
    {
4968
        //expand disallowed, restore placeholder
4969
0
        if (!bRet)
4970
0
        {
4971
0
            pPlaceHolder = &InsertDummyEntry(pEntry);
4972
0
            SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pPlaceHolder);
4973
0
            rViewData.SetSelectable(false);
4974
0
        }
4975
0
        m_aExpandingPlaceHolderParents.erase(pEntry);
4976
0
    }
4977
4978
0
    return bRet;
4979
0
}
4980
4981
IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool)
4982
0
{
4983
0
    return signal_editing_started(SalInstanceTreeIter(*this, pEntry));
4984
0
}
4985
4986
IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const EntryItemText&, rEntryItemString, bool)
4987
0
{
4988
0
    const int nColumn
4989
0
        = to_external_model(rEntryItemString.m_rEntry.GetPos(rEntryItemString.m_rItem));
4990
0
    return signal_editing_done(IterColText(SalInstanceTreeIter(*this, &rEntryItemString.m_rEntry),
4991
0
                                           nColumn, rEntryItemString.m_sText));
4992
0
}
4993
4994
SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder,
4995
                                         bool bTakeOwnership)
4996
0
    : SalInstanceItemView(pIconView, pBuilder, bTakeOwnership)
4997
0
    , m_xIconView(pIconView)
4998
0
{
4999
0
    m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
5000
0
    m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
5001
0
}
Unexecuted instantiation: SalInstanceIconView::SalInstanceIconView(IconView*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceIconView::SalInstanceIconView(IconView*, SalInstanceBuilder*, bool)
5002
5003
0
int SalInstanceIconView::get_item_width() const { return m_xIconView->GetEntryWidth(); }
5004
void SalInstanceIconView::set_item_width(int width)
5005
0
{
5006
0
    m_xIconView->SetEntryWidth(width);
5007
0
    m_bFixedItemWidth = true;
5008
0
    m_xIconView->Resize();
5009
0
}
5010
5011
void SalInstanceIconView::freeze()
5012
0
{
5013
0
    bool bIsFirstFreeze = IsFirstFreeze();
5014
0
    SalInstanceWidget::freeze();
5015
0
    if (bIsFirstFreeze)
5016
0
        m_xIconView->SetUpdateMode(false);
5017
0
}
5018
5019
void SalInstanceIconView::thaw()
5020
0
{
5021
0
    bool bIsLastThaw = IsLastThaw();
5022
0
    if (bIsLastThaw)
5023
0
        m_xIconView->SetUpdateMode(true);
5024
0
    SalInstanceWidget::thaw();
5025
0
}
5026
5027
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5028
                                    const Image& rImage, weld::TreeIter* pRet)
5029
0
{
5030
0
    auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
5031
0
    OUString* pUserData;
5032
0
    if (pId)
5033
0
    {
5034
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
5035
0
        pUserData = m_aUserData.back().get();
5036
0
    }
5037
0
    else
5038
0
        pUserData = nullptr;
5039
5040
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
5041
0
    pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage));
5042
5043
0
    if (pStr)
5044
0
        pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
5045
0
    pEntry->SetUserData(pUserData);
5046
0
    m_xIconView->Insert(pEntry, nInsertPos);
5047
0
    if (!m_bFixedItemWidth)
5048
0
        m_xIconView->UpdateEntrySize(*pEntry);
5049
5050
0
    if (pRet)
5051
0
    {
5052
0
        SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
5053
0
        pVclRetIter->iter = pEntry;
5054
0
    }
5055
0
}
5056
5057
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5058
                                    const OUString* pIconName, weld::TreeIter* pRet)
5059
0
{
5060
0
    const Image aImage = pIconName ? createImage(*pIconName) : Image();
5061
0
    do_insert(pos, pStr, pId, aImage, pRet);
5062
0
}
5063
5064
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5065
                                    const Bitmap* pIcon, weld::TreeIter* pRet)
5066
0
{
5067
0
    const Image aImage = pIcon ? Image(*pIcon) : Image();
5068
0
    do_insert(pos, pStr, pId, aImage, pRet);
5069
0
}
5070
5071
void SalInstanceIconView::insert_separator(int pos, const OUString* /* pId */)
5072
0
{
5073
0
    const auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
5074
0
    const OUString sSep(VclResId(STR_SEPARATOR));
5075
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
5076
0
    pEntry->SetSeparator();
5077
0
    const Image aDummy;
5078
0
    pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
5079
0
    pEntry->AddItem(std::make_unique<SvLBoxString>(sSep));
5080
0
    pEntry->SetUserData(nullptr);
5081
0
    m_xIconView->Insert(pEntry, nInsertPos);
5082
0
    SvViewDataEntry& rViewData = m_xIconView->GetViewDataEntry(*pEntry);
5083
0
    rViewData.SetSelectable(false);
5084
0
}
5085
5086
IMPL_LINK(SalInstanceIconView, TooltipHdl, SvTreeListEntry&, rEntry, OUString)
5087
0
{
5088
0
    return signal_query_tooltip(SalInstanceTreeIter(*this, &rEntry));
5089
0
}
5090
5091
void SalInstanceIconView::connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink)
5092
0
{
5093
0
    weld::IconView::connect_query_tooltip(rLink);
5094
0
    m_xIconView->SetTooltipHdl(LINK(this, SalInstanceIconView, TooltipHdl));
5095
0
}
5096
5097
0
int SalInstanceIconView::count_selected_items() const { return m_xIconView->GetSelectionCount(); }
5098
5099
void SalInstanceIconView::do_scroll_to_item(const weld::TreeIter& rIter)
5100
0
{
5101
0
    assert(m_xIconView->IsUpdateMode()
5102
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
5103
0
              "freeze");
5104
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5105
0
    m_xIconView->MakeVisible(rVclIter.iter);
5106
0
}
5107
5108
void SalInstanceIconView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
5109
0
{
5110
0
    SalInstanceTreeIter aVclIter(*this, m_xIconView->FirstSelected());
5111
0
    while (aVclIter.iter)
5112
0
    {
5113
0
        if (func(aVclIter))
5114
0
            return;
5115
0
        aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter);
5116
0
    }
5117
0
}
5118
5119
void SalInstanceIconView::set_image(int pos, VirtualDevice& rIcon)
5120
0
{
5121
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
5122
0
    if (pEntry == nullptr)
5123
0
        return;
5124
0
    SvLBoxContextBmp* pItem
5125
0
        = static_cast<SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp));
5126
5127
0
    Image aImage = createImage(rIcon);
5128
0
    if (pItem == nullptr)
5129
0
    {
5130
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage));
5131
0
    }
5132
0
    else
5133
0
    {
5134
0
        pItem->SetBitmap1(aImage);
5135
0
        pItem->SetBitmap2(aImage);
5136
0
        if (!m_bFixedItemWidth)
5137
0
            m_xIconView->UpdateEntrySize(*pEntry);
5138
0
        m_xIconView->ModelHasEntryInvalidated(pEntry);
5139
0
    }
5140
0
}
5141
5142
void SalInstanceIconView::set_text(int pos, const OUString& rText)
5143
0
{
5144
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
5145
0
    if (!pEntry)
5146
0
        return;
5147
5148
0
    SvLBoxString* aItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));
5149
0
    if (aItem == nullptr)
5150
0
    {
5151
0
        pEntry->AddItem(std::make_unique<SvLBoxString>(rText));
5152
0
    }
5153
0
    else
5154
0
    {
5155
0
        aItem->SetText(rText);
5156
0
    }
5157
5158
0
    if (!m_xIconView->GetModel()->IsEnableInvalidate())
5159
0
        m_xIconView->ModelHasEntryInvalidated(pEntry);
5160
0
}
5161
5162
void SalInstanceIconView::set_item_accessible_name(int pos, const OUString& rName)
5163
0
{
5164
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(pos);
5165
0
    assert(pEntry);
5166
0
    pEntry->SetAccessibleName(rName);
5167
0
}
5168
5169
void SalInstanceIconView::set_item_tooltip_text(int pos, const OUString& rToolTip)
5170
0
{
5171
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(pos);
5172
0
    assert(pEntry);
5173
0
    pEntry->SetToolTip(rToolTip);
5174
0
}
5175
5176
OUString SalInstanceIconView::get_item_tooltip_text(const weld::TreeIter& rIter) const
5177
0
{
5178
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5179
0
    assert(rVclIter.iter);
5180
0
    return rVclIter.iter->GetToolTip();
5181
0
}
5182
5183
tools::Rectangle SalInstanceIconView::get_rect(const weld::TreeIter& rIter) const
5184
0
{
5185
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5186
0
    assert(rVclIter.iter && "invalid iter");
5187
0
    return m_xIconView->GetBoundingRect(*rVclIter.iter);
5188
0
}
5189
5190
SalInstanceIconView::~SalInstanceIconView()
5191
0
{
5192
0
    m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>());
5193
0
    m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>());
5194
0
}
5195
5196
IMPL_LINK_NOARG(SalInstanceIconView, SelectHdl, SvTreeListBox*, void)
5197
0
{
5198
0
    signal_selection_changed();
5199
0
}
5200
5201
IMPL_LINK_NOARG(SalInstanceIconView, DeSelectHdl, SvTreeListBox*, void)
5202
0
{
5203
0
    if (m_xIconView->GetSelectionMode() == SelectionMode::Single)
5204
0
        return;
5205
0
    signal_selection_changed();
5206
0
}
5207
5208
SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder,
5209
                                             bool bTakeOwnership)
5210
0
    : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
5211
0
    , m_xButton(pButton)
5212
0
    , m_rFormatter(m_xButton->GetFormatter())
5213
0
{
5214
0
    m_rFormatter.SetThousandsSep(false); //off by default, MetricSpinButton enables it
5215
0
    m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
5216
0
    m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
5217
0
    m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl));
5218
0
    m_rFormatter.SetFormatValueHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
5219
0
    m_rFormatter.SetParseTextHdl(LINK(this, SalInstanceSpinButton, InputHdl));
5220
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5221
0
        pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
5222
0
    else
5223
0
        m_xButton->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
5224
0
}
Unexecuted instantiation: SalInstanceSpinButton::SalInstanceSpinButton(FormattedField*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceSpinButton::SalInstanceSpinButton(FormattedField*, SalInstanceBuilder*, bool)
5225
5226
0
double SalInstanceSpinButton::get_floating_point_value() const { return m_rFormatter.GetValue(); }
5227
5228
void SalInstanceSpinButton::set_floating_point_value(double fValue)
5229
0
{
5230
0
    m_rFormatter.SetValue(fValue);
5231
0
}
5232
5233
void SalInstanceSpinButton::set_floating_point_range(double fMin, double fMax)
5234
0
{
5235
0
    m_rFormatter.SetMinValue(fMin);
5236
0
    m_rFormatter.SetMaxValue(fMax);
5237
0
}
5238
5239
void SalInstanceSpinButton::get_floating_point_range(double& rMin, double& rMax) const
5240
0
{
5241
0
    rMin = m_rFormatter.GetMinValue();
5242
0
    rMax = m_rFormatter.GetMaxValue();
5243
0
}
5244
5245
void SalInstanceSpinButton::set_floating_point_increments(double fStep, double /*fPage*/)
5246
0
{
5247
0
    m_rFormatter.SetSpinSize(fStep);
5248
0
}
5249
5250
void SalInstanceSpinButton::get_floating_point_increments(double& rStep, double& rPage) const
5251
0
{
5252
0
    rStep = m_rFormatter.GetSpinSize();
5253
0
    rPage = m_rFormatter.GetSpinSize();
5254
0
}
5255
5256
void SalInstanceSpinButton::set_digits(unsigned int digits)
5257
0
{
5258
0
    m_rFormatter.SetDecimalDigits(digits);
5259
0
}
5260
5261
// SpinButton may be comprised of multiple subwidgets, consider the lot as
5262
// one thing for focus
5263
0
bool SalInstanceSpinButton::has_focus() const { return m_xWidget->HasChildPathFocus(); }
5264
5265
//off by default for direct SpinButtons, MetricSpinButton enables it
5266
0
void SalInstanceSpinButton::SetUseThousandSep() { m_rFormatter.SetThousandsSep(true); }
5267
5268
0
unsigned int SalInstanceSpinButton::get_digits() const { return m_rFormatter.GetDecimalDigits(); }
5269
5270
SalInstanceSpinButton::~SalInstanceSpinButton()
5271
0
{
5272
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5273
0
        pEdit->SetActivateHdl(Link<Edit&, bool>());
5274
0
    else
5275
0
        m_xButton->SetActivateHdl(Link<Edit&, bool>());
5276
0
    m_rFormatter.SetParseTextHdl(Link<const OUString&, Formatter::ParseResult>());
5277
0
    m_rFormatter.SetFormatValueHdl(Link<double, std::optional<OUString>>());
5278
0
    m_xButton->SetLoseFocusHdl(Link<Control&, void>());
5279
0
    m_xButton->SetDownHdl(Link<SpinField&, void>());
5280
0
    m_xButton->SetUpHdl(Link<SpinField&, void>());
5281
0
}
5282
5283
IMPL_LINK_NOARG(SalInstanceSpinButton, ActivateHdl, Edit&, bool)
5284
0
{
5285
    // tdf#122348 return pressed to end dialog
5286
0
    signal_value_changed();
5287
0
    return m_aActivateHdl.Call(*this);
5288
0
}
5289
5290
0
IMPL_LINK_NOARG(SalInstanceSpinButton, UpDownHdl, SpinField&, void) { signal_value_changed(); }
5291
5292
IMPL_LINK_NOARG(SalInstanceSpinButton, LoseFocusHdl, Control&, void)
5293
0
{
5294
    // tdf#134725 Don't signal for empty text, the Formatter has IsEmptyFieldEnabled
5295
    // enabled, so empty values are intended to be no-change.
5296
0
    if (!m_xButton->GetText().isEmpty())
5297
0
        signal_value_changed();
5298
0
}
5299
5300
IMPL_LINK(SalInstanceSpinButton, OutputHdl, double, fValue, std::optional<OUString>)
5301
0
{
5302
0
    return format_floating_point_value(fValue);
5303
0
}
5304
5305
IMPL_LINK(SalInstanceSpinButton, InputHdl, const OUString&, rText, Formatter::ParseResult)
5306
0
{
5307
0
    double fResult = 0;
5308
0
    TriState eRet = parse_text(rText, &fResult);
5309
5310
0
    return Formatter::ParseResult(eRet, fResult);
5311
0
}
5312
5313
SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField* pButton,
5314
                                                               SalInstanceBuilder* pBuilder,
5315
                                                               bool bTakeOwnership)
5316
0
    : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
5317
0
    , m_xButton(pButton)
5318
0
    , m_pFormatter(nullptr)
5319
0
{
5320
0
    m_xButton->SetUpHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
5321
0
    m_xButton->SetDownHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
5322
0
    m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceFormattedSpinButton, LoseFocusHdl));
5323
5324
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5325
0
    {
5326
0
        pEdit->SetActivateHdl(LINK(this, SalInstanceFormattedSpinButton, ActivateHdl));
5327
0
    }
5328
0
    else
5329
0
    {
5330
0
        m_xButton->SetActivateHdl(LINK(this, SalInstanceFormattedSpinButton, ActivateHdl));
5331
0
    }
5332
0
}
Unexecuted instantiation: SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField*, SalInstanceBuilder*, bool)
5333
5334
void SalInstanceFormattedSpinButton::do_set_text(const OUString& rText)
5335
0
{
5336
0
    m_xButton->SpinField::SetText(rText);
5337
0
}
5338
5339
void SalInstanceFormattedSpinButton::connect_changed(const Link<weld::TextWidget&, void>& rLink)
5340
0
{
5341
0
    if (!m_pFormatter) // once a formatter is set, it takes over "changed"
5342
0
    {
5343
0
        SalInstanceEntry::connect_changed(rLink);
5344
0
        return;
5345
0
    }
5346
0
    m_pFormatter->connect_changed(rLink);
5347
0
}
5348
5349
void SalInstanceFormattedSpinButton::connect_focus_out(const Link<weld::Widget&, void>& rLink)
5350
0
{
5351
0
    if (!m_pFormatter) // once a formatter is set, it takes over "focus-out"
5352
0
    {
5353
0
        m_aLoseFocusHdl = rLink;
5354
0
        return;
5355
0
    }
5356
0
    m_pFormatter->connect_focus_out(rLink);
5357
0
}
5358
5359
void SalInstanceFormattedSpinButton::SetFormatter(weld::EntryFormatter* pFormatter)
5360
0
{
5361
0
    m_pFormatter = pFormatter;
5362
0
    m_xButton->SetFormatter(pFormatter);
5363
0
}
5364
5365
0
Formatter& SalInstanceFormattedSpinButton::GetFormatter() { return m_xButton->GetFormatter(); }
5366
5367
SalInstanceFormattedSpinButton::~SalInstanceFormattedSpinButton()
5368
0
{
5369
0
    m_xButton->SetLoseFocusHdl(Link<Control&, void>());
5370
0
    m_xButton->SetDownHdl(Link<SpinField&, void>());
5371
0
    m_xButton->SetUpHdl(Link<SpinField&, void>());
5372
5373
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5374
0
    {
5375
0
        pEdit->SetActivateHdl(Link<Edit&, bool>());
5376
0
    }
5377
0
    else
5378
0
    {
5379
0
        m_xButton->SetActivateHdl(Link<Edit&, bool>());
5380
0
    }
5381
0
}
5382
5383
IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, UpDownHdl, SpinField&, void)
5384
0
{
5385
0
    signal_value_changed();
5386
0
}
5387
5388
IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, LoseFocusHdl, Control&, void)
5389
0
{
5390
0
    if (!m_pFormatter)
5391
0
        signal_value_changed();
5392
0
    m_aLoseFocusHdl.Call(*this);
5393
0
}
5394
5395
IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, ActivateHdl, Edit&, bool)
5396
0
{
5397
    // Return commits the typed text through the formatter the same way losing focus does, so
5398
    // the value read during the notification is the reformatted one.
5399
0
    if (m_pFormatter)
5400
0
        m_pFormatter->EntryLostFocus();
5401
5402
0
    signal_value_changed();
5403
0
    return m_aActivateHdl.Call(*this);
5404
0
}
5405
5406
SalInstanceLabel::SalInstanceLabel(Control* pLabel, SalInstanceBuilder* pBuilder,
5407
                                   bool bTakeOwnership)
5408
0
    : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership)
5409
0
    , m_xLabel(pLabel)
5410
0
{
5411
0
}
Unexecuted instantiation: SalInstanceLabel::SalInstanceLabel(Control*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceLabel::SalInstanceLabel(Control*, SalInstanceBuilder*, bool)
5412
5413
0
void SalInstanceLabel::set_label(const OUString& rText) { m_xLabel->SetText(rText); }
5414
5415
0
OUString SalInstanceLabel::get_label() const { return m_xLabel->GetText(); }
5416
5417
void SalInstanceLabel::set_mnemonic_widget(Widget* pTarget)
5418
0
{
5419
0
    FixedText* pLabel = dynamic_cast<FixedText*>(m_xLabel.get());
5420
0
    assert(pLabel && "can't use set_mnemonic_widget on SelectableFixedText");
5421
0
    SalInstanceWidget* pTargetWidget = dynamic_cast<SalInstanceWidget*>(pTarget);
5422
0
    pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr);
5423
0
}
5424
5425
void SalInstanceLabel::set_label_type(weld::LabelType eType)
5426
0
{
5427
0
    switch (eType)
5428
0
    {
5429
0
        case weld::LabelType::Normal:
5430
0
            m_xLabel->SetControlForeground();
5431
0
            m_xLabel->SetControlBackground();
5432
0
            break;
5433
0
        case weld::LabelType::Warning:
5434
0
            m_xLabel->SetControlForeground(
5435
0
                m_xLabel->GetSettings().GetStyleSettings().GetWarningTextColor());
5436
0
            m_xLabel->SetControlBackground(
5437
0
                m_xLabel->GetSettings().GetStyleSettings().GetWarningColor());
5438
0
            break;
5439
0
        case weld::LabelType::Error:
5440
0
            m_xLabel->SetControlForeground(
5441
0
                m_xLabel->GetSettings().GetStyleSettings().GetErrorTextColor());
5442
0
            m_xLabel->SetControlBackground(
5443
0
                m_xLabel->GetSettings().GetStyleSettings().GetErrorColor());
5444
0
            break;
5445
0
        case weld::LabelType::Title:
5446
0
            m_xLabel->SetControlForeground(
5447
0
                m_xLabel->GetSettings().GetStyleSettings().GetLightColor());
5448
0
            m_xLabel->SetControlBackground();
5449
0
            break;
5450
0
    }
5451
0
}
5452
5453
void SalInstanceLabel::set_font_color(const Color& rColor)
5454
0
{
5455
0
    if (rColor != COL_AUTO)
5456
0
        m_xLabel->SetControlForeground(rColor);
5457
0
    else
5458
0
        m_xLabel->SetControlForeground();
5459
0
}
5460
5461
void SalInstanceLabel::set_font(const vcl::Font& rFont)
5462
0
{
5463
0
    m_xLabel->SetControlFont(rFont);
5464
0
    m_xLabel->Invalidate();
5465
0
}
5466
5467
SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
5468
                                         bool bTakeOwnership)
5469
0
    : SalInstanceTextWidget(pTextView, pBuilder, bTakeOwnership)
5470
0
    , m_xTextView(pTextView)
5471
0
{
5472
    // tdf#150397 don't select text when receiving keyboard focus,
5473
    // GtkInstanceTextView also doesn't do it
5474
0
    m_xTextView->DisableSelectionOnFocus();
5475
5476
0
    m_xTextView->SetModifyHdl(LINK(this, SalInstanceTextView, ChangeHdl));
5477
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5478
0
    m_aOrigVScrollHdl = rVertScrollBar.GetScrollHdl();
5479
0
    rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl));
5480
0
}
Unexecuted instantiation: SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit*, SalInstanceBuilder*, bool)
5481
5482
0
void SalInstanceTextView::set_max_length(int nChars) { m_xTextView->SetMaxTextLen(nChars); }
5483
5484
void SalInstanceTextView::set_monospace(bool bMonospace)
5485
0
{
5486
0
    vcl::Font aOrigFont = m_xTextView->GetControlFont();
5487
0
    vcl::Font aFont;
5488
0
    if (bMonospace)
5489
0
        aFont
5490
0
            = OutputDevice::GetDefaultFont(DefaultFontType::UI_FIXED, LANGUAGE_DONTKNOW,
5491
0
                                           GetDefaultFontFlags::OnlyOne, m_xTextView->GetOutDev());
5492
0
    else
5493
0
        aFont = Application::GetSettings().GetStyleSettings().GetFieldFont();
5494
0
    aFont.SetFontHeight(aOrigFont.GetFontHeight());
5495
0
    set_font(aFont);
5496
0
}
5497
5498
void SalInstanceTextView::set_font(const vcl::Font& rFont)
5499
0
{
5500
0
    m_xTextView->SetFont(rFont);
5501
0
    m_xTextView->SetControlFont(rFont);
5502
0
    m_xTextView->Invalidate();
5503
0
}
5504
5505
bool SalInstanceTextView::can_move_cursor_with_up() const
5506
0
{
5507
0
    bool bNoSelection = !m_xTextView->GetSelection();
5508
0
    return !bNoSelection || m_xTextView->CanUp();
5509
0
}
5510
5511
bool SalInstanceTextView::can_move_cursor_with_down() const
5512
0
{
5513
0
    bool bNoSelection = !m_xTextView->GetSelection();
5514
0
    return !bNoSelection || m_xTextView->CanDown();
5515
0
}
5516
5517
0
void SalInstanceTextView::cut_clipboard() { m_xTextView->Cut(); }
5518
5519
0
void SalInstanceTextView::copy_clipboard() { m_xTextView->Copy(); }
5520
5521
0
void SalInstanceTextView::paste_clipboard() { m_xTextView->Paste(); }
5522
5523
void SalInstanceTextView::set_alignment(TxtAlign eXAlign)
5524
0
{
5525
0
    ::set_alignment(*m_xTextView, eXAlign);
5526
0
}
5527
5528
int SalInstanceTextView::vadjustment_get_value() const
5529
0
{
5530
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5531
0
    return rVertScrollBar.GetThumbPos();
5532
0
}
5533
5534
void SalInstanceTextView::vadjustment_set_value(int value)
5535
0
{
5536
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5537
0
    rVertScrollBar.SetThumbPos(value);
5538
0
    m_aOrigVScrollHdl.Call(&rVertScrollBar);
5539
0
}
5540
5541
int SalInstanceTextView::vadjustment_get_upper() const
5542
0
{
5543
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5544
0
    return rVertScrollBar.GetRangeMax();
5545
0
}
5546
5547
int SalInstanceTextView::vadjustment_get_page_size() const
5548
0
{
5549
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5550
0
    return rVertScrollBar.GetVisibleSize();
5551
0
}
5552
5553
0
bool SalInstanceTextView::has_focus() const { return m_xTextView->HasChildPathFocus(); }
5554
5555
SalInstanceTextView::~SalInstanceTextView()
5556
0
{
5557
0
    if (!m_xTextView->isDisposed())
5558
0
    {
5559
0
        m_xTextView->SetModifyHdl(Link<Edit&, void>());
5560
0
        ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5561
0
        rVertScrollBar.SetScrollHdl(m_aOrigVScrollHdl);
5562
0
    }
5563
0
}
5564
5565
IMPL_LINK(SalInstanceTextView, VscrollHdl, ScrollBar*, pScrollBar, void)
5566
0
{
5567
0
    signal_vadjustment_value_changed();
5568
0
    m_aOrigVScrollHdl.Call(pScrollBar);
5569
0
}
5570
5571
0
IMPL_LINK_NOARG(SalInstanceTextView, ChangeHdl, Edit&, void) { signal_changed(); }
5572
5573
SalInstanceExpander::SalInstanceExpander(VclExpander* pExpander, SalInstanceBuilder* pBuilder,
5574
                                         bool bTakeOwnership)
5575
0
    : SalInstanceWidget(pExpander, pBuilder, bTakeOwnership)
5576
0
    , m_xExpander(pExpander)
5577
0
{
5578
0
    m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl));
5579
0
}
Unexecuted instantiation: SalInstanceExpander::SalInstanceExpander(VclExpander*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceExpander::SalInstanceExpander(VclExpander*, SalInstanceBuilder*, bool)
5580
5581
0
void SalInstanceExpander::set_label(const OUString& rText) { m_xExpander->set_label(rText); }
5582
5583
0
OUString SalInstanceExpander::get_label() const { return m_xExpander->get_label(); }
5584
5585
0
bool SalInstanceExpander::get_expanded() const { return m_xExpander->get_expanded(); }
5586
5587
0
void SalInstanceExpander::set_expanded(bool bExpand) { m_xExpander->set_expanded(bExpand); }
5588
5589
bool SalInstanceExpander::has_focus() const
5590
0
{
5591
0
    return m_xExpander->get_label_widget()->HasFocus() || SalInstanceWidget::has_focus();
5592
0
}
5593
5594
0
void SalInstanceExpander::grab_focus() { return m_xExpander->get_label_widget()->GrabFocus(); }
5595
5596
SalInstanceExpander::~SalInstanceExpander()
5597
0
{
5598
0
    m_xExpander->SetExpandedHdl(Link<VclExpander&, void>());
5599
0
}
5600
5601
0
IMPL_LINK_NOARG(SalInstanceExpander, ExpandedHdl, VclExpander&, void) { signal_expanded(); }
5602
5603
// SalInstanceWidget has a generic listener for all these
5604
// events, ignore the ones we have specializations for
5605
// in VclDrawingArea
5606
void SalInstanceDrawingArea::HandleEventListener(VclWindowEvent& rEvent)
5607
0
{
5608
0
    if (rEvent.GetId() == VclEventId::WindowResize)
5609
0
        return;
5610
0
    SalInstanceWidget::HandleEventListener(rEvent);
5611
0
}
5612
5613
void SalInstanceDrawingArea::HandleMouseEventListener(VclWindowEvent& rEvent)
5614
0
{
5615
0
    if (rEvent.GetId() == VclEventId::WindowMouseButtonDown
5616
0
        || rEvent.GetId() == VclEventId::WindowMouseButtonUp
5617
0
        || rEvent.GetId() == VclEventId::WindowMouseMove)
5618
0
    {
5619
0
        return;
5620
0
    }
5621
0
    SalInstanceWidget::HandleMouseEventListener(rEvent);
5622
0
}
5623
5624
0
bool SalInstanceDrawingArea::HandleKeyEventListener(VclWindowEvent& /*rEvent*/) { return false; }
5625
5626
SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea* pDrawingArea,
5627
                                               SalInstanceBuilder* pBuilder,
5628
                                               const rtl::Reference<comphelper::OAccessible>& rAlly,
5629
                                               FactoryFunction pUITestFactoryFunction,
5630
                                               void* pUserData, bool bTakeOwnership)
5631
0
    : SalInstanceWidget(pDrawingArea, pBuilder, bTakeOwnership)
5632
0
    , m_xDrawingArea(pDrawingArea)
5633
0
{
5634
0
    m_xDrawingArea->SetAccessible(rAlly);
5635
0
    m_xDrawingArea->SetUITestFactory(std::move(pUITestFactoryFunction), pUserData);
5636
0
    m_xDrawingArea->SetPaintHdl(LINK(this, SalInstanceDrawingArea, PaintHdl));
5637
0
    m_xDrawingArea->SetResizeHdl(LINK(this, SalInstanceDrawingArea, ResizeHdl));
5638
0
    m_xDrawingArea->SetMousePressHdl(LINK(this, SalInstanceDrawingArea, MousePressHdl));
5639
0
    m_xDrawingArea->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea, MouseMoveHdl));
5640
0
    m_xDrawingArea->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea, MouseReleaseHdl));
5641
0
    m_xDrawingArea->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea, KeyPressHdl));
5642
0
    m_xDrawingArea->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea, KeyReleaseHdl));
5643
0
    m_xDrawingArea->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea, StyleUpdatedHdl));
5644
0
    m_xDrawingArea->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea, QueryTooltipHdl));
5645
0
    m_xDrawingArea->SetGetSurroundingHdl(LINK(this, SalInstanceDrawingArea, GetSurroundingHdl));
5646
0
    m_xDrawingArea->SetDeleteSurroundingHdl(
5647
0
        LINK(this, SalInstanceDrawingArea, DeleteSurroundingHdl));
5648
0
    m_xDrawingArea->SetStartDragHdl(LINK(this, SalInstanceDrawingArea, StartDragHdl));
5649
0
}
Unexecuted instantiation: SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea*, SalInstanceBuilder*, rtl::Reference<comphelper::OAccessible> const&, std::__1::function<std::__1::unique_ptr<UIObject, std::__1::default_delete<UIObject> > (vcl::Window*)>, void*, bool)
Unexecuted instantiation: SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea*, SalInstanceBuilder*, rtl::Reference<comphelper::OAccessible> const&, std::__1::function<std::__1::unique_ptr<UIObject, std::__1::default_delete<UIObject> > (vcl::Window*)>, void*, bool)
5650
5651
0
void SalInstanceDrawingArea::queue_draw() { m_xDrawingArea->Invalidate(); }
5652
5653
void SalInstanceDrawingArea::queue_draw_area(int x, int y, int width, int height)
5654
0
{
5655
0
    m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height)));
5656
0
}
5657
5658
void SalInstanceDrawingArea::connect_size_allocate(const Link<const Size&, void>& rLink)
5659
0
{
5660
0
    weld::Widget::connect_size_allocate(rLink);
5661
0
}
5662
5663
void SalInstanceDrawingArea::connect_key_press(const Link<const KeyEvent&, bool>& rLink)
5664
0
{
5665
0
    weld::Widget::connect_key_press(rLink);
5666
0
}
5667
5668
void SalInstanceDrawingArea::connect_key_release(const Link<const KeyEvent&, bool>& rLink)
5669
0
{
5670
0
    weld::Widget::connect_key_release(rLink);
5671
0
}
5672
5673
void SalInstanceDrawingArea::connect_style_updated(const Link<Widget&, void>& rLink)
5674
0
{
5675
0
    weld::Widget::connect_style_updated(rLink);
5676
0
}
5677
5678
void SalInstanceDrawingArea::set_cursor(PointerStyle ePointerStyle)
5679
0
{
5680
0
    m_xDrawingArea->SetPointer(ePointerStyle);
5681
0
}
5682
5683
void SalInstanceDrawingArea::set_input_context(const InputContext& rInputContext)
5684
0
{
5685
0
    m_xDrawingArea->SetInputContext(rInputContext);
5686
0
}
5687
5688
void SalInstanceDrawingArea::im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
5689
                                                            int nExtTextInputWidth)
5690
0
{
5691
0
    tools::Rectangle aCursorRect = m_xDrawingArea->PixelToLogic(rCursorRect);
5692
0
    m_xDrawingArea->SetCursorRect(
5693
0
        &aCursorRect, m_xDrawingArea->PixelToLogic(Size(nExtTextInputWidth, 0)).Width());
5694
0
}
5695
5696
rtl::Reference<comphelper::OAccessible> SalInstanceDrawingArea::get_accessible_parent()
5697
0
{
5698
0
    vcl::Window* pParent = m_xDrawingArea->GetParent();
5699
0
    if (pParent)
5700
0
        return pParent->GetAccessible();
5701
0
    return {};
5702
0
}
5703
5704
a11yrelationset SalInstanceDrawingArea::get_accessible_relation_set()
5705
0
{
5706
0
    rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSetHelper
5707
0
        = new utl::AccessibleRelationSetHelper;
5708
0
    vcl::Window* pWindow = m_xDrawingArea.get();
5709
0
    if (pWindow)
5710
0
    {
5711
0
        vcl::Window* pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
5712
0
        if (pLabeledBy && pLabeledBy != pWindow)
5713
0
        {
5714
0
            css::uno::Sequence<css::uno::Reference<css::accessibility::XAccessible>> aSequence{
5715
0
                pLabeledBy->GetAccessible()
5716
0
            };
5717
0
            pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation(
5718
0
                css::accessibility::AccessibleRelationType_LABELED_BY, aSequence));
5719
0
        }
5720
0
        vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
5721
0
        if (pMemberOf && pMemberOf != pWindow)
5722
0
        {
5723
0
            css::uno::Sequence<css::uno::Reference<css::accessibility::XAccessible>> aSequence{
5724
0
                pMemberOf->GetAccessible()
5725
0
            };
5726
0
            pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation(
5727
0
                css::accessibility::AccessibleRelationType_MEMBER_OF, aSequence));
5728
0
        }
5729
0
    }
5730
0
    return pRelationSetHelper;
5731
0
}
5732
5733
AbsoluteScreenPixelPoint SalInstanceDrawingArea::get_accessible_location_on_screen()
5734
0
{
5735
0
    return m_xDrawingArea->OutputToAbsoluteScreenPixel(Point());
5736
0
}
5737
5738
Point SalInstanceDrawingArea::get_pointer_position() const
5739
0
{
5740
0
    return m_xDrawingArea->GetPointerPosPixel();
5741
0
}
5742
5743
void SalInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
5744
                                                sal_uInt8 eDNDConstants)
5745
0
{
5746
0
    m_xDrawingArea->SetDragHelper(rHelper, eDNDConstants);
5747
0
}
5748
5749
SalInstanceDrawingArea::~SalInstanceDrawingArea()
5750
0
{
5751
0
    m_xDrawingArea->SetDeleteSurroundingHdl(Link<const Selection&, bool>());
5752
0
    m_xDrawingArea->SetGetSurroundingHdl(Link<OUString&, int>());
5753
0
    m_xDrawingArea->SetQueryTooltipHdl(Link<tools::Rectangle&, OUString>());
5754
0
    m_xDrawingArea->SetStyleUpdatedHdl(Link<VclDrawingArea&, void>());
5755
0
    m_xDrawingArea->SetMousePressHdl(Link<const MouseEvent&, bool>());
5756
0
    m_xDrawingArea->SetMouseMoveHdl(Link<const MouseEvent&, bool>());
5757
0
    m_xDrawingArea->SetMouseReleaseHdl(Link<const MouseEvent&, bool>());
5758
0
    m_xDrawingArea->SetKeyPressHdl(Link<const KeyEvent&, bool>());
5759
0
    m_xDrawingArea->SetKeyReleaseHdl(Link<const KeyEvent&, bool>());
5760
0
    m_xDrawingArea->SetResizeHdl(Link<const Size&, void>());
5761
0
    m_xDrawingArea->SetPaintHdl(
5762
0
        Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>());
5763
5764
    // tdf#159089 dispose custom accessible here and unset for `m_xDrawingArea`
5765
    // rather than waiting for `m_xDrawingArea` to get disposed, to prevent
5766
    // unsafe use of the now potentially non-functional accessible until it
5767
    // gets disposed with the VclDrawingArea
5768
0
    rtl::Reference<comphelper::OAccessible> pAccessible = m_xDrawingArea->GetAccessible();
5769
0
    if (pAccessible.is())
5770
0
    {
5771
0
        pAccessible->dispose();
5772
0
        m_xDrawingArea->SetAccessible(nullptr);
5773
0
    }
5774
0
}
5775
5776
0
OutputDevice& SalInstanceDrawingArea::get_ref_device() { return *m_xDrawingArea->GetOutDev(); }
5777
5778
IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void)
5779
0
{
5780
0
    m_aDrawHdl.Call(aPayload);
5781
0
    tools::Rectangle aFocusRect(m_aGetFocusRectHdl.Call(*this));
5782
0
    if (!aFocusRect.IsEmpty())
5783
0
        InvertFocusRect(aPayload.first, aFocusRect);
5784
0
}
5785
5786
IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void)
5787
0
{
5788
0
    signal_size_allocate(rSize);
5789
0
}
5790
5791
IMPL_LINK(SalInstanceDrawingArea, MousePressHdl, const MouseEvent&, rEvent, bool)
5792
0
{
5793
0
    return signal_mouse_press(rEvent);
5794
0
}
5795
5796
IMPL_LINK(SalInstanceDrawingArea, MouseMoveHdl, const MouseEvent&, rEvent, bool)
5797
0
{
5798
0
    return signal_mouse_motion(rEvent);
5799
0
}
5800
5801
IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const MouseEvent&, rEvent, bool)
5802
0
{
5803
0
    return signal_mouse_release(rEvent);
5804
0
}
5805
5806
IMPL_LINK(SalInstanceDrawingArea, KeyPressHdl, const KeyEvent&, rEvent, bool)
5807
0
{
5808
0
    return signal_key_press(rEvent);
5809
0
}
5810
5811
IMPL_LINK(SalInstanceDrawingArea, KeyReleaseHdl, const KeyEvent&, rEvent, bool)
5812
0
{
5813
0
    return signal_key_release(rEvent);
5814
0
}
5815
5816
IMPL_LINK_NOARG(SalInstanceDrawingArea, StyleUpdatedHdl, VclDrawingArea&, void)
5817
0
{
5818
0
    signal_style_updated();
5819
0
}
5820
5821
IMPL_LINK(SalInstanceDrawingArea, GetSurroundingHdl, OUString&, rSurrounding, int)
5822
0
{
5823
0
    return m_aGetSurroundingHdl.Call(rSurrounding);
5824
0
}
5825
5826
IMPL_LINK(SalInstanceDrawingArea, DeleteSurroundingHdl, const Selection&, rSelection, bool)
5827
0
{
5828
0
    return m_aDeleteSurroundingHdl.Call(rSelection);
5829
0
}
5830
5831
IMPL_LINK(SalInstanceDrawingArea, QueryTooltipHdl, tools::Rectangle&, rHelpArea, OUString)
5832
0
{
5833
0
    return signal_query_tooltip(rHelpArea);
5834
0
}
5835
5836
IMPL_LINK_NOARG(SalInstanceDrawingArea, StartDragHdl, VclDrawingArea*, bool)
5837
0
{
5838
0
    if (m_aDragBeginHdl.Call(*this))
5839
0
        return true;
5840
0
    return false;
5841
0
}
5842
5843
SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox* pListBox,
5844
                                                               SalInstanceBuilder* pBuilder,
5845
                                                               bool bTakeOwnership)
5846
0
    : SalInstanceComboBox<ListBox>(pListBox, pBuilder, bTakeOwnership)
5847
0
{
5848
0
    m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit, SelectHdl));
5849
0
}
Unexecuted instantiation: SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox*, SalInstanceBuilder*, bool)
5850
5851
OUString SalInstanceComboBoxWithoutEdit::get_active_text() const
5852
0
{
5853
0
    return m_xComboBox->GetSelectedEntry();
5854
0
}
5855
5856
0
void SalInstanceComboBoxWithoutEdit::remove(int pos) { m_xComboBox->RemoveEntry(pos); }
5857
5858
void SalInstanceComboBoxWithoutEdit::do_insert(int pos, const OUString& rStr, const OUString* pId,
5859
                                               const OUString* pIconName,
5860
                                               VirtualDevice* pImageSurface)
5861
0
{
5862
0
    auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
5863
0
    sal_Int32 nInsertedAt;
5864
0
    if (!pIconName && !pImageSurface)
5865
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos);
5866
0
    else if (pIconName)
5867
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pIconName), nInsertPos);
5868
0
    else
5869
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pImageSurface), nInsertPos);
5870
0
    if (pId)
5871
0
    {
5872
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
5873
0
        m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get());
5874
0
    }
5875
0
}
5876
5877
void SalInstanceComboBoxWithoutEdit::insert_separator(int pos, const OUString& /*rId*/)
5878
0
{
5879
0
    auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos;
5880
0
    m_xComboBox->AddSeparator(nInsertPos - 1);
5881
0
}
5882
5883
0
bool SalInstanceComboBoxWithoutEdit::has_entry() const { return false; }
5884
5885
0
bool SalInstanceComboBoxWithoutEdit::changed_by_direct_pick() const { return true; }
5886
5887
void SalInstanceComboBoxWithoutEdit::set_entry_message_type(weld::EntryMessageType /*eType*/)
5888
0
{
5889
0
    assert(false);
5890
0
}
5891
5892
0
void SalInstanceComboBoxWithoutEdit::do_set_entry_text(const OUString& /*rText*/) { assert(false); }
5893
5894
void SalInstanceComboBoxWithoutEdit::select_entry_region(int /*nStartPos*/, int /*nEndPos*/)
5895
0
{
5896
0
    assert(false);
5897
0
}
5898
5899
bool SalInstanceComboBoxWithoutEdit::get_entry_selection_bounds(int& /*rStartPos*/,
5900
                                                                int& /*rEndPos*/)
5901
0
{
5902
0
    assert(false);
5903
0
    return false;
5904
0
}
5905
5906
0
void SalInstanceComboBoxWithoutEdit::set_entry_width_chars(int /*nChars*/) { assert(false); }
5907
5908
0
void SalInstanceComboBoxWithoutEdit::set_entry_max_length(int /*nChars*/) { assert(false); }
5909
5910
0
void SalInstanceComboBoxWithoutEdit::set_entry_completion(bool, bool) { assert(false); }
5911
5912
0
void SalInstanceComboBoxWithoutEdit::set_entry_placeholder_text(const OUString&) { assert(false); }
5913
5914
0
void SalInstanceComboBoxWithoutEdit::set_entry_editable(bool /*bEditable*/) { assert(false); }
5915
5916
0
void SalInstanceComboBoxWithoutEdit::cut_entry_clipboard() { assert(false); }
5917
5918
0
void SalInstanceComboBoxWithoutEdit::copy_entry_clipboard() { assert(false); }
5919
5920
0
void SalInstanceComboBoxWithoutEdit::paste_entry_clipboard() { assert(false); }
5921
5922
void SalInstanceComboBoxWithoutEdit::set_font(const vcl::Font& rFont)
5923
0
{
5924
0
    m_xComboBox->SetControlFont(rFont);
5925
0
    m_xComboBox->Invalidate();
5926
0
}
5927
5928
0
void SalInstanceComboBoxWithoutEdit::set_entry_font(const vcl::Font&) { assert(false); }
5929
5930
vcl::Font SalInstanceComboBoxWithoutEdit::get_entry_font()
5931
0
{
5932
0
    assert(false);
5933
0
    return vcl::Font();
5934
0
}
5935
5936
void SalInstanceComboBoxWithoutEdit::set_custom_renderer(bool /*bOn*/)
5937
0
{
5938
0
    assert(false && "not implemented");
5939
0
}
5940
5941
int SalInstanceComboBoxWithoutEdit::get_max_mru_count() const
5942
0
{
5943
0
    assert(false && "not implemented");
5944
0
    return 0;
5945
0
}
5946
5947
0
void SalInstanceComboBoxWithoutEdit::set_max_mru_count(int) { assert(false && "not implemented"); }
5948
5949
std::vector<OUString> SalInstanceComboBoxWithoutEdit::get_mru_entries() const
5950
0
{
5951
0
    assert(false && "not implemented");
5952
0
    return {};
5953
0
}
5954
5955
void SalInstanceComboBoxWithoutEdit::set_mru_entries(const std::vector<OUString>&)
5956
0
{
5957
0
    assert(false && "not implemented");
5958
0
}
5959
5960
void SalInstanceComboBoxWithoutEdit::HandleEventListener(VclWindowEvent& rEvent)
5961
0
{
5962
0
    CallHandleEventListener(rEvent);
5963
0
}
5964
5965
SalInstanceComboBoxWithoutEdit::~SalInstanceComboBoxWithoutEdit()
5966
0
{
5967
0
    m_xComboBox->SetSelectHdl(Link<ListBox&, void>());
5968
0
}
5969
5970
IMPL_LINK_NOARG(SalInstanceComboBoxWithoutEdit, SelectHdl, ListBox&, void)
5971
0
{
5972
0
    return signal_changed();
5973
0
}
5974
5975
SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(::ComboBox* pComboBox,
5976
                                                         SalInstanceBuilder* pBuilder,
5977
                                                         bool bTakeOwnership)
5978
0
    : SalInstanceComboBox<::ComboBox>(pComboBox, pBuilder, bTakeOwnership)
5979
0
    , m_aTextFilter(m_aEntryInsertTextHdl)
5980
0
    , m_bInSelect(false)
5981
0
{
5982
0
    m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl));
5983
0
    m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithEdit, SelectHdl));
5984
0
    m_xComboBox->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit, EntryActivateHdl));
5985
0
    m_xComboBox->SetTextFilter(&m_aTextFilter);
5986
0
}
Unexecuted instantiation: SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(ComboBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(ComboBox*, SalInstanceBuilder*, bool)
5987
5988
0
bool SalInstanceComboBoxWithEdit::has_entry() const { return true; }
5989
5990
void SalInstanceComboBoxWithEdit::call_attention_to()
5991
0
{
5992
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
5993
0
    assert(pEdit);
5994
0
    m_xFlashAttention.reset(new SalFlashAttention(pEdit));
5995
0
    m_xFlashAttention->Start();
5996
0
}
5997
5998
bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const
5999
0
{
6000
0
    return m_bInSelect && !m_xComboBox->IsModifyByKeyboard() && !m_xComboBox->IsTravelSelect();
6001
0
}
6002
6003
void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType)
6004
0
{
6005
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
6006
0
    assert(pEdit);
6007
0
    ::set_message_type(pEdit, eType);
6008
0
}
6009
6010
0
OUString SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox->GetText(); }
6011
6012
0
void SalInstanceComboBoxWithEdit::remove(int pos) { m_xComboBox->RemoveEntryAt(pos); }
6013
6014
void SalInstanceComboBoxWithEdit::do_insert(int pos, const OUString& rStr, const OUString* pId,
6015
                                            const OUString* pIconName, VirtualDevice* pImageSurface)
6016
0
{
6017
0
    auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
6018
0
    sal_Int32 nInsertedAt;
6019
0
    if (!pIconName && !pImageSurface)
6020
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos);
6021
0
    else if (pIconName)
6022
0
        nInsertedAt = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pIconName), nInsertPos);
6023
0
    else
6024
0
        nInsertedAt
6025
0
            = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pImageSurface), nInsertPos);
6026
0
    if (pId)
6027
0
    {
6028
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
6029
0
        m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get());
6030
0
    }
6031
0
}
6032
6033
void SalInstanceComboBoxWithEdit::insert_separator(int pos, const OUString& /*rId*/)
6034
0
{
6035
0
    auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos;
6036
0
    m_xComboBox->AddSeparator(nInsertPos - 1);
6037
0
}
6038
6039
void SalInstanceComboBoxWithEdit::do_set_entry_text(const OUString& rText)
6040
0
{
6041
0
    m_xComboBox->SetText(rText);
6042
0
}
6043
6044
void SalInstanceComboBoxWithEdit::set_entry_width_chars(int nChars)
6045
0
{
6046
0
    m_xComboBox->SetWidthInChars(nChars);
6047
0
}
6048
6049
void SalInstanceComboBoxWithEdit::set_entry_max_length(int nChars)
6050
0
{
6051
0
    m_xComboBox->SetMaxTextLen(nChars);
6052
0
}
6053
6054
void SalInstanceComboBoxWithEdit::set_entry_completion(bool bEnable, bool bCaseSensitive)
6055
0
{
6056
0
    m_xComboBox->EnableAutocomplete(bEnable, bCaseSensitive);
6057
0
}
6058
6059
void SalInstanceComboBoxWithEdit::set_entry_placeholder_text(const OUString& rText)
6060
0
{
6061
0
    m_xComboBox->SetPlaceholderText(rText);
6062
0
}
6063
6064
void SalInstanceComboBoxWithEdit::set_entry_editable(bool bEditable)
6065
0
{
6066
0
    m_xComboBox->SetReadOnly(!bEditable);
6067
0
}
6068
6069
0
void SalInstanceComboBoxWithEdit::cut_entry_clipboard() { m_xComboBox->Cut(); }
6070
6071
0
void SalInstanceComboBoxWithEdit::copy_entry_clipboard() { m_xComboBox->Copy(); }
6072
6073
0
void SalInstanceComboBoxWithEdit::paste_entry_clipboard() { m_xComboBox->Paste(); }
6074
6075
void SalInstanceComboBoxWithEdit::select_entry_region(int nStartPos, int nEndPos)
6076
0
{
6077
0
    m_xComboBox->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
6078
0
}
6079
6080
bool SalInstanceComboBoxWithEdit::get_entry_selection_bounds(int& rStartPos, int& rEndPos)
6081
0
{
6082
0
    const Selection& rSelection = m_xComboBox->GetSelection();
6083
0
    rStartPos = rSelection.Min();
6084
0
    rEndPos = rSelection.Max();
6085
0
    return rSelection.Len();
6086
0
}
6087
6088
void SalInstanceComboBoxWithEdit::set_font(const vcl::Font& rFont)
6089
0
{
6090
0
    m_xComboBox->SetControlFont(rFont);
6091
0
    m_xComboBox->Invalidate();
6092
0
}
6093
6094
void SalInstanceComboBoxWithEdit::set_entry_font(const vcl::Font& rFont)
6095
0
{
6096
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
6097
0
    assert(pEdit);
6098
0
    pEdit->SetControlFont(rFont); // tdf#134601 set it as control font to take effect properly
6099
0
    pEdit->Invalidate();
6100
0
}
6101
6102
vcl::Font SalInstanceComboBoxWithEdit::get_entry_font()
6103
0
{
6104
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
6105
0
    assert(pEdit);
6106
0
    return pEdit->GetPointFont(*pEdit->GetOutDev());
6107
0
}
6108
6109
void SalInstanceComboBoxWithEdit::set_custom_renderer(bool bOn)
6110
0
{
6111
0
    if (m_xComboBox->IsUserDrawEnabled() == bOn)
6112
0
        return;
6113
6114
0
    auto nOldEntryHeight = m_xComboBox->GetDropDownEntryHeight();
6115
0
    auto nDropDownLineCount = m_xComboBox->GetDropDownLineCount();
6116
6117
0
    m_xComboBox->EnableUserDraw(bOn);
6118
0
    if (bOn)
6119
0
        m_xComboBox->SetUserDrawHdl(LINK(this, SalInstanceComboBoxWithEdit, UserDrawHdl));
6120
0
    else
6121
0
        m_xComboBox->SetUserDrawHdl(Link<UserDrawEvent*, void>());
6122
6123
    // adjust the line count to fit approx the height it would have been before
6124
    // changing the renderer
6125
0
    auto nNewEntryHeight = m_xComboBox->GetDropDownEntryHeight();
6126
0
    double fRatio = nOldEntryHeight / static_cast<double>(nNewEntryHeight);
6127
0
    m_xComboBox->SetDropDownLineCount(nDropDownLineCount * fRatio);
6128
0
}
6129
6130
0
int SalInstanceComboBoxWithEdit::get_max_mru_count() const { return m_xComboBox->GetMaxMRUCount(); }
6131
6132
void SalInstanceComboBoxWithEdit::set_max_mru_count(int nCount)
6133
0
{
6134
0
    return m_xComboBox->SetMaxMRUCount(nCount);
6135
0
}
6136
6137
std::vector<OUString> SalInstanceComboBoxWithEdit::get_mru_entries() const
6138
0
{
6139
0
    return m_xComboBox->GetMRUEntries();
6140
0
}
6141
6142
void SalInstanceComboBoxWithEdit::set_mru_entries(const std::vector<OUString>& rEntries)
6143
0
{
6144
0
    m_xComboBox->SetMRUEntries(rEntries);
6145
0
}
6146
6147
void SalInstanceComboBoxWithEdit::HandleEventListener(VclWindowEvent& rEvent)
6148
0
{
6149
0
    if (rEvent.GetId() == VclEventId::DropdownPreOpen)
6150
0
    {
6151
0
        Size aRowSize(signal_custom_get_size(*m_xComboBox->GetOutDev()));
6152
0
        m_xComboBox->SetUserItemSize(aRowSize);
6153
0
    }
6154
0
    CallHandleEventListener(rEvent);
6155
0
}
6156
6157
SalInstanceComboBoxWithEdit::~SalInstanceComboBoxWithEdit()
6158
0
{
6159
0
    m_xComboBox->SetTextFilter(nullptr);
6160
0
    m_xComboBox->SetEntryActivateHdl(Link<Edit&, bool>());
6161
0
    m_xComboBox->SetModifyHdl(Link<Edit&, void>());
6162
0
    m_xComboBox->SetSelectHdl(Link<::ComboBox&, void>());
6163
0
}
6164
6165
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, ChangeHdl, Edit&, void)
6166
0
{
6167
0
    if (!m_xComboBox->IsSyntheticModify()) // SelectHdl will be called
6168
0
        signal_changed();
6169
0
}
6170
6171
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, SelectHdl, ::ComboBox&, void)
6172
0
{
6173
0
    m_bInSelect = true;
6174
0
    signal_changed();
6175
0
    m_bInSelect = false;
6176
0
}
6177
6178
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, bool)
6179
0
{
6180
0
    return m_aEntryActivateHdl.Call(*this);
6181
0
}
6182
6183
IMPL_LINK(SalInstanceComboBoxWithEdit, UserDrawHdl, UserDrawEvent*, pEvent, void)
6184
0
{
6185
0
    call_signal_custom_render(pEvent);
6186
0
}
6187
6188
class SalInstanceEntryTreeView : public SalInstanceContainer, public virtual weld::EntryTreeView
6189
{
6190
private:
6191
    DECL_LINK(AutocompleteHdl, Edit&, void);
6192
    DECL_LINK(KeyPressListener, VclWindowEvent&, void);
6193
    SalInstanceEntry* m_pEntry;
6194
    SalInstanceTreeView* m_pTreeView;
6195
    bool m_bTreeChange;
6196
6197
public:
6198
    SalInstanceEntryTreeView(vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
6199
                             bool bTakeOwnership, std::unique_ptr<weld::Entry> xEntry,
6200
                             std::unique_ptr<weld::TreeView> xTreeView)
6201
0
        : EntryTreeView(std::move(xEntry), std::move(xTreeView))
6202
0
        , SalInstanceContainer(pContainer, pBuilder, bTakeOwnership)
6203
0
        , m_pEntry(dynamic_cast<SalInstanceEntry*>(m_xEntry.get()))
6204
0
        , m_pTreeView(dynamic_cast<SalInstanceTreeView*>(m_xTreeView.get()))
6205
0
        , m_bTreeChange(false)
6206
0
    {
6207
0
        assert(m_pEntry && m_pTreeView);
6208
6209
0
        Edit& rEntry = m_pEntry->getEntry();
6210
0
        rEntry.SetAutocompleteHdl(LINK(this, SalInstanceEntryTreeView, AutocompleteHdl));
6211
0
        rEntry.AddEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener));
6212
0
    }
6213
6214
    virtual void make_sorted() override
6215
0
    {
6216
0
        vcl::Window* pTreeView = m_pTreeView->getWidget();
6217
0
        pTreeView->SetStyle(pTreeView->GetStyle() | WB_SORT);
6218
0
    }
6219
6220
    virtual void set_entry_completion(bool bEnable, bool /*bCaseSensitive*/) override
6221
0
    {
6222
0
        assert(!bEnable && "not implemented yet");
6223
0
        (void)bEnable;
6224
0
        Edit& rEntry = m_pEntry->getEntry();
6225
0
        rEntry.SetAutocompleteHdl(Link<Edit&, void>());
6226
0
    }
6227
6228
0
    virtual void grab_focus() override { m_xEntry->grab_focus(); }
6229
6230
    virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
6231
0
    {
6232
0
        m_xEntry->connect_focus_in(rLink);
6233
0
    }
6234
6235
    virtual void connect_focus_out(const Link<Widget&, void>& rLink) override
6236
0
    {
6237
0
        m_xEntry->connect_focus_out(rLink);
6238
0
    }
6239
6240
0
    virtual bool changed_by_direct_pick() const override { return m_bTreeChange; }
6241
6242
    virtual ~SalInstanceEntryTreeView() override
6243
0
    {
6244
0
        Edit& rEntry = m_pEntry->getEntry();
6245
0
        rEntry.RemoveEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener));
6246
0
        rEntry.SetAutocompleteHdl(Link<Edit&, void>());
6247
0
    }
6248
};
6249
6250
IMPL_LINK(SalInstanceEntryTreeView, KeyPressListener, VclWindowEvent&, rEvent, void)
6251
0
{
6252
0
    if (rEvent.GetId() != VclEventId::WindowKeyInput)
6253
0
        return;
6254
0
    const KeyEvent& rKeyEvent = *static_cast<KeyEvent*>(rEvent.GetData());
6255
0
    if (rKeyEvent.GetKeyCode().GetModifier()) // tdf#163777 ignore when modifier held
6256
0
        return;
6257
0
    sal_uInt16 nKeyCode = rKeyEvent.GetKeyCode().GetCode();
6258
0
    const bool bNavigation = nKeyCode == KEY_UP || nKeyCode == KEY_DOWN || nKeyCode == KEY_PAGEUP
6259
0
                             || nKeyCode == KEY_PAGEDOWN;
6260
0
    if (!bNavigation)
6261
0
        return;
6262
6263
0
    m_pTreeView->disableNotifyEvents();
6264
0
    auto& rListBox = m_pTreeView->getTreeView();
6265
0
    if (!rListBox.FirstSelected())
6266
0
    {
6267
0
        if (SvTreeListEntry* pEntry = rListBox.First())
6268
0
            rListBox.Select(pEntry, true);
6269
0
    }
6270
0
    else
6271
0
        rListBox.KeyInput(rKeyEvent);
6272
0
    m_xEntry->set_text(m_xTreeView->get_selected_text());
6273
0
    m_xEntry->select_region(0, -1);
6274
0
    m_pTreeView->enableNotifyEvents();
6275
0
    m_bTreeChange = true;
6276
0
    m_pEntry->fire_signal_changed();
6277
0
    m_bTreeChange = false;
6278
0
}
6279
6280
IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void)
6281
0
{
6282
0
    Selection aSel = rEdit.GetSelection();
6283
6284
0
    OUString aFullText = rEdit.GetText();
6285
0
    OUString aStartText = aFullText.copy(0, static_cast<sal_Int32>(aSel.Max()));
6286
6287
0
    int nPos = -1;
6288
0
    int nCount = m_xTreeView->n_children();
6289
0
    for (int i = 0; i < nCount; ++i)
6290
0
    {
6291
0
        if (m_xTreeView->get_text(i).startsWithIgnoreAsciiCase(aStartText))
6292
0
        {
6293
0
            nPos = i;
6294
0
            break;
6295
0
        }
6296
0
    }
6297
6298
0
    m_xTreeView->select(nPos);
6299
6300
0
    if (nPos != -1)
6301
0
    {
6302
0
        OUString aText = m_xTreeView->get_text(nPos);
6303
0
        Selection aSelection(aText.getLength(), aStartText.getLength());
6304
0
        rEdit.SetText(aText, aSelection);
6305
0
    }
6306
0
}
6307
6308
SalInstancePopover::SalInstancePopover(DockingWindow* pPopover, SalInstanceBuilder* pBuilder,
6309
                                       bool bTakeOwnership)
6310
0
    : SalInstanceContainer(pPopover, pBuilder, bTakeOwnership)
6311
0
    , m_xPopover(pPopover)
6312
0
{
6313
0
}
Unexecuted instantiation: SalInstancePopover::SalInstancePopover(DockingWindow*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstancePopover::SalInstancePopover(DockingWindow*, SalInstanceBuilder*, bool)
6314
6315
SalInstancePopover::~SalInstancePopover()
6316
0
{
6317
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6318
0
    if (pDockingManager->IsInPopupMode(m_xPopover))
6319
0
        ImplPopDown();
6320
0
}
6321
6322
void SalInstancePopover::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
6323
                                       weld::Placement ePlace)
6324
0
{
6325
0
    SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent);
6326
0
    assert(pVclWidget);
6327
0
    vcl::Window* pWidget = pVclWidget->getWidget();
6328
6329
0
    tools::Rectangle aRect;
6330
0
    Point aPt = pWidget->OutputToScreenPixel(rRect.TopLeft());
6331
0
    aRect.SetLeft(aPt.X());
6332
0
    aRect.SetTop(aPt.Y());
6333
0
    aPt = pWidget->OutputToScreenPixel(rRect.BottomRight());
6334
0
    aRect.SetRight(aPt.X());
6335
0
    aRect.SetBottom(aPt.Y());
6336
6337
0
    FloatWinPopupFlags nFlags = FloatWinPopupFlags::NoMouseUpClose;
6338
0
    if (!(pWidget->GetStyle() & WB_NOPOINTERFOCUS))
6339
0
        nFlags = nFlags | FloatWinPopupFlags::GrabFocus;
6340
0
    if (ePlace == weld::Placement::Under)
6341
0
        nFlags = nFlags | FloatWinPopupFlags::Down;
6342
0
    else
6343
0
        nFlags = nFlags | FloatWinPopupFlags::Right;
6344
6345
0
    m_xPopover->EnableDocking();
6346
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6347
0
    pDockingManager->SetPopupModeEndHdl(m_xPopover,
6348
0
                                        LINK(this, SalInstancePopover, PopupModeEndHdl));
6349
0
    pDockingManager->StartPopupMode(m_xPopover, aRect, nFlags);
6350
0
}
6351
6352
void SalInstancePopover::ImplPopDown()
6353
0
{
6354
0
    vcl::Window::GetDockingManager()->EndPopupMode(m_xPopover);
6355
0
    m_xPopover->EnableDocking(false);
6356
0
    signal_closed();
6357
0
}
6358
6359
0
void SalInstancePopover::popdown() { ImplPopDown(); }
6360
6361
void SalInstancePopover::resize_to_request()
6362
0
{
6363
0
    ::resize_to_request(m_xPopover.get());
6364
6365
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6366
0
    if (pDockingManager->IsInPopupMode(m_xPopover.get()))
6367
0
    {
6368
0
        Size aSize = m_xPopover->get_preferred_size();
6369
0
        tools::Rectangle aRect = pDockingManager->GetPosSizePixel(m_xPopover.get());
6370
0
        pDockingManager->SetPosSizePixel(m_xPopover.get(), aRect.Left(), aRect.Top(), aSize.Width(),
6371
0
                                         aSize.Height(), PosSizeFlags::Size);
6372
0
    }
6373
0
}
6374
6375
0
IMPL_LINK_NOARG(SalInstancePopover, PopupModeEndHdl, FloatingWindow*, void) { signal_closed(); }
6376
6377
SalInstanceColorChooserDialog::SalInstanceColorChooserDialog(
6378
    std::unique_ptr<ColorPickerDialog> pColorDialog)
6379
0
    : SalInstanceDialog(dynamic_cast<SalInstanceDialog&>(*pColorDialog->getDialog()).getDialog(),
6380
0
                        nullptr, false)
6381
0
    , m_pColorPickerDialog(std::move(pColorDialog))
6382
0
{
6383
0
}
Unexecuted instantiation: SalInstanceColorChooserDialog::SalInstanceColorChooserDialog(std::__1::unique_ptr<ColorPickerDialog, std::__1::default_delete<ColorPickerDialog> >)
Unexecuted instantiation: SalInstanceColorChooserDialog::SalInstanceColorChooserDialog(std::__1::unique_ptr<ColorPickerDialog, std::__1::default_delete<ColorPickerDialog> >)
6384
6385
0
SalInstanceColorChooserDialog::~SalInstanceColorChooserDialog() {}
6386
6387
void SalInstanceColorChooserDialog::set_color(const Color& rColor)
6388
0
{
6389
0
    m_pColorPickerDialog->SetColor(rColor);
6390
0
}
6391
6392
0
Color SalInstanceColorChooserDialog::get_color() const { return m_pColorPickerDialog->GetColor(); }
6393
6394
SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, std::u16string_view sUIRoot,
6395
                                       const OUString& rUIFile,
6396
                                       const css::uno::Reference<css::frame::XFrame>& rFrame)
6397
0
    : weld::Builder()
6398
0
    , m_xBuilder(new VclBuilder(pParent, sUIRoot, rUIFile, {}, rFrame, false))
6399
0
{
6400
0
}
6401
6402
std::unique_ptr<weld::MessageDialog> SalInstanceBuilder::weld_message_dialog(const OUString& id)
6403
0
{
6404
0
    MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id);
6405
0
    std::unique_ptr<weld::MessageDialog> pRet(
6406
0
        pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr);
6407
0
    if (pMessageDialog)
6408
0
    {
6409
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6410
0
        m_aOwnedToplevel.reset(pMessageDialog);
6411
0
        m_xBuilder->drop_ownership(pMessageDialog);
6412
0
    }
6413
0
    return pRet;
6414
0
}
6415
6416
std::unique_ptr<weld::Dialog> SalInstanceBuilder::weld_dialog(const OUString& id)
6417
0
{
6418
0
    Dialog* pDialog = m_xBuilder->get<Dialog>(id);
6419
0
    std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false)
6420
0
                                               : nullptr);
6421
0
    if (pDialog)
6422
0
    {
6423
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6424
0
        m_aOwnedToplevel.reset(pDialog);
6425
0
        m_xBuilder->drop_ownership(pDialog);
6426
0
    }
6427
0
    return pRet;
6428
0
}
6429
6430
std::unique_ptr<weld::Assistant> SalInstanceBuilder::weld_assistant(const OUString& id)
6431
0
{
6432
0
    vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id);
6433
0
    std::unique_ptr<weld::Assistant> pRet(pDialog ? new SalInstanceAssistant(pDialog, this, false)
6434
0
                                                  : nullptr);
6435
0
    if (pDialog)
6436
0
    {
6437
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6438
0
        m_aOwnedToplevel.reset(pDialog);
6439
0
        m_xBuilder->drop_ownership(pDialog);
6440
0
    }
6441
0
    return pRet;
6442
0
}
6443
6444
std::unique_ptr<weld::Window> SalInstanceBuilder::create_screenshot_window()
6445
0
{
6446
0
    assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6447
6448
0
    vcl::Window* pRoot = m_xBuilder->get_widget_root();
6449
0
    if (SystemWindow* pWindow = dynamic_cast<SystemWindow*>(pRoot))
6450
0
    {
6451
0
        std::unique_ptr<weld::Window> xRet(new SalInstanceWindow(pWindow, this, false));
6452
0
        m_aOwnedToplevel.reset(pWindow);
6453
0
        m_xBuilder->drop_ownership(pWindow);
6454
0
        return xRet;
6455
0
    }
6456
6457
0
    VclPtrInstance<Dialog> xDialog(nullptr, WB_HIDE | WB_STDDIALOG | WB_SIZEABLE | WB_CLOSEABLE,
6458
0
                                   Dialog::InitFlag::NoParent);
6459
0
    xDialog->SetText(utl::ConfigManager::getProductName());
6460
6461
0
    auto xContentArea = VclPtr<VclVBox>::Create(xDialog, false, 12);
6462
0
    pRoot->SetParent(xContentArea);
6463
0
    assert(pRoot == xContentArea->GetWindow(GetWindowType::FirstChild));
6464
0
    xContentArea->Show();
6465
0
    pRoot->Show();
6466
0
    xDialog->SetHelpId(pRoot->GetHelpId());
6467
6468
0
    m_aOwnedToplevel.reset(xDialog);
6469
6470
0
    return std::unique_ptr<weld::Dialog>(new SalInstanceDialog(xDialog, this, false));
6471
0
}
6472
6473
std::unique_ptr<weld::Widget> SalInstanceBuilder::weld_widget(const OUString& id)
6474
0
{
6475
0
    vcl::Window* pWidget = m_xBuilder->get(id);
6476
0
    return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, false) : nullptr;
6477
0
}
6478
6479
std::unique_ptr<weld::Container> SalInstanceBuilder::weld_container(const OUString& id)
6480
0
{
6481
0
    vcl::Window* pContainer = m_xBuilder->get(id);
6482
0
    return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, false) : nullptr;
6483
0
}
6484
6485
std::unique_ptr<weld::Box> SalInstanceBuilder::weld_box(const OUString& id)
6486
0
{
6487
0
    VclBox* pContainer = m_xBuilder->get<VclBox>(id);
6488
0
    return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, false) : nullptr;
6489
0
}
6490
6491
std::unique_ptr<weld::Grid> SalInstanceBuilder::weld_grid(const OUString& id)
6492
0
{
6493
0
    VclGrid* pGrid = m_xBuilder->get<VclGrid>(id);
6494
0
    return pGrid ? std::make_unique<SalInstanceGrid>(pGrid, this, false) : nullptr;
6495
0
}
6496
6497
std::unique_ptr<weld::Paned> SalInstanceBuilder::weld_paned(const OUString& id)
6498
0
{
6499
0
    VclPaned* pPaned = m_xBuilder->get<VclPaned>(id);
6500
0
    return pPaned ? std::make_unique<SalInstancePaned>(pPaned, this, false) : nullptr;
6501
0
}
6502
6503
std::unique_ptr<weld::Frame> SalInstanceBuilder::weld_frame(const OUString& id)
6504
0
{
6505
0
    VclFrame* pFrame = m_xBuilder->get<VclFrame>(id);
6506
0
    std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr);
6507
0
    return pRet;
6508
0
}
6509
6510
std::unique_ptr<weld::ScrolledWindow>
6511
SalInstanceBuilder::weld_scrolled_window(const OUString& id, bool bUserManagedScrolling)
6512
0
{
6513
0
    VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id);
6514
0
    return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(
6515
0
                                 pScrolledWindow, this, false, bUserManagedScrolling)
6516
0
                           : nullptr;
6517
0
}
6518
6519
std::unique_ptr<weld::Notebook> SalInstanceBuilder::weld_notebook(const OUString& id)
6520
0
{
6521
0
    vcl::Window* pNotebook = m_xBuilder->get(id);
6522
0
    if (!pNotebook)
6523
0
        return nullptr;
6524
0
    if (pNotebook->GetType() == WindowType::TABCONTROL)
6525
0
        return std::make_unique<SalInstanceNotebook>(static_cast<TabControl*>(pNotebook), this,
6526
0
                                                     false);
6527
0
    if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL)
6528
0
        return std::make_unique<SalInstanceVerticalNotebook>(
6529
0
            static_cast<VerticalTabControl*>(pNotebook), this, false);
6530
0
    return nullptr;
6531
0
}
6532
6533
std::unique_ptr<weld::Button> SalInstanceBuilder::weld_button(const OUString& id)
6534
0
{
6535
0
    Button* pButton = m_xBuilder->get<Button>(id);
6536
0
    return pButton ? std::make_unique<SalInstanceButton>(pButton, this, false) : nullptr;
6537
0
}
6538
6539
std::unique_ptr<weld::MenuButton> SalInstanceBuilder::weld_menu_button(const OUString& id)
6540
0
{
6541
0
    MenuButton* pButton = m_xBuilder->get<MenuButton>(id);
6542
0
    return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, false) : nullptr;
6543
0
}
6544
6545
std::unique_ptr<weld::LinkButton> SalInstanceBuilder::weld_link_button(const OUString& id)
6546
0
{
6547
0
    FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id);
6548
0
    return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, false) : nullptr;
6549
0
}
6550
6551
std::unique_ptr<weld::ToggleButton> SalInstanceBuilder::weld_toggle_button(const OUString& id)
6552
0
{
6553
0
    PushButton* pToggleButton = m_xBuilder->get<PushButton>(id);
6554
0
    return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, false)
6555
0
                         : nullptr;
6556
0
}
6557
6558
std::unique_ptr<weld::RadioButton> SalInstanceBuilder::weld_radio_button(const OUString& id)
6559
0
{
6560
0
    RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id);
6561
0
    return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, false)
6562
0
                        : nullptr;
6563
0
}
6564
6565
std::unique_ptr<weld::CheckButton> SalInstanceBuilder::weld_check_button(const OUString& id)
6566
0
{
6567
0
    CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
6568
0
    return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, false)
6569
0
                        : nullptr;
6570
0
}
6571
6572
std::unique_ptr<weld::Scale> SalInstanceBuilder::weld_scale(const OUString& id)
6573
0
{
6574
0
    Slider* pSlider = m_xBuilder->get<Slider>(id);
6575
0
    return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, false) : nullptr;
6576
0
}
6577
6578
std::unique_ptr<weld::ProgressBar> SalInstanceBuilder::weld_progress_bar(const OUString& id)
6579
0
{
6580
0
    ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id);
6581
0
    return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, false) : nullptr;
6582
0
}
6583
6584
std::unique_ptr<weld::LevelBar> SalInstanceBuilder::weld_level_bar(const OUString& id)
6585
0
{
6586
0
    ::ProgressBar* pLevel = m_xBuilder->get<::ProgressBar>(id);
6587
0
    return pLevel ? std::make_unique<SalInstanceLevelBar>(pLevel, this, false) : nullptr;
6588
0
}
6589
6590
std::unique_ptr<weld::Spinner> SalInstanceBuilder::weld_spinner(const OUString& id)
6591
0
{
6592
0
    Throbber* pThrobber = m_xBuilder->get<Throbber>(id);
6593
0
    return pThrobber ? std::make_unique<SalInstanceSpinner>(pThrobber, this, false) : nullptr;
6594
0
}
6595
6596
std::unique_ptr<weld::Image> SalInstanceBuilder::weld_image(const OUString& id)
6597
0
{
6598
0
    FixedImage* pImage = m_xBuilder->get<FixedImage>(id);
6599
0
    return pImage ? std::make_unique<SalInstanceImage>(pImage, this, false) : nullptr;
6600
0
}
6601
6602
std::unique_ptr<weld::Calendar> SalInstanceBuilder::weld_calendar(const OUString& id)
6603
0
{
6604
0
    Calendar* pCalendar = m_xBuilder->get<Calendar>(id);
6605
0
    return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, false) : nullptr;
6606
0
}
6607
6608
std::unique_ptr<weld::Entry> SalInstanceBuilder::weld_entry(const OUString& id)
6609
0
{
6610
0
    Edit* pEntry = m_xBuilder->get<Edit>(id);
6611
0
    return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, false) : nullptr;
6612
0
}
6613
6614
std::unique_ptr<weld::SpinButton> SalInstanceBuilder::weld_spin_button(const OUString& id)
6615
0
{
6616
0
    FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
6617
0
    return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, false)
6618
0
                       : nullptr;
6619
0
}
6620
6621
std::unique_ptr<weld::MetricSpinButton>
6622
SalInstanceBuilder::weld_metric_spin_button(const OUString& id, FieldUnit eUnit)
6623
0
{
6624
0
    std::unique_ptr<weld::SpinButton> xButton(weld_spin_button(id));
6625
0
    if (xButton)
6626
0
    {
6627
0
        SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(*xButton);
6628
0
        rButton.SetUseThousandSep();
6629
0
    }
6630
0
    return std::make_unique<weld::MetricSpinButton>(std::move(xButton), eUnit);
6631
0
}
6632
6633
std::unique_ptr<weld::FormattedSpinButton>
6634
SalInstanceBuilder::weld_formatted_spin_button(const OUString& id)
6635
0
{
6636
0
    FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
6637
0
    return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, false)
6638
0
                       : nullptr;
6639
0
}
6640
6641
std::unique_ptr<weld::ComboBox> SalInstanceBuilder::weld_combo_box(const OUString& id)
6642
0
{
6643
0
    vcl::Window* pWidget = m_xBuilder->get(id);
6644
0
    ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget);
6645
0
    if (pComboBox)
6646
0
        return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, false);
6647
0
    ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
6648
0
    return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, false)
6649
0
                    : nullptr;
6650
0
}
6651
6652
std::unique_ptr<weld::EntryTreeView>
6653
SalInstanceBuilder::weld_entry_tree_view(const OUString& containerid, const OUString& entryid,
6654
                                         const OUString& treeviewid)
6655
0
{
6656
0
    vcl::Window* pContainer = m_xBuilder->get(containerid);
6657
0
    return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, this, false,
6658
0
                                                                   weld_entry(entryid),
6659
0
                                                                   weld_tree_view(treeviewid))
6660
0
                      : nullptr;
6661
0
}
6662
6663
std::unique_ptr<weld::TreeView> SalInstanceBuilder::weld_tree_view(const OUString& id)
6664
0
{
6665
0
    SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id);
6666
0
    return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, false) : nullptr;
6667
0
}
6668
6669
std::unique_ptr<weld::IconView> SalInstanceBuilder::weld_icon_view(const OUString& id)
6670
0
{
6671
0
    IconView* pIconView = m_xBuilder->get<IconView>(id);
6672
0
    return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, false) : nullptr;
6673
0
}
6674
6675
std::unique_ptr<weld::Label> SalInstanceBuilder::weld_label(const OUString& id)
6676
0
{
6677
0
    Control* pLabel = m_xBuilder->get<Control>(id);
6678
0
    return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, false) : nullptr;
6679
0
}
6680
6681
std::unique_ptr<weld::TextView> SalInstanceBuilder::weld_text_view(const OUString& id)
6682
0
{
6683
0
    VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
6684
0
    return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, false) : nullptr;
6685
0
}
6686
6687
std::unique_ptr<weld::Expander> SalInstanceBuilder::weld_expander(const OUString& id)
6688
0
{
6689
0
    VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
6690
0
    return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, false) : nullptr;
6691
0
}
6692
6693
std::unique_ptr<weld::DrawingArea>
6694
SalInstanceBuilder::weld_drawing_area(const OUString& id,
6695
                                      const rtl::Reference<comphelper::OAccessible>& rA11yImpl,
6696
                                      FactoryFunction pUITestFactoryFunction, void* pUserData)
6697
0
{
6698
0
    VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id);
6699
0
    return pDrawingArea
6700
0
               ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl,
6701
0
                                                          pUITestFactoryFunction, pUserData, false)
6702
0
               : nullptr;
6703
0
}
6704
6705
std::unique_ptr<weld::Menu> SalInstanceBuilder::weld_menu(const OUString& id)
6706
0
{
6707
0
    PopupMenu* pMenu = m_xBuilder->get_menu(id);
6708
0
    return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, true) : nullptr;
6709
0
}
6710
6711
std::unique_ptr<weld::Popover> SalInstanceBuilder::weld_popover(const OUString& id)
6712
0
{
6713
0
    DockingWindow* pDockingWindow = m_xBuilder->get<DockingWindow>(id);
6714
0
    std::unique_ptr<weld::Popover> pRet(
6715
0
        pDockingWindow ? new SalInstancePopover(pDockingWindow, this, false) : nullptr);
6716
0
    if (pDockingWindow)
6717
0
    {
6718
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6719
0
        m_aOwnedToplevel.reset(pDockingWindow);
6720
0
        m_xBuilder->drop_ownership(pDockingWindow);
6721
0
    }
6722
0
    return pRet;
6723
0
}
6724
6725
std::unique_ptr<weld::Toolbar> SalInstanceBuilder::weld_toolbar(const OUString& id)
6726
0
{
6727
0
    ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
6728
0
    return pToolBox ? std::make_unique<SalInstanceToolbar>(pToolBox, this, false) : nullptr;
6729
0
}
6730
6731
std::unique_ptr<weld::Scrollbar> SalInstanceBuilder::weld_scrollbar(const OUString& id)
6732
0
{
6733
0
    ScrollBar* pScrollbar = m_xBuilder->get<ScrollBar>(id);
6734
0
    return pScrollbar ? std::make_unique<SalInstanceScrollbar>(pScrollbar, this, false) : nullptr;
6735
0
}
6736
6737
std::unique_ptr<weld::SizeGroup> SalInstanceBuilder::create_size_group(VclSizeGroupMode eMode)
6738
0
{
6739
0
    return std::make_unique<SalInstanceSizeGroup>(eMode);
6740
0
}
6741
6742
OUString SalInstanceBuilder::get_current_page_help_id() const
6743
0
{
6744
0
    vcl::Window* pCtrl = m_xBuilder->get(u"tabcontrol");
6745
0
    if (!pCtrl)
6746
0
        return {};
6747
0
    VclPtr<vcl::Window> xTabPage;
6748
0
    if (pCtrl->GetType() == WindowType::TABCONTROL)
6749
0
    {
6750
0
        TabControl* pTabCtrl = static_cast<TabControl*>(pCtrl);
6751
0
        xTabPage = pTabCtrl->GetTabPage(pTabCtrl->GetCurPageId());
6752
0
    }
6753
0
    else if (pCtrl->GetType() == WindowType::VERTICALTABCONTROL)
6754
0
    {
6755
0
        VerticalTabControl* pTabCtrl = static_cast<VerticalTabControl*>(pCtrl);
6756
0
        xTabPage = pTabCtrl->GetPage(pTabCtrl->GetCurPageId());
6757
0
    }
6758
0
    vcl::Window* pTabChild = xTabPage ? xTabPage->GetWindow(GetWindowType::FirstChild) : nullptr;
6759
0
    pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr;
6760
0
    if (pTabChild)
6761
0
        return pTabChild->GetHelpId();
6762
0
    return {};
6763
0
}
6764
6765
SalInstanceBuilder::~SalInstanceBuilder()
6766
0
{
6767
0
    if (VclBuilderContainer* pOwnedToplevel
6768
0
        = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get()))
6769
0
        pOwnedToplevel->m_pUIBuilder = std::move(m_xBuilder);
6770
0
    else
6771
0
        m_xBuilder.reset();
6772
0
    m_aOwnedToplevel.disposeAndClear();
6773
0
}
6774
6775
void SalInstanceWindow::help()
6776
0
{
6777
    //show help for widget with keyboard focus
6778
0
    vcl::Window* pWidget = ImplGetSVData()->mpWinData->mpFocusWin;
6779
0
    if (!pWidget)
6780
0
        pWidget = m_xWindow;
6781
0
    if (comphelper::LibreOfficeKit::isActive() && m_xWindow->GetFocusedWindow())
6782
0
        pWidget = m_xWindow->GetFocusedWindow().get();
6783
0
    OUString sHelpId = pWidget->GetHelpId();
6784
0
    while (sHelpId.isEmpty())
6785
0
    {
6786
0
        pWidget = pWidget->GetParent();
6787
0
        if (!pWidget)
6788
0
            break;
6789
0
        sHelpId = pWidget->GetHelpId();
6790
0
    }
6791
0
    std::unique_ptr<weld::Widget> xTemp(
6792
0
        pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr);
6793
0
    weld::Widget* pSource = xTemp ? xTemp.get() : this;
6794
0
    bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource);
6795
0
    Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr;
6796
0
    if (!pHelp)
6797
0
        return;
6798
6799
    // tdf#126007, there's a nice fallback route for offline help where
6800
    // the current page of a notebook will get checked when the help
6801
    // button is pressed and there was no help for the dialog found.
6802
    //
6803
    // But for online help that route doesn't get taken, so bodge this here
6804
    // by using the page help id if available and if the help button itself
6805
    // was the original id
6806
0
    if (m_pBuilder && sHelpId.endsWith("/help"))
6807
0
    {
6808
0
        OUString sPageId = m_pBuilder->get_current_page_help_id();
6809
0
        if (!sPageId.isEmpty())
6810
0
            sHelpId = sPageId;
6811
0
        else
6812
0
        {
6813
            // tdf#129068 likewise the help for the wrapping dialog is less
6814
            // helpful than the help for the content area could be
6815
0
            vcl::Window* pContentArea = nullptr;
6816
0
            if (::Dialog* pDialog = dynamic_cast<::Dialog*>(m_xWindow.get()))
6817
0
                pContentArea = pDialog->get_content_area();
6818
0
            if (pContentArea)
6819
0
            {
6820
0
                vcl::Window* pContentWidget = pContentArea->GetWindow(GetWindowType::LastChild);
6821
0
                if (pContentWidget)
6822
0
                    sHelpId = pContentWidget->GetHelpId();
6823
0
            }
6824
0
        }
6825
0
    }
6826
0
    pHelp->Start(sHelpId, pSource);
6827
0
}
6828
6829
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */