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