1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_cui.hxx" 30 31 // include --------------------------------------------------------------- 32 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> 40 41 // Umwandlung der Modi zu den Positionen in der Listbox 42 const sal_uInt16 aPosToExportArr[] = 43 { 44 HTML_CFG_HTML32, 45 HTML_CFG_MSIE_40, 46 HTML_CFG_NS40, 47 HTML_CFG_WRITER 48 }; 49 50 //#define DEPRECATED_ENTRY 0xFFFF 51 52 const sal_uInt16 aExportToPosArr[] = 53 { 54 0, //HTML 3.2 55 1, //MS Internet Explorer 4.0 56 3, //StarWriter 57 2 //Netscape Navigator 4.0 58 }; 59 // ----------------------------------------------------------------------- 60 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 ) ) 90 91 { 92 FreeResource(); 93 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) 99 { 100 SvtLanguageTable aLangTab; 101 const String& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US); 102 if (rStr.Len()) 103 { 104 aText.Replace( nPos, aPlaceholder.Len(), rStr); 105 aNumbersEnglishUSCB.SetText( aText); 106 } 107 } 108 109 aExportLB.SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl)); 110 aStarBasicCB.SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl)); 111 112 // initialize the characterset listbox 113 aCharSetLB.FillWithMimeAndSelectBest(); 114 } 115 116 /*-----------------02.09.96 13.47------------------- 117 118 --------------------------------------------------*/ 119 120 OfaHtmlTabPage::~OfaHtmlTabPage() 121 { 122 } 123 124 /*-----------------02.09.96 13.47------------------- 125 126 --------------------------------------------------*/ 127 128 SfxTabPage* OfaHtmlTabPage::Create( Window* pParent, 129 const SfxItemSet& rAttrSet ) 130 { 131 return new OfaHtmlTabPage(pParent, rAttrSet); 132 } 133 134 /*-----------------02.09.96 13.47------------------- 135 136 --------------------------------------------------*/ 137 138 sal_Bool OfaHtmlTabPage::FillItemSet( SfxItemSet& ) 139 { 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()); 155 156 if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue()) 157 pHtmlOpt->SetNumbersEnglishUS(aNumbersEnglishUSCB.IsChecked()); 158 159 if(aUnknownTagCB.IsChecked() != aUnknownTagCB.GetSavedValue()) 160 pHtmlOpt->SetImportUnknown(aUnknownTagCB.IsChecked()); 161 162 if(aIgnoreFontNamesCB.IsChecked() != aIgnoreFontNamesCB.GetSavedValue()) 163 pHtmlOpt->SetIgnoreFontFamily(aIgnoreFontNamesCB.IsChecked()); 164 165 if(aExportLB.GetSelectEntryPos() != aExportLB.GetSavedValue()) 166 pHtmlOpt->SetExportMode(aPosToExportArr[aExportLB.GetSelectEntryPos()]); 167 168 if(aStarBasicCB.IsChecked() != aStarBasicCB.GetSavedValue()) 169 pHtmlOpt->SetStarBasic(aStarBasicCB.IsChecked()); 170 171 if(aStarBasicWarningCB.IsChecked() != aStarBasicWarningCB.GetSavedValue()) 172 pHtmlOpt->SetStarBasicWarning(aStarBasicWarningCB.IsChecked()); 173 174 if(aSaveGrfLocalCB.IsChecked() != aSaveGrfLocalCB.GetSavedValue()) 175 pHtmlOpt->SetSaveGraphicsLocal(aSaveGrfLocalCB.IsChecked()); 176 177 if(aPrintExtensionCB.IsChecked() != aPrintExtensionCB.GetSavedValue()) 178 pHtmlOpt->SetPrintLayoutExtension(aPrintExtensionCB.IsChecked()); 179 180 if( aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() ) 181 pHtmlOpt->SetTextEncoding( aCharSetLB.GetSelectTextEncoding() ); 182 183 return sal_False; 184 } 185 186 /*-----------------02.09.96 13.47------------------- 187 188 --------------------------------------------------*/ 189 190 void OfaHtmlTabPage::Reset( const SfxItemSet& ) 191 { 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(); 211 212 ExportHdl_Impl(&aExportLB); 213 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()); 219 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(); 234 235 if( !pHtmlOpt->IsDefaultTextEncoding() && 236 aCharSetLB.GetSelectTextEncoding() != pHtmlOpt->GetTextEncoding() ) 237 aCharSetLB.SelectTextEncoding( pHtmlOpt->GetTextEncoding() ); 238 } 239 240 /*-----------------16.04.98 16:03------------------- 241 242 --------------------------------------------------*/ 243 IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox) 244 { 245 sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ]; 246 switch( nExport ) 247 { 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); 254 } 255 256 return 0; 257 } 258 /* -----------------05.02.99 09:17------------------- 259 * 260 * --------------------------------------------------*/ 261 IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox) 262 { 263 aStarBasicWarningCB.Enable(!pBox->IsChecked()); 264 return 0; 265 } 266 267 268