1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
23 #include <string_view>
26 #include <WPFTEncodingDialog.hxx>
28 namespace writerperfect
32 std::pair
<std::u16string_view
, std::u16string_view
> const s_encodings
[]
33 = { { u
"MacArabic", u
"Arabic (Apple Macintosh)" },
34 { u
"CP864", u
"Arabic (DOS/OS2-864)" },
35 { u
"CP1006", u
"Arabic (IBM-1006)" },
36 { u
"CP1256", u
"Arabic (Windows-1256)" },
37 { u
"CP775", u
"Baltic (DOS/OS2-775)" },
38 { u
"CP1257", u
"Baltic (Windows-1257)" },
39 { u
"MacCeltic", u
"Celtic (Apple Macintosh)" },
40 { u
"MacCyrillic", u
"Cyrillic (Apple Macintosh)" },
41 { u
"CP855", u
"Cyrillic (DOS/OS2-855)" },
42 { u
"CP866", u
"Cyrillic (DOS/OS2-866/Russian)" },
43 { u
"CP1251", u
"Cyrillic (Windows-1251)" },
44 { u
"MacCEurope", u
"Eastern Europe (Apple Macintosh)" },
45 { u
"MacCroatian", u
"Eastern Europe (Apple Macintosh/Croatian)" },
46 { u
"MacRomanian", u
"Eastern Europe (Apple Macintosh/Romanian)" },
47 { u
"CP852", u
"Eastern Europe (DOS/OS2-852)" },
48 { u
"CP1250", u
"Eastern Europe (Windows-1250/WinLatin 2)" },
49 { u
"MacGreek", u
"Greek (Apple Macintosh)" },
50 { u
"CP737", u
"Greek (DOS/OS2-737)" },
51 { u
"CP869", u
"Greek (DOS/OS2-869/Greek-2)" },
52 { u
"CP875", u
"Greek (DOS/OS2-875)" },
53 { u
"CP1253", u
"Greek (Windows-1253)" },
54 { u
"MacHebrew", u
"Hebrew (Apple Macintosh)" },
55 { u
"CP424", u
"Hebrew (DOS/OS2-424)" },
56 { u
"CP856", u
"Hebrew (DOS/OS2-856)" },
57 { u
"CP862", u
"Hebrew (DOS/OS2-862)" },
58 { u
"CP1255", u
"Hebrew (Windows-1255)" },
59 { u
"CP500", u
"International (DOS/OS2-500)" },
60 { u
"CP932", u
"Japanese (Windows-932)" },
61 { u
"MacThai", u
"Thai (Apple Macintosh)" },
62 { u
"CP874", u
"Thai (DOS/OS2-874)" },
63 { u
"CP950", u
"Traditional Chinese (Windows-950)" },
64 { u
"MacTurkish", u
"Turkish (Apple Macintosh)" },
65 { u
"CP857", u
"Turkish (DOS/OS2-857)" },
66 { u
"CP1026", u
"Turkish (DOS/OS2-1026)" },
67 { u
"CP1254", u
"Turkish (Windows-1254)" },
68 { u
"CP1258", u
"Vietnamese (Windows-1258)" },
69 { u
"MacRoman", u
"Western Europe (Apple Macintosh)" },
70 { u
"MacIceland", u
"Western Europe (Apple Macintosh/Icelandic)" },
71 { u
"CP037", u
"Western Europe (DOS/OS2-037/US-Canada)" },
72 { u
"CP437", u
"Western Europe (DOS/OS2-437/US)" },
73 { u
"CP850", u
"Western Europe (DOS/OS2-850)" },
74 { u
"CP860", u
"Western Europe (DOS/OS2-860/Portuguese)" },
75 { u
"CP861", u
"Western Europe (DOS/OS2-861/Icelandic)" },
76 { u
"CP863", u
"Western Europe (DOS/OS2-863/French)" },
77 { u
"CP865", u
"Western Europe (DOS/OS2-865/Nordic)" },
78 { u
"CP1252", u
"Western Europe (Windows-1252/WinLatin 1)" } };
80 std::size_t const numEncodings
= SAL_N_ELEMENTS(s_encodings
);
82 void insertEncodings(weld::ComboBox
& box
)
84 for (std::size_t i
= 0; i
< numEncodings
; ++i
)
85 box
.append(OUString(s_encodings
[i
].first
), OUString(s_encodings
[i
].second
));
88 void selectEncoding(weld::ComboBox
& box
, const OUString
& encoding
) { box
.set_active_id(encoding
); }
90 OUString
getEncoding(const weld::ComboBox
& box
) { return box
.get_active_id(); }
93 WPFTEncodingDialog::WPFTEncodingDialog(weld::Window
* pParent
, const OUString
& title
,
94 const OUString
& encoding
)
95 : GenericDialogController(pParent
, "writerperfect/ui/wpftencodingdialog.ui",
97 , m_userHasCancelled(false)
98 , m_xLbCharset(m_xBuilder
->weld_combo_box("comboboxtext"))
99 , m_xBtnCancel(m_xBuilder
->weld_button("cancel"))
101 m_xBtnCancel
->connect_clicked(LINK(this, WPFTEncodingDialog
, CancelHdl
));
103 insertEncodings(*m_xLbCharset
);
104 m_xLbCharset
->make_sorted();
105 selectEncoding(*m_xLbCharset
, encoding
);
107 m_xDialog
->set_title(title
);
110 WPFTEncodingDialog::~WPFTEncodingDialog() {}
112 OUString
WPFTEncodingDialog::GetEncoding() const { return getEncoding(*m_xLbCharset
); }
114 IMPL_LINK_NOARG(WPFTEncodingDialog
, CancelHdl
, weld::Button
&, void)
116 m_userHasCancelled
= true;
117 m_xDialog
->response(RET_CANCEL
);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */