Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/writerperfect/source/common/WPFTEncodingDialog.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 <cstddef>
23
#include <string_view>
24
#include <utility>
25
26
#include <WPFTEncodingDialog.hxx>
27
28
#include <vcl/svapp.hxx>
29
#include <vcl/vclenum.hxx>
30
#include <vcl/weld/Builder.hxx>
31
#include <vcl/weld/Dialog.hxx>
32
33
namespace writerperfect
34
{
35
namespace
36
{
37
std::pair<std::u16string_view, std::u16string_view> const s_encodings[]
38
    = { { u"MacArabic", u"Arabic (Apple Macintosh)" },
39
        { u"CP864", u"Arabic (DOS/OS2-864)" },
40
        { u"CP1006", u"Arabic (IBM-1006)" },
41
        { u"CP1256", u"Arabic (Windows-1256)" },
42
        { u"CP775", u"Baltic (DOS/OS2-775)" },
43
        { u"CP1257", u"Baltic (Windows-1257)" },
44
        { u"MacCeltic", u"Celtic (Apple Macintosh)" },
45
        { u"MacCyrillic", u"Cyrillic (Apple Macintosh)" },
46
        { u"CP855", u"Cyrillic (DOS/OS2-855)" },
47
        { u"CP866", u"Cyrillic (DOS/OS2-866/Russian)" },
48
        { u"CP1251", u"Cyrillic (Windows-1251)" },
49
        { u"MacCEurope", u"Eastern Europe (Apple Macintosh)" },
50
        { u"MacCroatian", u"Eastern Europe (Apple Macintosh/Croatian)" },
51
        { u"MacRomanian", u"Eastern Europe (Apple Macintosh/Romanian)" },
52
        { u"CP852", u"Eastern Europe (DOS/OS2-852)" },
53
        { u"CP1250", u"Eastern Europe (Windows-1250/WinLatin 2)" },
54
        { u"MacGreek", u"Greek (Apple Macintosh)" },
55
        { u"CP737", u"Greek (DOS/OS2-737)" },
56
        { u"CP869", u"Greek (DOS/OS2-869/Greek-2)" },
57
        { u"CP875", u"Greek (DOS/OS2-875)" },
58
        { u"CP1253", u"Greek (Windows-1253)" },
59
        { u"MacHebrew", u"Hebrew (Apple Macintosh)" },
60
        { u"CP424", u"Hebrew (DOS/OS2-424)" },
61
        { u"CP856", u"Hebrew (DOS/OS2-856)" },
62
        { u"CP862", u"Hebrew (DOS/OS2-862)" },
63
        { u"CP1255", u"Hebrew (Windows-1255)" },
64
        { u"CP500", u"International (DOS/OS2-500)" },
65
        { u"CP932", u"Japanese (Windows-932)" },
66
        { u"MacThai", u"Thai (Apple Macintosh)" },
67
        { u"CP874", u"Thai (DOS/OS2-874)" },
68
        { u"CP950", u"Traditional Chinese (Windows-950)" },
69
        { u"MacTurkish", u"Turkish (Apple Macintosh)" },
70
        { u"CP857", u"Turkish (DOS/OS2-857)" },
71
        { u"CP1026", u"Turkish (DOS/OS2-1026)" },
72
        { u"CP1254", u"Turkish (Windows-1254)" },
73
        { u"CP1258", u"Vietnamese (Windows-1258)" },
74
        { u"MacRoman", u"Western Europe (Apple Macintosh)" },
75
        { u"MacIceland", u"Western Europe (Apple Macintosh/Icelandic)" },
76
        { u"CP037", u"Western Europe (DOS/OS2-037/US-Canada)" },
77
        { u"CP437", u"Western Europe (DOS/OS2-437/US)" },
78
        { u"CP850", u"Western Europe (DOS/OS2-850)" },
79
        { u"CP860", u"Western Europe (DOS/OS2-860/Portuguese)" },
80
        { u"CP861", u"Western Europe (DOS/OS2-861/Icelandic)" },
81
        { u"CP863", u"Western Europe (DOS/OS2-863/French)" },
82
        { u"CP865", u"Western Europe (DOS/OS2-865/Nordic)" },
83
        { u"CP1252", u"Western Europe (Windows-1252/WinLatin 1)" } };
84
85
void insertEncodings(weld::ComboBox& box)
86
0
{
87
0
    for (const auto& rEncoding : s_encodings)
88
0
        box.append(OUString(rEncoding.first), OUString(rEncoding.second));
89
0
}
90
}
91
92
WPFTEncodingDialog::WPFTEncodingDialog(weld::Window* pParent, const OUString& title,
93
                                       const OUString& encoding)
94
0
    : GenericDialogController(pParent, u"writerperfect/ui/wpftencodingdialog.ui"_ustr,
95
0
                              u"WPFTEncodingDialog"_ustr)
96
0
    , m_userHasCancelled(false)
97
0
    , m_xLbCharset(m_xBuilder->weld_combo_box(u"comboboxtext"_ustr))
98
0
    , m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr))
99
0
{
100
0
    m_xBtnCancel->connect_clicked(LINK(this, WPFTEncodingDialog, CancelHdl));
101
102
0
    insertEncodings(*m_xLbCharset);
103
0
    m_xLbCharset->make_sorted();
104
0
    m_xLbCharset->set_active_id(encoding);
105
106
0
    m_xDialog->set_title(title);
107
108
0
    m_xDialog->SetInstallLOKNotifierHdl(LINK(this, WPFTEncodingDialog, InstallLOKNotifierHdl));
109
0
}
110
111
IMPL_STATIC_LINK_NOARG(WPFTEncodingDialog, InstallLOKNotifierHdl, void*,
112
                       vcl::ILibreOfficeKitNotifier*)
113
0
{
114
0
    return GetpApp();
115
0
}
116
117
0
WPFTEncodingDialog::~WPFTEncodingDialog() {}
118
119
0
OUString WPFTEncodingDialog::GetEncoding() const { return m_xLbCharset->get_active_id(); }
120
121
IMPL_LINK_NOARG(WPFTEncodingDialog, CancelHdl, weld::Button&, void)
122
0
{
123
0
    m_userHasCancelled = true;
124
0
    m_xDialog->response(RET_CANCEL);
125
0
}
126
}
127
128
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */