Line data Source code
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 <cuires.hrc>
24 : #include "helpid.hrc"
25 : #include <dialmgr.hxx>
26 : #include <sal/macros.h>
27 :
28 : // modus conversion to the positions in the listbox
29 : const sal_uInt16 aPosToExportArr[] =
30 : {
31 : HTML_CFG_MSIE,
32 : HTML_CFG_NS40,
33 : HTML_CFG_WRITER
34 : };
35 :
36 : const sal_uInt16 aExportToPosArr[] =
37 : {
38 : 1, //HTML 3.2 (removed, map to Netscape Navigator 4.0)
39 : 0, //MS Internet Explorer 4.0
40 : 2, //StarWriter
41 : 1 //Netscape Navigator 4.0
42 : };
43 :
44 :
45 0 : OfaHtmlTabPage::OfaHtmlTabPage(vcl::Window* pParent, const SfxItemSet& rSet) :
46 0 : SfxTabPage( pParent, "OptHtmlPage" , "cui/ui/opthtmlpage.ui", &rSet )
47 : {
48 0 : get(aSize1NF,"size1");
49 0 : get(aSize2NF,"size2");
50 0 : get(aSize3NF,"size3");
51 0 : get(aSize4NF,"size4");
52 0 : get(aSize5NF,"size5");
53 0 : get(aSize6NF,"size6");
54 0 : get(aSize7NF,"size7");
55 0 : get(aNumbersEnglishUSCB,"numbersenglishus");
56 0 : get(aUnknownTagCB,"unknowntag");
57 0 : get(aIgnoreFontNamesCB,"ignorefontnames");
58 0 : get(aExportLB,"export");
59 0 : get(aStarBasicCB,"starbasic");
60 0 : get(aStarBasicWarningCB,"starbasicwarning");
61 0 : get(aPrintExtensionCB,"printextension");
62 0 : get(aSaveGrfLocalCB,"savegrflocal");
63 0 : get(aCharSetLB,"charset");
64 0 : aCharSetLB->SetStyle(aCharSetLB->GetStyle() | WB_SORT);
65 :
66 : // replace placeholder with UI string from language list
67 0 : OUString aText( aNumbersEnglishUSCB->GetText());
68 0 : OUString aPlaceholder("%ENGLISHUSLOCALE");
69 : sal_Int32 nPos;
70 0 : if ((nPos = aText.indexOf( aPlaceholder)) != -1)
71 : {
72 0 : const OUString& rStr = SvtLanguageTable::GetLanguageString( LANGUAGE_ENGLISH_US);
73 0 : if (!rStr.isEmpty())
74 : {
75 0 : aText = aText.replaceAt( nPos, aPlaceholder.getLength(), rStr);
76 0 : aNumbersEnglishUSCB->SetText( aText);
77 0 : }
78 : }
79 :
80 0 : aExportLB->SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
81 0 : aStarBasicCB->SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
82 :
83 : // initialize the characterset listbox
84 0 : aCharSetLB->FillWithMimeAndSelectBest();
85 0 : }
86 :
87 0 : OfaHtmlTabPage::~OfaHtmlTabPage()
88 : {
89 0 : disposeOnce();
90 0 : }
91 :
92 0 : void OfaHtmlTabPage::dispose()
93 : {
94 0 : aSize1NF.clear();
95 0 : aSize2NF.clear();
96 0 : aSize3NF.clear();
97 0 : aSize4NF.clear();
98 0 : aSize5NF.clear();
99 0 : aSize6NF.clear();
100 0 : aSize7NF.clear();
101 0 : aNumbersEnglishUSCB.clear();
102 0 : aUnknownTagCB.clear();
103 0 : aIgnoreFontNamesCB.clear();
104 0 : aExportLB.clear();
105 0 : aStarBasicCB.clear();
106 0 : aStarBasicWarningCB.clear();
107 0 : aPrintExtensionCB.clear();
108 0 : aSaveGrfLocalCB.clear();
109 0 : aCharSetLB.clear();
110 0 : SfxTabPage::dispose();
111 0 : }
112 :
113 0 : VclPtr<SfxTabPage> OfaHtmlTabPage::Create( vcl::Window* pParent,
114 : const SfxItemSet* rAttrSet )
115 : {
116 0 : return VclPtr<OfaHtmlTabPage>::Create(pParent, *rAttrSet);
117 : }
118 :
119 0 : bool OfaHtmlTabPage::FillItemSet( SfxItemSet* )
120 : {
121 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
122 0 : if(aSize1NF->IsValueChangedFromSaved())
123 0 : rHtmlOpt.SetFontSize(0, (sal_uInt16)aSize1NF->GetValue());
124 0 : if(aSize2NF->IsValueChangedFromSaved())
125 0 : rHtmlOpt.SetFontSize(1, (sal_uInt16)aSize2NF->GetValue());
126 0 : if(aSize3NF->IsValueChangedFromSaved())
127 0 : rHtmlOpt.SetFontSize(2, (sal_uInt16)aSize3NF->GetValue());
128 0 : if(aSize4NF->IsValueChangedFromSaved())
129 0 : rHtmlOpt.SetFontSize(3, (sal_uInt16)aSize4NF->GetValue());
130 0 : if(aSize5NF->IsValueChangedFromSaved())
131 0 : rHtmlOpt.SetFontSize(4, (sal_uInt16)aSize5NF->GetValue());
132 0 : if(aSize6NF->IsValueChangedFromSaved())
133 0 : rHtmlOpt.SetFontSize(5, (sal_uInt16)aSize6NF->GetValue());
134 0 : if(aSize7NF->IsValueChangedFromSaved())
135 0 : rHtmlOpt.SetFontSize(6, (sal_uInt16)aSize7NF->GetValue());
136 :
137 0 : if(aNumbersEnglishUSCB->IsValueChangedFromSaved())
138 0 : rHtmlOpt.SetNumbersEnglishUS(aNumbersEnglishUSCB->IsChecked());
139 :
140 0 : if(aUnknownTagCB->IsValueChangedFromSaved())
141 0 : rHtmlOpt.SetImportUnknown(aUnknownTagCB->IsChecked());
142 :
143 0 : if(aIgnoreFontNamesCB->IsValueChangedFromSaved())
144 0 : rHtmlOpt.SetIgnoreFontFamily(aIgnoreFontNamesCB->IsChecked());
145 :
146 0 : if(aExportLB->IsValueChangedFromSaved())
147 0 : rHtmlOpt.SetExportMode(aPosToExportArr[aExportLB->GetSelectEntryPos()]);
148 :
149 0 : if(aStarBasicCB->IsValueChangedFromSaved())
150 0 : rHtmlOpt.SetStarBasic(aStarBasicCB->IsChecked());
151 :
152 0 : if(aStarBasicWarningCB->IsValueChangedFromSaved())
153 0 : rHtmlOpt.SetStarBasicWarning(aStarBasicWarningCB->IsChecked());
154 :
155 0 : if(aSaveGrfLocalCB->IsValueChangedFromSaved())
156 0 : rHtmlOpt.SetSaveGraphicsLocal(aSaveGrfLocalCB->IsChecked());
157 :
158 0 : if(aPrintExtensionCB->IsValueChangedFromSaved())
159 0 : rHtmlOpt.SetPrintLayoutExtension(aPrintExtensionCB->IsChecked());
160 :
161 0 : if( aCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
162 0 : rHtmlOpt.SetTextEncoding( aCharSetLB->GetSelectTextEncoding() );
163 :
164 0 : return false;
165 : }
166 :
167 0 : void OfaHtmlTabPage::Reset( const SfxItemSet* )
168 : {
169 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
170 0 : aSize1NF->SetValue(rHtmlOpt.GetFontSize(0));
171 0 : aSize2NF->SetValue(rHtmlOpt.GetFontSize(1));
172 0 : aSize3NF->SetValue(rHtmlOpt.GetFontSize(2));
173 0 : aSize4NF->SetValue(rHtmlOpt.GetFontSize(3));
174 0 : aSize5NF->SetValue(rHtmlOpt.GetFontSize(4));
175 0 : aSize6NF->SetValue(rHtmlOpt.GetFontSize(5));
176 0 : aSize7NF->SetValue(rHtmlOpt.GetFontSize(6));
177 0 : aNumbersEnglishUSCB->Check(rHtmlOpt.IsNumbersEnglishUS());
178 0 : aUnknownTagCB->Check(rHtmlOpt.IsImportUnknown());
179 0 : aIgnoreFontNamesCB->Check(rHtmlOpt.IsIgnoreFontFamily());
180 0 : sal_uInt16 nExport = rHtmlOpt.GetExportMode();
181 0 : if( nExport >= SAL_N_ELEMENTS( aExportToPosArr ) )
182 0 : nExport = 3; // default for bad config entry is NS 4.0
183 0 : sal_uInt16 nPosArr = aExportToPosArr[ nExport ];
184 0 : aExportLB->SelectEntryPos( nPosArr );
185 0 : aExportLB->SaveValue();
186 :
187 0 : ExportHdl_Impl(aExportLB);
188 :
189 0 : aStarBasicCB->Check(rHtmlOpt.IsStarBasic());
190 0 : aStarBasicWarningCB->Check(rHtmlOpt.IsStarBasicWarning());
191 0 : aStarBasicWarningCB->Enable(!aStarBasicCB->IsChecked());
192 0 : aSaveGrfLocalCB->Check(rHtmlOpt.IsSaveGraphicsLocal());
193 0 : aPrintExtensionCB->Check(rHtmlOpt.IsPrintLayoutExtension());
194 :
195 0 : aPrintExtensionCB->SaveValue();
196 0 : aStarBasicCB->SaveValue();
197 0 : aStarBasicWarningCB->SaveValue();
198 0 : aSaveGrfLocalCB->SaveValue();
199 0 : aSize1NF->SaveValue();
200 0 : aSize2NF->SaveValue();
201 0 : aSize3NF->SaveValue();
202 0 : aSize4NF->SaveValue();
203 0 : aSize5NF->SaveValue();
204 0 : aSize6NF->SaveValue();
205 0 : aSize7NF->SaveValue();
206 0 : aNumbersEnglishUSCB->SaveValue();
207 0 : aUnknownTagCB->SaveValue();
208 0 : aIgnoreFontNamesCB->SaveValue();
209 :
210 0 : if( !rHtmlOpt.IsDefaultTextEncoding() &&
211 0 : aCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
212 0 : aCharSetLB->SelectTextEncoding( rHtmlOpt.GetTextEncoding() );
213 0 : }
214 :
215 0 : IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
216 : {
217 0 : sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
218 0 : switch( nExport )
219 : {
220 : case HTML_CFG_MSIE:
221 : case HTML_CFG_NS40 :
222 : case HTML_CFG_WRITER :
223 0 : aPrintExtensionCB->Enable(true);
224 0 : break;
225 0 : default: aPrintExtensionCB->Enable(false);
226 : }
227 :
228 0 : return 0;
229 : }
230 :
231 0 : IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
232 : {
233 0 : aStarBasicWarningCB->Enable(!pBox->IsChecked());
234 0 : return 0;
235 0 : }
236 :
237 :
238 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|