xref: /trunk/main/cui/source/options/opthtml.cxx (revision 93ed1f29)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 
29 #include <svtools/langtab.hxx>
30 #include <svtools/htmlcfg.hxx>
31 #include "opthtml.hxx"
32 #include "opthtml.hrc"
33 #include <cuires.hrc>
34 #include "helpid.hrc"
35 #include <dialmgr.hxx>
36 
37 // Umwandlung der Modi zu den Positionen in der Listbox
38 const sal_uInt16 aPosToExportArr[] =
39 {
40 	HTML_CFG_HTML32,
41 	HTML_CFG_MSIE_40,
42 	HTML_CFG_NS40,
43 	HTML_CFG_WRITER
44 };
45 
46 //#define DEPRECATED_ENTRY	0xFFFF
47 
48 const sal_uInt16 aExportToPosArr[] =
49 {
50 	0,	//HTML 3.2
51 	1,	//MS Internet Explorer 4.0
52     3,	//StarWriter
53     2	//Netscape Navigator 4.0
54 };
55 // -----------------------------------------------------------------------
56 
OfaHtmlTabPage(Window * pParent,const SfxItemSet & rSet)57 OfaHtmlTabPage::OfaHtmlTabPage(Window* pParent, const SfxItemSet& rSet) :
58 		SfxTabPage( pParent, CUI_RES( RID_OFAPAGE_HTMLOPT ), rSet ),
59 	aFontSizeGB		( this, CUI_RES( GB_FONTSIZE	   ) ),
60 	aSize1FT        ( this, CUI_RES( FT_SIZE1	       ) ),
61 	aSize1NF        ( this, CUI_RES( NF_SIZE1	       ) ),
62 	aSize2FT        ( this, CUI_RES( FT_SIZE2	       ) ),
63 	aSize2NF        ( this, CUI_RES( NF_SIZE2	       ) ),
64 	aSize3FT        ( this, CUI_RES( FT_SIZE3	       ) ),
65 	aSize3NF        ( this, CUI_RES( NF_SIZE3	       ) ),
66 	aSize4FT        ( this, CUI_RES( FT_SIZE4	       ) ),
67 	aSize4NF        ( this, CUI_RES( NF_SIZE4	       ) ),
68 	aSize5FT        ( this, CUI_RES( FT_SIZE5	       ) ),
69 	aSize5NF        ( this, CUI_RES( NF_SIZE5	       ) ),
70 	aSize6FT        ( this, CUI_RES( FT_SIZE6	       ) ),
71 	aSize6NF        ( this, CUI_RES( NF_SIZE6	       ) ),
72 	aSize7FT        ( this, CUI_RES( FT_SIZE7	       ) ),
73 	aSize7NF        ( this, CUI_RES( NF_SIZE7	       ) ),
74 	aImportGB       ( this, CUI_RES( GB_IMPORT	   ) ),
75 	aNumbersEnglishUSCB	( this, CUI_RES( CB_NUMBERS_ENGLISH_US ) ),
76 	aUnknownTagCB	( this, CUI_RES( CB_UNKNOWN_TAGS ) ),
77 	aIgnoreFontNamesCB( this, CUI_RES( CB_IGNORE_FONTNAMES ) ),
78 	aExportGB		( this, CUI_RES( GB_EXPORT       ) ),
79 	aExportLB       ( this, CUI_RES( LB_EXPORT       ) ),
80     aStarBasicCB    ( this, CUI_RES( CB_STARBASIC    ) ),
81 	aStarBasicWarningCB(this, CUI_RES( CB_STARBASIC_WARNING    ) ),
82     aPrintExtensionCB( this,CUI_RES(CB_PRINT_EXTENSION )),
83     aSaveGrfLocalCB ( this, CUI_RES( CB_LOCAL_GRF    ) ),
84 	aCharSetFT		( this, CUI_RES( FT_CHARSET      ) ),
85 	aCharSetLB		( this, CUI_RES( LB_CHARSET      ) )
86 
87 {
88 	FreeResource();
89 
90     // replace placeholder with UI string from language list
91     String aText( aNumbersEnglishUSCB.GetText());
92     String aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%ENGLISHUSLOCALE"));
93     xub_StrLen nPos;
94     if ((nPos = aText.Search( aPlaceholder)) != STRING_NOTFOUND)
95     {
96         SvtLanguageTable aLangTab;
97         const String& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US);
98         if (rStr.Len())
99         {
100             aText.Replace( nPos, aPlaceholder.Len(), rStr);
101             aNumbersEnglishUSCB.SetText( aText);
102         }
103     }
104 
105 	aExportLB.SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
106 	aStarBasicCB.SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
107 
108 	// initialize the characterset listbox
109 	aCharSetLB.FillWithMimeAndSelectBest();
110 }
111 
112 /*-----------------02.09.96 13.47-------------------
113 
114 --------------------------------------------------*/
115 
~OfaHtmlTabPage()116 OfaHtmlTabPage::~OfaHtmlTabPage()
117 {
118 }
119 
120 /*-----------------02.09.96 13.47-------------------
121 
122 --------------------------------------------------*/
123 
Create(Window * pParent,const SfxItemSet & rAttrSet)124 SfxTabPage*	OfaHtmlTabPage::Create( Window* pParent,
125 								const SfxItemSet& rAttrSet )
126 {
127 	return new OfaHtmlTabPage(pParent, rAttrSet);
128 }
129 
130 /*-----------------02.09.96 13.47-------------------
131 
132 --------------------------------------------------*/
133 
FillItemSet(SfxItemSet &)134 sal_Bool OfaHtmlTabPage::FillItemSet( SfxItemSet& )
135 {
136 	SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
137 	if(aSize1NF.GetSavedValue() != aSize1NF.GetText())
138 		pHtmlOpt->SetFontSize(0, (sal_uInt16)aSize1NF.GetValue());
139 	if(aSize2NF.GetSavedValue() != aSize2NF.GetText())
140 		pHtmlOpt->SetFontSize(1, (sal_uInt16)aSize2NF.GetValue());
141 	if(aSize3NF.GetSavedValue() != aSize3NF.GetText())
142 		pHtmlOpt->SetFontSize(2, (sal_uInt16)aSize3NF.GetValue());
143 	if(aSize4NF.GetSavedValue() != aSize4NF.GetText())
144 		pHtmlOpt->SetFontSize(3, (sal_uInt16)aSize4NF.GetValue());
145 	if(aSize5NF.GetSavedValue() != aSize5NF.GetText())
146 		pHtmlOpt->SetFontSize(4, (sal_uInt16)aSize5NF.GetValue());
147 	if(aSize6NF.GetSavedValue() != aSize6NF.GetText())
148 		pHtmlOpt->SetFontSize(5, (sal_uInt16)aSize6NF.GetValue());
149 	if(aSize7NF.GetSavedValue() != aSize7NF.GetText())
150 		pHtmlOpt->SetFontSize(6, (sal_uInt16)aSize7NF.GetValue());
151 
152 	if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue())
153 		pHtmlOpt->SetNumbersEnglishUS(aNumbersEnglishUSCB.IsChecked());
154 
155 	if(aUnknownTagCB.IsChecked() != aUnknownTagCB.GetSavedValue())
156 		pHtmlOpt->SetImportUnknown(aUnknownTagCB.IsChecked());
157 
158 	if(aIgnoreFontNamesCB.IsChecked() != aIgnoreFontNamesCB.GetSavedValue())
159 		pHtmlOpt->SetIgnoreFontFamily(aIgnoreFontNamesCB.IsChecked());
160 
161 	if(aExportLB.GetSelectEntryPos() != aExportLB.GetSavedValue())
162 		pHtmlOpt->SetExportMode(aPosToExportArr[aExportLB.GetSelectEntryPos()]);
163 
164 	if(aStarBasicCB.IsChecked() != aStarBasicCB.GetSavedValue())
165 		pHtmlOpt->SetStarBasic(aStarBasicCB.IsChecked());
166 
167 	if(aStarBasicWarningCB.IsChecked() != aStarBasicWarningCB.GetSavedValue())
168 		pHtmlOpt->SetStarBasicWarning(aStarBasicWarningCB.IsChecked());
169 
170 	if(aSaveGrfLocalCB.IsChecked() != aSaveGrfLocalCB.GetSavedValue())
171 		pHtmlOpt->SetSaveGraphicsLocal(aSaveGrfLocalCB.IsChecked());
172 
173 	if(aPrintExtensionCB.IsChecked() != aPrintExtensionCB.GetSavedValue())
174 		pHtmlOpt->SetPrintLayoutExtension(aPrintExtensionCB.IsChecked());
175 
176 	if( aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
177 		pHtmlOpt->SetTextEncoding( aCharSetLB.GetSelectTextEncoding() );
178 
179 	return sal_False;
180 }
181 
182 /*-----------------02.09.96 13.47-------------------
183 
184 --------------------------------------------------*/
185 
Reset(const SfxItemSet &)186 void OfaHtmlTabPage::Reset( const SfxItemSet& )
187 {
188 	SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
189 	aSize1NF.SetValue(pHtmlOpt->GetFontSize(0));
190 	aSize2NF.SetValue(pHtmlOpt->GetFontSize(1));
191 	aSize3NF.SetValue(pHtmlOpt->GetFontSize(2));
192 	aSize4NF.SetValue(pHtmlOpt->GetFontSize(3));
193 	aSize5NF.SetValue(pHtmlOpt->GetFontSize(4));
194 	aSize6NF.SetValue(pHtmlOpt->GetFontSize(5));
195 	aSize7NF.SetValue(pHtmlOpt->GetFontSize(6));
196 	aNumbersEnglishUSCB.Check(pHtmlOpt->IsNumbersEnglishUS());
197 	aUnknownTagCB.Check(pHtmlOpt->IsImportUnknown());
198 	aIgnoreFontNamesCB.Check(pHtmlOpt->IsIgnoreFontFamily());
199 	sal_uInt16 nExport = pHtmlOpt->GetExportMode();
200 	if( nExport >= ( sizeof( aExportToPosArr ) / sizeof( sal_uInt16 ) ) )
201     {
202         nExport = 3;    // default for bad config entry is NS 4.0
203     }
204 	sal_uInt16 nPosArr = aExportToPosArr[ nExport ];
205 //	if( nPosArr == DEPRECATED_ENTRY )
206 //		nPosArr = aExportToPosArr[ 4 ];		// again: NS 4.0 is default
207 	aExportLB.SelectEntryPos( nPosArr );
208 	aExportLB.SaveValue();
209 
210 	ExportHdl_Impl(&aExportLB);
211 
212 	aStarBasicCB .Check(pHtmlOpt->IsStarBasic());
213 	aStarBasicWarningCB .Check(pHtmlOpt->IsStarBasicWarning());
214 	aStarBasicWarningCB.Enable(!aStarBasicCB.IsChecked());
215 	aSaveGrfLocalCB.Check(pHtmlOpt->IsSaveGraphicsLocal());
216 	aPrintExtensionCB.Check(pHtmlOpt->IsPrintLayoutExtension());
217 
218 	aPrintExtensionCB.SaveValue();
219 	aStarBasicCB .SaveValue();
220 	aStarBasicWarningCB .SaveValue();
221 	aSaveGrfLocalCB.SaveValue();
222 	aSize1NF.SaveValue();
223 	aSize2NF.SaveValue();
224 	aSize3NF.SaveValue();
225 	aSize4NF.SaveValue();
226 	aSize5NF.SaveValue();
227 	aSize6NF.SaveValue();
228 	aSize7NF.SaveValue();
229 	aNumbersEnglishUSCB.SaveValue();
230 	aUnknownTagCB.SaveValue();
231 	aIgnoreFontNamesCB.SaveValue();
232 
233     if( !pHtmlOpt->IsDefaultTextEncoding() &&
234         aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() )
235 		aCharSetLB.SelectTextEncoding( pHtmlOpt->GetTextEncoding() );
236 }
237 
238 /*-----------------16.04.98 16:03-------------------
239 
240 --------------------------------------------------*/
IMPL_LINK(OfaHtmlTabPage,ExportHdl_Impl,ListBox *,pBox)241 IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
242 {
243 	sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
244 	switch( nExport )
245 	{
246 		case HTML_CFG_MSIE_40:
247 		case HTML_CFG_NS40  :
248 		case HTML_CFG_WRITER :
249 			aPrintExtensionCB.Enable(sal_True);
250 		break;
251 		default: aPrintExtensionCB.Enable(sal_False);
252 	}
253 
254 	return 0;
255 }
256 /* -----------------05.02.99 09:17-------------------
257  *
258  * --------------------------------------------------*/
IMPL_LINK(OfaHtmlTabPage,CheckBoxHdl_Impl,CheckBox *,pBox)259 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
260 {
261 	aStarBasicWarningCB.Enable(!pBox->IsChecked());
262 	return 0;
263 }
264 
265 
266