merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / opthtml.cxx
blobb7ba5a3f3c47ca297e49d612b5134ed4395b72ca
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: opthtml.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
40 #include <svtools/langtab.hxx>
42 #include "htmlcfg.hxx"
43 #include "opthtml.hxx"
44 #include "opthtml.hrc"
45 #include <svx/dialogs.hrc>
46 #include "helpid.hrc"
47 #include <svx/dialmgr.hxx>
49 // Umwandlung der Modi zu den Positionen in der Listbox
50 const USHORT aPosToExportArr[] =
52 HTML_CFG_HTML32,
53 HTML_CFG_MSIE_40,
54 HTML_CFG_NS40,
55 HTML_CFG_WRITER
58 //#define DEPRECATED_ENTRY 0xFFFF
60 const USHORT aExportToPosArr[] =
62 0, //HTML 3.2
63 1, //MS Internet Explorer 4.0
64 3, //StarWriter
65 2 //Netscape Navigator 4.0
67 // -----------------------------------------------------------------------
69 OfaHtmlTabPage::OfaHtmlTabPage(Window* pParent, const SfxItemSet& rSet) :
70 SfxTabPage( pParent, SVX_RES( RID_OFAPAGE_HTMLOPT ), rSet ),
71 aFontSizeGB ( this, SVX_RES( GB_FONTSIZE ) ),
72 aSize1FT ( this, SVX_RES( FT_SIZE1 ) ),
73 aSize1NF ( this, SVX_RES( NF_SIZE1 ) ),
74 aSize2FT ( this, SVX_RES( FT_SIZE2 ) ),
75 aSize2NF ( this, SVX_RES( NF_SIZE2 ) ),
76 aSize3FT ( this, SVX_RES( FT_SIZE3 ) ),
77 aSize3NF ( this, SVX_RES( NF_SIZE3 ) ),
78 aSize4FT ( this, SVX_RES( FT_SIZE4 ) ),
79 aSize4NF ( this, SVX_RES( NF_SIZE4 ) ),
80 aSize5FT ( this, SVX_RES( FT_SIZE5 ) ),
81 aSize5NF ( this, SVX_RES( NF_SIZE5 ) ),
82 aSize6FT ( this, SVX_RES( FT_SIZE6 ) ),
83 aSize6NF ( this, SVX_RES( NF_SIZE6 ) ),
84 aSize7FT ( this, SVX_RES( FT_SIZE7 ) ),
85 aSize7NF ( this, SVX_RES( NF_SIZE7 ) ),
86 aImportGB ( this, SVX_RES( GB_IMPORT ) ),
87 aNumbersEnglishUSCB ( this, SVX_RES( CB_NUMBERS_ENGLISH_US ) ),
88 aUnknownTagCB ( this, SVX_RES( CB_UNKNOWN_TAGS ) ),
89 aIgnoreFontNamesCB( this, SVX_RES( CB_IGNORE_FONTNAMES ) ),
90 aExportGB ( this, SVX_RES( GB_EXPORT ) ),
91 aExportLB ( this, SVX_RES( LB_EXPORT ) ),
92 aStarBasicCB ( this, SVX_RES( CB_STARBASIC ) ),
93 aStarBasicWarningCB(this, SVX_RES( CB_STARBASIC_WARNING ) ),
94 aPrintExtensionCB( this,SVX_RES(CB_PRINT_EXTENSION )),
95 aSaveGrfLocalCB ( this, SVX_RES( CB_LOCAL_GRF ) ),
96 aCharSetFT ( this, SVX_RES( FT_CHARSET ) ),
97 aCharSetLB ( this, SVX_RES( LB_CHARSET ) )
100 FreeResource();
102 // replace placeholder with UI string from language list
103 String aText( aNumbersEnglishUSCB.GetText());
104 String aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%ENGLISHUSLOCALE"));
105 xub_StrLen nPos;
106 if ((nPos = aText.Search( aPlaceholder)) != STRING_NOTFOUND)
108 SvtLanguageTable aLangTab;
109 const String& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US);
110 if (rStr.Len())
112 aText.Replace( nPos, aPlaceholder.Len(), rStr);
113 aNumbersEnglishUSCB.SetText( aText);
117 aExportLB.SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
118 aStarBasicCB.SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
120 // initialize the characterset listbox
121 aCharSetLB.FillWithMimeAndSelectBest();
124 /*-----------------02.09.96 13.47-------------------
126 --------------------------------------------------*/
128 OfaHtmlTabPage::~OfaHtmlTabPage()
132 /*-----------------02.09.96 13.47-------------------
134 --------------------------------------------------*/
136 SfxTabPage* OfaHtmlTabPage::Create( Window* pParent,
137 const SfxItemSet& rAttrSet )
139 return new OfaHtmlTabPage(pParent, rAttrSet);
142 /*-----------------02.09.96 13.47-------------------
144 --------------------------------------------------*/
146 BOOL OfaHtmlTabPage::FillItemSet( SfxItemSet& )
148 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
149 if(aSize1NF.GetSavedValue() != aSize1NF.GetText())
150 pHtmlOpt->SetFontSize(0, (USHORT)aSize1NF.GetValue());
151 if(aSize2NF.GetSavedValue() != aSize2NF.GetText())
152 pHtmlOpt->SetFontSize(1, (USHORT)aSize2NF.GetValue());
153 if(aSize3NF.GetSavedValue() != aSize3NF.GetText())
154 pHtmlOpt->SetFontSize(2, (USHORT)aSize3NF.GetValue());
155 if(aSize4NF.GetSavedValue() != aSize4NF.GetText())
156 pHtmlOpt->SetFontSize(3, (USHORT)aSize4NF.GetValue());
157 if(aSize5NF.GetSavedValue() != aSize5NF.GetText())
158 pHtmlOpt->SetFontSize(4, (USHORT)aSize5NF.GetValue());
159 if(aSize6NF.GetSavedValue() != aSize6NF.GetText())
160 pHtmlOpt->SetFontSize(5, (USHORT)aSize6NF.GetValue());
161 if(aSize7NF.GetSavedValue() != aSize7NF.GetText())
162 pHtmlOpt->SetFontSize(6, (USHORT)aSize7NF.GetValue());
164 if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue())
165 pHtmlOpt->SetNumbersEnglishUS(aNumbersEnglishUSCB.IsChecked());
167 if(aUnknownTagCB.IsChecked() != aUnknownTagCB.GetSavedValue())
168 pHtmlOpt->SetImportUnknown(aUnknownTagCB.IsChecked());
170 if(aIgnoreFontNamesCB.IsChecked() != aIgnoreFontNamesCB.GetSavedValue())
171 pHtmlOpt->SetIgnoreFontFamily(aIgnoreFontNamesCB.IsChecked());
173 if(aExportLB.GetSelectEntryPos() != aExportLB.GetSavedValue())
174 pHtmlOpt->SetExportMode(aPosToExportArr[aExportLB.GetSelectEntryPos()]);
176 if(aStarBasicCB.IsChecked() != aStarBasicCB.GetSavedValue())
177 pHtmlOpt->SetStarBasic(aStarBasicCB.IsChecked());
179 if(aStarBasicWarningCB.IsChecked() != aStarBasicWarningCB.GetSavedValue())
180 pHtmlOpt->SetStarBasicWarning(aStarBasicWarningCB.IsChecked());
182 if(aSaveGrfLocalCB.IsChecked() != aSaveGrfLocalCB.GetSavedValue())
183 pHtmlOpt->SetSaveGraphicsLocal(aSaveGrfLocalCB.IsChecked());
185 if(aPrintExtensionCB.IsChecked() != aPrintExtensionCB.GetSavedValue())
186 pHtmlOpt->SetPrintLayoutExtension(aPrintExtensionCB.IsChecked());
188 if( aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
189 pHtmlOpt->SetTextEncoding( aCharSetLB.GetSelectTextEncoding() );
191 return FALSE;
194 /*-----------------02.09.96 13.47-------------------
196 --------------------------------------------------*/
198 void OfaHtmlTabPage::Reset( const SfxItemSet& )
200 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
201 aSize1NF.SetValue(pHtmlOpt->GetFontSize(0));
202 aSize2NF.SetValue(pHtmlOpt->GetFontSize(1));
203 aSize3NF.SetValue(pHtmlOpt->GetFontSize(2));
204 aSize4NF.SetValue(pHtmlOpt->GetFontSize(3));
205 aSize5NF.SetValue(pHtmlOpt->GetFontSize(4));
206 aSize6NF.SetValue(pHtmlOpt->GetFontSize(5));
207 aSize7NF.SetValue(pHtmlOpt->GetFontSize(6));
208 aNumbersEnglishUSCB.Check(pHtmlOpt->IsNumbersEnglishUS());
209 aUnknownTagCB.Check(pHtmlOpt->IsImportUnknown());
210 aIgnoreFontNamesCB.Check(pHtmlOpt->IsIgnoreFontFamily());
211 USHORT nExport = pHtmlOpt->GetExportMode();
212 if( nExport >= ( sizeof( aExportToPosArr ) / sizeof( USHORT ) ) )
213 nExport = 4; // default for bad config entry is NS 4.0
214 USHORT nPosArr = aExportToPosArr[ nExport ];
215 // if( nPosArr == DEPRECATED_ENTRY )
216 // nPosArr = aExportToPosArr[ 4 ]; // again: NS 4.0 is default
217 aExportLB.SelectEntryPos( nPosArr );
218 aExportLB.SaveValue();
220 ExportHdl_Impl(&aExportLB);
222 aStarBasicCB .Check(pHtmlOpt->IsStarBasic());
223 aStarBasicWarningCB .Check(pHtmlOpt->IsStarBasicWarning());
224 aStarBasicWarningCB.Enable(!aStarBasicCB.IsChecked());
225 aSaveGrfLocalCB.Check(pHtmlOpt->IsSaveGraphicsLocal());
226 aPrintExtensionCB.Check(pHtmlOpt->IsPrintLayoutExtension());
228 aPrintExtensionCB.SaveValue();
229 aStarBasicCB .SaveValue();
230 aStarBasicWarningCB .SaveValue();
231 aSaveGrfLocalCB.SaveValue();
232 aSize1NF.SaveValue();
233 aSize2NF.SaveValue();
234 aSize3NF.SaveValue();
235 aSize4NF.SaveValue();
236 aSize5NF.SaveValue();
237 aSize6NF.SaveValue();
238 aSize7NF.SaveValue();
239 aNumbersEnglishUSCB.SaveValue();
240 aUnknownTagCB.SaveValue();
241 aIgnoreFontNamesCB.SaveValue();
243 if( !pHtmlOpt->IsDefaultTextEncoding() &&
244 aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
245 aCharSetLB.SelectTextEncoding( pHtmlOpt->GetTextEncoding() );
248 /*-----------------16.04.98 16:03-------------------
250 --------------------------------------------------*/
251 IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
253 USHORT nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
254 switch( nExport )
256 case HTML_CFG_MSIE_40:
257 case HTML_CFG_NS40 :
258 case HTML_CFG_WRITER :
259 aPrintExtensionCB.Enable(TRUE);
260 break;
261 default: aPrintExtensionCB.Enable(FALSE);
264 return 0;
266 /* -----------------05.02.99 09:17-------------------
268 * --------------------------------------------------*/
269 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
271 aStarBasicWarningCB.Enable(!pBox->IsChecked());
272 return 0;