1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svtools/langtab.hxx>
21 #include <svtools/htmlcfg.hxx>
22 #include "opthtml.hxx"
25 #include <dialmgr.hxx>
26 #include <sal/macros.h>
28 // modus conversion to the positions in the listbox
29 const sal_uInt16 aPosToExportArr
[] =
36 const sal_uInt16 aExportToPosArr
[] =
38 1, //HTML 3.2 (removed, map to Netscape Navigator 4.0)
39 0, //MS Internet Explorer 4.0
41 1 //Netscape Navigator 4.0
45 OfaHtmlTabPage::OfaHtmlTabPage(vcl::Window
* pParent
, const SfxItemSet
& rSet
) :
46 SfxTabPage( pParent
, "OptHtmlPage" , "cui/ui/opthtmlpage.ui", &rSet
)
48 get(aSize1NF
,"size1");
49 get(aSize2NF
,"size2");
50 get(aSize3NF
,"size3");
51 get(aSize4NF
,"size4");
52 get(aSize5NF
,"size5");
53 get(aSize6NF
,"size6");
54 get(aSize7NF
,"size7");
55 get(aNumbersEnglishUSCB
,"numbersenglishus");
56 get(aUnknownTagCB
,"unknowntag");
57 get(aIgnoreFontNamesCB
,"ignorefontnames");
58 get(aExportLB
,"export");
59 get(aStarBasicCB
,"starbasic");
60 get(aStarBasicWarningCB
,"starbasicwarning");
61 get(aPrintExtensionCB
,"printextension");
62 get(aSaveGrfLocalCB
,"savegrflocal");
63 get(aCharSetLB
,"charset");
64 aCharSetLB
->SetStyle(aCharSetLB
->GetStyle() | WB_SORT
);
66 // replace placeholder with UI string from language list
67 OUString
aText( aNumbersEnglishUSCB
->GetText());
68 OUString
aPlaceholder("%ENGLISHUSLOCALE");
70 if ((nPos
= aText
.indexOf( aPlaceholder
)) != -1)
72 const OUString
& rStr
= SvtLanguageTable::GetLanguageString( LANGUAGE_ENGLISH_US
);
75 aText
= aText
.replaceAt( nPos
, aPlaceholder
.getLength(), rStr
);
76 aNumbersEnglishUSCB
->SetText( aText
);
80 aExportLB
->SetSelectHdl(LINK(this, OfaHtmlTabPage
, ExportHdl_Impl
));
81 aStarBasicCB
->SetClickHdl(LINK(this, OfaHtmlTabPage
, CheckBoxHdl_Impl
));
83 // initialize the characterset listbox
84 aCharSetLB
->FillWithMimeAndSelectBest();
87 OfaHtmlTabPage::~OfaHtmlTabPage()
92 void OfaHtmlTabPage::dispose()
101 aNumbersEnglishUSCB
.clear();
102 aUnknownTagCB
.clear();
103 aIgnoreFontNamesCB
.clear();
105 aStarBasicCB
.clear();
106 aStarBasicWarningCB
.clear();
107 aPrintExtensionCB
.clear();
108 aSaveGrfLocalCB
.clear();
110 SfxTabPage::dispose();
113 VclPtr
<SfxTabPage
> OfaHtmlTabPage::Create( vcl::Window
* pParent
,
114 const SfxItemSet
* rAttrSet
)
116 return VclPtr
<OfaHtmlTabPage
>::Create(pParent
, *rAttrSet
);
119 bool OfaHtmlTabPage::FillItemSet( SfxItemSet
* )
121 SvxHtmlOptions
& rHtmlOpt
= SvxHtmlOptions::Get();
122 if(aSize1NF
->IsValueChangedFromSaved())
123 rHtmlOpt
.SetFontSize(0, (sal_uInt16
)aSize1NF
->GetValue());
124 if(aSize2NF
->IsValueChangedFromSaved())
125 rHtmlOpt
.SetFontSize(1, (sal_uInt16
)aSize2NF
->GetValue());
126 if(aSize3NF
->IsValueChangedFromSaved())
127 rHtmlOpt
.SetFontSize(2, (sal_uInt16
)aSize3NF
->GetValue());
128 if(aSize4NF
->IsValueChangedFromSaved())
129 rHtmlOpt
.SetFontSize(3, (sal_uInt16
)aSize4NF
->GetValue());
130 if(aSize5NF
->IsValueChangedFromSaved())
131 rHtmlOpt
.SetFontSize(4, (sal_uInt16
)aSize5NF
->GetValue());
132 if(aSize6NF
->IsValueChangedFromSaved())
133 rHtmlOpt
.SetFontSize(5, (sal_uInt16
)aSize6NF
->GetValue());
134 if(aSize7NF
->IsValueChangedFromSaved())
135 rHtmlOpt
.SetFontSize(6, (sal_uInt16
)aSize7NF
->GetValue());
137 if(aNumbersEnglishUSCB
->IsValueChangedFromSaved())
138 rHtmlOpt
.SetNumbersEnglishUS(aNumbersEnglishUSCB
->IsChecked());
140 if(aUnknownTagCB
->IsValueChangedFromSaved())
141 rHtmlOpt
.SetImportUnknown(aUnknownTagCB
->IsChecked());
143 if(aIgnoreFontNamesCB
->IsValueChangedFromSaved())
144 rHtmlOpt
.SetIgnoreFontFamily(aIgnoreFontNamesCB
->IsChecked());
146 if(aExportLB
->IsValueChangedFromSaved())
147 rHtmlOpt
.SetExportMode(aPosToExportArr
[aExportLB
->GetSelectEntryPos()]);
149 if(aStarBasicCB
->IsValueChangedFromSaved())
150 rHtmlOpt
.SetStarBasic(aStarBasicCB
->IsChecked());
152 if(aStarBasicWarningCB
->IsValueChangedFromSaved())
153 rHtmlOpt
.SetStarBasicWarning(aStarBasicWarningCB
->IsChecked());
155 if(aSaveGrfLocalCB
->IsValueChangedFromSaved())
156 rHtmlOpt
.SetSaveGraphicsLocal(aSaveGrfLocalCB
->IsChecked());
158 if(aPrintExtensionCB
->IsValueChangedFromSaved())
159 rHtmlOpt
.SetPrintLayoutExtension(aPrintExtensionCB
->IsChecked());
161 if( aCharSetLB
->GetSelectTextEncoding() != rHtmlOpt
.GetTextEncoding() )
162 rHtmlOpt
.SetTextEncoding( aCharSetLB
->GetSelectTextEncoding() );
167 void OfaHtmlTabPage::Reset( const SfxItemSet
* )
169 SvxHtmlOptions
& rHtmlOpt
= SvxHtmlOptions::Get();
170 aSize1NF
->SetValue(rHtmlOpt
.GetFontSize(0));
171 aSize2NF
->SetValue(rHtmlOpt
.GetFontSize(1));
172 aSize3NF
->SetValue(rHtmlOpt
.GetFontSize(2));
173 aSize4NF
->SetValue(rHtmlOpt
.GetFontSize(3));
174 aSize5NF
->SetValue(rHtmlOpt
.GetFontSize(4));
175 aSize6NF
->SetValue(rHtmlOpt
.GetFontSize(5));
176 aSize7NF
->SetValue(rHtmlOpt
.GetFontSize(6));
177 aNumbersEnglishUSCB
->Check(rHtmlOpt
.IsNumbersEnglishUS());
178 aUnknownTagCB
->Check(rHtmlOpt
.IsImportUnknown());
179 aIgnoreFontNamesCB
->Check(rHtmlOpt
.IsIgnoreFontFamily());
180 sal_uInt16 nExport
= rHtmlOpt
.GetExportMode();
181 if( nExport
>= SAL_N_ELEMENTS( aExportToPosArr
) )
182 nExport
= 3; // default for bad config entry is NS 4.0
183 sal_uInt16 nPosArr
= aExportToPosArr
[ nExport
];
184 aExportLB
->SelectEntryPos( nPosArr
);
185 aExportLB
->SaveValue();
187 ExportHdl_Impl(aExportLB
);
189 aStarBasicCB
->Check(rHtmlOpt
.IsStarBasic());
190 aStarBasicWarningCB
->Check(rHtmlOpt
.IsStarBasicWarning());
191 aStarBasicWarningCB
->Enable(!aStarBasicCB
->IsChecked());
192 aSaveGrfLocalCB
->Check(rHtmlOpt
.IsSaveGraphicsLocal());
193 aPrintExtensionCB
->Check(rHtmlOpt
.IsPrintLayoutExtension());
195 aPrintExtensionCB
->SaveValue();
196 aStarBasicCB
->SaveValue();
197 aStarBasicWarningCB
->SaveValue();
198 aSaveGrfLocalCB
->SaveValue();
199 aSize1NF
->SaveValue();
200 aSize2NF
->SaveValue();
201 aSize3NF
->SaveValue();
202 aSize4NF
->SaveValue();
203 aSize5NF
->SaveValue();
204 aSize6NF
->SaveValue();
205 aSize7NF
->SaveValue();
206 aNumbersEnglishUSCB
->SaveValue();
207 aUnknownTagCB
->SaveValue();
208 aIgnoreFontNamesCB
->SaveValue();
210 if( !rHtmlOpt
.IsDefaultTextEncoding() &&
211 aCharSetLB
->GetSelectTextEncoding() != rHtmlOpt
.GetTextEncoding() )
212 aCharSetLB
->SelectTextEncoding( rHtmlOpt
.GetTextEncoding() );
215 IMPL_LINK(OfaHtmlTabPage
, ExportHdl_Impl
, ListBox
*, pBox
)
217 sal_uInt16 nExport
= aPosToExportArr
[ pBox
->GetSelectEntryPos() ];
222 case HTML_CFG_WRITER
:
223 aPrintExtensionCB
->Enable(true);
225 default: aPrintExtensionCB
->Enable(false);
231 IMPL_LINK(OfaHtmlTabPage
, CheckBoxHdl_Impl
, CheckBox
*, pBox
)
233 aStarBasicWarningCB
->Enable(!pBox
->IsChecked());
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */