Coverage Report

Created: 2026-08-14 10:22

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
790k
{
94
790k
    if (ImplSVData* pSVData = ImplGetSVData())
95
790k
    {
96
790k
        auto& rCache = pSVData->maGDIData.maScaleCache;
97
98
790k
        rCache.remove_if([this](const lru_scale_cache::key_value_pair_t& rKeyValuePair) {
99
19.2k
            return rKeyValuePair.first.mpBitmap == this;
100
19.2k
        });
101
790k
    }
102
790k
}
103
104
408k
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.01M
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
91
    : m_xWidget(pWidget)
270
91
    , m_pBuilder(pBuilder)
271
91
    , m_bTakeOwnership(bTakeOwnership)
272
91
    , m_bEventListener(false)
273
91
    , m_bKeyEventListener(false)
274
91
    , m_bMouseEventListener(false)
275
91
    , m_nFreezeCount(0)
276
91
{
277
91
    m_xWidget->SetCommandHdl(LINK(this, SalInstanceWidget, CommandHdl));
278
91
}
SalInstanceWidget::SalInstanceWidget(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
269
91
    : m_xWidget(pWidget)
270
91
    , m_pBuilder(pBuilder)
271
91
    , m_bTakeOwnership(bTakeOwnership)
272
91
    , m_bEventListener(false)
273
91
    , m_bKeyEventListener(false)
274
91
    , m_bMouseEventListener(false)
275
91
    , m_nFreezeCount(0)
276
91
{
277
91
    m_xWidget->SetCommandHdl(LINK(this, SalInstanceWidget, CommandHdl));
278
91
}
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
91
{
537
91
    m_xWidget->SetCommandHdl(Link<const CommandEvent&, bool>());
538
91
    if (m_aStyleUpdatedHdl.IsSet())
539
0
        m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, SettingsChangedHdl));
540
91
    if (m_aMnemonicActivateHdl.IsSet())
541
0
        m_xWidget->SetMnemonicActivateHdl(Link<vcl::Window&, bool>());
542
91
    if (m_bMouseEventListener)
543
0
        m_xWidget->RemoveChildEventListener(LINK(this, SalInstanceWidget, MouseEventListener));
544
91
    if (m_bKeyEventListener)
545
0
        Application::RemoveKeyListener(LINK(this, SalInstanceWidget, KeyEventListener));
546
91
    if (m_bEventListener)
547
0
        m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener));
548
91
    if (m_bTakeOwnership)
549
0
        m_xWidget.disposeAndClear();
550
91
}
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 submens'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
91
    : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership)
1231
91
    , m_xContainer(pContainer)
1232
91
{
1233
91
}
SalInstanceContainer::SalInstanceContainer(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
1230
91
    : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership)
1231
91
    , m_xContainer(pContainer)
1232
91
{
1233
91
}
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
91
    : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership)
1499
91
    , m_xWindow(pWindow)
1500
91
{
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
91
    if (m_pBuilder)
1504
0
        override_child_help(m_xWindow);
1505
91
}
Unexecuted instantiation: SalInstanceWindow::SalInstanceWindow(vcl::Window*, SalInstanceBuilder*, bool)
SalInstanceWindow::SalInstanceWindow(vcl::Window*, SalInstanceBuilder*, bool)
Line
Count
Source
1498
91
    : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership)
1499
91
    , m_xWindow(pWindow)
1500
91
{
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
91
    if (m_pBuilder)
1504
0
        override_child_help(m_xWindow);
1505
91
}
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
139
{
1513
139
    css::uno::Reference<css::awt::XWindow> xWindow(m_xWindow->GetComponentInterface(),
1514
139
                                                   css::uno::UNO_QUERY);
1515
139
    return xWindow;
1516
139
}
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
91
{
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
91
    if (m_pBuilder)
1594
0
        clear_child_help(m_xWindow);
1595
91
}
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
            pEntry->SetForceControlBackground(false);
3217
0
            pEntry->SetControlForeground();
3218
0
            pEntry->SetControlBackground();
3219
0
            break;
3220
0
        case weld::EntryMessageType::Warning:
3221
            // tdf#114603: enable setting the background to a different color;
3222
            // relevant for GTK; see also #i75179#
3223
0
            pEntry->SetForceControlBackground(true);
3224
0
            pEntry->SetControlForeground(COL_BLACK);
3225
0
            pEntry->SetControlBackground(0xffff38); // "light yellow 1"
3226
0
            break;
3227
0
        case weld::EntryMessageType::Error:
3228
            // tdf#114603: enable setting the background to a different color;
3229
            // relevant for GTK; see also #i75179#
3230
0
            pEntry->SetForceControlBackground(true);
3231
0
            pEntry->SetControlForeground(COL_BLACK); // contrast of 5.87 to the red background
3232
0
            pEntry->SetControlBackground(0xff3838); // "light red 1"
3233
0
            break;
3234
0
    }
3235
0
}
3236
}
3237
3238
void SalInstanceEntry::set_message_type(weld::EntryMessageType eType)
3239
0
{
3240
0
    ::set_message_type(m_xEntry, eType);
3241
0
}
3242
3243
void SalInstanceEntry::set_font(const vcl::Font& rFont)
3244
0
{
3245
0
    m_xEntry->SetControlFont(rFont);
3246
0
    m_xEntry->Invalidate();
3247
0
}
3248
3249
void SalInstanceEntry::set_placeholder_text(const OUString& rText)
3250
0
{
3251
0
    m_xEntry->SetPlaceholderText(rText);
3252
0
}
3253
3254
0
Edit& SalInstanceEntry::getEntry() { return *m_xEntry; }
3255
3256
0
void SalInstanceEntry::fire_signal_changed() { signal_changed(); }
3257
3258
void SalInstanceEntry::cut_clipboard()
3259
0
{
3260
0
    m_xEntry->Cut();
3261
0
    m_xEntry->Modify();
3262
0
}
3263
3264
0
void SalInstanceEntry::copy_clipboard() { m_xEntry->Copy(); }
3265
3266
void SalInstanceEntry::paste_clipboard()
3267
0
{
3268
0
    m_xEntry->Paste();
3269
0
    m_xEntry->Modify();
3270
0
}
3271
3272
namespace
3273
{
3274
void set_alignment(Edit& rEntry, TxtAlign eXAlign)
3275
0
{
3276
0
    WinBits nAlign(0);
3277
0
    switch (eXAlign)
3278
0
    {
3279
0
        case TxtAlign::Left:
3280
0
            nAlign = WB_LEFT;
3281
0
            break;
3282
0
        case TxtAlign::Center:
3283
0
            nAlign = WB_CENTER;
3284
0
            break;
3285
0
        case TxtAlign::Right:
3286
0
            nAlign = WB_RIGHT;
3287
0
            break;
3288
0
    }
3289
0
    WinBits nBits = rEntry.GetStyle();
3290
0
    nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
3291
0
    rEntry.SetStyle(nBits | nAlign);
3292
0
}
3293
}
3294
3295
0
void SalInstanceEntry::set_alignment(TxtAlign eXAlign) { ::set_alignment(*m_xEntry, eXAlign); }
3296
3297
SalInstanceEntry::~SalInstanceEntry()
3298
0
{
3299
0
    m_xEntry->SetTextFilter(nullptr);
3300
0
    m_xEntry->SetActivateHdl(Link<Edit&, bool>());
3301
0
    m_xEntry->SetModifyHdl(Link<Edit&, void>());
3302
0
}
3303
3304
0
IMPL_LINK_NOARG(SalInstanceEntry, ChangeHdl, Edit&, void) { signal_changed(); }
3305
3306
0
IMPL_LINK_NOARG(SalInstanceEntry, ActivateHdl, Edit&, bool) { return m_aActivateHdl.Call(*this); }
3307
3308
static SalInstanceTreeView* g_DragSource;
3309
3310
namespace
3311
{
3312
// tdf#131581 if the TreeView is hidden then there are possibly additional
3313
// optimizations available
3314
class UpdateGuardIfHidden
3315
{
3316
private:
3317
    SvTabListBox& m_rTreeView;
3318
    bool m_bOrigUpdate;
3319
    bool m_bOrigEnableInvalidate;
3320
3321
public:
3322
    UpdateGuardIfHidden(SvTabListBox& rTreeView)
3323
0
        : m_rTreeView(rTreeView)
3324
        // tdf#136962 only do SetUpdateMode(false) optimization if the widget is currently hidden
3325
0
        , m_bOrigUpdate(!m_rTreeView.IsVisible() && m_rTreeView.IsUpdateMode())
3326
        // tdf#137432 only do EnableInvalidate(false) optimization if the widget is currently hidden
3327
0
        , m_bOrigEnableInvalidate(!m_rTreeView.IsVisible()
3328
0
                                  && m_rTreeView.GetModel()->IsEnableInvalidate())
3329
0
    {
3330
0
        if (m_bOrigUpdate)
3331
0
            m_rTreeView.SetUpdateMode(false);
3332
0
        if (m_bOrigEnableInvalidate)
3333
0
            m_rTreeView.GetModel()->EnableInvalidate(false);
3334
0
    }
3335
3336
    ~UpdateGuardIfHidden()
3337
0
    {
3338
0
        if (m_bOrigEnableInvalidate)
3339
0
            m_rTreeView.GetModel()->EnableInvalidate(true);
3340
0
        if (m_bOrigUpdate)
3341
0
            m_rTreeView.SetUpdateMode(true);
3342
0
    }
3343
};
3344
}
3345
3346
SalInstanceItemView::SalInstanceItemView(SvTreeListBox* pTreeListBox, SalInstanceBuilder* pBuilder,
3347
                                         bool bTakeOwnership)
3348
0
    : SalInstanceWidget(pTreeListBox, pBuilder, bTakeOwnership)
3349
0
    , m_pTreeListBox(pTreeListBox)
3350
0
{
3351
0
    m_pTreeListBox->SetDoubleClickHdl(LINK(this, SalInstanceItemView, DoubleClickHdl));
3352
0
}
3353
3354
SalInstanceItemView::~SalInstanceItemView()
3355
0
{
3356
0
    m_pTreeListBox->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
3357
0
}
3358
3359
std::unique_ptr<weld::TreeIter>
3360
SalInstanceItemView::make_iterator(const weld::TreeIter* pOrig) const
3361
0
{
3362
0
    return std::unique_ptr<weld::TreeIter>(
3363
0
        new SalInstanceTreeIter(*this, static_cast<const SalInstanceTreeIter*>(pOrig)));
3364
0
}
3365
3366
bool SalInstanceItemView::get_iter_first(weld::TreeIter& rIter) const
3367
0
{
3368
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
3369
0
    SvTreeListEntry* pFirst = m_pTreeListBox->GetEntry(0);
3370
0
    if (!pFirst)
3371
0
        return false;
3372
3373
0
    rVclIter.iter = pFirst;
3374
0
    return true;
3375
0
}
3376
3377
bool SalInstanceItemView::iter_next_sibling(weld::TreeIter& rIter) const
3378
0
{
3379
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
3380
0
    SvTreeListEntry* pSibling = rVclIter.iter->NextSibling();
3381
0
    if (!pSibling)
3382
0
        return false;
3383
3384
0
    rVclIter.iter = pSibling;
3385
0
    return true;
3386
0
}
3387
3388
int SalInstanceItemView::get_iter_index_in_parent(const weld::TreeIter& rIter) const
3389
0
{
3390
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3391
0
    return SvTreeList::GetRelPos(rVclIter.iter);
3392
0
}
3393
3394
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_iterator(int nPos) const
3395
0
{
3396
0
    if (SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry(nPos))
3397
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3398
3399
0
    return {};
3400
0
}
3401
3402
IMPL_LINK_NOARG(SalInstanceItemView, DoubleClickHdl, SvTreeListBox*, bool)
3403
0
{
3404
0
    if (SvTreeListEntry* pCurEntry = m_pTreeListBox->GetCurEntry())
3405
0
        return !signal_item_activated(SalInstanceTreeIter(*this, pCurEntry));
3406
3407
0
    return false;
3408
0
}
3409
3410
OUString SalInstanceItemView::get_id(const weld::TreeIter& rIter) const
3411
0
{
3412
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3413
0
    const OUString* pStr = rVclIter.iter->GetUserData();
3414
0
    if (pStr)
3415
0
        return *pStr;
3416
0
    return OUString();
3417
0
}
3418
3419
void SalInstanceItemView::set_id(const weld::TreeIter& rIter, const OUString& rId)
3420
0
{
3421
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3422
0
    m_aUserData.emplace_back(std::make_unique<OUString>(rId));
3423
0
    rVclIter.iter->SetUserData(m_aUserData.back().get());
3424
0
}
3425
3426
OUString SalInstanceItemView::get_selected_text() const
3427
0
{
3428
0
    assert(m_pTreeListBox->IsUpdateMode() && "don't request selection when frozen");
3429
0
    if (SvTreeListEntry* pEntry = m_pTreeListBox->FirstSelected())
3430
0
        return SvTabListBox::GetEntryText(pEntry, 0);
3431
0
    return OUString();
3432
0
}
3433
3434
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_selected() const
3435
0
{
3436
0
    SvTreeListEntry* pEntry = m_pTreeListBox->FirstSelected();
3437
0
    if (pEntry)
3438
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3439
3440
0
    return {};
3441
0
}
3442
3443
std::unique_ptr<weld::TreeIter> SalInstanceItemView::get_cursor() const
3444
0
{
3445
0
    SvTreeListEntry* pEntry = m_pTreeListBox->GetCurEntry();
3446
0
    if (pEntry)
3447
0
        return std::make_unique<SalInstanceTreeIter>(*this, pEntry);
3448
3449
0
    return {};
3450
0
}
3451
3452
void SalInstanceItemView::do_select_all()
3453
0
{
3454
0
    assert(m_pTreeListBox->IsUpdateMode()
3455
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3456
0
              "freeze");
3457
0
    m_pTreeListBox->SelectAll(true);
3458
0
}
3459
3460
void SalInstanceItemView::do_unselect_all()
3461
0
{
3462
0
    assert(m_pTreeListBox->IsUpdateMode()
3463
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3464
0
              "freeze");
3465
0
    m_pTreeListBox->SelectAll(false);
3466
0
}
3467
3468
int SalInstanceItemView::n_children() const
3469
0
{
3470
0
    return m_pTreeListBox->GetModel()->GetChildList(nullptr).size();
3471
0
}
3472
3473
void SalInstanceItemView::do_set_cursor(const weld::TreeIter& rIter)
3474
0
{
3475
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3476
0
    m_pTreeListBox->SetCurEntry(rVclIter.iter);
3477
0
}
3478
3479
void SalInstanceItemView::do_select(const weld::TreeIter& rIter)
3480
0
{
3481
0
    assert(m_pTreeListBox->IsUpdateMode()
3482
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3483
0
              "freeze");
3484
3485
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3486
0
    m_pTreeListBox->Select(rVclIter.iter, true);
3487
0
    m_pTreeListBox->MakeVisible(rVclIter.iter);
3488
0
}
3489
3490
void SalInstanceItemView::do_unselect(const weld::TreeIter& rIter)
3491
0
{
3492
0
    assert(m_pTreeListBox->IsUpdateMode()
3493
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
3494
0
              "freeze");
3495
3496
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3497
0
    m_pTreeListBox->Select(rVclIter.iter, false);
3498
0
}
3499
3500
void SalInstanceItemView::do_remove(const weld::TreeIter& rIter)
3501
0
{
3502
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
3503
0
    m_pTreeListBox->RemoveEntry(rVclIter.iter);
3504
0
}
3505
3506
void SalInstanceItemView::do_clear()
3507
0
{
3508
0
    m_pTreeListBox->Clear();
3509
0
    m_aUserData.clear();
3510
0
}
3511
3512
// Each row has a cell for the expander image, (and an optional cell for a
3513
// checkbutton if enable_toggle_buttons has been called) which precede
3514
// index 0
3515
int SalInstanceTreeView::to_internal_model(int col) const
3516
0
{
3517
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3518
0
        ++col; // skip checkbutton column
3519
0
    ++col; //skip expander column
3520
0
    return col;
3521
0
}
3522
3523
int SalInstanceTreeView::to_external_model(int col) const
3524
0
{
3525
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3526
0
        --col; // skip checkbutton column
3527
0
    --col; //skip expander column
3528
0
    return col;
3529
0
}
3530
3531
SvTreeListEntry& SalInstanceTreeView::InsertDummyEntry(SvTreeListEntry* pParent)
3532
0
{
3533
0
    return m_xTreeView->InsertEntry(u"<dummy>"_ustr, pParent, 0);
3534
0
}
3535
3536
bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const
3537
0
{
3538
0
    return o3tl::trim(m_xTreeView->GetEntryText(pEntry)) == u"<dummy>";
3539
0
}
3540
3541
SvTreeListEntry* SalInstanceTreeView::GetPlaceHolderChild(const SvTreeListEntry* pEntry) const
3542
0
{
3543
0
    if (pEntry->HasChildren())
3544
0
    {
3545
0
        auto pChild = m_xTreeView->FirstChild(pEntry);
3546
0
        assert(pChild);
3547
0
        if (IsDummyEntry(pChild))
3548
0
            return pChild;
3549
0
    }
3550
0
    return nullptr;
3551
0
}
3552
3553
void SalInstanceTreeView::set_font_color(SvTreeListEntry* pEntry, const Color& rColor)
3554
0
{
3555
0
    if (rColor == COL_AUTO)
3556
0
        pEntry->SetTextColor(std::optional<Color>());
3557
0
    else
3558
0
        pEntry->SetTextColor(rColor);
3559
0
}
3560
3561
void SalInstanceTreeView::AddStringItem(SvTreeListEntry& rEntry, const OUString& rStr, int nCol)
3562
0
{
3563
0
    auto xCell = std::make_unique<SvLBoxString>(rStr);
3564
0
    if (m_aCustomRenders.contains(nCol))
3565
0
        xCell->SetCustomRender();
3566
0
    rEntry.AddItem(std::move(xCell));
3567
0
}
3568
3569
void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
3570
                                    const OUString* pId, const OUString* pIconName,
3571
                                    const VirtualDevice* pImageSurface, bool bChildrenOnDemand,
3572
                                    weld::TreeIter* pRet, bool bIsSeparator)
3573
0
{
3574
0
    const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
3575
0
    SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr;
3576
0
    auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
3577
0
    OUString* pUserData;
3578
0
    if (pId)
3579
0
    {
3580
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
3581
0
        pUserData = m_aUserData.back().get();
3582
0
    }
3583
0
    else
3584
0
        pUserData = nullptr;
3585
3586
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
3587
0
    if (bIsSeparator)
3588
0
        pEntry->SetSeparator();
3589
3590
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
3591
0
        AddStringItem(*pEntry, u""_ustr, -1);
3592
3593
0
    if (pIconName || pImageSurface)
3594
0
    {
3595
0
        Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
3596
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage));
3597
0
    }
3598
0
    else
3599
0
    {
3600
0
        Image aDummy;
3601
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
3602
0
    }
3603
0
    if (pStr)
3604
0
        AddStringItem(*pEntry, *pStr, pEntry->ItemCount());
3605
0
    pEntry->SetUserData(pUserData);
3606
0
    m_xTreeView->Insert(pEntry, nInsertPos, iter);
3607
3608
0
    if (pRet)
3609
0
    {
3610
0
        SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
3611
0
        pVclRetIter->iter = pEntry;
3612
0
    }
3613
3614
0
    if (bChildrenOnDemand)
3615
0
    {
3616
0
        SvTreeListEntry& rPlaceHolder = InsertDummyEntry(pEntry);
3617
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rPlaceHolder);
3618
0
        rViewData.SetSelectable(false);
3619
0
    }
3620
3621
0
    if (bIsSeparator)
3622
0
    {
3623
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pEntry);
3624
0
        rViewData.SetSelectable(false);
3625
0
    }
3626
0
}
3627
3628
void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry& rEntry)
3629
0
{
3630
0
    SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rEntry);
3631
0
    m_xTreeView->InitViewData(rViewData, rEntry);
3632
0
    m_xTreeView->CheckBoxInserted(rEntry);
3633
0
}
3634
3635
void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry* pEntry)
3636
0
{
3637
0
    if (!m_xTreeView->GetModel()->IsEnableInvalidate())
3638
0
        return;
3639
0
    m_xTreeView->ModelHasEntryInvalidated(pEntry);
3640
0
}
3641
3642
void SalInstanceTreeView::set_toggle(SvTreeListEntry& rEntry, TriState eState, int col)
3643
0
{
3644
0
    assert(col >= 0 && o3tl::make_unsigned(col) < rEntry.ItemCount());
3645
    // if it's the placeholder to allow a blank column, replace it now
3646
0
    if (rEntry.GetItem(col).GetType() != SvLBoxItemType::Button)
3647
0
    {
3648
0
        SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
3649
0
        rEntry.ReplaceItem(std::make_unique<SvLBoxButton>(rData), 0);
3650
0
        update_checkbutton_column_width(rEntry);
3651
0
    }
3652
0
    SvLBoxItem& rItem = rEntry.GetItem(col);
3653
0
    assert(dynamic_cast<SvLBoxButton*>(&rItem));
3654
0
    switch (eState)
3655
0
    {
3656
0
        case TRISTATE_TRUE:
3657
0
            static_cast<SvLBoxButton&>(rItem).SetStateChecked();
3658
0
            break;
3659
0
        case TRISTATE_FALSE:
3660
0
            static_cast<SvLBoxButton&>(rItem).SetStateUnchecked();
3661
0
            break;
3662
0
        case TRISTATE_INDET:
3663
0
            static_cast<SvLBoxButton&>(rItem).SetStateTristate();
3664
0
            break;
3665
0
    }
3666
3667
0
    InvalidateModelEntry(&rEntry);
3668
0
}
3669
3670
TriState SalInstanceTreeView::do_get_toggle(SvTreeListEntry* pEntry, int col)
3671
0
{
3672
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
3673
0
        return TRISTATE_FALSE;
3674
3675
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
3676
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
3677
0
    assert(dynamic_cast<SvLBoxButton*>(&rItem));
3678
0
    SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem);
3679
0
    if (rToggle.IsStateTristate())
3680
0
        return TRISTATE_INDET;
3681
0
    else if (rToggle.IsStateChecked())
3682
0
        return TRISTATE_TRUE;
3683
0
    return TRISTATE_FALSE;
3684
0
}
3685
3686
TriState SalInstanceTreeView::get_toggle(SvTreeListEntry* pEntry, int col) const
3687
0
{
3688
0
    if (col == -1)
3689
0
    {
3690
0
        assert(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
3691
0
        return do_get_toggle(pEntry, 0);
3692
0
    }
3693
0
    col = to_internal_model(col);
3694
0
    return do_get_toggle(pEntry, col);
3695
0
}
3696
3697
bool SalInstanceTreeView::get_text_emphasis(SvTreeListEntry* pEntry, int col) const
3698
0
{
3699
0
    col = to_internal_model(col);
3700
3701
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
3702
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
3703
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
3704
0
    return static_cast<SvLBoxString&>(rItem).IsEmphasized();
3705
0
}
3706
3707
void SalInstanceTreeView::set_header_item_width(const std::vector<int>& rWidths)
3708
0
{
3709
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3710
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3711
0
    {
3712
0
        for (size_t i = 0; i < rWidths.size(); ++i)
3713
0
            pHeaderBar->SetItemSize(pHeaderBar->GetItemId(i), rWidths[i]);
3714
0
    }
3715
0
}
3716
3717
SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder,
3718
                                         bool bTakeOwnership)
3719
0
    : SalInstanceItemView(pTreeView, pBuilder, bTakeOwnership)
3720
0
    , m_xTreeView(pTreeView)
3721
0
    , m_aCheckButtonData(*pTreeView, false)
3722
0
    , m_aRadioButtonData(*pTreeView, true)
3723
0
    , m_bTogglesAsRadio(false)
3724
0
    , m_nSortColumn(-1)
3725
0
{
3726
0
    m_xTreeView->SetNodeDefaultImages();
3727
0
    m_xTreeView->SetForceMakeVisible(true);
3728
0
    m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
3729
0
    m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
3730
0
    m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl));
3731
0
    m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, CustomRenderHdl));
3732
0
    m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, CustomMeasureHdl));
3733
0
    const std::vector<tools::Long> aTabPositions{ 0 };
3734
0
    m_xTreeView->SetTabs(aTabPositions);
3735
    // by default, 1st one is editable, others not; override with set_column_editables
3736
0
    m_xTreeView->SetTabEditable(0, true);
3737
3738
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3739
3740
0
    if (pHeaderBox)
3741
0
    {
3742
0
        if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
3743
0
        {
3744
            //make the last entry fill available space
3745
0
            pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1),
3746
0
                                    HEADERBAR_FULLSIZE);
3747
0
            pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
3748
0
            pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl));
3749
0
        }
3750
0
    }
3751
0
    else
3752
0
    {
3753
0
        LclTabListBox& rLclTabListBox = static_cast<LclTabListBox&>(*m_xTreeView);
3754
0
        rLclTabListBox.SetModelChangedHdl(LINK(this, SalInstanceTreeView, ModelChangedHdl));
3755
0
        rLclTabListBox.SetStartDragHdl(LINK(this, SalInstanceTreeView, StartDragHdl));
3756
0
        rLclTabListBox.SetEndDragHdl(LINK(this, SalInstanceTreeView, FinishDragHdl));
3757
0
    }
3758
0
    m_xTreeView->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
3759
0
    m_xTreeView->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
3760
3761
0
    m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
3762
0
    m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
3763
0
}
Unexecuted instantiation: SalInstanceTreeView::SalInstanceTreeView(SvTabListBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceTreeView::SalInstanceTreeView(SvTabListBox*, SalInstanceBuilder*, bool)
3764
3765
void SalInstanceTreeView::connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink)
3766
0
{
3767
0
    weld::TreeView::connect_query_tooltip(rLink);
3768
0
    m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl));
3769
0
}
3770
3771
void SalInstanceTreeView::columns_autosize()
3772
0
{
3773
0
    std::vector<tools::Long> aWidths;
3774
0
    m_xTreeView->getPreferredDimensions(aWidths);
3775
0
    if (aWidths.size() > 2)
3776
0
    {
3777
0
        std::vector<int> aColWidths;
3778
0
        aColWidths.push_back(aWidths[1] + aWidths[0]);
3779
0
        aColWidths.insert(aColWidths.end(), aWidths.begin() + 2, aWidths.end());
3780
3781
        // take column headers into account
3782
0
        if (VclPtr<SvHeaderTabListBox> pTabListBox
3783
0
            = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3784
0
        {
3785
0
            if (VclPtr<HeaderBar> pHeaderBar = pTabListBox->GetHeaderBar())
3786
0
            {
3787
0
                const size_t nCount
3788
0
                    = std::min(aColWidths.size(), size_t(pHeaderBar->GetItemCount()));
3789
0
                for (size_t i = 0; i < nCount; ++i)
3790
0
                {
3791
0
                    const OUString sHeaderText = pHeaderBar->GetItemText(pHeaderBar->GetItemId(i));
3792
0
                    constexpr int PADDING = 6;
3793
0
                    const int nHeaderColWidth = pHeaderBar->GetTextWidth(sHeaderText) + PADDING;
3794
0
                    aColWidths[i] = std::max(aColWidths.at(i), nHeaderColWidth);
3795
0
                }
3796
0
            }
3797
0
        }
3798
3799
0
        set_column_fixed_widths(aColWidths);
3800
0
    }
3801
0
}
3802
3803
void SalInstanceTreeView::freeze()
3804
0
{
3805
0
    bool bIsFirstFreeze = IsFirstFreeze();
3806
0
    SalInstanceWidget::freeze();
3807
0
    if (bIsFirstFreeze)
3808
0
    {
3809
0
        m_xTreeView->SetUpdateMode(false);
3810
0
        m_xTreeView->GetModel()->EnableInvalidate(false);
3811
0
    }
3812
0
}
3813
3814
void SalInstanceTreeView::thaw()
3815
0
{
3816
0
    bool bIsLastThaw = IsLastThaw();
3817
0
    if (bIsLastThaw)
3818
0
    {
3819
0
        m_xTreeView->GetModel()->EnableInvalidate(true);
3820
0
        m_xTreeView->SetUpdateMode(true);
3821
0
    }
3822
0
    SalInstanceWidget::thaw();
3823
0
}
3824
3825
void SalInstanceTreeView::set_column_fixed_widths(const std::vector<int>& rWidths)
3826
0
{
3827
0
    std::vector<tools::Long> aTabPositions{ 0 };
3828
0
    for (size_t i = 0; i < rWidths.size(); ++i)
3829
0
        aTabPositions.push_back(aTabPositions[i]
3830
0
                                + (m_xTreeView->GetTabVisible(i) ? rWidths[i] : 0));
3831
0
    m_xTreeView->SetTabs(aTabPositions);
3832
0
    set_header_item_width(rWidths);
3833
    // call Resize to recalculate based on the new tabs
3834
0
    m_xTreeView->Resize();
3835
0
}
3836
3837
void SalInstanceTreeView::set_column_editables(const std::vector<bool>& rEditables)
3838
0
{
3839
0
    size_t nTabCount = rEditables.size();
3840
0
    for (size_t i = 0; i < nTabCount; ++i)
3841
0
        m_xTreeView->SetTabEditable(i, rEditables[i]);
3842
0
}
3843
3844
0
void SalInstanceTreeView::set_centered_column(int nCol) { m_xTreeView->SetTabAlignCenter(nCol); }
3845
3846
int SalInstanceTreeView::get_column_width(int nColumn) const
3847
0
{
3848
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3849
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3850
0
        return pHeaderBar->GetItemSize(pHeaderBar->GetItemId(nColumn));
3851
    // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
3852
    // So the first text column's width is Tab(2)-Tab(1).
3853
0
    auto nWidthPixel
3854
0
        = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1);
3855
0
    nWidthPixel -= SV_TAB_BORDER;
3856
0
    return nWidthPixel;
3857
0
}
3858
3859
OUString SalInstanceTreeView::get_column_title(int nColumn) const
3860
0
{
3861
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3862
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3863
0
    {
3864
0
        return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn));
3865
0
    }
3866
0
    return OUString();
3867
0
}
3868
3869
void SalInstanceTreeView::set_column_title(int nColumn, const OUString& rTitle)
3870
0
{
3871
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3872
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3873
0
    {
3874
0
        return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle);
3875
0
    }
3876
0
}
3877
3878
bool SalInstanceTreeView::get_column_visible(int nColumn) const
3879
0
{
3880
0
    return m_xTreeView->GetTabVisible(nColumn);
3881
0
}
3882
3883
void SalInstanceTreeView::set_column_visible(int nColumn, const bool bVisible)
3884
0
{
3885
0
    tools::Long width = bVisible ? m_xTreeView->GetEntryWidth() : 0;
3886
0
    m_xTreeView->SetTabWidth(nColumn, width);
3887
3888
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
3889
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
3890
0
    {
3891
0
        sal_uInt16 nItemId = pHeaderBar->GetItemId(nColumn);
3892
0
        pHeaderBar->SetItemVisible(nItemId, bVisible);
3893
0
        pHeaderBar->SetItemSize(nItemId, width);
3894
0
    }
3895
3896
    // Set flag for columns_autosize() to respect the visibility
3897
0
    m_xTreeView->SetTabVisible(nColumn, bVisible);
3898
3899
    // call Resize to recalculate based on the new tab positions
3900
0
    m_xTreeView->Resize();
3901
0
}
3902
3903
void SalInstanceTreeView::set_column_custom_renderer(int nColumn, bool bEnable)
3904
0
{
3905
0
    assert(n_children() == 0 && "tree must be empty");
3906
0
    if (bEnable)
3907
0
        m_aCustomRenders.insert(nColumn);
3908
0
    else
3909
0
        m_aCustomRenders.erase(nColumn);
3910
0
}
3911
3912
void SalInstanceTreeView::queue_draw()
3913
0
{
3914
    // invalidate the entries
3915
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
3916
0
        m_xTreeView->InvalidateEntry(*pEntry);
3917
0
}
3918
3919
void SalInstanceTreeView::show()
3920
0
{
3921
0
    if (SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3922
0
        pHeaderBox->GetParent()->Show();
3923
0
    SalInstanceWidget::show();
3924
0
}
3925
3926
void SalInstanceTreeView::hide()
3927
0
{
3928
0
    if (SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()))
3929
0
        pHeaderBox->GetParent()->Hide();
3930
0
    SalInstanceWidget::hide();
3931
0
}
3932
3933
void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
3934
                                    const OUString* pId, const OUString* pIconName,
3935
                                    VirtualDevice* pImageSurface, bool bChildrenOnDemand,
3936
                                    weld::TreeIter* pRet)
3937
0
{
3938
0
    do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet, false);
3939
0
}
3940
3941
void SalInstanceTreeView::do_insert_separator(int pos, const OUString& /*rId*/)
3942
0
{
3943
0
    OUString sSep(VclResId(STR_SEPARATOR));
3944
0
    do_insert(nullptr, pos, &sSep, nullptr, nullptr, nullptr, false, nullptr, true);
3945
0
}
3946
3947
void SalInstanceTreeView::bulk_insert_for_each(
3948
    int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
3949
    const weld::TreeIter* pParent, const std::vector<int>* pFixedWidths, bool bGoingToSetText, bool)
3950
0
{
3951
0
    const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
3952
0
    SvTreeListEntry* pVclParent = pVclIter ? pVclIter->iter : nullptr;
3953
3954
0
    freeze();
3955
0
    if (!pVclParent)
3956
0
        clear();
3957
0
    else
3958
0
    {
3959
0
        while (SvTreeListEntry* pChild = m_xTreeView->FirstChild(pVclParent))
3960
0
            m_xTreeView->RemoveEntry(pChild);
3961
0
    }
3962
0
    SalInstanceTreeIter aVclIter(*this, static_cast<SvTreeListEntry*>(nullptr));
3963
3964
0
    m_xTreeView->m_nTreeFlags |= SvTreeFlags::MANINS;
3965
3966
0
    if (pFixedWidths)
3967
0
        set_header_item_width(*pFixedWidths);
3968
3969
0
    bool bHasAutoCheckButton(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
3970
0
    size_t nExtraCols = bHasAutoCheckButton ? 2 : 1;
3971
3972
0
    Image aDummy;
3973
0
    for (int i = 0; i < nSourceCount; ++i)
3974
0
    {
3975
0
        aVclIter.iter = new SvTreeListEntry;
3976
0
        if (bHasAutoCheckButton)
3977
0
            AddStringItem(*aVclIter.iter, u""_ustr, -1);
3978
0
        aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
3979
0
        if (bGoingToSetText)
3980
0
            AddStringItem(*aVclIter.iter, u""_ustr, aVclIter.iter->ItemCount());
3981
0
        m_xTreeView->Insert(aVclIter.iter, TREELIST_APPEND, pVclParent);
3982
0
        func(aVclIter, i);
3983
0
        m_xTreeView->CalcEntryHeight(*aVclIter.iter);
3984
3985
0
        if (!pFixedWidths)
3986
0
            continue;
3987
3988
0
        size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
3989
0
        for (size_t j = 0; j < nFixedWidths; ++j)
3990
0
        {
3991
0
            SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols);
3992
0
            SvViewDataItem& rViewDataItem = m_xTreeView->GetViewDataItem(*aVclIter.iter, rItem);
3993
0
            rViewDataItem.mnWidth = (*pFixedWidths)[j];
3994
0
        }
3995
0
    }
3996
3997
0
    m_xTreeView->m_nTreeFlags &= ~SvTreeFlags::MANINS;
3998
3999
0
    thaw();
4000
0
}
4001
4002
void SalInstanceTreeView::set_font_color(const weld::TreeIter& rIter, const Color& rColor)
4003
0
{
4004
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4005
0
    set_font_color(rVclIter.iter, rColor);
4006
0
}
4007
4008
int SalInstanceTreeView::find_text(const OUString& rText) const
4009
0
{
4010
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
4011
0
    {
4012
0
        if (SvTabListBox::GetEntryText(pEntry, 0) == rText)
4013
0
            return SvTreeList::GetRelPos(pEntry);
4014
0
    }
4015
0
    return -1;
4016
0
}
4017
4018
int SalInstanceTreeView::find_id(const OUString& rId) const
4019
0
{
4020
0
    for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
4021
0
    {
4022
0
        const OUString* pId = pEntry->GetUserData();
4023
0
        if (!pId)
4024
0
            continue;
4025
0
        if (rId == *pId)
4026
0
            return SvTreeList::GetRelPos(pEntry);
4027
0
    }
4028
0
    return -1;
4029
0
}
4030
4031
void SalInstanceTreeView::swap(int pos1, int pos2)
4032
0
{
4033
0
    int min = std::min(pos1, pos2);
4034
0
    int max = std::max(pos1, pos2);
4035
0
    SvTreeList* pModel = m_xTreeView->GetModel();
4036
0
    SvTreeListEntry* pEntry1 = pModel->GetEntry(nullptr, min);
4037
0
    SvTreeListEntry* pEntry2 = pModel->GetEntry(nullptr, max);
4038
0
    pModel->Move(pEntry1, pEntry2);
4039
0
}
4040
4041
int SalInstanceTreeView::do_iter_n_children(const weld::TreeIter& rIter) const
4042
0
{
4043
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4044
0
    return m_xTreeView->GetModel()->GetChildList(rVclIter.iter).size();
4045
0
}
4046
4047
void SalInstanceTreeView::do_set_cursor(int pos)
4048
0
{
4049
0
    if (pos == -1)
4050
0
        m_xTreeView->SetCurEntry(nullptr);
4051
0
    else
4052
0
    {
4053
0
        SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
4054
0
        m_xTreeView->SetCurEntry(pEntry);
4055
0
    }
4056
0
}
4057
4058
std::vector<int> SalInstanceTreeView::get_selected_rows() const
4059
0
{
4060
0
    std::vector<int> aRows;
4061
4062
0
    aRows.reserve(m_xTreeView->GetSelectionCount());
4063
0
    for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry;
4064
0
         pEntry = m_xTreeView->NextSelected(pEntry))
4065
0
        aRows.push_back(SvTreeList::GetRelPos(pEntry));
4066
4067
0
    return aRows;
4068
0
}
4069
4070
void SalInstanceTreeView::set_text(SvTreeListEntry& rEntry, const OUString& rText, int col)
4071
0
{
4072
0
    if (col == -1)
4073
0
    {
4074
0
        m_xTreeView->SetEntryText(rEntry, rText);
4075
0
        return;
4076
0
    }
4077
4078
0
    col = to_internal_model(col);
4079
4080
    // blank out missing entries
4081
0
    for (int i = rEntry.ItemCount(); i < col; ++i)
4082
0
        AddStringItem(rEntry, u""_ustr, i - 1);
4083
4084
0
    if (static_cast<size_t>(col) == rEntry.ItemCount())
4085
0
    {
4086
0
        AddStringItem(rEntry, rText, col - 1);
4087
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(rEntry);
4088
0
        m_xTreeView->InitViewData(rViewData, rEntry);
4089
0
    }
4090
0
    else
4091
0
    {
4092
0
        assert(col >= 0 && o3tl::make_unsigned(col) < rEntry.ItemCount());
4093
0
        SvLBoxItem& rItem = rEntry.GetItem(col);
4094
0
        assert(dynamic_cast<SvLBoxString*>(&rItem));
4095
0
        static_cast<SvLBoxString&>(rItem).SetText(rText);
4096
0
    }
4097
4098
0
    InvalidateModelEntry(&rEntry);
4099
0
}
4100
4101
void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col)
4102
0
{
4103
0
    if (col == -1)
4104
0
    {
4105
0
        auto nFlags = pEntry->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT;
4106
0
        if (!bSensitive)
4107
0
            nFlags = nFlags | SvTLEntryFlags::SEMITRANSPARENT;
4108
0
        pEntry->SetFlags(nFlags);
4109
0
        const sal_uInt16 nCount = pEntry->ItemCount();
4110
0
        for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur)
4111
0
        {
4112
0
            SvLBoxItem& rItem = pEntry->GetItem(nCur);
4113
0
            if (rItem.GetType() == SvLBoxItemType::String
4114
0
                || rItem.GetType() == SvLBoxItemType::Button
4115
0
                || rItem.GetType() == SvLBoxItemType::ContextBmp)
4116
0
            {
4117
0
                rItem.Enable(bSensitive);
4118
0
                InvalidateModelEntry(pEntry);
4119
0
            }
4120
0
        }
4121
0
        return;
4122
0
    }
4123
4124
0
    col = to_internal_model(col);
4125
4126
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4127
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4128
0
    rItem.Enable(bSensitive);
4129
4130
0
    InvalidateModelEntry(pEntry);
4131
0
}
4132
4133
bool SalInstanceTreeView::do_get_sensitive(SvTreeListEntry* pEntry, int col)
4134
0
{
4135
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
4136
0
        return false;
4137
4138
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4139
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4140
0
    return rItem.isEnable();
4141
0
}
4142
4143
bool SalInstanceTreeView::get_sensitive(SvTreeListEntry* pEntry, int col) const
4144
0
{
4145
0
    col = to_internal_model(col);
4146
0
    return do_get_sensitive(pEntry, col);
4147
0
}
4148
4149
void SalInstanceTreeView::set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col)
4150
0
{
4151
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4152
0
    set_sensitive(rVclIter.iter, bSensitive, col);
4153
0
}
4154
4155
bool SalInstanceTreeView::get_sensitive(const weld::TreeIter& rIter, int col) const
4156
0
{
4157
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4158
0
    return get_sensitive(rVclIter.iter, col);
4159
0
}
4160
4161
TriState SalInstanceTreeView::get_toggle(const weld::TreeIter& rIter, int col) const
4162
0
{
4163
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4164
0
    return get_toggle(rVclIter.iter, col);
4165
0
}
4166
4167
void SalInstanceTreeView::enable_toggle_buttons()
4168
0
{
4169
0
    assert(n_children() == 0 && "tree must be empty");
4170
4171
0
    SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
4172
0
    m_xTreeView->EnableCheckButton(rData);
4173
0
}
4174
4175
void SalInstanceTreeView::set_toggle_button_type(weld::ColumnToggleType eType)
4176
0
{
4177
0
    assert(n_children() == 0 && "tree must be empty");
4178
0
    m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio;
4179
4180
    // Update type of check buttons to use for the special toggle button column, if active
4181
0
    if (m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN)
4182
0
        enable_toggle_buttons();
4183
0
}
4184
4185
void SalInstanceTreeView::do_set_toggle(const weld::TreeIter& rIter, TriState eState, int col)
4186
0
{
4187
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4188
0
    assert(rVclIter.iter && "Invalid iter");
4189
0
    SvTreeListEntry& rEntry = *rVclIter.iter;
4190
4191
0
    if (col == -1)
4192
0
    {
4193
0
        assert(m_xTreeView->m_nTreeFlags & SvTreeFlags::CHKBTN);
4194
0
        set_toggle(rEntry, eState, 0);
4195
0
        return;
4196
0
    }
4197
4198
0
    col = to_internal_model(col);
4199
4200
    // blank out missing entries
4201
0
    for (int i = rEntry.ItemCount(); i < col; ++i)
4202
0
        AddStringItem(rEntry, u""_ustr, i - 1);
4203
4204
0
    if (static_cast<size_t>(col) == rEntry.ItemCount())
4205
0
    {
4206
0
        SvLBoxButtonData& rData = m_bTogglesAsRadio ? m_aRadioButtonData : m_aCheckButtonData;
4207
0
        rEntry.AddItem(std::make_unique<SvLBoxButton>(rData));
4208
0
        update_checkbutton_column_width(rEntry);
4209
0
    }
4210
4211
0
    set_toggle(rEntry, eState, col);
4212
0
}
4213
4214
void SalInstanceTreeView::set_clicks_to_toggle(int nToggleBehavior)
4215
0
{
4216
0
    m_xTreeView->SetClicksToToggle(nToggleBehavior);
4217
0
}
4218
4219
void SalInstanceTreeView::set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel)
4220
0
{
4221
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4222
0
    rVclIter.iter->SetExtraIndent(nIndentLevel);
4223
0
}
4224
4225
void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col)
4226
0
{
4227
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4228
0
    SvTreeListEntry* pEntry = rVclIter.iter;
4229
4230
0
    if (col == -1)
4231
0
    {
4232
0
        for (size_t nCur = 0; nCur < pEntry->ItemCount(); ++nCur)
4233
0
        {
4234
0
            SvLBoxItem& rItem = pEntry->GetItem(nCur);
4235
0
            if (rItem.GetType() == SvLBoxItemType::String)
4236
0
            {
4237
0
                static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
4238
0
                InvalidateModelEntry(pEntry);
4239
0
            }
4240
0
        }
4241
0
        return;
4242
0
    }
4243
4244
0
    col = to_internal_model(col);
4245
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4246
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4247
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4248
0
    static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
4249
4250
0
    InvalidateModelEntry(pEntry);
4251
0
}
4252
4253
bool SalInstanceTreeView::get_text_emphasis(const weld::TreeIter& rIter, int col) const
4254
0
{
4255
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4256
0
    return get_text_emphasis(rVclIter.iter, col);
4257
0
}
4258
4259
void SalInstanceTreeView::set_text_align(SvTreeListEntry* pEntry, TxtAlign eAlign, int col)
4260
0
{
4261
0
    col = to_internal_model(col);
4262
4263
0
    assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4264
0
    SvLBoxItem& rItem = pEntry->GetItem(col);
4265
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4266
0
    static_cast<SvLBoxString&>(rItem).Align(eAlign);
4267
4268
0
    InvalidateModelEntry(pEntry);
4269
0
}
4270
4271
void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, TxtAlign eAlign, int col)
4272
0
{
4273
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4274
0
    set_text_align(rVclIter.iter, eAlign, col);
4275
0
}
4276
4277
void SalInstanceTreeView::connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
4278
                                          const Link<const IterColText&, bool>& rEndLink)
4279
0
{
4280
0
    m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet());
4281
0
    weld::TreeView::connect_editing(rStartLink, rEndLink);
4282
0
}
4283
4284
void SalInstanceTreeView::start_editing(const weld::TreeIter& rIter)
4285
0
{
4286
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4287
0
    m_xTreeView->EditEntry(rVclIter.iter);
4288
0
}
4289
4290
0
void SalInstanceTreeView::end_editing() { m_xTreeView->EndEditing(); }
4291
4292
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, const Image& rImage, int col)
4293
0
{
4294
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4295
0
    SvTreeListEntry* pEntry = rVclIter.iter;
4296
0
    assert(pEntry);
4297
4298
0
    if (col == -1 || col == 0)
4299
0
    {
4300
0
        m_xTreeView->SetExpandedEntryBmp(*pEntry, rImage);
4301
0
        m_xTreeView->SetCollapsedEntryBmp(*pEntry, rImage);
4302
0
        return;
4303
0
    }
4304
4305
0
    col = to_internal_model(col);
4306
4307
    // blank out missing entries
4308
0
    for (int i = pEntry->ItemCount(); i < col; ++i)
4309
0
        AddStringItem(*pEntry, u""_ustr, i - 1);
4310
4311
0
    if (static_cast<size_t>(col) == pEntry->ItemCount())
4312
0
    {
4313
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage));
4314
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pEntry);
4315
0
        m_xTreeView->InitViewData(rViewData, *pEntry);
4316
0
    }
4317
0
    else
4318
0
    {
4319
0
        assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
4320
0
        SvLBoxItem& rItem = pEntry->GetItem(col);
4321
0
        assert(dynamic_cast<SvLBoxContextBmp*>(&rItem));
4322
0
        static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage);
4323
0
        static_cast<SvLBoxContextBmp&>(rItem).SetBitmap2(rImage);
4324
0
    }
4325
4326
0
    m_xTreeView->CalcEntryHeight(*pEntry);
4327
0
    InvalidateModelEntry(pEntry);
4328
0
}
4329
4330
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, const OUString& rImage, int col)
4331
0
{
4332
0
    set_image(rIter, createImage(rImage), col);
4333
0
}
4334
4335
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter,
4336
                                    const css::uno::Reference<css::graphic::XGraphic>& rImage,
4337
                                    int col)
4338
0
{
4339
0
    set_image(rIter, Image(rImage), col);
4340
0
}
4341
4342
void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, VirtualDevice& rImage, int col)
4343
0
{
4344
0
    set_image(rIter, createImage(rImage), col);
4345
0
}
4346
4347
void SalInstanceTreeView::copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const
4348
0
{
4349
0
    const SalInstanceTreeIter& rVclSource(static_cast<const SalInstanceTreeIter&>(rSource));
4350
0
    SalInstanceTreeIter& rVclDest(static_cast<SalInstanceTreeIter&>(rDest));
4351
0
    rVclDest.iter = rVclSource.iter;
4352
0
}
4353
4354
bool SalInstanceTreeView::iter_previous_sibling(weld::TreeIter& rIter) const
4355
0
{
4356
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4357
0
    SvTreeListEntry* pSibling = rVclIter.iter->PrevSibling();
4358
0
    if (!pSibling)
4359
0
        return false;
4360
4361
0
    rVclIter.iter = pSibling;
4362
0
    return true;
4363
0
}
4364
4365
bool SalInstanceTreeView::do_iter_children(weld::TreeIter& rIter) const
4366
0
{
4367
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4368
0
    SvTreeListEntry* pChild = m_xTreeView->FirstChild(rVclIter.iter);
4369
0
    if (!pChild)
4370
0
        return false;
4371
4372
0
    rVclIter.iter = pChild;
4373
0
    return true;
4374
0
}
4375
4376
bool SalInstanceTreeView::iter_parent(weld::TreeIter& rIter) const
4377
0
{
4378
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
4379
0
    SvTreeListEntry* pParent = m_xTreeView->GetParent(rVclIter.iter);
4380
0
    if (!pParent)
4381
0
        return false;
4382
4383
0
    rVclIter.iter = pParent;
4384
0
    return true;
4385
0
}
4386
4387
void SalInstanceTreeView::do_select(const weld::TreeIter& rIter)
4388
0
{
4389
0
    assert(m_xTreeView->IsUpdateMode()
4390
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4391
0
              "freeze");
4392
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4393
0
    m_xTreeView->Select(rVclIter.iter, true);
4394
0
}
4395
4396
void SalInstanceTreeView::do_scroll_to_row(const weld::TreeIter& rIter)
4397
0
{
4398
0
    assert(m_xTreeView->IsUpdateMode()
4399
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4400
0
              "freeze");
4401
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4402
0
    m_xTreeView->MakeVisible(rVclIter.iter);
4403
0
}
4404
4405
void SalInstanceTreeView::do_unselect(const weld::TreeIter& rIter)
4406
0
{
4407
0
    assert(m_xTreeView->IsUpdateMode() && "don't unselect when frozen");
4408
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4409
0
    m_xTreeView->Select(rVclIter.iter, false);
4410
0
}
4411
4412
int SalInstanceTreeView::get_iter_depth(const weld::TreeIter& rIter) const
4413
0
{
4414
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4415
0
    return m_xTreeView->GetModel()->GetDepth(rVclIter.iter);
4416
0
}
4417
4418
bool SalInstanceTreeView::get_row_expanded(const weld::TreeIter& rIter) const
4419
0
{
4420
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4421
0
    return m_xTreeView->IsExpanded(rVclIter.iter);
4422
0
}
4423
4424
bool SalInstanceTreeView::get_children_on_demand(const weld::TreeIter& rIter) const
4425
0
{
4426
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4427
0
    if (m_aExpandingPlaceHolderParents.contains(rVclIter.iter))
4428
0
        return true;
4429
0
    return GetPlaceHolderChild(rVclIter.iter) != nullptr;
4430
0
}
4431
4432
void SalInstanceTreeView::do_set_children_on_demand(const weld::TreeIter& rIter,
4433
                                                    bool bChildrenOnDemand)
4434
0
{
4435
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4436
4437
0
    SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(rVclIter.iter);
4438
4439
0
    if (bChildrenOnDemand && !pPlaceHolder)
4440
0
    {
4441
0
        pPlaceHolder = &InsertDummyEntry(rVclIter.iter);
4442
0
        SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pPlaceHolder);
4443
0
        rViewData.SetSelectable(false);
4444
0
    }
4445
0
    else if (!bChildrenOnDemand && pPlaceHolder)
4446
0
        m_xTreeView->RemoveEntry(pPlaceHolder);
4447
0
}
4448
4449
void SalInstanceTreeView::expand_row(const weld::TreeIter& rIter)
4450
0
{
4451
0
    assert(m_xTreeView->IsUpdateMode() && "don't expand when frozen");
4452
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4453
0
    assert(rVclIter.iter);
4454
0
    if (!m_xTreeView->IsExpanded(rVclIter.iter) && ExpandRow(rVclIter))
4455
0
        m_xTreeView->Expand(*rVclIter.iter);
4456
0
}
4457
4458
void SalInstanceTreeView::collapse_row(const weld::TreeIter& rIter)
4459
0
{
4460
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4461
0
    if (m_xTreeView->IsExpanded(rVclIter.iter) && signal_collapsing(rIter))
4462
0
        m_xTreeView->Collapse(rVclIter.iter);
4463
0
}
4464
4465
OUString SalInstanceTreeView::get_text(const weld::TreeIter& rIter, int col) const
4466
0
{
4467
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4468
4469
0
    if (col == -1)
4470
0
        return SvTabListBox::GetEntryText(rVclIter.iter, 0);
4471
4472
0
    col = to_internal_model(col);
4473
4474
0
    if (static_cast<size_t>(col) == rVclIter.iter->ItemCount())
4475
0
        return OUString();
4476
4477
0
    assert(col >= 0 && o3tl::make_unsigned(col) < rVclIter.iter->ItemCount());
4478
0
    SvLBoxItem& rItem = rVclIter.iter->GetItem(col);
4479
0
    assert(dynamic_cast<SvLBoxString*>(&rItem));
4480
0
    return static_cast<SvLBoxString&>(rItem).GetText();
4481
0
}
4482
4483
void SalInstanceTreeView::set_text(const weld::TreeIter& rIter, const OUString& rText, int col)
4484
0
{
4485
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4486
0
    assert(rVclIter.iter && "Invalid iter");
4487
0
    set_text(*rVclIter.iter, rText, col);
4488
0
}
4489
4490
void SalInstanceTreeView::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
4491
                                             sal_uInt8 eDNDConstants)
4492
0
{
4493
0
    m_xTreeView->SetDragHelper(rHelper, eDNDConstants);
4494
0
}
4495
4496
void SalInstanceTreeView::set_selection_mode(SelectionMode eMode)
4497
0
{
4498
0
    m_xTreeView->SetSelectionMode(eMode);
4499
0
}
4500
4501
void SalInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>& func)
4502
0
{
4503
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4504
4505
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->First());
4506
0
    bool bContinue = aVclIter.iter;
4507
0
    while (bContinue)
4508
0
    {
4509
0
        if (func(aVclIter))
4510
0
            return;
4511
0
        bContinue = iter_next(aVclIter);
4512
0
    }
4513
0
}
4514
4515
void SalInstanceTreeView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
4516
0
{
4517
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4518
4519
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->FirstSelected());
4520
0
    while (aVclIter.iter)
4521
0
    {
4522
0
        if (func(aVclIter))
4523
0
            return;
4524
0
        aVclIter.iter = m_xTreeView->NextSelected(aVclIter.iter);
4525
0
    }
4526
0
}
4527
4528
void SalInstanceTreeView::visible_foreach(const std::function<bool(weld::TreeIter&)>& func)
4529
0
{
4530
0
    UpdateGuardIfHidden aGuard(*m_xTreeView);
4531
4532
0
    SalInstanceTreeIter aVclIter(*this, m_xTreeView->GetFirstEntryInView());
4533
0
    while (aVclIter.iter)
4534
0
    {
4535
0
        if (func(aVclIter))
4536
0
            return;
4537
0
        aVclIter.iter = m_xTreeView->GetNextEntryInView(aVclIter.iter);
4538
0
    }
4539
0
}
4540
4541
void SalInstanceTreeView::connect_visible_range_changed(const Link<weld::TreeView&, void>& rLink)
4542
0
{
4543
0
    m_xTreeView->SetCustomEntryRenderer(true);
4544
0
    weld::TreeView::connect_visible_range_changed(rLink);
4545
0
    m_xTreeView->SetScrolledHdl(LINK(this, SalInstanceTreeView, VisibleRangeChangedHdl));
4546
0
}
4547
4548
void SalInstanceTreeView::do_remove_selection()
4549
0
{
4550
0
    SvTreeListEntry* pSelected = m_xTreeView->FirstSelected();
4551
0
    while (pSelected)
4552
0
    {
4553
0
        SvTreeListEntry* pNextSelected = m_xTreeView->NextSelected(pSelected);
4554
0
        m_xTreeView->RemoveEntry(pSelected);
4555
0
        pSelected = pNextSelected;
4556
0
    }
4557
0
}
4558
4559
bool SalInstanceTreeView::is_selected(const weld::TreeIter& rIter) const
4560
0
{
4561
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4562
0
    return m_xTreeView->IsSelected(rVclIter.iter);
4563
0
}
4564
4565
int SalInstanceTreeView::iter_compare(const weld::TreeIter& a, const weld::TreeIter& b) const
4566
0
{
4567
0
    const SalInstanceTreeIter& rVclIterA = static_cast<const SalInstanceTreeIter&>(a);
4568
0
    const SalInstanceTreeIter& rVclIterB = static_cast<const SalInstanceTreeIter&>(b);
4569
0
    const SvTreeList* pModel = m_xTreeView->GetModel();
4570
0
    auto nAbsPosA = pModel->GetAbsPos(rVclIterA.iter);
4571
0
    auto nAbsPosB = pModel->GetAbsPos(rVclIterB.iter);
4572
0
    if (nAbsPosA < nAbsPosB)
4573
0
        return -1;
4574
0
    if (nAbsPosA > nAbsPosB)
4575
0
        return 1;
4576
0
    return 0;
4577
0
}
4578
4579
void SalInstanceTreeView::move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent,
4580
                                       int nIndexInNewParent)
4581
0
{
4582
0
    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNode);
4583
0
    const SalInstanceTreeIter* pVclParentIter = static_cast<const SalInstanceTreeIter*>(pNewParent);
4584
0
    m_xTreeView->GetModel()->Move(rVclIter.iter, pVclParentIter ? pVclParentIter->iter : nullptr,
4585
0
                                  nIndexInNewParent);
4586
0
}
4587
4588
0
int SalInstanceTreeView::count_selected_rows() const { return m_xTreeView->GetSelectionCount(); }
4589
4590
int SalInstanceTreeView::get_height_rows(int nRows) const
4591
0
{
4592
0
    int nHeight = m_xTreeView->GetEntryHeight() * nRows;
4593
4594
0
    sal_Int32 nLeftBorder(0), nTopBorder(0), nRightBorder(0), nBottomBorder(0);
4595
0
    m_xTreeView->GetBorder(nLeftBorder, nTopBorder, nRightBorder, nBottomBorder);
4596
0
    nHeight += nTopBorder + nBottomBorder;
4597
4598
0
    return nHeight;
4599
0
}
4600
4601
void SalInstanceTreeView::make_sorted()
4602
0
{
4603
0
    assert(m_xTreeView->IsUpdateMode() && "don't sort when frozen");
4604
0
    m_xTreeView->SetStyle(m_xTreeView->GetStyle() | WB_SORT);
4605
0
    m_xTreeView->GetModel()->SetCompareHdl(LINK(this, SalInstanceTreeView, CompareHdl));
4606
0
    set_sort_order(true);
4607
0
}
4608
4609
void SalInstanceTreeView::set_sort_func(
4610
    const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func)
4611
0
{
4612
0
    weld::TreeView::set_sort_func(func);
4613
0
    SvTreeList* pListModel = m_xTreeView->GetModel();
4614
0
    pListModel->Resort();
4615
0
}
4616
4617
void SalInstanceTreeView::make_unsorted()
4618
0
{
4619
0
    m_xTreeView->SetStyle(m_xTreeView->GetStyle() & ~WB_SORT);
4620
0
}
4621
4622
void SalInstanceTreeView::set_sort_order(bool bAscending)
4623
0
{
4624
0
    SvTreeList* pListModel = m_xTreeView->GetModel();
4625
0
    pListModel->SetSortMode(bAscending ? SvSortMode::Ascending : SvSortMode::Descending);
4626
0
    pListModel->Resort();
4627
0
}
4628
4629
bool SalInstanceTreeView::get_sort_order() const
4630
0
{
4631
0
    return m_xTreeView->GetModel()->GetSortMode() == SvSortMode::Ascending;
4632
0
}
4633
4634
void SalInstanceTreeView::set_sort_indicator(TriState eState, int col)
4635
0
{
4636
0
    assert(col >= 0 && "cannot sort on expander column");
4637
4638
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4639
0
    HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr;
4640
0
    if (!pHeaderBar)
4641
0
        return;
4642
4643
0
    sal_uInt16 nTextId = pHeaderBar->GetItemId(col);
4644
0
    HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId);
4645
0
    nBits &= ~HeaderBarItemBits::UPARROW;
4646
0
    nBits &= ~HeaderBarItemBits::DOWNARROW;
4647
0
    if (eState != TRISTATE_INDET)
4648
0
    {
4649
0
        if (eState == TRISTATE_TRUE)
4650
0
            nBits |= HeaderBarItemBits::DOWNARROW;
4651
0
        else
4652
0
            nBits |= HeaderBarItemBits::UPARROW;
4653
0
    }
4654
0
    pHeaderBar->SetItemBits(nTextId, nBits);
4655
0
}
4656
4657
TriState SalInstanceTreeView::get_sort_indicator(int col) const
4658
0
{
4659
0
    assert(col >= 0 && "cannot sort on expander column");
4660
4661
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4662
0
    if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
4663
0
    {
4664
0
        sal_uInt16 nTextId = pHeaderBar->GetItemId(col);
4665
0
        HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId);
4666
0
        if (nBits & HeaderBarItemBits::DOWNARROW)
4667
0
            return TRISTATE_TRUE;
4668
0
        if (nBits & HeaderBarItemBits::UPARROW)
4669
0
            return TRISTATE_FALSE;
4670
0
    }
4671
4672
0
    return TRISTATE_INDET;
4673
0
}
4674
4675
0
int SalInstanceTreeView::get_sort_column() const { return m_nSortColumn; }
4676
4677
void SalInstanceTreeView::set_sort_column(int nColumn)
4678
0
{
4679
0
    if (nColumn == -1)
4680
0
    {
4681
0
        make_unsorted();
4682
0
        m_nSortColumn = -1;
4683
0
        return;
4684
0
    }
4685
4686
0
    if (nColumn != m_nSortColumn)
4687
0
    {
4688
0
        m_nSortColumn = nColumn;
4689
0
        m_xTreeView->GetModel()->Resort();
4690
0
    }
4691
0
}
4692
4693
0
SvTabListBox& SalInstanceTreeView::getTreeView() { return *m_xTreeView; }
4694
4695
std::unique_ptr<weld::TreeIter>
4696
SalInstanceTreeView::get_dest_row_at_pos(const Point& rPos, bool bDnDMode, bool bAutoScroll)
4697
0
{
4698
0
    LclTabListBox* pTreeView
4699
0
        = !bDnDMode ? dynamic_cast<LclTabListBox*>(m_xTreeView.get()) : nullptr;
4700
0
    SvTreeListEntry* pTarget = pTreeView ? pTreeView->GetTargetAtPoint(rPos, false, bAutoScroll)
4701
0
                                         : m_xTreeView->GetDropTarget(rPos);
4702
4703
0
    if (pTarget)
4704
0
        return std::make_unique<SalInstanceTreeIter>(*this, pTarget);
4705
4706
0
    return {};
4707
0
}
4708
4709
0
void SalInstanceTreeView::unset_drag_dest_row() { m_xTreeView->UnsetDropTarget(); }
4710
4711
tools::Rectangle SalInstanceTreeView::get_row_area(const weld::TreeIter& rIter) const
4712
0
{
4713
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
4714
0
    assert(rVclIter.iter && "invalid iter");
4715
0
    return m_xTreeView->GetBoundingRect(*rVclIter.iter);
4716
0
}
4717
4718
0
weld::TreeView* SalInstanceTreeView::get_drag_source() const { return g_DragSource; }
4719
4720
int SalInstanceTreeView::vadjustment_get_value() const
4721
0
{
4722
0
    int nValue = -1;
4723
0
    const SvTreeListEntry* pEntry = m_xTreeView->GetFirstEntryInView();
4724
0
    if (pEntry)
4725
0
        nValue = m_xTreeView->GetAbsPos(pEntry);
4726
0
    return nValue;
4727
0
}
4728
4729
void SalInstanceTreeView::vadjustment_set_value(int nValue)
4730
0
{
4731
0
    if (nValue == -1)
4732
0
        return;
4733
0
    bool bUpdate = m_xTreeView->IsUpdateMode();
4734
0
    if (bUpdate)
4735
0
        m_xTreeView->SetUpdateMode(false);
4736
0
    m_xTreeView->ScrollToAbsPos(nValue);
4737
0
    if (bUpdate)
4738
0
        m_xTreeView->SetUpdateMode(true);
4739
0
}
4740
4741
void SalInstanceTreeView::set_show_expanders(bool bShow)
4742
0
{
4743
0
    m_xTreeView->set_property(u"show-expanders"_ustr, OUString::boolean(bShow));
4744
0
}
4745
4746
0
bool SalInstanceTreeView::changed_by_hover() const { return m_xTreeView->IsSelectDueToHover(); }
4747
4748
SalInstanceTreeView::~SalInstanceTreeView()
4749
0
{
4750
0
    SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
4751
0
    if (pHeaderBox)
4752
0
    {
4753
0
        if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
4754
0
        {
4755
0
            pHeaderBar->SetSelectHdl(Link<HeaderBar*, void>());
4756
0
            pHeaderBar->SetEndDragHdl(Link<HeaderBar*, void>());
4757
0
        }
4758
0
    }
4759
0
    else
4760
0
    {
4761
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetEndDragHdl(Link<SvTreeListBox*, void>());
4762
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetStartDragHdl(Link<SvTreeListBox*, bool>());
4763
0
        static_cast<LclTabListBox&>(*m_xTreeView).SetModelChangedHdl(Link<SvTreeListBox*, void>());
4764
0
    }
4765
0
    if (g_DragSource == this)
4766
0
        g_DragSource = nullptr;
4767
0
    m_xTreeView->SetExpandingHdl(Link<SvTreeListBox*, bool>());
4768
0
    m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>());
4769
0
    m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>());
4770
0
    m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>());
4771
0
    m_xTreeView->SetTooltipHdl({});
4772
0
    m_xTreeView->SetCustomRenderHdl(Link<svtree_render_args, void>());
4773
0
    m_xTreeView->SetCustomMeasureHdl(Link<svtree_measure_args, Size>());
4774
0
}
4775
4776
IMPL_LINK(SalInstanceTreeView, TooltipHdl, SvTreeListEntry&, rEntry, OUString)
4777
0
{
4778
0
    return signal_query_tooltip(SalInstanceTreeIter(*this, &rEntry));
4779
0
}
4780
4781
IMPL_LINK(SalInstanceTreeView, CustomRenderHdl, svtree_render_args, payload, void)
4782
0
{
4783
0
    vcl::RenderContext& rRenderDevice = std::get<0>(payload);
4784
0
    const tools::Rectangle& rRect = std::get<1>(payload);
4785
0
    const SvTreeListEntry& rEntry = std::get<2>(payload);
4786
0
    const OUString* pId = rEntry.GetUserData();
4787
0
    if (!pId)
4788
0
        return;
4789
0
    signal_custom_render(rRenderDevice, rRect, m_xTreeView->IsSelected(&rEntry), *pId);
4790
0
}
4791
4792
IMPL_LINK(SalInstanceTreeView, CustomMeasureHdl, svtree_measure_args, payload, Size)
4793
0
{
4794
0
    vcl::RenderContext& rRenderDevice = payload.first;
4795
0
    const SvTreeListEntry& rEntry = payload.second;
4796
0
    const OUString* pId = rEntry.GetUserData();
4797
0
    if (!pId)
4798
0
        return Size();
4799
0
    return signal_custom_get_size(rRenderDevice, *pId);
4800
0
}
4801
4802
IMPL_LINK(SalInstanceTreeView, CompareHdl, const SvSortData&, rSortData, sal_Int32)
4803
0
{
4804
0
    const SvTreeListEntry* pLHS = rSortData.pLeft;
4805
0
    const SvTreeListEntry* pRHS = rSortData.pRight;
4806
0
    assert(pLHS && pRHS);
4807
4808
0
    if (m_aCustomSort)
4809
0
        return m_aCustomSort(SalInstanceTreeIter(*this, const_cast<SvTreeListEntry*>(pLHS)),
4810
0
                             SalInstanceTreeIter(*this, const_cast<SvTreeListEntry*>(pRHS)));
4811
4812
0
    const SvLBoxString* pLeftTextItem;
4813
0
    const SvLBoxString* pRightTextItem;
4814
4815
0
    if (m_nSortColumn != -1)
4816
0
    {
4817
0
        size_t col = to_internal_model(m_nSortColumn);
4818
4819
0
        if (col < pLHS->ItemCount())
4820
0
        {
4821
0
            const SvLBoxString& rLeftTextItem
4822
0
                = static_cast<const SvLBoxString&>(pLHS->GetItem(col));
4823
0
            pLeftTextItem = &rLeftTextItem;
4824
0
        }
4825
0
        else
4826
0
            pLeftTextItem = nullptr;
4827
0
        if (col < pRHS->ItemCount())
4828
0
        {
4829
0
            const SvLBoxString& rRightTextItem
4830
0
                = static_cast<const SvLBoxString&>(pRHS->GetItem(col));
4831
0
            pRightTextItem = &rRightTextItem;
4832
0
        }
4833
0
        else
4834
0
            pRightTextItem = nullptr;
4835
0
    }
4836
0
    else
4837
0
    {
4838
0
        pLeftTextItem
4839
0
            = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SvLBoxItemType::String));
4840
0
        pRightTextItem
4841
0
            = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SvLBoxItemType::String));
4842
0
    }
4843
4844
0
    return m_xTreeView->DefaultCompare(pLeftTextItem, pRightTextItem);
4845
0
}
4846
4847
IMPL_LINK_NOARG(SalInstanceTreeView, VisibleRangeChangedHdl, SvTreeListBox*, void)
4848
0
{
4849
0
    signal_visible_range_changed();
4850
0
}
4851
4852
IMPL_LINK_NOARG(SalInstanceTreeView, ModelChangedHdl, SvTreeListBox*, void)
4853
0
{
4854
0
    signal_model_changed();
4855
0
}
4856
4857
IMPL_LINK_NOARG(SalInstanceTreeView, StartDragHdl, SvTreeListBox*, bool)
4858
0
{
4859
0
    bool bUnsetDragIcon(false); // ignored for vcl
4860
0
    if (m_aDragBeginHdl.Call(bUnsetDragIcon))
4861
0
        return true;
4862
0
    g_DragSource = this;
4863
0
    return false;
4864
0
}
4865
4866
IMPL_STATIC_LINK_NOARG(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void)
4867
0
{
4868
0
    g_DragSource = nullptr;
4869
0
}
4870
4871
IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)
4872
0
{
4873
0
    SvTreeListEntry* pEntry = pData->GetActEntry();
4874
0
    SvLBoxButton* pBox = pData->GetActBox();
4875
4876
    // tdf#122874 Select the row, calling SelectHdl, before handling
4877
    // the toggle
4878
0
    if (!m_xTreeView->IsSelected(pEntry))
4879
0
    {
4880
0
        m_xTreeView->SelectAll(false);
4881
0
        m_xTreeView->Select(pEntry, true);
4882
0
    }
4883
4884
    // additionally set the cursor into the row the toggled element is in
4885
0
    m_xTreeView->m_pImpl->m_pCursor = pEntry;
4886
4887
0
    for (int i = 0, nCount = pEntry->ItemCount(); i < nCount; ++i)
4888
0
    {
4889
0
        SvLBoxItem& rItem = pEntry->GetItem(i);
4890
0
        if (&rItem == pBox)
4891
0
        {
4892
0
            int nCol = to_external_model(i);
4893
0
            signal_toggled(iter_col(SalInstanceTreeIter(*this, pEntry), nCol));
4894
0
            break;
4895
0
        }
4896
0
    }
4897
0
}
4898
4899
IMPL_LINK_NOARG(SalInstanceTreeView, SelectHdl, SvTreeListBox*, void)
4900
0
{
4901
0
    signal_selection_changed();
4902
0
}
4903
4904
IMPL_LINK_NOARG(SalInstanceTreeView, DeSelectHdl, SvTreeListBox*, void)
4905
0
{
4906
0
    if (m_xTreeView->GetSelectionMode() == SelectionMode::Single
4907
0
        && !m_xTreeView->GetHoverSelection())
4908
0
        return;
4909
0
    signal_selection_changed();
4910
0
}
4911
4912
IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void)
4913
0
{
4914
0
    std::vector<tools::Long> aTabPositions{ 0 };
4915
0
    for (int i = 0; i < pHeaderBar->GetItemCount() - 1; ++i)
4916
0
        aTabPositions.push_back(aTabPositions[i]
4917
0
                                + pHeaderBar->GetItemSize(pHeaderBar->GetItemId(i)));
4918
0
    m_xTreeView->SetTabs(aTabPositions);
4919
0
}
4920
4921
IMPL_LINK(SalInstanceTreeView, HeaderBarClickedHdl, HeaderBar*, pHeaderBar, void)
4922
0
{
4923
0
    sal_uInt16 nId = pHeaderBar->GetCurItemId();
4924
0
    if (!(pHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE))
4925
0
        return;
4926
0
    signal_column_header_clicked(pHeaderBar->GetItemPos(nId));
4927
0
}
4928
4929
IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool)
4930
0
{
4931
0
    SvTreeListEntry* pEntry = m_xTreeView->GetHdlEntry();
4932
0
    SalInstanceTreeIter aIter(*this, pEntry);
4933
4934
0
    if (m_xTreeView->IsExpanded(pEntry))
4935
0
    {
4936
        //collapsing;
4937
0
        return signal_collapsing(aIter);
4938
0
    }
4939
4940
    // expanding
4941
0
    return ExpandRow(aIter);
4942
0
}
4943
4944
bool SalInstanceTreeView::ExpandRow(const SalInstanceTreeIter& rIter)
4945
0
{
4946
0
    SvTreeListEntry* pEntry = rIter.iter;
4947
    // if there's a preexisting placeholder child, required to make this
4948
    // potentially expandable in the first place, now we remove it
4949
0
    SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry);
4950
0
    if (pPlaceHolder)
4951
0
    {
4952
0
        m_aExpandingPlaceHolderParents.insert(pEntry);
4953
0
        m_xTreeView->RemoveEntry(pPlaceHolder);
4954
0
    }
4955
4956
0
    bool bRet = signal_expanding(rIter);
4957
4958
0
    if (pPlaceHolder)
4959
0
    {
4960
        //expand disallowed, restore placeholder
4961
0
        if (!bRet)
4962
0
        {
4963
0
            pPlaceHolder = &InsertDummyEntry(pEntry);
4964
0
            SvViewDataEntry& rViewData = m_xTreeView->GetViewDataEntry(*pPlaceHolder);
4965
0
            rViewData.SetSelectable(false);
4966
0
        }
4967
0
        m_aExpandingPlaceHolderParents.erase(pEntry);
4968
0
    }
4969
4970
0
    return bRet;
4971
0
}
4972
4973
IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool)
4974
0
{
4975
0
    return signal_editing_started(SalInstanceTreeIter(*this, pEntry));
4976
0
}
4977
4978
IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const EntryItemText&, rEntryItemString, bool)
4979
0
{
4980
0
    const int nColumn
4981
0
        = to_external_model(rEntryItemString.m_rEntry.GetPos(rEntryItemString.m_rItem));
4982
0
    return signal_editing_done(IterColText(SalInstanceTreeIter(*this, &rEntryItemString.m_rEntry),
4983
0
                                           nColumn, rEntryItemString.m_sText));
4984
0
}
4985
4986
SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder,
4987
                                         bool bTakeOwnership)
4988
0
    : SalInstanceItemView(pIconView, pBuilder, bTakeOwnership)
4989
0
    , m_xIconView(pIconView)
4990
0
{
4991
0
    m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
4992
0
    m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
4993
0
}
Unexecuted instantiation: SalInstanceIconView::SalInstanceIconView(IconView*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceIconView::SalInstanceIconView(IconView*, SalInstanceBuilder*, bool)
4994
4995
0
int SalInstanceIconView::get_item_width() const { return m_xIconView->GetEntryWidth(); }
4996
void SalInstanceIconView::set_item_width(int width)
4997
0
{
4998
0
    m_xIconView->SetEntryWidth(width);
4999
0
    m_bFixedItemWidth = true;
5000
0
    m_xIconView->Resize();
5001
0
}
5002
5003
void SalInstanceIconView::freeze()
5004
0
{
5005
0
    bool bIsFirstFreeze = IsFirstFreeze();
5006
0
    SalInstanceWidget::freeze();
5007
0
    if (bIsFirstFreeze)
5008
0
        m_xIconView->SetUpdateMode(false);
5009
0
}
5010
5011
void SalInstanceIconView::thaw()
5012
0
{
5013
0
    bool bIsLastThaw = IsLastThaw();
5014
0
    if (bIsLastThaw)
5015
0
        m_xIconView->SetUpdateMode(true);
5016
0
    SalInstanceWidget::thaw();
5017
0
}
5018
5019
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5020
                                    const Image& rImage, weld::TreeIter* pRet)
5021
0
{
5022
0
    auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
5023
0
    OUString* pUserData;
5024
0
    if (pId)
5025
0
    {
5026
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
5027
0
        pUserData = m_aUserData.back().get();
5028
0
    }
5029
0
    else
5030
0
        pUserData = nullptr;
5031
5032
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
5033
0
    pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage));
5034
5035
0
    if (pStr)
5036
0
        pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
5037
0
    pEntry->SetUserData(pUserData);
5038
0
    m_xIconView->Insert(pEntry, nInsertPos);
5039
0
    if (!m_bFixedItemWidth)
5040
0
        m_xIconView->UpdateEntrySize(*pEntry);
5041
5042
0
    if (pRet)
5043
0
    {
5044
0
        SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
5045
0
        pVclRetIter->iter = pEntry;
5046
0
    }
5047
0
}
5048
5049
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5050
                                    const OUString* pIconName, weld::TreeIter* pRet)
5051
0
{
5052
0
    const Image aImage = pIconName ? createImage(*pIconName) : Image();
5053
0
    do_insert(pos, pStr, pId, aImage, pRet);
5054
0
}
5055
5056
void SalInstanceIconView::do_insert(int pos, const OUString* pStr, const OUString* pId,
5057
                                    const Bitmap* pIcon, weld::TreeIter* pRet)
5058
0
{
5059
0
    const Image aImage = pIcon ? Image(*pIcon) : Image();
5060
0
    do_insert(pos, pStr, pId, aImage, pRet);
5061
0
}
5062
5063
void SalInstanceIconView::insert_separator(int pos, const OUString* /* pId */)
5064
0
{
5065
0
    const auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
5066
0
    const OUString sSep(VclResId(STR_SEPARATOR));
5067
0
    SvTreeListEntry* pEntry = new SvTreeListEntry;
5068
0
    pEntry->SetSeparator();
5069
0
    const Image aDummy;
5070
0
    pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy));
5071
0
    pEntry->AddItem(std::make_unique<SvLBoxString>(sSep));
5072
0
    pEntry->SetUserData(nullptr);
5073
0
    m_xIconView->Insert(pEntry, nInsertPos);
5074
0
    SvViewDataEntry& rViewData = m_xIconView->GetViewDataEntry(*pEntry);
5075
0
    rViewData.SetSelectable(false);
5076
0
}
5077
5078
IMPL_LINK(SalInstanceIconView, TooltipHdl, SvTreeListEntry&, rEntry, OUString)
5079
0
{
5080
0
    return signal_query_tooltip(SalInstanceTreeIter(*this, &rEntry));
5081
0
}
5082
5083
void SalInstanceIconView::connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink)
5084
0
{
5085
0
    weld::IconView::connect_query_tooltip(rLink);
5086
0
    m_xIconView->SetTooltipHdl(LINK(this, SalInstanceIconView, TooltipHdl));
5087
0
}
5088
5089
0
int SalInstanceIconView::count_selected_items() const { return m_xIconView->GetSelectionCount(); }
5090
5091
void SalInstanceIconView::do_scroll_to_item(const weld::TreeIter& rIter)
5092
0
{
5093
0
    assert(m_xIconView->IsUpdateMode()
5094
0
           && "don't select when frozen, select after thaw. Note selection doesn't survive a "
5095
0
              "freeze");
5096
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5097
0
    m_xIconView->MakeVisible(rVclIter.iter);
5098
0
}
5099
5100
void SalInstanceIconView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func)
5101
0
{
5102
0
    SalInstanceTreeIter aVclIter(*this, m_xIconView->FirstSelected());
5103
0
    while (aVclIter.iter)
5104
0
    {
5105
0
        if (func(aVclIter))
5106
0
            return;
5107
0
        aVclIter.iter = m_xIconView->NextSelected(aVclIter.iter);
5108
0
    }
5109
0
}
5110
5111
void SalInstanceIconView::set_image(int pos, VirtualDevice& rIcon)
5112
0
{
5113
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
5114
0
    if (pEntry == nullptr)
5115
0
        return;
5116
0
    SvLBoxContextBmp* pItem
5117
0
        = static_cast<SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp));
5118
5119
0
    Image aImage = createImage(rIcon);
5120
0
    if (pItem == nullptr)
5121
0
    {
5122
0
        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage));
5123
0
    }
5124
0
    else
5125
0
    {
5126
0
        pItem->SetBitmap1(aImage);
5127
0
        pItem->SetBitmap2(aImage);
5128
0
        if (!m_bFixedItemWidth)
5129
0
            m_xIconView->UpdateEntrySize(*pEntry);
5130
0
        m_xIconView->ModelHasEntryInvalidated(pEntry);
5131
0
    }
5132
0
}
5133
5134
void SalInstanceIconView::set_text(int pos, const OUString& rText)
5135
0
{
5136
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(nullptr, pos);
5137
0
    if (!pEntry)
5138
0
        return;
5139
5140
0
    SvLBoxString* aItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));
5141
0
    if (aItem == nullptr)
5142
0
    {
5143
0
        pEntry->AddItem(std::make_unique<SvLBoxString>(rText));
5144
0
    }
5145
0
    else
5146
0
    {
5147
0
        aItem->SetText(rText);
5148
0
    }
5149
5150
0
    if (!m_xIconView->GetModel()->IsEnableInvalidate())
5151
0
        m_xIconView->ModelHasEntryInvalidated(pEntry);
5152
0
}
5153
5154
void SalInstanceIconView::set_item_accessible_name(int pos, const OUString& rName)
5155
0
{
5156
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(pos);
5157
0
    assert(pEntry);
5158
0
    pEntry->SetAccessibleName(rName);
5159
0
}
5160
5161
void SalInstanceIconView::set_item_tooltip_text(int pos, const OUString& rToolTip)
5162
0
{
5163
0
    SvTreeListEntry* pEntry = m_xIconView->GetEntry(pos);
5164
0
    assert(pEntry);
5165
0
    pEntry->SetToolTip(rToolTip);
5166
0
}
5167
5168
OUString SalInstanceIconView::get_item_tooltip_text(const weld::TreeIter& rIter) const
5169
0
{
5170
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5171
0
    assert(rVclIter.iter);
5172
0
    return rVclIter.iter->GetToolTip();
5173
0
}
5174
5175
tools::Rectangle SalInstanceIconView::get_rect(const weld::TreeIter& rIter) const
5176
0
{
5177
0
    const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
5178
0
    assert(rVclIter.iter && "invalid iter");
5179
0
    return m_xIconView->GetBoundingRect(*rVclIter.iter);
5180
0
}
5181
5182
SalInstanceIconView::~SalInstanceIconView()
5183
0
{
5184
0
    m_xIconView->SetSelectHdl(Link<SvTreeListBox*, void>());
5185
0
    m_xIconView->SetDeselectHdl(Link<SvTreeListBox*, void>());
5186
0
}
5187
5188
IMPL_LINK_NOARG(SalInstanceIconView, SelectHdl, SvTreeListBox*, void)
5189
0
{
5190
0
    signal_selection_changed();
5191
0
}
5192
5193
IMPL_LINK_NOARG(SalInstanceIconView, DeSelectHdl, SvTreeListBox*, void)
5194
0
{
5195
0
    if (m_xIconView->GetSelectionMode() == SelectionMode::Single)
5196
0
        return;
5197
0
    signal_selection_changed();
5198
0
}
5199
5200
SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder,
5201
                                             bool bTakeOwnership)
5202
0
    : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
5203
0
    , m_xButton(pButton)
5204
0
    , m_rFormatter(m_xButton->GetFormatter())
5205
0
{
5206
0
    m_rFormatter.SetThousandsSep(false); //off by default, MetricSpinButton enables it
5207
0
    m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
5208
0
    m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
5209
0
    m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl));
5210
0
    m_rFormatter.SetFormatValueHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
5211
0
    m_rFormatter.SetParseTextHdl(LINK(this, SalInstanceSpinButton, InputHdl));
5212
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5213
0
        pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
5214
0
    else
5215
0
        m_xButton->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
5216
0
}
Unexecuted instantiation: SalInstanceSpinButton::SalInstanceSpinButton(FormattedField*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceSpinButton::SalInstanceSpinButton(FormattedField*, SalInstanceBuilder*, bool)
5217
5218
0
double SalInstanceSpinButton::get_floating_point_value() const { return m_rFormatter.GetValue(); }
5219
5220
void SalInstanceSpinButton::set_floating_point_value(double fValue)
5221
0
{
5222
0
    m_rFormatter.SetValue(fValue);
5223
0
}
5224
5225
void SalInstanceSpinButton::set_floating_point_range(double fMin, double fMax)
5226
0
{
5227
0
    m_rFormatter.SetMinValue(fMin);
5228
0
    m_rFormatter.SetMaxValue(fMax);
5229
0
}
5230
5231
void SalInstanceSpinButton::get_floating_point_range(double& rMin, double& rMax) const
5232
0
{
5233
0
    rMin = m_rFormatter.GetMinValue();
5234
0
    rMax = m_rFormatter.GetMaxValue();
5235
0
}
5236
5237
void SalInstanceSpinButton::set_floating_point_increments(double fStep, double /*fPage*/)
5238
0
{
5239
0
    m_rFormatter.SetSpinSize(fStep);
5240
0
}
5241
5242
void SalInstanceSpinButton::get_floating_point_increments(double& rStep, double& rPage) const
5243
0
{
5244
0
    rStep = m_rFormatter.GetSpinSize();
5245
0
    rPage = m_rFormatter.GetSpinSize();
5246
0
}
5247
5248
void SalInstanceSpinButton::set_digits(unsigned int digits)
5249
0
{
5250
0
    m_rFormatter.SetDecimalDigits(digits);
5251
0
}
5252
5253
// SpinButton may be comprised of multiple subwidgets, consider the lot as
5254
// one thing for focus
5255
0
bool SalInstanceSpinButton::has_focus() const { return m_xWidget->HasChildPathFocus(); }
5256
5257
//off by default for direct SpinButtons, MetricSpinButton enables it
5258
0
void SalInstanceSpinButton::SetUseThousandSep() { m_rFormatter.SetThousandsSep(true); }
5259
5260
0
unsigned int SalInstanceSpinButton::get_digits() const { return m_rFormatter.GetDecimalDigits(); }
5261
5262
SalInstanceSpinButton::~SalInstanceSpinButton()
5263
0
{
5264
0
    if (Edit* pEdit = m_xButton->GetSubEdit())
5265
0
        pEdit->SetActivateHdl(Link<Edit&, bool>());
5266
0
    else
5267
0
        m_xButton->SetActivateHdl(Link<Edit&, bool>());
5268
0
    m_rFormatter.SetParseTextHdl(Link<const OUString&, Formatter::ParseResult>());
5269
0
    m_rFormatter.SetFormatValueHdl(Link<double, std::optional<OUString>>());
5270
0
    m_xButton->SetLoseFocusHdl(Link<Control&, void>());
5271
0
    m_xButton->SetDownHdl(Link<SpinField&, void>());
5272
0
    m_xButton->SetUpHdl(Link<SpinField&, void>());
5273
0
}
5274
5275
IMPL_LINK_NOARG(SalInstanceSpinButton, ActivateHdl, Edit&, bool)
5276
0
{
5277
    // tdf#122348 return pressed to end dialog
5278
0
    signal_value_changed();
5279
0
    return m_aActivateHdl.Call(*this);
5280
0
}
5281
5282
0
IMPL_LINK_NOARG(SalInstanceSpinButton, UpDownHdl, SpinField&, void) { signal_value_changed(); }
5283
5284
IMPL_LINK_NOARG(SalInstanceSpinButton, LoseFocusHdl, Control&, void)
5285
0
{
5286
    // tdf#134725 Don't signal for empty text, the Formatter has IsEmptyFieldEnabled
5287
    // enabled, so empty values are intended to be no-change.
5288
0
    if (!m_xButton->GetText().isEmpty())
5289
0
        signal_value_changed();
5290
0
}
5291
5292
IMPL_LINK(SalInstanceSpinButton, OutputHdl, double, fValue, std::optional<OUString>)
5293
0
{
5294
0
    return format_floating_point_value(fValue);
5295
0
}
5296
5297
IMPL_LINK(SalInstanceSpinButton, InputHdl, const OUString&, rText, Formatter::ParseResult)
5298
0
{
5299
0
    double fResult = 0;
5300
0
    TriState eRet = parse_text(rText, &fResult);
5301
5302
0
    return Formatter::ParseResult(eRet, fResult);
5303
0
}
5304
5305
SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField* pButton,
5306
                                                               SalInstanceBuilder* pBuilder,
5307
                                                               bool bTakeOwnership)
5308
0
    : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
5309
0
    , m_xButton(pButton)
5310
0
    , m_pFormatter(nullptr)
5311
0
{
5312
0
    m_xButton->SetUpHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
5313
0
    m_xButton->SetDownHdl(LINK(this, SalInstanceFormattedSpinButton, UpDownHdl));
5314
0
    m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceFormattedSpinButton, LoseFocusHdl));
5315
0
}
Unexecuted instantiation: SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceFormattedSpinButton::SalInstanceFormattedSpinButton(FormattedField*, SalInstanceBuilder*, bool)
5316
5317
void SalInstanceFormattedSpinButton::do_set_text(const OUString& rText)
5318
0
{
5319
0
    m_xButton->SpinField::SetText(rText);
5320
0
}
5321
5322
void SalInstanceFormattedSpinButton::connect_changed(const Link<weld::TextWidget&, void>& rLink)
5323
0
{
5324
0
    if (!m_pFormatter) // once a formatter is set, it takes over "changed"
5325
0
    {
5326
0
        SalInstanceEntry::connect_changed(rLink);
5327
0
        return;
5328
0
    }
5329
0
    m_pFormatter->connect_changed(rLink);
5330
0
}
5331
5332
void SalInstanceFormattedSpinButton::connect_focus_out(const Link<weld::Widget&, void>& rLink)
5333
0
{
5334
0
    if (!m_pFormatter) // once a formatter is set, it takes over "focus-out"
5335
0
    {
5336
0
        m_aLoseFocusHdl = rLink;
5337
0
        return;
5338
0
    }
5339
0
    m_pFormatter->connect_focus_out(rLink);
5340
0
}
5341
5342
void SalInstanceFormattedSpinButton::SetFormatter(weld::EntryFormatter* pFormatter)
5343
0
{
5344
0
    m_pFormatter = pFormatter;
5345
0
    m_xButton->SetFormatter(pFormatter);
5346
0
}
5347
5348
0
Formatter& SalInstanceFormattedSpinButton::GetFormatter() { return m_xButton->GetFormatter(); }
5349
5350
SalInstanceFormattedSpinButton::~SalInstanceFormattedSpinButton()
5351
0
{
5352
0
    m_xButton->SetLoseFocusHdl(Link<Control&, void>());
5353
0
    m_xButton->SetDownHdl(Link<SpinField&, void>());
5354
0
    m_xButton->SetUpHdl(Link<SpinField&, void>());
5355
0
}
5356
5357
IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, UpDownHdl, SpinField&, void)
5358
0
{
5359
0
    signal_value_changed();
5360
0
}
5361
5362
IMPL_LINK_NOARG(SalInstanceFormattedSpinButton, LoseFocusHdl, Control&, void)
5363
0
{
5364
0
    if (!m_pFormatter)
5365
0
        signal_value_changed();
5366
0
    m_aLoseFocusHdl.Call(*this);
5367
0
}
5368
5369
SalInstanceLabel::SalInstanceLabel(Control* pLabel, SalInstanceBuilder* pBuilder,
5370
                                   bool bTakeOwnership)
5371
0
    : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership)
5372
0
    , m_xLabel(pLabel)
5373
0
{
5374
0
}
Unexecuted instantiation: SalInstanceLabel::SalInstanceLabel(Control*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceLabel::SalInstanceLabel(Control*, SalInstanceBuilder*, bool)
5375
5376
0
void SalInstanceLabel::set_label(const OUString& rText) { m_xLabel->SetText(rText); }
5377
5378
0
OUString SalInstanceLabel::get_label() const { return m_xLabel->GetText(); }
5379
5380
void SalInstanceLabel::set_mnemonic_widget(Widget* pTarget)
5381
0
{
5382
0
    FixedText* pLabel = dynamic_cast<FixedText*>(m_xLabel.get());
5383
0
    assert(pLabel && "can't use set_mnemonic_widget on SelectableFixedText");
5384
0
    SalInstanceWidget* pTargetWidget = dynamic_cast<SalInstanceWidget*>(pTarget);
5385
0
    pLabel->set_mnemonic_widget(pTargetWidget ? pTargetWidget->getWidget() : nullptr);
5386
0
}
5387
5388
void SalInstanceLabel::set_label_type(weld::LabelType eType)
5389
0
{
5390
0
    switch (eType)
5391
0
    {
5392
0
        case weld::LabelType::Normal:
5393
0
            m_xLabel->SetControlForeground();
5394
0
            m_xLabel->SetControlBackground();
5395
0
            break;
5396
0
        case weld::LabelType::Warning:
5397
0
            m_xLabel->SetControlForeground(
5398
0
                m_xLabel->GetSettings().GetStyleSettings().GetWarningTextColor());
5399
0
            m_xLabel->SetControlBackground(
5400
0
                m_xLabel->GetSettings().GetStyleSettings().GetWarningColor());
5401
0
            break;
5402
0
        case weld::LabelType::Error:
5403
0
            m_xLabel->SetControlForeground(
5404
0
                m_xLabel->GetSettings().GetStyleSettings().GetErrorTextColor());
5405
0
            m_xLabel->SetControlBackground(
5406
0
                m_xLabel->GetSettings().GetStyleSettings().GetErrorColor());
5407
0
            break;
5408
0
        case weld::LabelType::Title:
5409
0
            m_xLabel->SetControlForeground(
5410
0
                m_xLabel->GetSettings().GetStyleSettings().GetLightColor());
5411
0
            m_xLabel->SetControlBackground();
5412
0
            break;
5413
0
    }
5414
0
}
5415
5416
void SalInstanceLabel::set_font_color(const Color& rColor)
5417
0
{
5418
0
    if (rColor != COL_AUTO)
5419
0
        m_xLabel->SetControlForeground(rColor);
5420
0
    else
5421
0
        m_xLabel->SetControlForeground();
5422
0
}
5423
5424
void SalInstanceLabel::set_font(const vcl::Font& rFont)
5425
0
{
5426
0
    m_xLabel->SetControlFont(rFont);
5427
0
    m_xLabel->Invalidate();
5428
0
}
5429
5430
SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder,
5431
                                         bool bTakeOwnership)
5432
0
    : SalInstanceTextWidget(pTextView, pBuilder, bTakeOwnership)
5433
0
    , m_xTextView(pTextView)
5434
0
{
5435
    // tdf#150397 don't select text when receiving keyboard focus,
5436
    // GtkInstanceTextView also doesn't do it
5437
0
    m_xTextView->DisableSelectionOnFocus();
5438
5439
0
    m_xTextView->SetModifyHdl(LINK(this, SalInstanceTextView, ChangeHdl));
5440
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5441
0
    m_aOrigVScrollHdl = rVertScrollBar.GetScrollHdl();
5442
0
    rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl));
5443
0
}
Unexecuted instantiation: SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit*, SalInstanceBuilder*, bool)
5444
5445
0
void SalInstanceTextView::set_max_length(int nChars) { m_xTextView->SetMaxTextLen(nChars); }
5446
5447
void SalInstanceTextView::set_monospace(bool bMonospace)
5448
0
{
5449
0
    vcl::Font aOrigFont = m_xTextView->GetControlFont();
5450
0
    vcl::Font aFont;
5451
0
    if (bMonospace)
5452
0
        aFont
5453
0
            = OutputDevice::GetDefaultFont(DefaultFontType::UI_FIXED, LANGUAGE_DONTKNOW,
5454
0
                                           GetDefaultFontFlags::OnlyOne, m_xTextView->GetOutDev());
5455
0
    else
5456
0
        aFont = Application::GetSettings().GetStyleSettings().GetFieldFont();
5457
0
    aFont.SetFontHeight(aOrigFont.GetFontHeight());
5458
0
    set_font(aFont);
5459
0
}
5460
5461
void SalInstanceTextView::set_font(const vcl::Font& rFont)
5462
0
{
5463
0
    m_xTextView->SetFont(rFont);
5464
0
    m_xTextView->SetControlFont(rFont);
5465
0
    m_xTextView->Invalidate();
5466
0
}
5467
5468
bool SalInstanceTextView::can_move_cursor_with_up() const
5469
0
{
5470
0
    bool bNoSelection = !m_xTextView->GetSelection();
5471
0
    return !bNoSelection || m_xTextView->CanUp();
5472
0
}
5473
5474
bool SalInstanceTextView::can_move_cursor_with_down() const
5475
0
{
5476
0
    bool bNoSelection = !m_xTextView->GetSelection();
5477
0
    return !bNoSelection || m_xTextView->CanDown();
5478
0
}
5479
5480
0
void SalInstanceTextView::cut_clipboard() { m_xTextView->Cut(); }
5481
5482
0
void SalInstanceTextView::copy_clipboard() { m_xTextView->Copy(); }
5483
5484
0
void SalInstanceTextView::paste_clipboard() { m_xTextView->Paste(); }
5485
5486
void SalInstanceTextView::set_alignment(TxtAlign eXAlign)
5487
0
{
5488
0
    ::set_alignment(*m_xTextView, eXAlign);
5489
0
}
5490
5491
int SalInstanceTextView::vadjustment_get_value() const
5492
0
{
5493
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5494
0
    return rVertScrollBar.GetThumbPos();
5495
0
}
5496
5497
void SalInstanceTextView::vadjustment_set_value(int value)
5498
0
{
5499
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5500
0
    rVertScrollBar.SetThumbPos(value);
5501
0
    m_aOrigVScrollHdl.Call(&rVertScrollBar);
5502
0
}
5503
5504
int SalInstanceTextView::vadjustment_get_upper() const
5505
0
{
5506
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5507
0
    return rVertScrollBar.GetRangeMax();
5508
0
}
5509
5510
int SalInstanceTextView::vadjustment_get_page_size() const
5511
0
{
5512
0
    ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5513
0
    return rVertScrollBar.GetVisibleSize();
5514
0
}
5515
5516
0
bool SalInstanceTextView::has_focus() const { return m_xTextView->HasChildPathFocus(); }
5517
5518
SalInstanceTextView::~SalInstanceTextView()
5519
0
{
5520
0
    if (!m_xTextView->isDisposed())
5521
0
    {
5522
0
        m_xTextView->SetModifyHdl(Link<Edit&, void>());
5523
0
        ScrollBar& rVertScrollBar = m_xTextView->GetVScrollBar();
5524
0
        rVertScrollBar.SetScrollHdl(m_aOrigVScrollHdl);
5525
0
    }
5526
0
}
5527
5528
IMPL_LINK(SalInstanceTextView, VscrollHdl, ScrollBar*, pScrollBar, void)
5529
0
{
5530
0
    signal_vadjustment_value_changed();
5531
0
    m_aOrigVScrollHdl.Call(pScrollBar);
5532
0
}
5533
5534
0
IMPL_LINK_NOARG(SalInstanceTextView, ChangeHdl, Edit&, void) { signal_changed(); }
5535
5536
SalInstanceExpander::SalInstanceExpander(VclExpander* pExpander, SalInstanceBuilder* pBuilder,
5537
                                         bool bTakeOwnership)
5538
0
    : SalInstanceWidget(pExpander, pBuilder, bTakeOwnership)
5539
0
    , m_xExpander(pExpander)
5540
0
{
5541
0
    m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl));
5542
0
}
Unexecuted instantiation: SalInstanceExpander::SalInstanceExpander(VclExpander*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceExpander::SalInstanceExpander(VclExpander*, SalInstanceBuilder*, bool)
5543
5544
0
void SalInstanceExpander::set_label(const OUString& rText) { m_xExpander->set_label(rText); }
5545
5546
0
OUString SalInstanceExpander::get_label() const { return m_xExpander->get_label(); }
5547
5548
0
bool SalInstanceExpander::get_expanded() const { return m_xExpander->get_expanded(); }
5549
5550
0
void SalInstanceExpander::set_expanded(bool bExpand) { m_xExpander->set_expanded(bExpand); }
5551
5552
bool SalInstanceExpander::has_focus() const
5553
0
{
5554
0
    return m_xExpander->get_label_widget()->HasFocus() || SalInstanceWidget::has_focus();
5555
0
}
5556
5557
0
void SalInstanceExpander::grab_focus() { return m_xExpander->get_label_widget()->GrabFocus(); }
5558
5559
SalInstanceExpander::~SalInstanceExpander()
5560
0
{
5561
0
    m_xExpander->SetExpandedHdl(Link<VclExpander&, void>());
5562
0
}
5563
5564
0
IMPL_LINK_NOARG(SalInstanceExpander, ExpandedHdl, VclExpander&, void) { signal_expanded(); }
5565
5566
// SalInstanceWidget has a generic listener for all these
5567
// events, ignore the ones we have specializations for
5568
// in VclDrawingArea
5569
void SalInstanceDrawingArea::HandleEventListener(VclWindowEvent& rEvent)
5570
0
{
5571
0
    if (rEvent.GetId() == VclEventId::WindowResize)
5572
0
        return;
5573
0
    SalInstanceWidget::HandleEventListener(rEvent);
5574
0
}
5575
5576
void SalInstanceDrawingArea::HandleMouseEventListener(VclWindowEvent& rEvent)
5577
0
{
5578
0
    if (rEvent.GetId() == VclEventId::WindowMouseButtonDown
5579
0
        || rEvent.GetId() == VclEventId::WindowMouseButtonUp
5580
0
        || rEvent.GetId() == VclEventId::WindowMouseMove)
5581
0
    {
5582
0
        return;
5583
0
    }
5584
0
    SalInstanceWidget::HandleMouseEventListener(rEvent);
5585
0
}
5586
5587
0
bool SalInstanceDrawingArea::HandleKeyEventListener(VclWindowEvent& /*rEvent*/) { return false; }
5588
5589
SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea* pDrawingArea,
5590
                                               SalInstanceBuilder* pBuilder,
5591
                                               const rtl::Reference<comphelper::OAccessible>& rAlly,
5592
                                               FactoryFunction pUITestFactoryFunction,
5593
                                               void* pUserData, bool bTakeOwnership)
5594
0
    : SalInstanceWidget(pDrawingArea, pBuilder, bTakeOwnership)
5595
0
    , m_xDrawingArea(pDrawingArea)
5596
0
{
5597
0
    m_xDrawingArea->SetAccessible(rAlly);
5598
0
    m_xDrawingArea->SetUITestFactory(std::move(pUITestFactoryFunction), pUserData);
5599
0
    m_xDrawingArea->SetPaintHdl(LINK(this, SalInstanceDrawingArea, PaintHdl));
5600
0
    m_xDrawingArea->SetResizeHdl(LINK(this, SalInstanceDrawingArea, ResizeHdl));
5601
0
    m_xDrawingArea->SetMousePressHdl(LINK(this, SalInstanceDrawingArea, MousePressHdl));
5602
0
    m_xDrawingArea->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea, MouseMoveHdl));
5603
0
    m_xDrawingArea->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea, MouseReleaseHdl));
5604
0
    m_xDrawingArea->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea, KeyPressHdl));
5605
0
    m_xDrawingArea->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea, KeyReleaseHdl));
5606
0
    m_xDrawingArea->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea, StyleUpdatedHdl));
5607
0
    m_xDrawingArea->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea, QueryTooltipHdl));
5608
0
    m_xDrawingArea->SetGetSurroundingHdl(LINK(this, SalInstanceDrawingArea, GetSurroundingHdl));
5609
0
    m_xDrawingArea->SetDeleteSurroundingHdl(
5610
0
        LINK(this, SalInstanceDrawingArea, DeleteSurroundingHdl));
5611
0
    m_xDrawingArea->SetStartDragHdl(LINK(this, SalInstanceDrawingArea, StartDragHdl));
5612
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)
5613
5614
0
void SalInstanceDrawingArea::queue_draw() { m_xDrawingArea->Invalidate(); }
5615
5616
void SalInstanceDrawingArea::queue_draw_area(int x, int y, int width, int height)
5617
0
{
5618
0
    m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height)));
5619
0
}
5620
5621
void SalInstanceDrawingArea::connect_size_allocate(const Link<const Size&, void>& rLink)
5622
0
{
5623
0
    weld::Widget::connect_size_allocate(rLink);
5624
0
}
5625
5626
void SalInstanceDrawingArea::connect_key_press(const Link<const KeyEvent&, bool>& rLink)
5627
0
{
5628
0
    weld::Widget::connect_key_press(rLink);
5629
0
}
5630
5631
void SalInstanceDrawingArea::connect_key_release(const Link<const KeyEvent&, bool>& rLink)
5632
0
{
5633
0
    weld::Widget::connect_key_release(rLink);
5634
0
}
5635
5636
void SalInstanceDrawingArea::connect_style_updated(const Link<Widget&, void>& rLink)
5637
0
{
5638
0
    weld::Widget::connect_style_updated(rLink);
5639
0
}
5640
5641
void SalInstanceDrawingArea::set_cursor(PointerStyle ePointerStyle)
5642
0
{
5643
0
    m_xDrawingArea->SetPointer(ePointerStyle);
5644
0
}
5645
5646
void SalInstanceDrawingArea::set_input_context(const InputContext& rInputContext)
5647
0
{
5648
0
    m_xDrawingArea->SetInputContext(rInputContext);
5649
0
}
5650
5651
void SalInstanceDrawingArea::im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
5652
                                                            int nExtTextInputWidth)
5653
0
{
5654
0
    tools::Rectangle aCursorRect = m_xDrawingArea->PixelToLogic(rCursorRect);
5655
0
    m_xDrawingArea->SetCursorRect(
5656
0
        &aCursorRect, m_xDrawingArea->PixelToLogic(Size(nExtTextInputWidth, 0)).Width());
5657
0
}
5658
5659
rtl::Reference<comphelper::OAccessible> SalInstanceDrawingArea::get_accessible_parent()
5660
0
{
5661
0
    vcl::Window* pParent = m_xDrawingArea->GetParent();
5662
0
    if (pParent)
5663
0
        return pParent->GetAccessible();
5664
0
    return {};
5665
0
}
5666
5667
a11yrelationset SalInstanceDrawingArea::get_accessible_relation_set()
5668
0
{
5669
0
    rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSetHelper
5670
0
        = new utl::AccessibleRelationSetHelper;
5671
0
    vcl::Window* pWindow = m_xDrawingArea.get();
5672
0
    if (pWindow)
5673
0
    {
5674
0
        vcl::Window* pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
5675
0
        if (pLabeledBy && pLabeledBy != pWindow)
5676
0
        {
5677
0
            css::uno::Sequence<css::uno::Reference<css::accessibility::XAccessible>> aSequence{
5678
0
                pLabeledBy->GetAccessible()
5679
0
            };
5680
0
            pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation(
5681
0
                css::accessibility::AccessibleRelationType_LABELED_BY, aSequence));
5682
0
        }
5683
0
        vcl::Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
5684
0
        if (pMemberOf && pMemberOf != pWindow)
5685
0
        {
5686
0
            css::uno::Sequence<css::uno::Reference<css::accessibility::XAccessible>> aSequence{
5687
0
                pMemberOf->GetAccessible()
5688
0
            };
5689
0
            pRelationSetHelper->AddRelation(css::accessibility::AccessibleRelation(
5690
0
                css::accessibility::AccessibleRelationType_MEMBER_OF, aSequence));
5691
0
        }
5692
0
    }
5693
0
    return pRelationSetHelper;
5694
0
}
5695
5696
AbsoluteScreenPixelPoint SalInstanceDrawingArea::get_accessible_location_on_screen()
5697
0
{
5698
0
    return m_xDrawingArea->OutputToAbsoluteScreenPixel(Point());
5699
0
}
5700
5701
Point SalInstanceDrawingArea::get_pointer_position() const
5702
0
{
5703
0
    return m_xDrawingArea->GetPointerPosPixel();
5704
0
}
5705
5706
void SalInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
5707
                                                sal_uInt8 eDNDConstants)
5708
0
{
5709
0
    m_xDrawingArea->SetDragHelper(rHelper, eDNDConstants);
5710
0
}
5711
5712
SalInstanceDrawingArea::~SalInstanceDrawingArea()
5713
0
{
5714
0
    m_xDrawingArea->SetDeleteSurroundingHdl(Link<const Selection&, bool>());
5715
0
    m_xDrawingArea->SetGetSurroundingHdl(Link<OUString&, int>());
5716
0
    m_xDrawingArea->SetQueryTooltipHdl(Link<tools::Rectangle&, OUString>());
5717
0
    m_xDrawingArea->SetStyleUpdatedHdl(Link<VclDrawingArea&, void>());
5718
0
    m_xDrawingArea->SetMousePressHdl(Link<const MouseEvent&, bool>());
5719
0
    m_xDrawingArea->SetMouseMoveHdl(Link<const MouseEvent&, bool>());
5720
0
    m_xDrawingArea->SetMouseReleaseHdl(Link<const MouseEvent&, bool>());
5721
0
    m_xDrawingArea->SetKeyPressHdl(Link<const KeyEvent&, bool>());
5722
0
    m_xDrawingArea->SetKeyReleaseHdl(Link<const KeyEvent&, bool>());
5723
0
    m_xDrawingArea->SetResizeHdl(Link<const Size&, void>());
5724
0
    m_xDrawingArea->SetPaintHdl(
5725
0
        Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>());
5726
5727
    // tdf#159089 dispose custom accessible here and unset for `m_xDrawingArea`
5728
    // rather than waiting for `m_xDrawingArea` to get disposed, to prevent
5729
    // unsafe use of the now potentially non-functional accessible until it
5730
    // gets disposed with the VclDrawingArea
5731
0
    rtl::Reference<comphelper::OAccessible> pAccessible = m_xDrawingArea->GetAccessible();
5732
0
    if (pAccessible.is())
5733
0
    {
5734
0
        pAccessible->dispose();
5735
0
        m_xDrawingArea->SetAccessible(nullptr);
5736
0
    }
5737
0
}
5738
5739
0
OutputDevice& SalInstanceDrawingArea::get_ref_device() { return *m_xDrawingArea->GetOutDev(); }
5740
5741
IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void)
5742
0
{
5743
0
    m_aDrawHdl.Call(aPayload);
5744
0
    tools::Rectangle aFocusRect(m_aGetFocusRectHdl.Call(*this));
5745
0
    if (!aFocusRect.IsEmpty())
5746
0
        InvertFocusRect(aPayload.first, aFocusRect);
5747
0
}
5748
5749
IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void)
5750
0
{
5751
0
    signal_size_allocate(rSize);
5752
0
}
5753
5754
IMPL_LINK(SalInstanceDrawingArea, MousePressHdl, const MouseEvent&, rEvent, bool)
5755
0
{
5756
0
    return m_aMousePressHdl.Call(rEvent);
5757
0
}
5758
5759
IMPL_LINK(SalInstanceDrawingArea, MouseMoveHdl, const MouseEvent&, rEvent, bool)
5760
0
{
5761
0
    return m_aMouseMotionHdl.Call(rEvent);
5762
0
}
5763
5764
IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const MouseEvent&, rEvent, bool)
5765
0
{
5766
0
    return m_aMouseReleaseHdl.Call(rEvent);
5767
0
}
5768
5769
IMPL_LINK(SalInstanceDrawingArea, KeyPressHdl, const KeyEvent&, rEvent, bool)
5770
0
{
5771
0
    return m_aKeyPressHdl.Call(rEvent);
5772
0
}
5773
5774
IMPL_LINK(SalInstanceDrawingArea, KeyReleaseHdl, const KeyEvent&, rEvent, bool)
5775
0
{
5776
0
    return m_aKeyReleaseHdl.Call(rEvent);
5777
0
}
5778
5779
IMPL_LINK_NOARG(SalInstanceDrawingArea, StyleUpdatedHdl, VclDrawingArea&, void)
5780
0
{
5781
0
    m_aStyleUpdatedHdl.Call(*this);
5782
0
}
5783
5784
IMPL_LINK(SalInstanceDrawingArea, GetSurroundingHdl, OUString&, rSurrounding, int)
5785
0
{
5786
0
    return m_aGetSurroundingHdl.Call(rSurrounding);
5787
0
}
5788
5789
IMPL_LINK(SalInstanceDrawingArea, DeleteSurroundingHdl, const Selection&, rSelection, bool)
5790
0
{
5791
0
    return m_aDeleteSurroundingHdl.Call(rSelection);
5792
0
}
5793
5794
IMPL_LINK(SalInstanceDrawingArea, QueryTooltipHdl, tools::Rectangle&, rHelpArea, OUString)
5795
0
{
5796
0
    return m_aQueryTooltipHdl.Call(rHelpArea);
5797
0
}
5798
5799
IMPL_LINK_NOARG(SalInstanceDrawingArea, StartDragHdl, VclDrawingArea*, bool)
5800
0
{
5801
0
    if (m_aDragBeginHdl.Call(*this))
5802
0
        return true;
5803
0
    return false;
5804
0
}
5805
5806
SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox* pListBox,
5807
                                                               SalInstanceBuilder* pBuilder,
5808
                                                               bool bTakeOwnership)
5809
0
    : SalInstanceComboBox<ListBox>(pListBox, pBuilder, bTakeOwnership)
5810
0
{
5811
0
    m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit, SelectHdl));
5812
0
}
Unexecuted instantiation: SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox*, SalInstanceBuilder*, bool)
5813
5814
OUString SalInstanceComboBoxWithoutEdit::get_active_text() const
5815
0
{
5816
0
    return m_xComboBox->GetSelectedEntry();
5817
0
}
5818
5819
0
void SalInstanceComboBoxWithoutEdit::remove(int pos) { m_xComboBox->RemoveEntry(pos); }
5820
5821
void SalInstanceComboBoxWithoutEdit::do_insert(int pos, const OUString& rStr, const OUString* pId,
5822
                                               const OUString* pIconName,
5823
                                               VirtualDevice* pImageSurface)
5824
0
{
5825
0
    auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
5826
0
    sal_Int32 nInsertedAt;
5827
0
    if (!pIconName && !pImageSurface)
5828
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos);
5829
0
    else if (pIconName)
5830
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pIconName), nInsertPos);
5831
0
    else
5832
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pImageSurface), nInsertPos);
5833
0
    if (pId)
5834
0
    {
5835
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
5836
0
        m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get());
5837
0
    }
5838
0
}
5839
5840
void SalInstanceComboBoxWithoutEdit::insert_separator(int pos, const OUString& /*rId*/)
5841
0
{
5842
0
    auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos;
5843
0
    m_xComboBox->AddSeparator(nInsertPos - 1);
5844
0
}
5845
5846
0
bool SalInstanceComboBoxWithoutEdit::has_entry() const { return false; }
5847
5848
0
bool SalInstanceComboBoxWithoutEdit::changed_by_direct_pick() const { return true; }
5849
5850
void SalInstanceComboBoxWithoutEdit::set_entry_message_type(weld::EntryMessageType /*eType*/)
5851
0
{
5852
0
    assert(false);
5853
0
}
5854
5855
0
void SalInstanceComboBoxWithoutEdit::do_set_entry_text(const OUString& /*rText*/) { assert(false); }
5856
5857
void SalInstanceComboBoxWithoutEdit::select_entry_region(int /*nStartPos*/, int /*nEndPos*/)
5858
0
{
5859
0
    assert(false);
5860
0
}
5861
5862
bool SalInstanceComboBoxWithoutEdit::get_entry_selection_bounds(int& /*rStartPos*/,
5863
                                                                int& /*rEndPos*/)
5864
0
{
5865
0
    assert(false);
5866
0
    return false;
5867
0
}
5868
5869
0
void SalInstanceComboBoxWithoutEdit::set_entry_width_chars(int /*nChars*/) { assert(false); }
5870
5871
0
void SalInstanceComboBoxWithoutEdit::set_entry_max_length(int /*nChars*/) { assert(false); }
5872
5873
0
void SalInstanceComboBoxWithoutEdit::set_entry_completion(bool, bool) { assert(false); }
5874
5875
0
void SalInstanceComboBoxWithoutEdit::set_entry_placeholder_text(const OUString&) { assert(false); }
5876
5877
0
void SalInstanceComboBoxWithoutEdit::set_entry_editable(bool /*bEditable*/) { assert(false); }
5878
5879
0
void SalInstanceComboBoxWithoutEdit::cut_entry_clipboard() { assert(false); }
5880
5881
0
void SalInstanceComboBoxWithoutEdit::copy_entry_clipboard() { assert(false); }
5882
5883
0
void SalInstanceComboBoxWithoutEdit::paste_entry_clipboard() { assert(false); }
5884
5885
void SalInstanceComboBoxWithoutEdit::set_font(const vcl::Font& rFont)
5886
0
{
5887
0
    m_xComboBox->SetControlFont(rFont);
5888
0
    m_xComboBox->Invalidate();
5889
0
}
5890
5891
0
void SalInstanceComboBoxWithoutEdit::set_entry_font(const vcl::Font&) { assert(false); }
5892
5893
vcl::Font SalInstanceComboBoxWithoutEdit::get_entry_font()
5894
0
{
5895
0
    assert(false);
5896
0
    return vcl::Font();
5897
0
}
5898
5899
void SalInstanceComboBoxWithoutEdit::set_custom_renderer(bool /*bOn*/)
5900
0
{
5901
0
    assert(false && "not implemented");
5902
0
}
5903
5904
int SalInstanceComboBoxWithoutEdit::get_max_mru_count() const
5905
0
{
5906
0
    assert(false && "not implemented");
5907
0
    return 0;
5908
0
}
5909
5910
0
void SalInstanceComboBoxWithoutEdit::set_max_mru_count(int) { assert(false && "not implemented"); }
5911
5912
std::vector<OUString> SalInstanceComboBoxWithoutEdit::get_mru_entries() const
5913
0
{
5914
0
    assert(false && "not implemented");
5915
0
    return {};
5916
0
}
5917
5918
void SalInstanceComboBoxWithoutEdit::set_mru_entries(const std::vector<OUString>&)
5919
0
{
5920
0
    assert(false && "not implemented");
5921
0
}
5922
5923
void SalInstanceComboBoxWithoutEdit::HandleEventListener(VclWindowEvent& rEvent)
5924
0
{
5925
0
    CallHandleEventListener(rEvent);
5926
0
}
5927
5928
SalInstanceComboBoxWithoutEdit::~SalInstanceComboBoxWithoutEdit()
5929
0
{
5930
0
    m_xComboBox->SetSelectHdl(Link<ListBox&, void>());
5931
0
}
5932
5933
IMPL_LINK_NOARG(SalInstanceComboBoxWithoutEdit, SelectHdl, ListBox&, void)
5934
0
{
5935
0
    return signal_changed();
5936
0
}
5937
5938
SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(::ComboBox* pComboBox,
5939
                                                         SalInstanceBuilder* pBuilder,
5940
                                                         bool bTakeOwnership)
5941
0
    : SalInstanceComboBox<::ComboBox>(pComboBox, pBuilder, bTakeOwnership)
5942
0
    , m_aTextFilter(m_aEntryInsertTextHdl)
5943
0
    , m_bInSelect(false)
5944
0
{
5945
0
    m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl));
5946
0
    m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithEdit, SelectHdl));
5947
0
    m_xComboBox->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit, EntryActivateHdl));
5948
0
    m_xComboBox->SetTextFilter(&m_aTextFilter);
5949
0
}
Unexecuted instantiation: SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(ComboBox*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(ComboBox*, SalInstanceBuilder*, bool)
5950
5951
0
bool SalInstanceComboBoxWithEdit::has_entry() const { return true; }
5952
5953
void SalInstanceComboBoxWithEdit::call_attention_to()
5954
0
{
5955
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
5956
0
    assert(pEdit);
5957
0
    m_xFlashAttention.reset(new SalFlashAttention(pEdit));
5958
0
    m_xFlashAttention->Start();
5959
0
}
5960
5961
bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const
5962
0
{
5963
0
    return m_bInSelect && !m_xComboBox->IsModifyByKeyboard() && !m_xComboBox->IsTravelSelect();
5964
0
}
5965
5966
void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType)
5967
0
{
5968
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
5969
0
    assert(pEdit);
5970
0
    ::set_message_type(pEdit, eType);
5971
0
}
5972
5973
0
OUString SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox->GetText(); }
5974
5975
0
void SalInstanceComboBoxWithEdit::remove(int pos) { m_xComboBox->RemoveEntryAt(pos); }
5976
5977
void SalInstanceComboBoxWithEdit::do_insert(int pos, const OUString& rStr, const OUString* pId,
5978
                                            const OUString* pIconName, VirtualDevice* pImageSurface)
5979
0
{
5980
0
    auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
5981
0
    sal_Int32 nInsertedAt;
5982
0
    if (!pIconName && !pImageSurface)
5983
0
        nInsertedAt = m_xComboBox->InsertEntry(rStr, nInsertPos);
5984
0
    else if (pIconName)
5985
0
        nInsertedAt = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pIconName), nInsertPos);
5986
0
    else
5987
0
        nInsertedAt
5988
0
            = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pImageSurface), nInsertPos);
5989
0
    if (pId)
5990
0
    {
5991
0
        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
5992
0
        m_xComboBox->SetEntryData(nInsertedAt, m_aUserData.back().get());
5993
0
    }
5994
0
}
5995
5996
void SalInstanceComboBoxWithEdit::insert_separator(int pos, const OUString& /*rId*/)
5997
0
{
5998
0
    auto nInsertPos = pos == -1 ? m_xComboBox->GetEntryCount() : pos;
5999
0
    m_xComboBox->AddSeparator(nInsertPos - 1);
6000
0
}
6001
6002
void SalInstanceComboBoxWithEdit::do_set_entry_text(const OUString& rText)
6003
0
{
6004
0
    m_xComboBox->SetText(rText);
6005
0
}
6006
6007
void SalInstanceComboBoxWithEdit::set_entry_width_chars(int nChars)
6008
0
{
6009
0
    m_xComboBox->SetWidthInChars(nChars);
6010
0
}
6011
6012
void SalInstanceComboBoxWithEdit::set_entry_max_length(int nChars)
6013
0
{
6014
0
    m_xComboBox->SetMaxTextLen(nChars);
6015
0
}
6016
6017
void SalInstanceComboBoxWithEdit::set_entry_completion(bool bEnable, bool bCaseSensitive)
6018
0
{
6019
0
    m_xComboBox->EnableAutocomplete(bEnable, bCaseSensitive);
6020
0
}
6021
6022
void SalInstanceComboBoxWithEdit::set_entry_placeholder_text(const OUString& rText)
6023
0
{
6024
0
    m_xComboBox->SetPlaceholderText(rText);
6025
0
}
6026
6027
void SalInstanceComboBoxWithEdit::set_entry_editable(bool bEditable)
6028
0
{
6029
0
    m_xComboBox->SetReadOnly(!bEditable);
6030
0
}
6031
6032
0
void SalInstanceComboBoxWithEdit::cut_entry_clipboard() { m_xComboBox->Cut(); }
6033
6034
0
void SalInstanceComboBoxWithEdit::copy_entry_clipboard() { m_xComboBox->Copy(); }
6035
6036
0
void SalInstanceComboBoxWithEdit::paste_entry_clipboard() { m_xComboBox->Paste(); }
6037
6038
void SalInstanceComboBoxWithEdit::select_entry_region(int nStartPos, int nEndPos)
6039
0
{
6040
0
    m_xComboBox->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
6041
0
}
6042
6043
bool SalInstanceComboBoxWithEdit::get_entry_selection_bounds(int& rStartPos, int& rEndPos)
6044
0
{
6045
0
    const Selection& rSelection = m_xComboBox->GetSelection();
6046
0
    rStartPos = rSelection.Min();
6047
0
    rEndPos = rSelection.Max();
6048
0
    return rSelection.Len();
6049
0
}
6050
6051
void SalInstanceComboBoxWithEdit::set_font(const vcl::Font& rFont)
6052
0
{
6053
0
    m_xComboBox->SetControlFont(rFont);
6054
0
    m_xComboBox->Invalidate();
6055
0
}
6056
6057
void SalInstanceComboBoxWithEdit::set_entry_font(const vcl::Font& rFont)
6058
0
{
6059
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
6060
0
    assert(pEdit);
6061
0
    pEdit->SetControlFont(rFont); // tdf#134601 set it as control font to take effect properly
6062
0
    pEdit->Invalidate();
6063
0
}
6064
6065
vcl::Font SalInstanceComboBoxWithEdit::get_entry_font()
6066
0
{
6067
0
    Edit* pEdit = m_xComboBox->GetSubEdit();
6068
0
    assert(pEdit);
6069
0
    return pEdit->GetPointFont(*pEdit->GetOutDev());
6070
0
}
6071
6072
void SalInstanceComboBoxWithEdit::set_custom_renderer(bool bOn)
6073
0
{
6074
0
    if (m_xComboBox->IsUserDrawEnabled() == bOn)
6075
0
        return;
6076
6077
0
    auto nOldEntryHeight = m_xComboBox->GetDropDownEntryHeight();
6078
0
    auto nDropDownLineCount = m_xComboBox->GetDropDownLineCount();
6079
6080
0
    m_xComboBox->EnableUserDraw(bOn);
6081
0
    if (bOn)
6082
0
        m_xComboBox->SetUserDrawHdl(LINK(this, SalInstanceComboBoxWithEdit, UserDrawHdl));
6083
0
    else
6084
0
        m_xComboBox->SetUserDrawHdl(Link<UserDrawEvent*, void>());
6085
6086
    // adjust the line count to fit approx the height it would have been before
6087
    // changing the renderer
6088
0
    auto nNewEntryHeight = m_xComboBox->GetDropDownEntryHeight();
6089
0
    double fRatio = nOldEntryHeight / static_cast<double>(nNewEntryHeight);
6090
0
    m_xComboBox->SetDropDownLineCount(nDropDownLineCount * fRatio);
6091
0
}
6092
6093
0
int SalInstanceComboBoxWithEdit::get_max_mru_count() const { return m_xComboBox->GetMaxMRUCount(); }
6094
6095
void SalInstanceComboBoxWithEdit::set_max_mru_count(int nCount)
6096
0
{
6097
0
    return m_xComboBox->SetMaxMRUCount(nCount);
6098
0
}
6099
6100
std::vector<OUString> SalInstanceComboBoxWithEdit::get_mru_entries() const
6101
0
{
6102
0
    return m_xComboBox->GetMRUEntries();
6103
0
}
6104
6105
void SalInstanceComboBoxWithEdit::set_mru_entries(const std::vector<OUString>& rEntries)
6106
0
{
6107
0
    m_xComboBox->SetMRUEntries(rEntries);
6108
0
}
6109
6110
void SalInstanceComboBoxWithEdit::HandleEventListener(VclWindowEvent& rEvent)
6111
0
{
6112
0
    if (rEvent.GetId() == VclEventId::DropdownPreOpen)
6113
0
    {
6114
0
        Size aRowSize(signal_custom_get_size(*m_xComboBox->GetOutDev()));
6115
0
        m_xComboBox->SetUserItemSize(aRowSize);
6116
0
    }
6117
0
    CallHandleEventListener(rEvent);
6118
0
}
6119
6120
SalInstanceComboBoxWithEdit::~SalInstanceComboBoxWithEdit()
6121
0
{
6122
0
    m_xComboBox->SetTextFilter(nullptr);
6123
0
    m_xComboBox->SetEntryActivateHdl(Link<Edit&, bool>());
6124
0
    m_xComboBox->SetModifyHdl(Link<Edit&, void>());
6125
0
    m_xComboBox->SetSelectHdl(Link<::ComboBox&, void>());
6126
0
}
6127
6128
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, ChangeHdl, Edit&, void)
6129
0
{
6130
0
    if (!m_xComboBox->IsSyntheticModify()) // SelectHdl will be called
6131
0
        signal_changed();
6132
0
}
6133
6134
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, SelectHdl, ::ComboBox&, void)
6135
0
{
6136
0
    m_bInSelect = true;
6137
0
    signal_changed();
6138
0
    m_bInSelect = false;
6139
0
}
6140
6141
IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, bool)
6142
0
{
6143
0
    return m_aEntryActivateHdl.Call(*this);
6144
0
}
6145
6146
IMPL_LINK(SalInstanceComboBoxWithEdit, UserDrawHdl, UserDrawEvent*, pEvent, void)
6147
0
{
6148
0
    call_signal_custom_render(pEvent);
6149
0
}
6150
6151
class SalInstanceEntryTreeView : public SalInstanceContainer, public virtual weld::EntryTreeView
6152
{
6153
private:
6154
    DECL_LINK(AutocompleteHdl, Edit&, void);
6155
    DECL_LINK(KeyPressListener, VclWindowEvent&, void);
6156
    SalInstanceEntry* m_pEntry;
6157
    SalInstanceTreeView* m_pTreeView;
6158
    bool m_bTreeChange;
6159
6160
public:
6161
    SalInstanceEntryTreeView(vcl::Window* pContainer, SalInstanceBuilder* pBuilder,
6162
                             bool bTakeOwnership, std::unique_ptr<weld::Entry> xEntry,
6163
                             std::unique_ptr<weld::TreeView> xTreeView)
6164
0
        : EntryTreeView(std::move(xEntry), std::move(xTreeView))
6165
0
        , SalInstanceContainer(pContainer, pBuilder, bTakeOwnership)
6166
0
        , m_pEntry(dynamic_cast<SalInstanceEntry*>(m_xEntry.get()))
6167
0
        , m_pTreeView(dynamic_cast<SalInstanceTreeView*>(m_xTreeView.get()))
6168
0
        , m_bTreeChange(false)
6169
0
    {
6170
0
        assert(m_pEntry && m_pTreeView);
6171
6172
0
        Edit& rEntry = m_pEntry->getEntry();
6173
0
        rEntry.SetAutocompleteHdl(LINK(this, SalInstanceEntryTreeView, AutocompleteHdl));
6174
0
        rEntry.AddEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener));
6175
0
    }
6176
6177
    virtual void make_sorted() override
6178
0
    {
6179
0
        vcl::Window* pTreeView = m_pTreeView->getWidget();
6180
0
        pTreeView->SetStyle(pTreeView->GetStyle() | WB_SORT);
6181
0
    }
6182
6183
    virtual void set_entry_completion(bool bEnable, bool /*bCaseSensitive*/) override
6184
0
    {
6185
0
        assert(!bEnable && "not implemented yet");
6186
0
        (void)bEnable;
6187
0
        Edit& rEntry = m_pEntry->getEntry();
6188
0
        rEntry.SetAutocompleteHdl(Link<Edit&, void>());
6189
0
    }
6190
6191
0
    virtual void grab_focus() override { m_xEntry->grab_focus(); }
6192
6193
    virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
6194
0
    {
6195
0
        m_xEntry->connect_focus_in(rLink);
6196
0
    }
6197
6198
    virtual void connect_focus_out(const Link<Widget&, void>& rLink) override
6199
0
    {
6200
0
        m_xEntry->connect_focus_out(rLink);
6201
0
    }
6202
6203
0
    virtual bool changed_by_direct_pick() const override { return m_bTreeChange; }
6204
6205
    virtual ~SalInstanceEntryTreeView() override
6206
0
    {
6207
0
        Edit& rEntry = m_pEntry->getEntry();
6208
0
        rEntry.RemoveEventListener(LINK(this, SalInstanceEntryTreeView, KeyPressListener));
6209
0
        rEntry.SetAutocompleteHdl(Link<Edit&, void>());
6210
0
    }
6211
};
6212
6213
IMPL_LINK(SalInstanceEntryTreeView, KeyPressListener, VclWindowEvent&, rEvent, void)
6214
0
{
6215
0
    if (rEvent.GetId() != VclEventId::WindowKeyInput)
6216
0
        return;
6217
0
    const KeyEvent& rKeyEvent = *static_cast<KeyEvent*>(rEvent.GetData());
6218
0
    if (rKeyEvent.GetKeyCode().GetModifier()) // tdf#163777 ignore when modifier held
6219
0
        return;
6220
0
    sal_uInt16 nKeyCode = rKeyEvent.GetKeyCode().GetCode();
6221
0
    const bool bNavigation = nKeyCode == KEY_UP || nKeyCode == KEY_DOWN || nKeyCode == KEY_PAGEUP
6222
0
                             || nKeyCode == KEY_PAGEDOWN;
6223
0
    if (!bNavigation)
6224
0
        return;
6225
6226
0
    m_pTreeView->disableNotifyEvents();
6227
0
    auto& rListBox = m_pTreeView->getTreeView();
6228
0
    if (!rListBox.FirstSelected())
6229
0
    {
6230
0
        if (SvTreeListEntry* pEntry = rListBox.First())
6231
0
            rListBox.Select(pEntry, true);
6232
0
    }
6233
0
    else
6234
0
        rListBox.KeyInput(rKeyEvent);
6235
0
    m_xEntry->set_text(m_xTreeView->get_selected_text());
6236
0
    m_xEntry->select_region(0, -1);
6237
0
    m_pTreeView->enableNotifyEvents();
6238
0
    m_bTreeChange = true;
6239
0
    m_pEntry->fire_signal_changed();
6240
0
    m_bTreeChange = false;
6241
0
}
6242
6243
IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void)
6244
0
{
6245
0
    Selection aSel = rEdit.GetSelection();
6246
6247
0
    OUString aFullText = rEdit.GetText();
6248
0
    OUString aStartText = aFullText.copy(0, static_cast<sal_Int32>(aSel.Max()));
6249
6250
0
    int nPos = -1;
6251
0
    int nCount = m_xTreeView->n_children();
6252
0
    for (int i = 0; i < nCount; ++i)
6253
0
    {
6254
0
        if (m_xTreeView->get_text(i).startsWithIgnoreAsciiCase(aStartText))
6255
0
        {
6256
0
            nPos = i;
6257
0
            break;
6258
0
        }
6259
0
    }
6260
6261
0
    m_xTreeView->select(nPos);
6262
6263
0
    if (nPos != -1)
6264
0
    {
6265
0
        OUString aText = m_xTreeView->get_text(nPos);
6266
0
        Selection aSelection(aText.getLength(), aStartText.getLength());
6267
0
        rEdit.SetText(aText, aSelection);
6268
0
    }
6269
0
}
6270
6271
SalInstancePopover::SalInstancePopover(DockingWindow* pPopover, SalInstanceBuilder* pBuilder,
6272
                                       bool bTakeOwnership)
6273
0
    : SalInstanceContainer(pPopover, pBuilder, bTakeOwnership)
6274
0
    , m_xPopover(pPopover)
6275
0
{
6276
0
}
Unexecuted instantiation: SalInstancePopover::SalInstancePopover(DockingWindow*, SalInstanceBuilder*, bool)
Unexecuted instantiation: SalInstancePopover::SalInstancePopover(DockingWindow*, SalInstanceBuilder*, bool)
6277
6278
SalInstancePopover::~SalInstancePopover()
6279
0
{
6280
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6281
0
    if (pDockingManager->IsInPopupMode(m_xPopover))
6282
0
        ImplPopDown();
6283
0
}
6284
6285
void SalInstancePopover::popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
6286
                                       weld::Placement ePlace)
6287
0
{
6288
0
    SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pParent);
6289
0
    assert(pVclWidget);
6290
0
    vcl::Window* pWidget = pVclWidget->getWidget();
6291
6292
0
    tools::Rectangle aRect;
6293
0
    Point aPt = pWidget->OutputToScreenPixel(rRect.TopLeft());
6294
0
    aRect.SetLeft(aPt.X());
6295
0
    aRect.SetTop(aPt.Y());
6296
0
    aPt = pWidget->OutputToScreenPixel(rRect.BottomRight());
6297
0
    aRect.SetRight(aPt.X());
6298
0
    aRect.SetBottom(aPt.Y());
6299
6300
0
    FloatWinPopupFlags nFlags = FloatWinPopupFlags::NoMouseUpClose;
6301
0
    if (!(pWidget->GetStyle() & WB_NOPOINTERFOCUS))
6302
0
        nFlags = nFlags | FloatWinPopupFlags::GrabFocus;
6303
0
    if (ePlace == weld::Placement::Under)
6304
0
        nFlags = nFlags | FloatWinPopupFlags::Down;
6305
0
    else
6306
0
        nFlags = nFlags | FloatWinPopupFlags::Right;
6307
6308
0
    m_xPopover->EnableDocking();
6309
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6310
0
    pDockingManager->SetPopupModeEndHdl(m_xPopover,
6311
0
                                        LINK(this, SalInstancePopover, PopupModeEndHdl));
6312
0
    pDockingManager->StartPopupMode(m_xPopover, aRect, nFlags);
6313
0
}
6314
6315
void SalInstancePopover::ImplPopDown()
6316
0
{
6317
0
    vcl::Window::GetDockingManager()->EndPopupMode(m_xPopover);
6318
0
    m_xPopover->EnableDocking(false);
6319
0
    signal_closed();
6320
0
}
6321
6322
0
void SalInstancePopover::popdown() { ImplPopDown(); }
6323
6324
void SalInstancePopover::resize_to_request()
6325
0
{
6326
0
    ::resize_to_request(m_xPopover.get());
6327
6328
0
    DockingManager* pDockingManager = vcl::Window::GetDockingManager();
6329
0
    if (pDockingManager->IsInPopupMode(m_xPopover.get()))
6330
0
    {
6331
0
        Size aSize = m_xPopover->get_preferred_size();
6332
0
        tools::Rectangle aRect = pDockingManager->GetPosSizePixel(m_xPopover.get());
6333
0
        pDockingManager->SetPosSizePixel(m_xPopover.get(), aRect.Left(), aRect.Top(), aSize.Width(),
6334
0
                                         aSize.Height(), PosSizeFlags::Size);
6335
0
    }
6336
0
}
6337
6338
0
IMPL_LINK_NOARG(SalInstancePopover, PopupModeEndHdl, FloatingWindow*, void) { signal_closed(); }
6339
6340
SalInstanceColorChooserDialog::SalInstanceColorChooserDialog(
6341
    std::unique_ptr<ColorPickerDialog> pColorDialog)
6342
0
    : SalInstanceDialog(dynamic_cast<SalInstanceDialog&>(*pColorDialog->getDialog()).getDialog(),
6343
0
                        nullptr, false)
6344
0
    , m_pColorPickerDialog(std::move(pColorDialog))
6345
0
{
6346
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> >)
6347
6348
0
SalInstanceColorChooserDialog::~SalInstanceColorChooserDialog() {}
6349
6350
void SalInstanceColorChooserDialog::set_color(const Color& rColor)
6351
0
{
6352
0
    m_pColorPickerDialog->SetColor(rColor);
6353
0
}
6354
6355
0
Color SalInstanceColorChooserDialog::get_color() const { return m_pColorPickerDialog->GetColor(); }
6356
6357
SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, std::u16string_view sUIRoot,
6358
                                       const OUString& rUIFile,
6359
                                       const css::uno::Reference<css::frame::XFrame>& rFrame)
6360
0
    : weld::Builder()
6361
0
    , m_xBuilder(new VclBuilder(pParent, sUIRoot, rUIFile, {}, rFrame, false))
6362
0
{
6363
0
}
6364
6365
std::unique_ptr<weld::MessageDialog> SalInstanceBuilder::weld_message_dialog(const OUString& id)
6366
0
{
6367
0
    MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id);
6368
0
    std::unique_ptr<weld::MessageDialog> pRet(
6369
0
        pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr);
6370
0
    if (pMessageDialog)
6371
0
    {
6372
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6373
0
        m_aOwnedToplevel.reset(pMessageDialog);
6374
0
        m_xBuilder->drop_ownership(pMessageDialog);
6375
0
    }
6376
0
    return pRet;
6377
0
}
6378
6379
std::unique_ptr<weld::Dialog> SalInstanceBuilder::weld_dialog(const OUString& id)
6380
0
{
6381
0
    Dialog* pDialog = m_xBuilder->get<Dialog>(id);
6382
0
    std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false)
6383
0
                                               : nullptr);
6384
0
    if (pDialog)
6385
0
    {
6386
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6387
0
        m_aOwnedToplevel.reset(pDialog);
6388
0
        m_xBuilder->drop_ownership(pDialog);
6389
0
    }
6390
0
    return pRet;
6391
0
}
6392
6393
std::unique_ptr<weld::Assistant> SalInstanceBuilder::weld_assistant(const OUString& id)
6394
0
{
6395
0
    vcl::RoadmapWizard* pDialog = m_xBuilder->get<vcl::RoadmapWizard>(id);
6396
0
    std::unique_ptr<weld::Assistant> pRet(pDialog ? new SalInstanceAssistant(pDialog, this, false)
6397
0
                                                  : nullptr);
6398
0
    if (pDialog)
6399
0
    {
6400
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6401
0
        m_aOwnedToplevel.reset(pDialog);
6402
0
        m_xBuilder->drop_ownership(pDialog);
6403
0
    }
6404
0
    return pRet;
6405
0
}
6406
6407
std::unique_ptr<weld::Window> SalInstanceBuilder::create_screenshot_window()
6408
0
{
6409
0
    assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6410
6411
0
    vcl::Window* pRoot = m_xBuilder->get_widget_root();
6412
0
    if (SystemWindow* pWindow = dynamic_cast<SystemWindow*>(pRoot))
6413
0
    {
6414
0
        std::unique_ptr<weld::Window> xRet(new SalInstanceWindow(pWindow, this, false));
6415
0
        m_aOwnedToplevel.reset(pWindow);
6416
0
        m_xBuilder->drop_ownership(pWindow);
6417
0
        return xRet;
6418
0
    }
6419
6420
0
    VclPtrInstance<Dialog> xDialog(nullptr, WB_HIDE | WB_STDDIALOG | WB_SIZEABLE | WB_CLOSEABLE,
6421
0
                                   Dialog::InitFlag::NoParent);
6422
0
    xDialog->SetText(utl::ConfigManager::getProductName());
6423
6424
0
    auto xContentArea = VclPtr<VclVBox>::Create(xDialog, false, 12);
6425
0
    pRoot->SetParent(xContentArea);
6426
0
    assert(pRoot == xContentArea->GetWindow(GetWindowType::FirstChild));
6427
0
    xContentArea->Show();
6428
0
    pRoot->Show();
6429
0
    xDialog->SetHelpId(pRoot->GetHelpId());
6430
6431
0
    m_aOwnedToplevel.reset(xDialog);
6432
6433
0
    return std::unique_ptr<weld::Dialog>(new SalInstanceDialog(xDialog, this, false));
6434
0
}
6435
6436
std::unique_ptr<weld::Widget> SalInstanceBuilder::weld_widget(const OUString& id)
6437
0
{
6438
0
    vcl::Window* pWidget = m_xBuilder->get(id);
6439
0
    return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, false) : nullptr;
6440
0
}
6441
6442
std::unique_ptr<weld::Container> SalInstanceBuilder::weld_container(const OUString& id)
6443
0
{
6444
0
    vcl::Window* pContainer = m_xBuilder->get(id);
6445
0
    return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, false) : nullptr;
6446
0
}
6447
6448
std::unique_ptr<weld::Box> SalInstanceBuilder::weld_box(const OUString& id)
6449
0
{
6450
0
    VclBox* pContainer = m_xBuilder->get<VclBox>(id);
6451
0
    return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, false) : nullptr;
6452
0
}
6453
6454
std::unique_ptr<weld::Grid> SalInstanceBuilder::weld_grid(const OUString& id)
6455
0
{
6456
0
    VclGrid* pGrid = m_xBuilder->get<VclGrid>(id);
6457
0
    return pGrid ? std::make_unique<SalInstanceGrid>(pGrid, this, false) : nullptr;
6458
0
}
6459
6460
std::unique_ptr<weld::Paned> SalInstanceBuilder::weld_paned(const OUString& id)
6461
0
{
6462
0
    VclPaned* pPaned = m_xBuilder->get<VclPaned>(id);
6463
0
    return pPaned ? std::make_unique<SalInstancePaned>(pPaned, this, false) : nullptr;
6464
0
}
6465
6466
std::unique_ptr<weld::Frame> SalInstanceBuilder::weld_frame(const OUString& id)
6467
0
{
6468
0
    VclFrame* pFrame = m_xBuilder->get<VclFrame>(id);
6469
0
    std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr);
6470
0
    return pRet;
6471
0
}
6472
6473
std::unique_ptr<weld::ScrolledWindow>
6474
SalInstanceBuilder::weld_scrolled_window(const OUString& id, bool bUserManagedScrolling)
6475
0
{
6476
0
    VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id);
6477
0
    return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(
6478
0
                                 pScrolledWindow, this, false, bUserManagedScrolling)
6479
0
                           : nullptr;
6480
0
}
6481
6482
std::unique_ptr<weld::Notebook> SalInstanceBuilder::weld_notebook(const OUString& id)
6483
0
{
6484
0
    vcl::Window* pNotebook = m_xBuilder->get(id);
6485
0
    if (!pNotebook)
6486
0
        return nullptr;
6487
0
    if (pNotebook->GetType() == WindowType::TABCONTROL)
6488
0
        return std::make_unique<SalInstanceNotebook>(static_cast<TabControl*>(pNotebook), this,
6489
0
                                                     false);
6490
0
    if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL)
6491
0
        return std::make_unique<SalInstanceVerticalNotebook>(
6492
0
            static_cast<VerticalTabControl*>(pNotebook), this, false);
6493
0
    return nullptr;
6494
0
}
6495
6496
std::unique_ptr<weld::Button> SalInstanceBuilder::weld_button(const OUString& id)
6497
0
{
6498
0
    Button* pButton = m_xBuilder->get<Button>(id);
6499
0
    return pButton ? std::make_unique<SalInstanceButton>(pButton, this, false) : nullptr;
6500
0
}
6501
6502
std::unique_ptr<weld::MenuButton> SalInstanceBuilder::weld_menu_button(const OUString& id)
6503
0
{
6504
0
    MenuButton* pButton = m_xBuilder->get<MenuButton>(id);
6505
0
    return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, false) : nullptr;
6506
0
}
6507
6508
std::unique_ptr<weld::LinkButton> SalInstanceBuilder::weld_link_button(const OUString& id)
6509
0
{
6510
0
    FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id);
6511
0
    return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, false) : nullptr;
6512
0
}
6513
6514
std::unique_ptr<weld::ToggleButton> SalInstanceBuilder::weld_toggle_button(const OUString& id)
6515
0
{
6516
0
    PushButton* pToggleButton = m_xBuilder->get<PushButton>(id);
6517
0
    return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, false)
6518
0
                         : nullptr;
6519
0
}
6520
6521
std::unique_ptr<weld::RadioButton> SalInstanceBuilder::weld_radio_button(const OUString& id)
6522
0
{
6523
0
    RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id);
6524
0
    return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, false)
6525
0
                        : nullptr;
6526
0
}
6527
6528
std::unique_ptr<weld::CheckButton> SalInstanceBuilder::weld_check_button(const OUString& id)
6529
0
{
6530
0
    CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
6531
0
    return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, false)
6532
0
                        : nullptr;
6533
0
}
6534
6535
std::unique_ptr<weld::Scale> SalInstanceBuilder::weld_scale(const OUString& id)
6536
0
{
6537
0
    Slider* pSlider = m_xBuilder->get<Slider>(id);
6538
0
    return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, false) : nullptr;
6539
0
}
6540
6541
std::unique_ptr<weld::ProgressBar> SalInstanceBuilder::weld_progress_bar(const OUString& id)
6542
0
{
6543
0
    ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id);
6544
0
    return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, false) : nullptr;
6545
0
}
6546
6547
std::unique_ptr<weld::LevelBar> SalInstanceBuilder::weld_level_bar(const OUString& id)
6548
0
{
6549
0
    ::ProgressBar* pLevel = m_xBuilder->get<::ProgressBar>(id);
6550
0
    return pLevel ? std::make_unique<SalInstanceLevelBar>(pLevel, this, false) : nullptr;
6551
0
}
6552
6553
std::unique_ptr<weld::Spinner> SalInstanceBuilder::weld_spinner(const OUString& id)
6554
0
{
6555
0
    Throbber* pThrobber = m_xBuilder->get<Throbber>(id);
6556
0
    return pThrobber ? std::make_unique<SalInstanceSpinner>(pThrobber, this, false) : nullptr;
6557
0
}
6558
6559
std::unique_ptr<weld::Image> SalInstanceBuilder::weld_image(const OUString& id)
6560
0
{
6561
0
    FixedImage* pImage = m_xBuilder->get<FixedImage>(id);
6562
0
    return pImage ? std::make_unique<SalInstanceImage>(pImage, this, false) : nullptr;
6563
0
}
6564
6565
std::unique_ptr<weld::Calendar> SalInstanceBuilder::weld_calendar(const OUString& id)
6566
0
{
6567
0
    Calendar* pCalendar = m_xBuilder->get<Calendar>(id);
6568
0
    return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, false) : nullptr;
6569
0
}
6570
6571
std::unique_ptr<weld::Entry> SalInstanceBuilder::weld_entry(const OUString& id)
6572
0
{
6573
0
    Edit* pEntry = m_xBuilder->get<Edit>(id);
6574
0
    return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, false) : nullptr;
6575
0
}
6576
6577
std::unique_ptr<weld::SpinButton> SalInstanceBuilder::weld_spin_button(const OUString& id)
6578
0
{
6579
0
    FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
6580
0
    return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, false)
6581
0
                       : nullptr;
6582
0
}
6583
6584
std::unique_ptr<weld::MetricSpinButton>
6585
SalInstanceBuilder::weld_metric_spin_button(const OUString& id, FieldUnit eUnit)
6586
0
{
6587
0
    std::unique_ptr<weld::SpinButton> xButton(weld_spin_button(id));
6588
0
    if (xButton)
6589
0
    {
6590
0
        SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(*xButton);
6591
0
        rButton.SetUseThousandSep();
6592
0
    }
6593
0
    return std::make_unique<weld::MetricSpinButton>(std::move(xButton), eUnit);
6594
0
}
6595
6596
std::unique_ptr<weld::FormattedSpinButton>
6597
SalInstanceBuilder::weld_formatted_spin_button(const OUString& id)
6598
0
{
6599
0
    FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
6600
0
    return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, false)
6601
0
                       : nullptr;
6602
0
}
6603
6604
std::unique_ptr<weld::ComboBox> SalInstanceBuilder::weld_combo_box(const OUString& id)
6605
0
{
6606
0
    vcl::Window* pWidget = m_xBuilder->get(id);
6607
0
    ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget);
6608
0
    if (pComboBox)
6609
0
        return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, false);
6610
0
    ListBox* pListBox = dynamic_cast<ListBox*>(pWidget);
6611
0
    return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, false)
6612
0
                    : nullptr;
6613
0
}
6614
6615
std::unique_ptr<weld::EntryTreeView>
6616
SalInstanceBuilder::weld_entry_tree_view(const OUString& containerid, const OUString& entryid,
6617
                                         const OUString& treeviewid)
6618
0
{
6619
0
    vcl::Window* pContainer = m_xBuilder->get(containerid);
6620
0
    return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, this, false,
6621
0
                                                                   weld_entry(entryid),
6622
0
                                                                   weld_tree_view(treeviewid))
6623
0
                      : nullptr;
6624
0
}
6625
6626
std::unique_ptr<weld::TreeView> SalInstanceBuilder::weld_tree_view(const OUString& id)
6627
0
{
6628
0
    SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id);
6629
0
    return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, false) : nullptr;
6630
0
}
6631
6632
std::unique_ptr<weld::IconView> SalInstanceBuilder::weld_icon_view(const OUString& id)
6633
0
{
6634
0
    IconView* pIconView = m_xBuilder->get<IconView>(id);
6635
0
    return pIconView ? std::make_unique<SalInstanceIconView>(pIconView, this, false) : nullptr;
6636
0
}
6637
6638
std::unique_ptr<weld::Label> SalInstanceBuilder::weld_label(const OUString& id)
6639
0
{
6640
0
    Control* pLabel = m_xBuilder->get<Control>(id);
6641
0
    return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, false) : nullptr;
6642
0
}
6643
6644
std::unique_ptr<weld::TextView> SalInstanceBuilder::weld_text_view(const OUString& id)
6645
0
{
6646
0
    VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
6647
0
    return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, false) : nullptr;
6648
0
}
6649
6650
std::unique_ptr<weld::Expander> SalInstanceBuilder::weld_expander(const OUString& id)
6651
0
{
6652
0
    VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
6653
0
    return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, false) : nullptr;
6654
0
}
6655
6656
std::unique_ptr<weld::DrawingArea>
6657
SalInstanceBuilder::weld_drawing_area(const OUString& id,
6658
                                      const rtl::Reference<comphelper::OAccessible>& rA11yImpl,
6659
                                      FactoryFunction pUITestFactoryFunction, void* pUserData)
6660
0
{
6661
0
    VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id);
6662
0
    return pDrawingArea
6663
0
               ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl,
6664
0
                                                          pUITestFactoryFunction, pUserData, false)
6665
0
               : nullptr;
6666
0
}
6667
6668
std::unique_ptr<weld::Menu> SalInstanceBuilder::weld_menu(const OUString& id)
6669
0
{
6670
0
    PopupMenu* pMenu = m_xBuilder->get_menu(id);
6671
0
    return pMenu ? std::make_unique<SalInstanceMenu>(pMenu, true) : nullptr;
6672
0
}
6673
6674
std::unique_ptr<weld::Popover> SalInstanceBuilder::weld_popover(const OUString& id)
6675
0
{
6676
0
    DockingWindow* pDockingWindow = m_xBuilder->get<DockingWindow>(id);
6677
0
    std::unique_ptr<weld::Popover> pRet(
6678
0
        pDockingWindow ? new SalInstancePopover(pDockingWindow, this, false) : nullptr);
6679
0
    if (pDockingWindow)
6680
0
    {
6681
0
        assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
6682
0
        m_aOwnedToplevel.reset(pDockingWindow);
6683
0
        m_xBuilder->drop_ownership(pDockingWindow);
6684
0
    }
6685
0
    return pRet;
6686
0
}
6687
6688
std::unique_ptr<weld::Toolbar> SalInstanceBuilder::weld_toolbar(const OUString& id)
6689
0
{
6690
0
    ToolBox* pToolBox = m_xBuilder->get<ToolBox>(id);
6691
0
    return pToolBox ? std::make_unique<SalInstanceToolbar>(pToolBox, this, false) : nullptr;
6692
0
}
6693
6694
std::unique_ptr<weld::Scrollbar> SalInstanceBuilder::weld_scrollbar(const OUString& id)
6695
0
{
6696
0
    ScrollBar* pScrollbar = m_xBuilder->get<ScrollBar>(id);
6697
0
    return pScrollbar ? std::make_unique<SalInstanceScrollbar>(pScrollbar, this, false) : nullptr;
6698
0
}
6699
6700
std::unique_ptr<weld::SizeGroup> SalInstanceBuilder::create_size_group(VclSizeGroupMode eMode)
6701
0
{
6702
0
    return std::make_unique<SalInstanceSizeGroup>(eMode);
6703
0
}
6704
6705
OUString SalInstanceBuilder::get_current_page_help_id() const
6706
0
{
6707
0
    vcl::Window* pCtrl = m_xBuilder->get(u"tabcontrol");
6708
0
    if (!pCtrl)
6709
0
        return {};
6710
0
    VclPtr<vcl::Window> xTabPage;
6711
0
    if (pCtrl->GetType() == WindowType::TABCONTROL)
6712
0
    {
6713
0
        TabControl* pTabCtrl = static_cast<TabControl*>(pCtrl);
6714
0
        xTabPage = pTabCtrl->GetTabPage(pTabCtrl->GetCurPageId());
6715
0
    }
6716
0
    else if (pCtrl->GetType() == WindowType::VERTICALTABCONTROL)
6717
0
    {
6718
0
        VerticalTabControl* pTabCtrl = static_cast<VerticalTabControl*>(pCtrl);
6719
0
        xTabPage = pTabCtrl->GetPage(pTabCtrl->GetCurPageId());
6720
0
    }
6721
0
    vcl::Window* pTabChild = xTabPage ? xTabPage->GetWindow(GetWindowType::FirstChild) : nullptr;
6722
0
    pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr;
6723
0
    if (pTabChild)
6724
0
        return pTabChild->GetHelpId();
6725
0
    return {};
6726
0
}
6727
6728
SalInstanceBuilder::~SalInstanceBuilder()
6729
0
{
6730
0
    if (VclBuilderContainer* pOwnedToplevel
6731
0
        = dynamic_cast<VclBuilderContainer*>(m_aOwnedToplevel.get()))
6732
0
        pOwnedToplevel->m_pUIBuilder = std::move(m_xBuilder);
6733
0
    else
6734
0
        m_xBuilder.reset();
6735
0
    m_aOwnedToplevel.disposeAndClear();
6736
0
}
6737
6738
void SalInstanceWindow::help()
6739
0
{
6740
    //show help for widget with keyboard focus
6741
0
    vcl::Window* pWidget = ImplGetSVData()->mpWinData->mpFocusWin;
6742
0
    if (!pWidget)
6743
0
        pWidget = m_xWindow;
6744
0
    if (comphelper::LibreOfficeKit::isActive() && m_xWindow->GetFocusedWindow())
6745
0
        pWidget = m_xWindow->GetFocusedWindow().get();
6746
0
    OUString sHelpId = pWidget->GetHelpId();
6747
0
    while (sHelpId.isEmpty())
6748
0
    {
6749
0
        pWidget = pWidget->GetParent();
6750
0
        if (!pWidget)
6751
0
            break;
6752
0
        sHelpId = pWidget->GetHelpId();
6753
0
    }
6754
0
    std::unique_ptr<weld::Widget> xTemp(
6755
0
        pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr);
6756
0
    weld::Widget* pSource = xTemp ? xTemp.get() : this;
6757
0
    bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource);
6758
0
    Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr;
6759
0
    if (!pHelp)
6760
0
        return;
6761
6762
    // tdf#126007, there's a nice fallback route for offline help where
6763
    // the current page of a notebook will get checked when the help
6764
    // button is pressed and there was no help for the dialog found.
6765
    //
6766
    // But for online help that route doesn't get taken, so bodge this here
6767
    // by using the page help id if available and if the help button itself
6768
    // was the original id
6769
0
    if (m_pBuilder && sHelpId.endsWith("/help"))
6770
0
    {
6771
0
        OUString sPageId = m_pBuilder->get_current_page_help_id();
6772
0
        if (!sPageId.isEmpty())
6773
0
            sHelpId = sPageId;
6774
0
        else
6775
0
        {
6776
            // tdf#129068 likewise the help for the wrapping dialog is less
6777
            // helpful than the help for the content area could be
6778
0
            vcl::Window* pContentArea = nullptr;
6779
0
            if (::Dialog* pDialog = dynamic_cast<::Dialog*>(m_xWindow.get()))
6780
0
                pContentArea = pDialog->get_content_area();
6781
0
            if (pContentArea)
6782
0
            {
6783
0
                vcl::Window* pContentWidget = pContentArea->GetWindow(GetWindowType::LastChild);
6784
0
                if (pContentWidget)
6785
0
                    sHelpId = pContentWidget->GetHelpId();
6786
0
            }
6787
0
        }
6788
0
    }
6789
0
    pHelp->Start(sHelpId, pSource);
6790
0
}
6791
6792
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */