1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sw.hxx" 30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #include <hintids.hxx> 34*cdf0e10cSrcweir #include <rtl/textenc.h> 35*cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp> 37*cdf0e10cSrcweir #include <unotools/lingucfg.hxx> 38*cdf0e10cSrcweir #include <fontcfg.hxx> 39*cdf0e10cSrcweir #include <swmodule.hxx> 40*cdf0e10cSrcweir #include <editeng/unolingu.hxx> 41*cdf0e10cSrcweir #include <sfx2/printer.hxx> 42*cdf0e10cSrcweir #include <editeng/flstitem.hxx> 43*cdf0e10cSrcweir #include <svx/dlgutil.hxx> 44*cdf0e10cSrcweir #include <editeng/fontitem.hxx> 45*cdf0e10cSrcweir #include <editeng/langitem.hxx> 46*cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx> 47*cdf0e10cSrcweir #include <swtypes.hxx> 48*cdf0e10cSrcweir #include <ascfldlg.hxx> 49*cdf0e10cSrcweir #include <shellio.hxx> 50*cdf0e10cSrcweir #include <docsh.hxx> 51*cdf0e10cSrcweir #include <doc.hxx> 52*cdf0e10cSrcweir #include <errhdl.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #ifndef _DIALOG_HRC 55*cdf0e10cSrcweir #include <dialog.hrc> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifndef _ASCFLDLG_HRC 58*cdf0e10cSrcweir #include <ascfldlg.hrc> 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #include "vcl/metric.hxx" 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir using namespace ::com::sun::star; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir const sal_Unicode cDialogExtraDataClose = '}'; 67*cdf0e10cSrcweir const char __FAR_DATA sDialogImpExtraData[] = "EncImpDlg:{"; 68*cdf0e10cSrcweir const char __FAR_DATA sDialogExpExtraData[] = "EncExpDlg:{"; 69*cdf0e10cSrcweir const sal_uInt16 nDialogExtraDataLen = 11; // 12345678901 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, 72*cdf0e10cSrcweir SvStream* pStream ) 73*cdf0e10cSrcweir : SfxModalDialog( pParent, SW_RES( DLG_ASCII_FILTER )), 74*cdf0e10cSrcweir aFL( this, SW_RES( FL_1 )), 75*cdf0e10cSrcweir aCharSetFT( this, SW_RES( FT_CHARSET )), 76*cdf0e10cSrcweir aCharSetLB( this, SW_RES( LB_CHARSET )), 77*cdf0e10cSrcweir aFontFT( this, SW_RES( FT_FONT )), 78*cdf0e10cSrcweir aFontLB( this, SW_RES( LB_FONT )), 79*cdf0e10cSrcweir aLanguageFT( this, SW_RES( FT_LANGUAGE )), 80*cdf0e10cSrcweir aLanguageLB( this, SW_RES( LB_LANGUAGE )), 81*cdf0e10cSrcweir aCRLF_FT( this, SW_RES( FT_CRLF )), 82*cdf0e10cSrcweir aCRLF_RB( this, SW_RES( RB_CRLF )), 83*cdf0e10cSrcweir aCR_RB( this, SW_RES( RB_CR )), 84*cdf0e10cSrcweir aLF_RB( this, SW_RES( RB_LF )), 85*cdf0e10cSrcweir aOkPB( this, SW_RES( PB_OK )), 86*cdf0e10cSrcweir aCancelPB( this, SW_RES( PB_CANCEL )), 87*cdf0e10cSrcweir aHelpPB( this, SW_RES( PB_HELP )), 88*cdf0e10cSrcweir sSystemCharSet( SW_RES( STR_SYS_CHARSET )), 89*cdf0e10cSrcweir bSaveLineStatus( sal_True ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir FreeResource(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir SwAsciiOptions aOpt; 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir const String& rFindNm = String::CreateFromAscii( 96*cdf0e10cSrcweir pStream ? sDialogImpExtraData 97*cdf0e10cSrcweir : sDialogExpExtraData); 98*cdf0e10cSrcweir sal_uInt16 nEnd, nStt = GetExtraData().Search( rFindNm ); 99*cdf0e10cSrcweir if( STRING_NOTFOUND != nStt ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir nStt += nDialogExtraDataLen; 102*cdf0e10cSrcweir nEnd = GetExtraData().Search( cDialogExtraDataClose, nStt ); 103*cdf0e10cSrcweir if( STRING_NOTFOUND != nEnd ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir aOpt.ReadUserData( GetExtraData().Copy( nStt, nEnd - nStt )); 106*cdf0e10cSrcweir nStt -= nDialogExtraDataLen; 107*cdf0e10cSrcweir GetExtraData().Erase( nStt, nEnd - nStt + 1 ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // read the first chars and check the charset, (language - with L&H) 113*cdf0e10cSrcweir if( pStream ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir char aBuffer[ 4098 ]; 116*cdf0e10cSrcweir sal_uLong nOldPos = pStream->Tell(); 117*cdf0e10cSrcweir sal_uLong nBytesRead = pStream->Read( aBuffer, 4096 ); 118*cdf0e10cSrcweir pStream->Seek( nOldPos ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir if( nBytesRead <= 4096 ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir aBuffer[ nBytesRead ] = '0'; 123*cdf0e10cSrcweir aBuffer[ nBytesRead+1 ] = '0'; 124*cdf0e10cSrcweir if( 0 != ( nBytesRead & 0x00000001 ) ) 125*cdf0e10cSrcweir aBuffer[ nBytesRead + 2 ] = '0'; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir sal_Bool bCR = sal_False, bLF = sal_False, bNoNormalChar = sal_False, 129*cdf0e10cSrcweir bNullChar = sal_False; 130*cdf0e10cSrcweir for( sal_uInt16 nCnt = 0; nCnt < nBytesRead; ++nCnt ) 131*cdf0e10cSrcweir switch( aBuffer[ nCnt ] ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir case 0x0: bNullChar = sal_True; break; 134*cdf0e10cSrcweir case 0xA: bLF = sal_True; break; 135*cdf0e10cSrcweir case 0xD: bCR = sal_True; break; 136*cdf0e10cSrcweir case 0xC: 137*cdf0e10cSrcweir case 0x1A: 138*cdf0e10cSrcweir case 0x9: break; 139*cdf0e10cSrcweir default: 140*cdf0e10cSrcweir if( 0x20 > aBuffer[ nCnt ] ) 141*cdf0e10cSrcweir bNoNormalChar = sal_True; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir if( !bNullChar ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir if( bCR ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir if( bLF ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir aOpt.SetParaFlags( LINEEND_CRLF ); 151*cdf0e10cSrcweir // have to check if of CharSet is type of ANSI 152*cdf0e10cSrcweir // aOpt.SetCharSet( CHARSET_ANSI ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir else 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir aOpt.SetParaFlags( LINEEND_CR ); 157*cdf0e10cSrcweir // have to check if CharSet is type of MAC 158*cdf0e10cSrcweir // aOpt.SetCharSet( CHARSET_MAC ); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir else if( bLF ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir aOpt.SetParaFlags( LINEEND_LF ); 164*cdf0e10cSrcweir // have to check if of CharSet is type of ANSI 165*cdf0e10cSrcweir // aOpt.SetCharSet( CHARSET_ANSI ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir SwDoc* pDoc = rDocSh.GetDoc(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir sal_uInt16 nAppScriptType = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ); 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir sal_Bool bDelPrinter = sal_False; 174*cdf0e10cSrcweir SfxPrinter* pPrt = pDoc ? pDoc->getPrinter(false) : 0; 175*cdf0e10cSrcweir if( !pPrt ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir SfxItemSet* pSet = new SfxItemSet( rDocSh.GetPool(), 178*cdf0e10cSrcweir SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 179*cdf0e10cSrcweir SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, 180*cdf0e10cSrcweir 0 ); 181*cdf0e10cSrcweir pPrt = new SfxPrinter( pSet ); 182*cdf0e10cSrcweir bDelPrinter = sal_True; 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // get the set of disctinct available family names 187*cdf0e10cSrcweir std::set< String > aFontNames; 188*cdf0e10cSrcweir int nFontNames = pPrt->GetDevFontCount(); 189*cdf0e10cSrcweir for( int i = 0; i < nFontNames; i++ ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir FontInfo aInf( pPrt->GetDevFont( i ) ); 192*cdf0e10cSrcweir aFontNames.insert( aInf.GetName() ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // insert to listbox 196*cdf0e10cSrcweir for( std::set< String >::const_iterator it = aFontNames.begin(); 197*cdf0e10cSrcweir it != aFontNames.end(); ++it ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir aFontLB.InsertEntry( *it ); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir if( !aOpt.GetFontName().Len() ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir if(pDoc) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir sal_uInt16 nFontRes = RES_CHRATR_FONT; 207*cdf0e10cSrcweir if(SCRIPTTYPE_ASIAN == nAppScriptType) 208*cdf0e10cSrcweir nFontRes = RES_CHRATR_CJK_FONT; 209*cdf0e10cSrcweir else if(SCRIPTTYPE_COMPLEX == nAppScriptType) 210*cdf0e10cSrcweir nFontRes = RES_CHRATR_CTL_FONT; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir aOpt.SetFontName( ((SvxFontItem&)pDoc->GetDefault( 213*cdf0e10cSrcweir nFontRes )).GetFamilyName() ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir else 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir sal_uInt16 nFontType = FONT_STANDARD; 218*cdf0e10cSrcweir if(SCRIPTTYPE_ASIAN == nAppScriptType) 219*cdf0e10cSrcweir nFontType = FONT_STANDARD_CJK; 220*cdf0e10cSrcweir else if(SCRIPTTYPE_COMPLEX == nAppScriptType) 221*cdf0e10cSrcweir nFontType = FONT_STANDARD_CTL; 222*cdf0e10cSrcweir aOpt.SetFontName(SW_MOD()->GetStdFontConfig()->GetFontFor(nFontType)); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir aFontLB.SelectEntry( aOpt.GetFontName() ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir if( bDelPrinter ) 228*cdf0e10cSrcweir delete pPrt; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir // initialisiere Sprache 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if( !aOpt.GetLanguage() ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir if(pDoc) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir sal_uInt16 nWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nAppScriptType); 238*cdf0e10cSrcweir aOpt.SetLanguage( ((SvxLanguageItem&)pDoc-> 239*cdf0e10cSrcweir GetDefault( nWhich )).GetLanguage()); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir SvtLinguOptions aLinguOpt; 244*cdf0e10cSrcweir SvtLinguConfig().GetOptions( aLinguOpt ); 245*cdf0e10cSrcweir switch(nAppScriptType) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir case SCRIPTTYPE_ASIAN: 248*cdf0e10cSrcweir aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, SCRIPTTYPE_ASIAN)); 249*cdf0e10cSrcweir break; 250*cdf0e10cSrcweir case SCRIPTTYPE_COMPLEX: 251*cdf0e10cSrcweir aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, SCRIPTTYPE_COMPLEX)); 252*cdf0e10cSrcweir break; 253*cdf0e10cSrcweir //SCRIPTTYPE_LATIN: 254*cdf0e10cSrcweir default: 255*cdf0e10cSrcweir aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, SCRIPTTYPE_LATIN)); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir aLanguageLB.SetLanguageList( LANG_LIST_ALL, sal_True, sal_False ); 261*cdf0e10cSrcweir aLanguageLB.SelectLanguage( aOpt.GetLanguage() ); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir else 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // hide the used Control for the Export and move the 267*cdf0e10cSrcweir // other behind the charset controls 268*cdf0e10cSrcweir aFontFT.Hide(); 269*cdf0e10cSrcweir aFontLB.Hide(); 270*cdf0e10cSrcweir aLanguageFT.Hide(); 271*cdf0e10cSrcweir aLanguageLB.Hide(); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir long nY = aFontFT.GetPosPixel().Y() + 1; 274*cdf0e10cSrcweir Point aPos( aCRLF_FT.GetPosPixel() ); aPos.Y() = nY; 275*cdf0e10cSrcweir aCRLF_FT.SetPosPixel( aPos ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir aPos = aCRLF_RB.GetPosPixel(); aPos.Y() = nY; 278*cdf0e10cSrcweir aCRLF_RB.SetPosPixel( aPos ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir aPos = aCR_RB.GetPosPixel(); aPos.Y() = nY; 281*cdf0e10cSrcweir aCR_RB.SetPosPixel( aPos ); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir aPos = aLF_RB.GetPosPixel(); aPos.Y() = nY; 284*cdf0e10cSrcweir aLF_RB.SetPosPixel( aPos ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir Size aSize = GetSizePixel(); 287*cdf0e10cSrcweir Size aTmpSz( 6, 6 ); 288*cdf0e10cSrcweir aTmpSz = LogicToPixel(aTmpSz, MAP_APPFONT); 289*cdf0e10cSrcweir aSize.Height() = aHelpPB.GetPosPixel().Y() + 290*cdf0e10cSrcweir aHelpPB.GetSizePixel().Height() + aTmpSz.Height(); 291*cdf0e10cSrcweir SetSizePixel( aSize ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // initialisiere Zeichensatz 295*cdf0e10cSrcweir aCharSetLB.FillFromTextEncodingTable( pStream != NULL ); 296*cdf0e10cSrcweir aCharSetLB.SelectTextEncoding( aOpt.GetCharSet() ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir aCharSetLB.SetSelectHdl( LINK( this, SwAsciiFilterDlg, CharSetSelHdl )); 299*cdf0e10cSrcweir aCRLF_RB.SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl )); 300*cdf0e10cSrcweir aLF_RB.SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl )); 301*cdf0e10cSrcweir aCR_RB.SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl )); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir SetCRLF( aOpt.GetParaFlags() ); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir aCRLF_RB.SaveValue(); 306*cdf0e10cSrcweir aLF_RB.SaveValue(); 307*cdf0e10cSrcweir aCR_RB.SaveValue(); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir SwAsciiFilterDlg::~SwAsciiFilterDlg() 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir sal_uLong nCCode = aCharSetLB.GetSelectTextEncoding(); 319*cdf0e10cSrcweir String sFont; 320*cdf0e10cSrcweir sal_uLong nLng = 0; 321*cdf0e10cSrcweir if( aFontLB.IsVisible() ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir sFont = aFontLB.GetSelectEntry(); 324*cdf0e10cSrcweir nLng = (sal_uLong)aLanguageLB.GetSelectLanguage(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir rOptions.SetFontName( sFont ); 328*cdf0e10cSrcweir rOptions.SetCharSet( rtl_TextEncoding( nCCode ) ); 329*cdf0e10cSrcweir rOptions.SetLanguage( sal_uInt16( nLng ) ); 330*cdf0e10cSrcweir rOptions.SetParaFlags( GetCRLF() ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir // JP: Task #71802# save the user settings 333*cdf0e10cSrcweir String sData; 334*cdf0e10cSrcweir rOptions.WriteUserData( sData ); 335*cdf0e10cSrcweir if( sData.Len() ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir const String& rFindNm = String::CreateFromAscii( 338*cdf0e10cSrcweir aFontLB.IsVisible() ? sDialogImpExtraData 339*cdf0e10cSrcweir : sDialogExpExtraData); 340*cdf0e10cSrcweir sal_uInt16 nEnd, nStt = GetExtraData().Search( rFindNm ); 341*cdf0e10cSrcweir if( STRING_NOTFOUND != nStt ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir // called twice, so remove "old" settings 344*cdf0e10cSrcweir nEnd = GetExtraData().Search( cDialogExtraDataClose, 345*cdf0e10cSrcweir nStt + nDialogExtraDataLen ); 346*cdf0e10cSrcweir if( STRING_NOTFOUND != nEnd ) 347*cdf0e10cSrcweir GetExtraData().Erase( nStt, nEnd - nStt + 1 ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir String sTmp(GetExtraData()); 350*cdf0e10cSrcweir sTmp += rFindNm; 351*cdf0e10cSrcweir sTmp += sData; 352*cdf0e10cSrcweir sTmp += cDialogExtraDataClose; 353*cdf0e10cSrcweir GetExtraData() = sTmp; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void SwAsciiFilterDlg::SetCRLF( LineEnd eEnd ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir switch( eEnd ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir case LINEEND_CR: aCR_RB.Check(); break; 362*cdf0e10cSrcweir case LINEEND_CRLF: aCRLF_RB.Check(); break; 363*cdf0e10cSrcweir case LINEEND_LF: aLF_RB.Check(); break; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir LineEnd SwAsciiFilterDlg::GetCRLF() const 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir LineEnd eEnd; 370*cdf0e10cSrcweir if( aCR_RB.IsChecked() ) 371*cdf0e10cSrcweir eEnd = LINEEND_CR; 372*cdf0e10cSrcweir else if( aLF_RB.IsChecked() ) 373*cdf0e10cSrcweir eEnd = LINEEND_LF; 374*cdf0e10cSrcweir else 375*cdf0e10cSrcweir eEnd = LINEEND_CRLF; 376*cdf0e10cSrcweir return eEnd; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir IMPL_LINK( SwAsciiFilterDlg, CharSetSelHdl, SvxTextEncodingBox*, pBox ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir LineEnd eOldEnd = GetCRLF(), eEnd = (LineEnd)-1; 382*cdf0e10cSrcweir LanguageType nLng = aFontLB.IsVisible() 383*cdf0e10cSrcweir ? aLanguageLB.GetSelectLanguage() 384*cdf0e10cSrcweir : LANGUAGE_SYSTEM, 385*cdf0e10cSrcweir nOldLng = nLng; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir rtl_TextEncoding nChrSet = pBox->GetSelectTextEncoding(); 388*cdf0e10cSrcweir if( nChrSet == gsl_getSystemTextEncoding() ) 389*cdf0e10cSrcweir eEnd = GetSystemLineEnd(); 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir switch( nChrSet ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir case RTL_TEXTENCODING_MS_1252: 395*cdf0e10cSrcweir #ifdef UNX 396*cdf0e10cSrcweir eEnd = LINEEND_LF; 397*cdf0e10cSrcweir #else 398*cdf0e10cSrcweir eEnd = LINEEND_CRLF; // ANSI 399*cdf0e10cSrcweir #endif 400*cdf0e10cSrcweir break; 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_ROMAN: // MAC 403*cdf0e10cSrcweir eEnd = LINEEND_CR; 404*cdf0e10cSrcweir break; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir case RTL_TEXTENCODING_IBM_850: // DOS 407*cdf0e10cSrcweir eEnd = LINEEND_CRLF; 408*cdf0e10cSrcweir break; 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_ARABIC: 411*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_CENTEURO: 412*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_CROATIAN: 413*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_CYRILLIC: 414*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_DEVANAGARI: 415*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_FARSI: 416*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_GREEK: 417*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_GUJARATI: 418*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_GURMUKHI: 419*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_HEBREW: 420*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_ICELAND: 421*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_ROMANIAN: 422*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_THAI: 423*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_TURKISH: 424*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_UKRAINIAN: 425*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_CHINSIMP: 426*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_CHINTRAD: 427*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_JAPANESE: 428*cdf0e10cSrcweir case RTL_TEXTENCODING_APPLE_KOREAN: 429*cdf0e10cSrcweir eEnd = LINEEND_CR; 430*cdf0e10cSrcweir break; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir bSaveLineStatus = sal_False; 435*cdf0e10cSrcweir if( eEnd != (LineEnd)-1 ) // changed? 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir if( eOldEnd != eEnd ) 438*cdf0e10cSrcweir SetCRLF( eEnd ); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir else 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir // restore old user choise (not the automatic!) 443*cdf0e10cSrcweir aCRLF_RB.Check( aCRLF_RB.GetSavedValue() ); 444*cdf0e10cSrcweir aCR_RB.Check( aCR_RB.GetSavedValue() ); 445*cdf0e10cSrcweir aLF_RB.Check( aLF_RB.GetSavedValue() ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir bSaveLineStatus = sal_True; 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir if( nOldLng != nLng && aFontLB.IsVisible() ) 450*cdf0e10cSrcweir aLanguageLB.SelectLanguage( nLng ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir return 0; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir IMPL_LINK( SwAsciiFilterDlg, LineEndHdl, RadioButton*, pBtn ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir if( bSaveLineStatus ) 458*cdf0e10cSrcweir pBtn->SaveValue(); 459*cdf0e10cSrcweir return 0; 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir 463