masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / opthtml.cxx
blobaa32ce136386184f7056ca1ae6c9cc1a9bf8acc2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
33 #include <svtools/langtab.hxx>
34 #include <svtools/htmlcfg.hxx>
35 #include "opthtml.hxx"
36 #include "opthtml.hrc"
37 #include <cuires.hrc>
38 #include "helpid.hrc"
39 #include <dialmgr.hxx>
41 // Umwandlung der Modi zu den Positionen in der Listbox
42 const sal_uInt16 aPosToExportArr[] =
44 HTML_CFG_HTML32,
45 HTML_CFG_MSIE_40,
46 HTML_CFG_NS40,
47 HTML_CFG_WRITER
50 //#define DEPRECATED_ENTRY 0xFFFF
52 const sal_uInt16 aExportToPosArr[] =
54 0, //HTML 3.2
55 1, //MS Internet Explorer 4.0
56 3, //StarWriter
57 2 //Netscape Navigator 4.0
59 // -----------------------------------------------------------------------
61 OfaHtmlTabPage::OfaHtmlTabPage(Window* pParent, const SfxItemSet& rSet) :
62 SfxTabPage( pParent, CUI_RES( RID_OFAPAGE_HTMLOPT ), rSet ),
63 aFontSizeGB ( this, CUI_RES( GB_FONTSIZE ) ),
64 aSize1FT ( this, CUI_RES( FT_SIZE1 ) ),
65 aSize1NF ( this, CUI_RES( NF_SIZE1 ) ),
66 aSize2FT ( this, CUI_RES( FT_SIZE2 ) ),
67 aSize2NF ( this, CUI_RES( NF_SIZE2 ) ),
68 aSize3FT ( this, CUI_RES( FT_SIZE3 ) ),
69 aSize3NF ( this, CUI_RES( NF_SIZE3 ) ),
70 aSize4FT ( this, CUI_RES( FT_SIZE4 ) ),
71 aSize4NF ( this, CUI_RES( NF_SIZE4 ) ),
72 aSize5FT ( this, CUI_RES( FT_SIZE5 ) ),
73 aSize5NF ( this, CUI_RES( NF_SIZE5 ) ),
74 aSize6FT ( this, CUI_RES( FT_SIZE6 ) ),
75 aSize6NF ( this, CUI_RES( NF_SIZE6 ) ),
76 aSize7FT ( this, CUI_RES( FT_SIZE7 ) ),
77 aSize7NF ( this, CUI_RES( NF_SIZE7 ) ),
78 aImportGB ( this, CUI_RES( GB_IMPORT ) ),
79 aNumbersEnglishUSCB ( this, CUI_RES( CB_NUMBERS_ENGLISH_US ) ),
80 aUnknownTagCB ( this, CUI_RES( CB_UNKNOWN_TAGS ) ),
81 aIgnoreFontNamesCB( this, CUI_RES( CB_IGNORE_FONTNAMES ) ),
82 aExportGB ( this, CUI_RES( GB_EXPORT ) ),
83 aExportLB ( this, CUI_RES( LB_EXPORT ) ),
84 aStarBasicCB ( this, CUI_RES( CB_STARBASIC ) ),
85 aStarBasicWarningCB(this, CUI_RES( CB_STARBASIC_WARNING ) ),
86 aPrintExtensionCB( this,CUI_RES(CB_PRINT_EXTENSION )),
87 aSaveGrfLocalCB ( this, CUI_RES( CB_LOCAL_GRF ) ),
88 aCharSetFT ( this, CUI_RES( FT_CHARSET ) ),
89 aCharSetLB ( this, CUI_RES( LB_CHARSET ) )
92 FreeResource();
94 // replace placeholder with UI string from language list
95 String aText( aNumbersEnglishUSCB.GetText());
96 String aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%ENGLISHUSLOCALE"));
97 xub_StrLen nPos;
98 if ((nPos = aText.Search( aPlaceholder)) != STRING_NOTFOUND)
100 SvtLanguageTable aLangTab;
101 const String& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US);
102 if (rStr.Len())
104 aText.Replace( nPos, aPlaceholder.Len(), rStr);
105 aNumbersEnglishUSCB.SetText( aText);
109 aExportLB.SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
110 aStarBasicCB.SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
112 // initialize the characterset listbox
113 aCharSetLB.FillWithMimeAndSelectBest();
116 /*-----------------02.09.96 13.47-------------------
118 --------------------------------------------------*/
120 OfaHtmlTabPage::~OfaHtmlTabPage()
124 /*-----------------02.09.96 13.47-------------------
126 --------------------------------------------------*/
128 SfxTabPage* OfaHtmlTabPage::Create( Window* pParent,
129 const SfxItemSet& rAttrSet )
131 return new OfaHtmlTabPage(pParent, rAttrSet);
134 /*-----------------02.09.96 13.47-------------------
136 --------------------------------------------------*/
138 sal_Bool OfaHtmlTabPage::FillItemSet( SfxItemSet& )
140 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
141 if(aSize1NF.GetSavedValue() != aSize1NF.GetText())
142 pHtmlOpt->SetFontSize(0, (sal_uInt16)aSize1NF.GetValue());
143 if(aSize2NF.GetSavedValue() != aSize2NF.GetText())
144 pHtmlOpt->SetFontSize(1, (sal_uInt16)aSize2NF.GetValue());
145 if(aSize3NF.GetSavedValue() != aSize3NF.GetText())
146 pHtmlOpt->SetFontSize(2, (sal_uInt16)aSize3NF.GetValue());
147 if(aSize4NF.GetSavedValue() != aSize4NF.GetText())
148 pHtmlOpt->SetFontSize(3, (sal_uInt16)aSize4NF.GetValue());
149 if(aSize5NF.GetSavedValue() != aSize5NF.GetText())
150 pHtmlOpt->SetFontSize(4, (sal_uInt16)aSize5NF.GetValue());
151 if(aSize6NF.GetSavedValue() != aSize6NF.GetText())
152 pHtmlOpt->SetFontSize(5, (sal_uInt16)aSize6NF.GetValue());
153 if(aSize7NF.GetSavedValue() != aSize7NF.GetText())
154 pHtmlOpt->SetFontSize(6, (sal_uInt16)aSize7NF.GetValue());
156 if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue())
157 pHtmlOpt->SetNumbersEnglishUS(aNumbersEnglishUSCB.IsChecked());
159 if(aUnknownTagCB.IsChecked() != aUnknownTagCB.GetSavedValue())
160 pHtmlOpt->SetImportUnknown(aUnknownTagCB.IsChecked());
162 if(aIgnoreFontNamesCB.IsChecked() != aIgnoreFontNamesCB.GetSavedValue())
163 pHtmlOpt->SetIgnoreFontFamily(aIgnoreFontNamesCB.IsChecked());
165 if(aExportLB.GetSelectEntryPos() != aExportLB.GetSavedValue())
166 pHtmlOpt->SetExportMode(aPosToExportArr[aExportLB.GetSelectEntryPos()]);
168 if(aStarBasicCB.IsChecked() != aStarBasicCB.GetSavedValue())
169 pHtmlOpt->SetStarBasic(aStarBasicCB.IsChecked());
171 if(aStarBasicWarningCB.IsChecked() != aStarBasicWarningCB.GetSavedValue())
172 pHtmlOpt->SetStarBasicWarning(aStarBasicWarningCB.IsChecked());
174 if(aSaveGrfLocalCB.IsChecked() != aSaveGrfLocalCB.GetSavedValue())
175 pHtmlOpt->SetSaveGraphicsLocal(aSaveGrfLocalCB.IsChecked());
177 if(aPrintExtensionCB.IsChecked() != aPrintExtensionCB.GetSavedValue())
178 pHtmlOpt->SetPrintLayoutExtension(aPrintExtensionCB.IsChecked());
180 if( aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
181 pHtmlOpt->SetTextEncoding( aCharSetLB.GetSelectTextEncoding() );
183 return sal_False;
186 /*-----------------02.09.96 13.47-------------------
188 --------------------------------------------------*/
190 void OfaHtmlTabPage::Reset( const SfxItemSet& )
192 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
193 aSize1NF.SetValue(pHtmlOpt->GetFontSize(0));
194 aSize2NF.SetValue(pHtmlOpt->GetFontSize(1));
195 aSize3NF.SetValue(pHtmlOpt->GetFontSize(2));
196 aSize4NF.SetValue(pHtmlOpt->GetFontSize(3));
197 aSize5NF.SetValue(pHtmlOpt->GetFontSize(4));
198 aSize6NF.SetValue(pHtmlOpt->GetFontSize(5));
199 aSize7NF.SetValue(pHtmlOpt->GetFontSize(6));
200 aNumbersEnglishUSCB.Check(pHtmlOpt->IsNumbersEnglishUS());
201 aUnknownTagCB.Check(pHtmlOpt->IsImportUnknown());
202 aIgnoreFontNamesCB.Check(pHtmlOpt->IsIgnoreFontFamily());
203 sal_uInt16 nExport = pHtmlOpt->GetExportMode();
204 if( nExport >= ( sizeof( aExportToPosArr ) / sizeof( sal_uInt16 ) ) )
205 nExport = 4; // default for bad config entry is NS 4.0
206 sal_uInt16 nPosArr = aExportToPosArr[ nExport ];
207 // if( nPosArr == DEPRECATED_ENTRY )
208 // nPosArr = aExportToPosArr[ 4 ]; // again: NS 4.0 is default
209 aExportLB.SelectEntryPos( nPosArr );
210 aExportLB.SaveValue();
212 ExportHdl_Impl(&aExportLB);
214 aStarBasicCB .Check(pHtmlOpt->IsStarBasic());
215 aStarBasicWarningCB .Check(pHtmlOpt->IsStarBasicWarning());
216 aStarBasicWarningCB.Enable(!aStarBasicCB.IsChecked());
217 aSaveGrfLocalCB.Check(pHtmlOpt->IsSaveGraphicsLocal());
218 aPrintExtensionCB.Check(pHtmlOpt->IsPrintLayoutExtension());
220 aPrintExtensionCB.SaveValue();
221 aStarBasicCB .SaveValue();
222 aStarBasicWarningCB .SaveValue();
223 aSaveGrfLocalCB.SaveValue();
224 aSize1NF.SaveValue();
225 aSize2NF.SaveValue();
226 aSize3NF.SaveValue();
227 aSize4NF.SaveValue();
228 aSize5NF.SaveValue();
229 aSize6NF.SaveValue();
230 aSize7NF.SaveValue();
231 aNumbersEnglishUSCB.SaveValue();
232 aUnknownTagCB.SaveValue();
233 aIgnoreFontNamesCB.SaveValue();
235 if( !pHtmlOpt->IsDefaultTextEncoding() &&
236 aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
237 aCharSetLB.SelectTextEncoding( pHtmlOpt->GetTextEncoding() );
240 /*-----------------16.04.98 16:03-------------------
242 --------------------------------------------------*/
243 IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
245 sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
246 switch( nExport )
248 case HTML_CFG_MSIE_40:
249 case HTML_CFG_NS40 :
250 case HTML_CFG_WRITER :
251 aPrintExtensionCB.Enable(sal_True);
252 break;
253 default: aPrintExtensionCB.Enable(sal_False);
256 return 0;
258 /* -----------------05.02.99 09:17-------------------
260 * --------------------------------------------------*/
261 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
263 aStarBasicWarningCB.Enable(!pBox->IsChecked());
264 return 0;