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(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 : SvtLanguageTable aLangTab;
73 0 : const OUString& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US);
74 0 : if (!rStr.isEmpty())
75 : {
76 0 : aText = aText.replaceAt( nPos, aPlaceholder.getLength(), rStr);
77 0 : aNumbersEnglishUSCB->SetText( aText);
78 0 : }
79 : }
80 :
81 0 : aExportLB->SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
82 0 : aStarBasicCB->SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
83 :
84 : // initialize the characterset listbox
85 0 : aCharSetLB->FillWithMimeAndSelectBest();
86 0 : }
87 :
88 0 : OfaHtmlTabPage::~OfaHtmlTabPage()
89 : {
90 0 : }
91 :
92 0 : SfxTabPage* OfaHtmlTabPage::Create( Window* pParent,
93 : const SfxItemSet& rAttrSet )
94 : {
95 0 : return new OfaHtmlTabPage(pParent, rAttrSet);
96 : }
97 :
98 0 : bool OfaHtmlTabPage::FillItemSet( SfxItemSet& )
99 : {
100 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
101 0 : if(aSize1NF->GetSavedValue() != aSize1NF->GetText())
102 0 : rHtmlOpt.SetFontSize(0, (sal_uInt16)aSize1NF->GetValue());
103 0 : if(aSize2NF->GetSavedValue() != aSize2NF->GetText())
104 0 : rHtmlOpt.SetFontSize(1, (sal_uInt16)aSize2NF->GetValue());
105 0 : if(aSize3NF->GetSavedValue() != aSize3NF->GetText())
106 0 : rHtmlOpt.SetFontSize(2, (sal_uInt16)aSize3NF->GetValue());
107 0 : if(aSize4NF->GetSavedValue() != aSize4NF->GetText())
108 0 : rHtmlOpt.SetFontSize(3, (sal_uInt16)aSize4NF->GetValue());
109 0 : if(aSize5NF->GetSavedValue() != aSize5NF->GetText())
110 0 : rHtmlOpt.SetFontSize(4, (sal_uInt16)aSize5NF->GetValue());
111 0 : if(aSize6NF->GetSavedValue() != aSize6NF->GetText())
112 0 : rHtmlOpt.SetFontSize(5, (sal_uInt16)aSize6NF->GetValue());
113 0 : if(aSize7NF->GetSavedValue() != aSize7NF->GetText())
114 0 : rHtmlOpt.SetFontSize(6, (sal_uInt16)aSize7NF->GetValue());
115 :
116 0 : if(TriState(aNumbersEnglishUSCB->IsChecked()) != aNumbersEnglishUSCB->GetSavedValue())
117 0 : rHtmlOpt.SetNumbersEnglishUS(aNumbersEnglishUSCB->IsChecked());
118 :
119 0 : if(TriState(aUnknownTagCB->IsChecked()) != aUnknownTagCB->GetSavedValue())
120 0 : rHtmlOpt.SetImportUnknown(aUnknownTagCB->IsChecked());
121 :
122 0 : if(TriState(aIgnoreFontNamesCB->IsChecked()) != aIgnoreFontNamesCB->GetSavedValue())
123 0 : rHtmlOpt.SetIgnoreFontFamily(aIgnoreFontNamesCB->IsChecked());
124 :
125 0 : if(aExportLB->GetSelectEntryPos() != aExportLB->GetSavedValue())
126 0 : rHtmlOpt.SetExportMode(aPosToExportArr[aExportLB->GetSelectEntryPos()]);
127 :
128 0 : if(TriState(aStarBasicCB->IsChecked()) != aStarBasicCB->GetSavedValue())
129 0 : rHtmlOpt.SetStarBasic(aStarBasicCB->IsChecked());
130 :
131 0 : if(TriState(aStarBasicWarningCB->IsChecked()) != aStarBasicWarningCB->GetSavedValue())
132 0 : rHtmlOpt.SetStarBasicWarning(aStarBasicWarningCB->IsChecked());
133 :
134 0 : if(TriState(aSaveGrfLocalCB->IsChecked()) != aSaveGrfLocalCB->GetSavedValue())
135 0 : rHtmlOpt.SetSaveGraphicsLocal(aSaveGrfLocalCB->IsChecked());
136 :
137 0 : if(TriState(aPrintExtensionCB->IsChecked()) != aPrintExtensionCB->GetSavedValue())
138 0 : rHtmlOpt.SetPrintLayoutExtension(aPrintExtensionCB->IsChecked());
139 :
140 0 : if( aCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
141 0 : rHtmlOpt.SetTextEncoding( aCharSetLB->GetSelectTextEncoding() );
142 :
143 0 : return false;
144 : }
145 :
146 0 : void OfaHtmlTabPage::Reset( const SfxItemSet& )
147 : {
148 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
149 0 : aSize1NF->SetValue(rHtmlOpt.GetFontSize(0));
150 0 : aSize2NF->SetValue(rHtmlOpt.GetFontSize(1));
151 0 : aSize3NF->SetValue(rHtmlOpt.GetFontSize(2));
152 0 : aSize4NF->SetValue(rHtmlOpt.GetFontSize(3));
153 0 : aSize5NF->SetValue(rHtmlOpt.GetFontSize(4));
154 0 : aSize6NF->SetValue(rHtmlOpt.GetFontSize(5));
155 0 : aSize7NF->SetValue(rHtmlOpt.GetFontSize(6));
156 0 : aNumbersEnglishUSCB->Check(rHtmlOpt.IsNumbersEnglishUS());
157 0 : aUnknownTagCB->Check(rHtmlOpt.IsImportUnknown());
158 0 : aIgnoreFontNamesCB->Check(rHtmlOpt.IsIgnoreFontFamily());
159 0 : sal_uInt16 nExport = rHtmlOpt.GetExportMode();
160 0 : if( nExport >= SAL_N_ELEMENTS( aExportToPosArr ) )
161 0 : nExport = 3; // default for bad config entry is NS 4.0
162 0 : sal_uInt16 nPosArr = aExportToPosArr[ nExport ];
163 0 : aExportLB->SelectEntryPos( nPosArr );
164 0 : aExportLB->SaveValue();
165 :
166 0 : ExportHdl_Impl(aExportLB);
167 :
168 0 : aStarBasicCB->Check(rHtmlOpt.IsStarBasic());
169 0 : aStarBasicWarningCB->Check(rHtmlOpt.IsStarBasicWarning());
170 0 : aStarBasicWarningCB->Enable(!aStarBasicCB->IsChecked());
171 0 : aSaveGrfLocalCB->Check(rHtmlOpt.IsSaveGraphicsLocal());
172 0 : aPrintExtensionCB->Check(rHtmlOpt.IsPrintLayoutExtension());
173 :
174 0 : aPrintExtensionCB->SaveValue();
175 0 : aStarBasicCB->SaveValue();
176 0 : aStarBasicWarningCB->SaveValue();
177 0 : aSaveGrfLocalCB->SaveValue();
178 0 : aSize1NF->SaveValue();
179 0 : aSize2NF->SaveValue();
180 0 : aSize3NF->SaveValue();
181 0 : aSize4NF->SaveValue();
182 0 : aSize5NF->SaveValue();
183 0 : aSize6NF->SaveValue();
184 0 : aSize7NF->SaveValue();
185 0 : aNumbersEnglishUSCB->SaveValue();
186 0 : aUnknownTagCB->SaveValue();
187 0 : aIgnoreFontNamesCB->SaveValue();
188 :
189 0 : if( !rHtmlOpt.IsDefaultTextEncoding() &&
190 0 : aCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
191 0 : aCharSetLB->SelectTextEncoding( rHtmlOpt.GetTextEncoding() );
192 0 : }
193 :
194 0 : IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
195 : {
196 0 : sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
197 0 : switch( nExport )
198 : {
199 : case HTML_CFG_MSIE:
200 : case HTML_CFG_NS40 :
201 : case HTML_CFG_WRITER :
202 0 : aPrintExtensionCB->Enable(true);
203 0 : break;
204 0 : default: aPrintExtensionCB->Enable(false);
205 : }
206 :
207 0 : return 0;
208 : }
209 :
210 0 : IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
211 : {
212 0 : aStarBasicWarningCB->Enable(!pBox->IsChecked());
213 0 : return 0;
214 0 : }
215 :
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|