LibreOffice Module cui (master)  1
opthtml.cxx
Go to the documentation of this file.
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 <svtools/langtab.hxx>
21 #include <svtools/htmlcfg.hxx>
23 #include <officecfg/Office/Common.hxx>
24 #include "opthtml.hxx"
25 
26 
28  : SfxTabPage(pPage, pController, "cui/ui/opthtmlpage.ui", "OptHtmlPage", &rSet)
29  , m_xSize1NF(m_xBuilder->weld_spin_button("size1"))
30  , m_xSize2NF(m_xBuilder->weld_spin_button("size2"))
31  , m_xSize3NF(m_xBuilder->weld_spin_button("size3"))
32  , m_xSize4NF(m_xBuilder->weld_spin_button("size4"))
33  , m_xSize5NF(m_xBuilder->weld_spin_button("size5"))
34  , m_xSize6NF(m_xBuilder->weld_spin_button("size6"))
35  , m_xSize7NF(m_xBuilder->weld_spin_button("size7"))
36  , m_xNumbersEnglishUSCB(m_xBuilder->weld_check_button("numbersenglishus"))
37  , m_xUnknownTagCB(m_xBuilder->weld_check_button("unknowntag"))
38  , m_xIgnoreFontNamesCB(m_xBuilder->weld_check_button("ignorefontnames"))
39  , m_xStarBasicCB(m_xBuilder->weld_check_button("starbasic"))
40  , m_xStarBasicWarningCB(m_xBuilder->weld_check_button("starbasicwarning"))
41  , m_xPrintExtensionCB(m_xBuilder->weld_check_button("printextension"))
42  , m_xSaveGrfLocalCB(m_xBuilder->weld_check_button("savegrflocal"))
43  , m_xCharSetLB(new SvxTextEncodingBox(m_xBuilder->weld_combo_box("charset")))
44 {
45  // replace placeholder with UI string from language list
46  OUString aText(m_xNumbersEnglishUSCB->get_label());
47  OUString aPlaceholder("%ENGLISHUSLOCALE");
48  sal_Int32 nPos;
49  if ((nPos = aText.indexOf( aPlaceholder)) != -1)
50  {
52  if (!rStr.isEmpty())
53  {
54  aText = aText.replaceAt( nPos, aPlaceholder.getLength(), rStr);
55  m_xNumbersEnglishUSCB->set_label( aText);
56  }
57  }
58 
59  m_xStarBasicCB->connect_toggled(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
60 
61  // initialize the characterset listbox
62  m_xCharSetLB->FillWithMimeAndSelectBest();
63 }
64 
66 {
67 }
68 
69 std::unique_ptr<SfxTabPage> OfaHtmlTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
70  const SfxItemSet* rAttrSet )
71 {
72  return std::make_unique<OfaHtmlTabPage>(pPage, pController, *rAttrSet);
73 }
74 
76 {
77  std::shared_ptr<comphelper::ConfigurationChanges> xChanges = comphelper::ConfigurationChanges::create();
78  if(m_xSize1NF->get_value_changed_from_saved())
79  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::set(
80  static_cast<sal_uInt16>(m_xSize1NF->get_value()), xChanges);
81  if(m_xSize2NF->get_value_changed_from_saved())
82  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::set(
83  static_cast<sal_uInt16>(m_xSize2NF->get_value()), xChanges);
84  if(m_xSize3NF->get_value_changed_from_saved())
85  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::set(
86  static_cast<sal_uInt16>(m_xSize3NF->get_value()), xChanges);
87  if(m_xSize4NF->get_value_changed_from_saved())
88  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::set(
89  static_cast<sal_uInt16>(m_xSize4NF->get_value()), xChanges);
90  if(m_xSize5NF->get_value_changed_from_saved())
91  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::set(
92  static_cast<sal_uInt16>(m_xSize5NF->get_value()), xChanges);
93  if(m_xSize6NF->get_value_changed_from_saved())
94  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::set(
95  static_cast<sal_uInt16>(m_xSize6NF->get_value()), xChanges);
96  if(m_xSize7NF->get_value_changed_from_saved())
97  officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::set(
98  static_cast<sal_uInt16>(m_xSize7NF->get_value()), xChanges);
99 
100  if(m_xNumbersEnglishUSCB->get_state_changed_from_saved())
101  officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::set(
102  m_xNumbersEnglishUSCB->get_active(), xChanges);
103 
104  if(m_xUnknownTagCB->get_state_changed_from_saved())
105  officecfg::Office::Common::Filter::HTML::Import::UnknownTag::set(
106  m_xUnknownTagCB->get_active(), xChanges);
107 
108  if(m_xIgnoreFontNamesCB->get_state_changed_from_saved())
109  officecfg::Office::Common::Filter::HTML::Import::FontSetting::set(
110  m_xIgnoreFontNamesCB->get_active(), xChanges);
111 
112  if(m_xStarBasicCB->get_state_changed_from_saved())
113  officecfg::Office::Common::Filter::HTML::Export::Basic::set(
114  m_xStarBasicCB->get_active(), xChanges);
115 
116  if(m_xStarBasicWarningCB->get_state_changed_from_saved())
117  officecfg::Office::Common::Filter::HTML::Export::Warning::set(
118  m_xStarBasicWarningCB->get_active(), xChanges);
119 
120  if(m_xSaveGrfLocalCB->get_state_changed_from_saved())
121  officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::set(
122  m_xSaveGrfLocalCB->get_active(), xChanges);
123 
124  if(m_xPrintExtensionCB->get_state_changed_from_saved())
125  officecfg::Office::Common::Filter::HTML::Export::PrintLayout::set(
126  m_xPrintExtensionCB->get_active(), xChanges);
127 
128  if( m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() )
129  officecfg::Office::Common::Filter::HTML::Export::Encoding::set(
130  m_xCharSetLB->GetSelectTextEncoding(), xChanges );
131 
132  xChanges->commit();
133  return false;
134 }
135 
137 {
138  m_xSize1NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get());
139  m_xSize2NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get());
140  m_xSize3NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get());
141  m_xSize4NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get());
142  m_xSize5NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get());
143  m_xSize6NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get());
144  m_xSize7NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get());
145  m_xNumbersEnglishUSCB->set_active(officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get());
146  m_xUnknownTagCB->set_active(officecfg::Office::Common::Filter::HTML::Import::UnknownTag::get());
147  m_xIgnoreFontNamesCB->set_active(officecfg::Office::Common::Filter::HTML::Import::FontSetting::get());
148 
149  m_xStarBasicCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Basic::get());
150  m_xStarBasicWarningCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Warning::get());
151  m_xStarBasicWarningCB->set_sensitive(!m_xStarBasicCB->get_active());
152  m_xSaveGrfLocalCB->set_active(officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get());
154 
155  m_xPrintExtensionCB->save_state();
156  m_xStarBasicCB->save_state();
157  m_xStarBasicWarningCB->save_state();
158  m_xSaveGrfLocalCB->save_state();
159  m_xSize1NF->save_value();
160  m_xSize2NF->save_value();
161  m_xSize3NF->save_value();
162  m_xSize4NF->save_value();
163  m_xSize5NF->save_value();
164  m_xSize6NF->save_value();
165  m_xSize7NF->save_value();
166  m_xNumbersEnglishUSCB->save_state();
167  m_xUnknownTagCB->save_state();
168  m_xIgnoreFontNamesCB->save_state();
169 
171  m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() )
172  m_xCharSetLB->SelectTextEncoding( SvxHtmlOptions::GetTextEncoding() );
173 }
174 
175 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::Toggleable&, rBox, void)
176 {
177  m_xStarBasicWarningCB->set_sensitive(!rBox.get_active());
178 }
179 
180 
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: opthtml.cxx:75
std::unique_ptr< weld::SpinButton > m_xSize7NF
Definition: opthtml.hxx:33
#define LANGUAGE_ENGLISH_US
std::unique_ptr< weld::SpinButton > m_xSize4NF
Definition: opthtml.hxx:30
std::unique_ptr< weld::SpinButton > m_xSize5NF
Definition: opthtml.hxx:31
rtl_TextEncoding GetTextEncoding()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: opthtml.cxx:69
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
virtual void Reset(const SfxItemSet *rSet) override
Definition: opthtml.cxx:136
std::unique_ptr< SvxTextEncodingBox > m_xCharSetLB
Definition: opthtml.hxx:43
bool IsPrintLayoutExtension()
IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::Toggleable &, rBox, void)
Definition: opthtml.cxx:175
bool IsDefaultTextEncoding()
std::unique_ptr< weld::CheckButton > m_xStarBasicCB
Definition: opthtml.hxx:39
std::unique_ptr< weld::CheckButton > m_xUnknownTagCB
Definition: opthtml.hxx:36
OfaHtmlTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: opthtml.cxx:27
std::unique_ptr< weld::CheckButton > m_xStarBasicWarningCB
Definition: opthtml.hxx:40
std::unique_ptr< weld::CheckButton > m_xSaveGrfLocalCB
Definition: opthtml.hxx:42
static OUString GetLanguageString(const LanguageType eType)
std::unique_ptr< weld::SpinButton > m_xSize6NF
Definition: opthtml.hxx:32
std::unique_ptr< weld::CheckButton > m_xNumbersEnglishUSCB
Definition: opthtml.hxx:35
std::unique_ptr< weld::SpinButton > m_xSize2NF
Definition: opthtml.hxx:28
std::unique_ptr< weld::SpinButton > m_xSize3NF
Definition: opthtml.hxx:29
std::unique_ptr< weld::CheckButton > m_xIgnoreFontNamesCB
Definition: opthtml.hxx:37
virtual ~OfaHtmlTabPage() override
Definition: opthtml.cxx:65
sal_uInt16 nPos
std::unique_ptr< weld::CheckButton > m_xPrintExtensionCB
Definition: opthtml.hxx:41
std::unique_ptr< weld::SpinButton > m_xSize1NF
Definition: opthtml.hxx:27