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 <svtools/langtab.hxx>
21 #include <comphelper/configuration.hxx>
22 #include <officecfg/Office/Common.hxx>
23 #include "opthtml.hxx"
26 OfaHtmlTabPage::OfaHtmlTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
27 : SfxTabPage(pPage
, pController
, u
"cui/ui/opthtmlpage.ui"_ustr
, u
"OptHtmlPage"_ustr
, &rSet
)
28 , m_xSize1NF(m_xBuilder
->weld_spin_button(u
"size1"_ustr
))
29 , m_xSize1Img(m_xBuilder
->weld_widget(u
"locksize1"_ustr
))
30 , m_xSize2NF(m_xBuilder
->weld_spin_button(u
"size2"_ustr
))
31 , m_xSize2Img(m_xBuilder
->weld_widget(u
"locksize2"_ustr
))
32 , m_xSize3NF(m_xBuilder
->weld_spin_button(u
"size3"_ustr
))
33 , m_xSize3Img(m_xBuilder
->weld_widget(u
"locksize3"_ustr
))
34 , m_xSize4NF(m_xBuilder
->weld_spin_button(u
"size4"_ustr
))
35 , m_xSize4Img(m_xBuilder
->weld_widget(u
"locksize4"_ustr
))
36 , m_xSize5NF(m_xBuilder
->weld_spin_button(u
"size5"_ustr
))
37 , m_xSize5Img(m_xBuilder
->weld_widget(u
"locksize5"_ustr
))
38 , m_xSize6NF(m_xBuilder
->weld_spin_button(u
"size6"_ustr
))
39 , m_xSize6Img(m_xBuilder
->weld_widget(u
"locksize6"_ustr
))
40 , m_xSize7NF(m_xBuilder
->weld_spin_button(u
"size7"_ustr
))
41 , m_xSize7Img(m_xBuilder
->weld_widget(u
"locksize7"_ustr
))
42 , m_xNumbersEnglishUSCB(m_xBuilder
->weld_check_button(u
"numbersenglishus"_ustr
))
43 , m_xNumbersEnglishUSImg(m_xBuilder
->weld_widget(u
"locknumbersenglishus"_ustr
))
44 , m_xUnknownTagCB(m_xBuilder
->weld_check_button(u
"unknowntag"_ustr
))
45 , m_xUnknownTagImg(m_xBuilder
->weld_widget(u
"lockunknowntag"_ustr
))
46 , m_xIgnoreFontNamesCB(m_xBuilder
->weld_check_button(u
"ignorefontnames"_ustr
))
47 , m_xIgnoreFontNamesImg(m_xBuilder
->weld_widget(u
"lockignorefontnames"_ustr
))
48 , m_xStarBasicCB(m_xBuilder
->weld_check_button(u
"starbasic"_ustr
))
49 , m_xStarBasicImg(m_xBuilder
->weld_widget(u
"lockstarbasic"_ustr
))
50 , m_xStarBasicWarningCB(m_xBuilder
->weld_check_button(u
"starbasicwarning"_ustr
))
51 , m_xStarBasicWarningImg(m_xBuilder
->weld_widget(u
"lockstarbasicwarning"_ustr
))
52 , m_xPrintExtensionCB(m_xBuilder
->weld_check_button(u
"printextension"_ustr
))
53 , m_xPrintExtensionImg(m_xBuilder
->weld_widget(u
"lockprintextension"_ustr
))
54 , m_xSaveGrfLocalCB(m_xBuilder
->weld_check_button(u
"savegrflocal"_ustr
))
55 , m_xSaveGrfLocalImg(m_xBuilder
->weld_widget(u
"locksavegrflocal"_ustr
))
57 // replace placeholder with UI string from language list
58 OUString
aText(m_xNumbersEnglishUSCB
->get_label());
59 OUString
aPlaceholder(u
"%ENGLISHUSLOCALE"_ustr
);
61 if ((nPos
= aText
.indexOf( aPlaceholder
)) != -1)
63 const OUString aStr
= SvtLanguageTable::GetLanguageString( LANGUAGE_ENGLISH_US
);
66 aText
= aText
.replaceAt( nPos
, aPlaceholder
.getLength(), aStr
);
67 m_xNumbersEnglishUSCB
->set_label( aText
);
71 m_xStarBasicCB
->connect_toggled(LINK(this, OfaHtmlTabPage
, CheckBoxHdl_Impl
));
74 OfaHtmlTabPage::~OfaHtmlTabPage()
78 std::unique_ptr
<SfxTabPage
> OfaHtmlTabPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
79 const SfxItemSet
* rAttrSet
)
81 return std::make_unique
<OfaHtmlTabPage
>(pPage
, pController
, *rAttrSet
);
84 OUString
OfaHtmlTabPage::GetAllStrings()
87 OUString labels
[] = { u
"label1"_ustr
, u
"label2"_ustr
, u
"label3"_ustr
, u
"size1FT"_ustr
, u
"size2FT"_ustr
,
88 u
"size3FT"_ustr
, u
"size4FT"_ustr
, u
"size5FT"_ustr
, u
"size6FT"_ustr
, u
"size7FT"_ustr
};
90 for (const auto& label
: labels
)
92 if (const auto pString
= m_xBuilder
->weld_label(label
))
93 sAllStrings
+= pString
->get_label() + " ";
96 OUString checkButton
[] = { u
"numbersenglishus"_ustr
, u
"unknowntag"_ustr
, u
"ignorefontnames"_ustr
, u
"starbasic"_ustr
,
97 u
"starbasicwarning"_ustr
, u
"printextension"_ustr
, u
"savegrflocal"_ustr
};
99 for (const auto& check
: checkButton
)
101 if (const auto pString
= m_xBuilder
->weld_check_button(check
))
102 sAllStrings
+= pString
->get_label() + " ";
105 return sAllStrings
.replaceAll("_", "");
108 bool OfaHtmlTabPage::FillItemSet( SfxItemSet
* )
110 std::shared_ptr
<comphelper::ConfigurationChanges
> xChanges
= comphelper::ConfigurationChanges::create();
111 if(m_xSize1NF
->get_value_changed_from_saved())
112 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::set(
113 static_cast<sal_uInt16
>(m_xSize1NF
->get_value()), xChanges
);
114 if(m_xSize2NF
->get_value_changed_from_saved())
115 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::set(
116 static_cast<sal_uInt16
>(m_xSize2NF
->get_value()), xChanges
);
117 if(m_xSize3NF
->get_value_changed_from_saved())
118 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::set(
119 static_cast<sal_uInt16
>(m_xSize3NF
->get_value()), xChanges
);
120 if(m_xSize4NF
->get_value_changed_from_saved())
121 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::set(
122 static_cast<sal_uInt16
>(m_xSize4NF
->get_value()), xChanges
);
123 if(m_xSize5NF
->get_value_changed_from_saved())
124 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::set(
125 static_cast<sal_uInt16
>(m_xSize5NF
->get_value()), xChanges
);
126 if(m_xSize6NF
->get_value_changed_from_saved())
127 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::set(
128 static_cast<sal_uInt16
>(m_xSize6NF
->get_value()), xChanges
);
129 if(m_xSize7NF
->get_value_changed_from_saved())
130 officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::set(
131 static_cast<sal_uInt16
>(m_xSize7NF
->get_value()), xChanges
);
133 if(m_xNumbersEnglishUSCB
->get_state_changed_from_saved())
134 officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::set(
135 m_xNumbersEnglishUSCB
->get_active(), xChanges
);
137 if(m_xUnknownTagCB
->get_state_changed_from_saved())
138 officecfg::Office::Common::Filter::HTML::Import::UnknownTag::set(
139 m_xUnknownTagCB
->get_active(), xChanges
);
141 if(m_xIgnoreFontNamesCB
->get_state_changed_from_saved())
142 officecfg::Office::Common::Filter::HTML::Import::FontSetting::set(
143 m_xIgnoreFontNamesCB
->get_active(), xChanges
);
145 if(m_xStarBasicCB
->get_state_changed_from_saved())
146 officecfg::Office::Common::Filter::HTML::Export::Basic::set(
147 m_xStarBasicCB
->get_active(), xChanges
);
149 if(m_xStarBasicWarningCB
->get_state_changed_from_saved())
150 officecfg::Office::Common::Filter::HTML::Export::Warning::set(
151 m_xStarBasicWarningCB
->get_active(), xChanges
);
153 if(m_xSaveGrfLocalCB
->get_state_changed_from_saved())
154 officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::set(
155 m_xSaveGrfLocalCB
->get_active(), xChanges
);
157 if(m_xPrintExtensionCB
->get_state_changed_from_saved())
158 officecfg::Office::Common::Filter::HTML::Export::PrintLayout::set(
159 m_xPrintExtensionCB
->get_active(), xChanges
);
165 void OfaHtmlTabPage::Reset( const SfxItemSet
* )
167 m_xSize1NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get());
168 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::isReadOnly())
170 m_xSize1NF
->set_sensitive(false);
171 m_xSize1Img
->set_visible(true);
174 m_xSize2NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get());
175 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::isReadOnly())
177 m_xSize2NF
->set_sensitive(false);
178 m_xSize2Img
->set_visible(true);
181 m_xSize3NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get());
182 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::isReadOnly())
184 m_xSize3NF
->set_sensitive(false);
185 m_xSize3Img
->set_visible(true);
188 m_xSize4NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get());
189 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::isReadOnly())
191 m_xSize4NF
->set_sensitive(false);
192 m_xSize4Img
->set_visible(true);
195 m_xSize5NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get());
196 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::isReadOnly())
198 m_xSize5NF
->set_sensitive(false);
199 m_xSize5Img
->set_visible(true);
202 m_xSize6NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get());
203 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::isReadOnly())
205 m_xSize6NF
->set_sensitive(false);
206 m_xSize6Img
->set_visible(true);
209 m_xSize7NF
->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get());
210 if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::isReadOnly())
212 m_xSize7NF
->set_sensitive(false);
213 m_xSize7Img
->set_visible(true);
216 m_xNumbersEnglishUSCB
->set_active(officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get());
217 if (officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::isReadOnly())
219 m_xNumbersEnglishUSCB
->set_sensitive(false);
220 m_xNumbersEnglishUSImg
->set_visible(true);
223 m_xUnknownTagCB
->set_active(officecfg::Office::Common::Filter::HTML::Import::UnknownTag::get());
224 if (officecfg::Office::Common::Filter::HTML::Import::UnknownTag::isReadOnly())
226 m_xUnknownTagCB
->set_sensitive(false);
227 m_xUnknownTagImg
->set_visible(true);
230 m_xIgnoreFontNamesCB
->set_active(officecfg::Office::Common::Filter::HTML::Import::FontSetting::get());
231 if (officecfg::Office::Common::Filter::HTML::Import::FontSetting::isReadOnly())
233 m_xIgnoreFontNamesCB
->set_sensitive(false);
234 m_xIgnoreFontNamesImg
->set_visible(true);
237 m_xStarBasicCB
->set_active(officecfg::Office::Common::Filter::HTML::Export::Basic::get());
238 if (officecfg::Office::Common::Filter::HTML::Export::Basic::isReadOnly())
240 m_xStarBasicCB
->set_sensitive(false);
241 m_xStarBasicImg
->set_visible(true);
244 m_xStarBasicWarningCB
->set_active(officecfg::Office::Common::Filter::HTML::Export::Warning::get());
245 m_xStarBasicWarningCB
->set_sensitive(!m_xStarBasicCB
->get_active() && !officecfg::Office::Common::Filter::HTML::Export::Warning::isReadOnly());
246 m_xStarBasicWarningImg
->set_visible(officecfg::Office::Common::Filter::HTML::Export::Warning::isReadOnly());
248 m_xSaveGrfLocalCB
->set_active(officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get());
249 if (officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::isReadOnly())
251 m_xSaveGrfLocalCB
->set_sensitive(false);
252 m_xSaveGrfLocalImg
->set_visible(true);
255 m_xPrintExtensionCB
->set_active(officecfg::Office::Common::Filter::HTML::Export::PrintLayout::get());
256 if (officecfg::Office::Common::Filter::HTML::Export::PrintLayout::isReadOnly())
258 m_xPrintExtensionCB
->set_sensitive(false);
259 m_xPrintExtensionImg
->set_visible(true);
262 m_xPrintExtensionCB
->save_state();
263 m_xStarBasicCB
->save_state();
264 m_xStarBasicWarningCB
->save_state();
265 m_xSaveGrfLocalCB
->save_state();
266 m_xSize1NF
->save_value();
267 m_xSize2NF
->save_value();
268 m_xSize3NF
->save_value();
269 m_xSize4NF
->save_value();
270 m_xSize5NF
->save_value();
271 m_xSize6NF
->save_value();
272 m_xSize7NF
->save_value();
273 m_xNumbersEnglishUSCB
->save_state();
274 m_xUnknownTagCB
->save_state();
275 m_xIgnoreFontNamesCB
->save_state();
278 IMPL_LINK(OfaHtmlTabPage
, CheckBoxHdl_Impl
, weld::Toggleable
&, rBox
, void)
280 m_xStarBasicWarningCB
->set_sensitive(!rBox
.get_active());
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */