summaryrefslogtreecommitdiff
path: root/sc/source/ui/miscdlgs/gototabdlg.cxx
blob: e38e671009eebd5a0931377ad40084def81cdc57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

#undef SC_DLLIMPLEMENTATION

#include <gototabdlg.hxx>

ScGoToTabDlg::ScGoToTabDlg(weld::Window* pParent)
    : GenericDialogController(pParent, "modules/scalc/ui/gotosheetdialog.ui", "GoToSheetDialog")
    , m_xFrameMask(m_xBuilder->weld_frame("frame-mask"))
    , m_xEnNameMask(m_xBuilder->weld_entry("entry-mask"))
    , m_xFrameSheets(m_xBuilder->weld_frame("frame-sheets"))
    , m_xLb(m_xBuilder->weld_tree_view("treeview"))
{
    m_xLb->set_selection_mode(SelectionMode::Single);
    m_xLb->set_size_request(-1, m_xLb->get_height_rows(10));
    m_xLb->connect_row_activated(LINK(this, ScGoToTabDlg, DblClkHdl));
    m_xEnNameMask->connect_changed(LINK(this, ScGoToTabDlg, FindNameHdl));
}

ScGoToTabDlg::~ScGoToTabDlg() {}

void ScGoToTabDlg::SetDescription(const OUString& rTitle, const OUString& rEntryLabel,
                                  const OUString& rListLabel, const OString& rDlgHelpId,
                                  const OString& rEnHelpId, const OString& rLbHelpId)
{
    m_xDialog->set_title(rTitle);
    m_xFrameMask->set_label(rEntryLabel);
    m_xFrameSheets->set_label(rListLabel);
    m_xDialog->set_help_id(rDlgHelpId);
    m_xEnNameMask->set_help_id(rEnHelpId);
    m_xLb->set_help_id(rLbHelpId);
}

void ScGoToTabDlg::Insert(const OUString& rString, bool bSelected)
{
    maCacheSheetsNames.push_back(rString);
    m_xLb->append_text(rString);
    if (bSelected)
        m_xLb->select(m_xLb->n_children() - 1);
}

OUString ScGoToTabDlg::GetSelectedEntry() const { return m_xLb->get_selected_text(); }

IMPL_LINK_NOARG(ScGoToTabDlg, DblClkHdl, weld::TreeView&, bool)
{
    m_xDialog->response(RET_OK);
    return true;
}

IMPL_LINK_NOARG(ScGoToTabDlg, FindNameHdl, weld::Entry&, void)
{
    const OUString aMask = m_xEnNameMask->get_text();
    m_xLb->clear();
    if (aMask.isEmpty())
    {
        for (const OUString& s : maCacheSheetsNames)
        {
            m_xLb->append_text(s);
        }
    }
    else
    {
        for (const OUString& s : maCacheSheetsNames)
        {
            if (s.indexOf(aMask) >= 0)
            {
                m_xLb->append_text(s);
            }
        }
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */