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