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>
22 #include "opthtml.hxx"
23 
24 
26  : SfxTabPage(pPage, pController, "cui/ui/opthtmlpage.ui", "OptHtmlPage", &rSet)
27  , m_xSize1NF(m_xBuilder->weld_spin_button("size1"))
28  , m_xSize2NF(m_xBuilder->weld_spin_button("size2"))
29  , m_xSize3NF(m_xBuilder->weld_spin_button("size3"))
30  , m_xSize4NF(m_xBuilder->weld_spin_button("size4"))
31  , m_xSize5NF(m_xBuilder->weld_spin_button("size5"))
32  , m_xSize6NF(m_xBuilder->weld_spin_button("size6"))
33  , m_xSize7NF(m_xBuilder->weld_spin_button("size7"))
34  , m_xNumbersEnglishUSCB(m_xBuilder->weld_check_button("numbersenglishus"))
35  , m_xUnknownTagCB(m_xBuilder->weld_check_button("unknowntag"))
36  , m_xIgnoreFontNamesCB(m_xBuilder->weld_check_button("ignorefontnames"))
37  , m_xStarBasicCB(m_xBuilder->weld_check_button("starbasic"))
38  , m_xStarBasicWarningCB(m_xBuilder->weld_check_button("starbasicwarning"))
39  , m_xPrintExtensionCB(m_xBuilder->weld_check_button("printextension"))
40  , m_xSaveGrfLocalCB(m_xBuilder->weld_check_button("savegrflocal"))
41  , m_xCharSetLB(new SvxTextEncodingBox(m_xBuilder->weld_combo_box("charset")))
42 {
43  // replace placeholder with UI string from language list
44  OUString aText(m_xNumbersEnglishUSCB->get_label());
45  OUString aPlaceholder("%ENGLISHUSLOCALE");
46  sal_Int32 nPos;
47  if ((nPos = aText.indexOf( aPlaceholder)) != -1)
48  {
50  if (!rStr.isEmpty())
51  {
52  aText = aText.replaceAt( nPos, aPlaceholder.getLength(), rStr);
53  m_xNumbersEnglishUSCB->set_label( aText);
54  }
55  }
56 
57  m_xStarBasicCB->connect_toggled(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
58 
59  // initialize the characterset listbox
60  m_xCharSetLB->FillWithMimeAndSelectBest();
61 }
62 
64 {
65 }
66 
67 std::unique_ptr<SfxTabPage> OfaHtmlTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
68  const SfxItemSet* rAttrSet )
69 {
70  return std::make_unique<OfaHtmlTabPage>(pPage, pController, *rAttrSet);
71 }
72 
74 {
75  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
76  if(m_xSize1NF->get_value_changed_from_saved())
77  rHtmlOpt.SetFontSize(0, static_cast<sal_uInt16>(m_xSize1NF->get_value()));
78  if(m_xSize2NF->get_value_changed_from_saved())
79  rHtmlOpt.SetFontSize(1, static_cast<sal_uInt16>(m_xSize2NF->get_value()));
80  if(m_xSize3NF->get_value_changed_from_saved())
81  rHtmlOpt.SetFontSize(2, static_cast<sal_uInt16>(m_xSize3NF->get_value()));
82  if(m_xSize4NF->get_value_changed_from_saved())
83  rHtmlOpt.SetFontSize(3, static_cast<sal_uInt16>(m_xSize4NF->get_value()));
84  if(m_xSize5NF->get_value_changed_from_saved())
85  rHtmlOpt.SetFontSize(4, static_cast<sal_uInt16>(m_xSize5NF->get_value()));
86  if(m_xSize6NF->get_value_changed_from_saved())
87  rHtmlOpt.SetFontSize(5, static_cast<sal_uInt16>(m_xSize6NF->get_value()));
88  if(m_xSize7NF->get_value_changed_from_saved())
89  rHtmlOpt.SetFontSize(6, static_cast<sal_uInt16>(m_xSize7NF->get_value()));
90 
91  if(m_xNumbersEnglishUSCB->get_state_changed_from_saved())
92  rHtmlOpt.SetNumbersEnglishUS(m_xNumbersEnglishUSCB->get_active());
93 
94  if(m_xUnknownTagCB->get_state_changed_from_saved())
95  rHtmlOpt.SetImportUnknown(m_xUnknownTagCB->get_active());
96 
97  if(m_xIgnoreFontNamesCB->get_state_changed_from_saved())
98  rHtmlOpt.SetIgnoreFontFamily(m_xIgnoreFontNamesCB->get_active());
99 
100  if(m_xStarBasicCB->get_state_changed_from_saved())
101  rHtmlOpt.SetStarBasic(m_xStarBasicCB->get_active());
102 
103  if(m_xStarBasicWarningCB->get_state_changed_from_saved())
104  rHtmlOpt.SetStarBasicWarning(m_xStarBasicWarningCB->get_active());
105 
106  if(m_xSaveGrfLocalCB->get_state_changed_from_saved())
107  rHtmlOpt.SetSaveGraphicsLocal(m_xSaveGrfLocalCB->get_active());
108 
109  if(m_xPrintExtensionCB->get_state_changed_from_saved())
110  rHtmlOpt.SetPrintLayoutExtension(m_xPrintExtensionCB->get_active());
111 
112  if( m_xCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
113  rHtmlOpt.SetTextEncoding( m_xCharSetLB->GetSelectTextEncoding() );
114 
115  return false;
116 }
117 
119 {
120  SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
121  m_xSize1NF->set_value(rHtmlOpt.GetFontSize(0));
122  m_xSize2NF->set_value(rHtmlOpt.GetFontSize(1));
123  m_xSize3NF->set_value(rHtmlOpt.GetFontSize(2));
124  m_xSize4NF->set_value(rHtmlOpt.GetFontSize(3));
125  m_xSize5NF->set_value(rHtmlOpt.GetFontSize(4));
126  m_xSize6NF->set_value(rHtmlOpt.GetFontSize(5));
127  m_xSize7NF->set_value(rHtmlOpt.GetFontSize(6));
128  m_xNumbersEnglishUSCB->set_active(rHtmlOpt.IsNumbersEnglishUS());
129  m_xUnknownTagCB->set_active(rHtmlOpt.IsImportUnknown());
130  m_xIgnoreFontNamesCB->set_active(rHtmlOpt.IsIgnoreFontFamily());
131 
132  m_xStarBasicCB->set_active(rHtmlOpt.IsStarBasic());
133  m_xStarBasicWarningCB->set_active(rHtmlOpt.IsStarBasicWarning());
134  m_xStarBasicWarningCB->set_sensitive(!m_xStarBasicCB->get_active());
135  m_xSaveGrfLocalCB->set_active(rHtmlOpt.IsSaveGraphicsLocal());
136  m_xPrintExtensionCB->set_active(rHtmlOpt.IsPrintLayoutExtension());
137 
138  m_xPrintExtensionCB->save_state();
139  m_xStarBasicCB->save_state();
140  m_xStarBasicWarningCB->save_state();
141  m_xSaveGrfLocalCB->save_state();
142  m_xSize1NF->save_value();
143  m_xSize2NF->save_value();
144  m_xSize3NF->save_value();
145  m_xSize4NF->save_value();
146  m_xSize5NF->save_value();
147  m_xSize6NF->save_value();
148  m_xSize7NF->save_value();
149  m_xNumbersEnglishUSCB->save_state();
150  m_xUnknownTagCB->save_state();
151  m_xIgnoreFontNamesCB->save_state();
152 
153  if( !rHtmlOpt.IsDefaultTextEncoding() &&
154  m_xCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
155  m_xCharSetLB->SelectTextEncoding( rHtmlOpt.GetTextEncoding() );
156 }
157 
158 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::ToggleButton&, rBox, void)
159 {
160  m_xStarBasicWarningCB->set_sensitive(!rBox.get_active());
161 }
162 
163 
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetSaveGraphicsLocal(bool bSet)
bool IsIgnoreFontFamily() const
bool IsPrintLayoutExtension() const
bool IsStarBasic() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: opthtml.cxx:73
std::unique_ptr< weld::SpinButton > m_xSize7NF
Definition: opthtml.hxx:34
bool IsSaveGraphicsLocal() const
#define LANGUAGE_ENGLISH_US
bool IsStarBasicWarning() const
std::unique_ptr< weld::SpinButton > m_xSize4NF
Definition: opthtml.hxx:31
std::unique_ptr< weld::SpinButton > m_xSize5NF
Definition: opthtml.hxx:32
void SetTextEncoding(rtl_TextEncoding)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: opthtml.cxx:67
IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::ToggleButton &, rBox, void)
Definition: opthtml.cxx:158
virtual void Reset(const SfxItemSet *rSet) override
Definition: opthtml.cxx:118
bool IsNumbersEnglishUS() const
std::unique_ptr< SvxTextEncodingBox > m_xCharSetLB
Definition: opthtml.hxx:44
static SvxHtmlOptions & Get()
void SetStarBasicWarning(bool bSet)
void SetPrintLayoutExtension(bool bSet)
void SetIgnoreFontFamily(bool bSet)
bool IsDefaultTextEncoding() const
bool IsImportUnknown() const
void SetStarBasic(bool bSet)
void SetFontSize(sal_uInt16 nPos, sal_uInt16 nSize)
std::unique_ptr< weld::CheckButton > m_xStarBasicCB
Definition: opthtml.hxx:40
std::unique_ptr< weld::CheckButton > m_xUnknownTagCB
Definition: opthtml.hxx:37
sal_uInt16 GetFontSize(sal_uInt16 nPos) const
void SetImportUnknown(bool bSet)
OfaHtmlTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: opthtml.cxx:25
std::unique_ptr< weld::CheckButton > m_xStarBasicWarningCB
Definition: opthtml.hxx:41
std::unique_ptr< weld::CheckButton > m_xSaveGrfLocalCB
Definition: opthtml.hxx:43
static OUString GetLanguageString(const LanguageType eType)
std::unique_ptr< weld::SpinButton > m_xSize6NF
Definition: opthtml.hxx:33
std::unique_ptr< weld::CheckButton > m_xNumbersEnglishUSCB
Definition: opthtml.hxx:36
rtl_TextEncoding GetTextEncoding() const
std::unique_ptr< weld::SpinButton > m_xSize2NF
Definition: opthtml.hxx:29
std::unique_ptr< weld::SpinButton > m_xSize3NF
Definition: opthtml.hxx:30
void SetNumbersEnglishUS(bool bSet)
std::unique_ptr< weld::CheckButton > m_xIgnoreFontNamesCB
Definition: opthtml.hxx:38
virtual ~OfaHtmlTabPage() override
Definition: opthtml.cxx:63
sal_uInt16 nPos
std::unique_ptr< weld::CheckButton > m_xPrintExtensionCB
Definition: opthtml.hxx:42
std::unique_ptr< weld::SpinButton > m_xSize1NF
Definition: opthtml.hxx:28