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