xref: /aoo42x/main/sc/source/ui/inc/asciiopt.hxx (revision cdf0e10c)
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 // ============================================================================
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #ifndef SC_ASCIIOPT_HXX
31*cdf0e10cSrcweir #define SC_ASCIIOPT_HXX
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <tools/string.hxx>
34*cdf0e10cSrcweir #ifndef _DIALOG_HXX //autogen
35*cdf0e10cSrcweir #include <vcl/dialog.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #ifndef _BUTTON_HXX //autogen
38*cdf0e10cSrcweir #include <vcl/button.hxx>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #ifndef _FIXED_HXX //autogen
41*cdf0e10cSrcweir #include <vcl/fixed.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #ifndef _LSTBOX_HXX //autogen
44*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #ifndef _COMBOBOX_HXX //autogen
47*cdf0e10cSrcweir #include <vcl/combobox.hxx>
48*cdf0e10cSrcweir #endif
49*cdf0e10cSrcweir #ifndef _FIELD_HXX //autogen
50*cdf0e10cSrcweir #include <vcl/field.hxx>
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir #include <tools/stream.hxx>
53*cdf0e10cSrcweir #include <svx/txencbox.hxx>
54*cdf0e10cSrcweir #include "csvtablebox.hxx"
55*cdf0e10cSrcweir #include "i18npool/lang.h"
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir // ============================================================================
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir class ScAsciiOptions
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir private:
62*cdf0e10cSrcweir 	sal_Bool		bFixedLen;
63*cdf0e10cSrcweir 	String		aFieldSeps;
64*cdf0e10cSrcweir 	sal_Bool		bMergeFieldSeps;
65*cdf0e10cSrcweir     bool        bQuotedFieldAsText;
66*cdf0e10cSrcweir     bool        bDetectSpecialNumber;
67*cdf0e10cSrcweir 	sal_Unicode	cTextSep;
68*cdf0e10cSrcweir 	CharSet		eCharSet;
69*cdf0e10cSrcweir     LanguageType eLang;
70*cdf0e10cSrcweir 	sal_Bool		bCharSetSystem;
71*cdf0e10cSrcweir 	long		nStartRow;
72*cdf0e10cSrcweir 	sal_uInt16		nInfoCount;
73*cdf0e10cSrcweir     xub_StrLen* pColStart;  //! TODO replace with vector
74*cdf0e10cSrcweir     sal_uInt8*       pColFormat; //! TODO replace with vector
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir public:
77*cdf0e10cSrcweir 					ScAsciiOptions();
78*cdf0e10cSrcweir 					ScAsciiOptions(const ScAsciiOptions& rOpt);
79*cdf0e10cSrcweir 					~ScAsciiOptions();
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir     static const sal_Unicode cDefaultTextSep = '"';
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	ScAsciiOptions&	operator=( const ScAsciiOptions& rCpy );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	sal_Bool			operator==( const ScAsciiOptions& rCmp ) const;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 	void			ReadFromString( const String& rString );
88*cdf0e10cSrcweir 	String			WriteToString() const;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	void			InterpretColumnList( const String& rString );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	CharSet				GetCharSet() const		{ return eCharSet; }
93*cdf0e10cSrcweir 	sal_Bool				GetCharSetSystem() const	{ return bCharSetSystem; }
94*cdf0e10cSrcweir 	const String&		GetFieldSeps() const	{ return aFieldSeps; }
95*cdf0e10cSrcweir 	sal_Bool				IsMergeSeps() const		{ return bMergeFieldSeps; }
96*cdf0e10cSrcweir     bool                IsQuotedAsText() const  { return bQuotedFieldAsText; }
97*cdf0e10cSrcweir     bool                IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
98*cdf0e10cSrcweir 	sal_Unicode			GetTextSep() const		{ return cTextSep; }
99*cdf0e10cSrcweir 	sal_Bool				IsFixedLen() const		{ return bFixedLen; }
100*cdf0e10cSrcweir 	sal_uInt16				GetInfoCount() const	{ return nInfoCount; }
101*cdf0e10cSrcweir 	const xub_StrLen*	GetColStart() const		{ return pColStart; }
102*cdf0e10cSrcweir 	const sal_uInt8*			GetColFormat() const	{ return pColFormat; }
103*cdf0e10cSrcweir 	long				GetStartRow() const		{ return nStartRow; }
104*cdf0e10cSrcweir     LanguageType        GetLanguage() const     { return eLang; }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	void	SetCharSet( CharSet eNew )			{ eCharSet = eNew; }
107*cdf0e10cSrcweir 	void	SetCharSetSystem( sal_Bool bSet )		{ bCharSetSystem = bSet; }
108*cdf0e10cSrcweir 	void	SetFixedLen( sal_Bool bSet )			{ bFixedLen = bSet; }
109*cdf0e10cSrcweir 	void	SetFieldSeps( const String& rStr )	{ aFieldSeps = rStr; }
110*cdf0e10cSrcweir 	void	SetMergeSeps( sal_Bool bSet )			{ bMergeFieldSeps = bSet; }
111*cdf0e10cSrcweir     void    SetQuotedAsText(bool bSet)          { bQuotedFieldAsText = bSet; }
112*cdf0e10cSrcweir     void    SetDetectSpecialNumber(bool bSet)   { bDetectSpecialNumber = bSet; }
113*cdf0e10cSrcweir 	void	SetTextSep( sal_Unicode c )			{ cTextSep = c; }
114*cdf0e10cSrcweir 	void	SetStartRow( long nRow)				{ nStartRow= nRow; }
115*cdf0e10cSrcweir     void    SetLanguage(LanguageType e)         { eLang = e; }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	void	SetColInfo( sal_uInt16 nCount, const xub_StrLen* pStart, const sal_uInt8* pFormat );
118*cdf0e10cSrcweir     void    SetColumnInfo( const ScCsvExpDataVec& rDataVec );
119*cdf0e10cSrcweir };
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir //CHINA001 // ============================================================================
123*cdf0e10cSrcweir //CHINA001
124*cdf0e10cSrcweir //CHINA001 class ScImportAsciiDlg : public ModalDialog
125*cdf0e10cSrcweir //CHINA001 {
126*cdf0e10cSrcweir //CHINA001 SvStream*                   pDatStream;
127*cdf0e10cSrcweir //CHINA001 sal_uLong*                      pRowPosArray;
128*cdf0e10cSrcweir //CHINA001 sal_uLong*                      pRowPosArrayUnicode;
129*cdf0e10cSrcweir //CHINA001 sal_uInt16                      nArrayEndPos;
130*cdf0e10cSrcweir //CHINA001 sal_uInt16                      nArrayEndPosUnicode;
131*cdf0e10cSrcweir //CHINA001 sal_uLong                       nStreamPos;
132*cdf0e10cSrcweir //CHINA001 sal_uLong                       nStreamPosUnicode;
133*cdf0e10cSrcweir //CHINA001 sal_Bool                        bVFlag;
134*cdf0e10cSrcweir //CHINA001
135*cdf0e10cSrcweir //CHINA001 FixedLine                   aFlFieldOpt;
136*cdf0e10cSrcweir //CHINA001 FixedText                   aFtCharSet;
137*cdf0e10cSrcweir //CHINA001 SvxTextEncodingBox          aLbCharSet;
138*cdf0e10cSrcweir //CHINA001
139*cdf0e10cSrcweir //CHINA001 FixedText                   aFtRow;
140*cdf0e10cSrcweir //CHINA001 NumericField                aNfRow;
141*cdf0e10cSrcweir //CHINA001
142*cdf0e10cSrcweir //CHINA001 FixedLine                   aFlSepOpt;
143*cdf0e10cSrcweir //CHINA001 RadioButton                 aRbFixed;
144*cdf0e10cSrcweir //CHINA001 RadioButton                 aRbSeparated;
145*cdf0e10cSrcweir //CHINA001
146*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbTab;
147*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbSemicolon;
148*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbComma;
149*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbSpace;
150*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbOther;
151*cdf0e10cSrcweir //CHINA001 Edit                        aEdOther;
152*cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbAsOnce;
153*cdf0e10cSrcweir //CHINA001 FixedText                   aFtTextSep;
154*cdf0e10cSrcweir //CHINA001 ComboBox                    aCbTextSep;
155*cdf0e10cSrcweir //CHINA001
156*cdf0e10cSrcweir //CHINA001 FixedLine                   aFlWidth;
157*cdf0e10cSrcweir //CHINA001 FixedText                   aFtType;
158*cdf0e10cSrcweir //CHINA001 ListBox                     aLbType;
159*cdf0e10cSrcweir //CHINA001
160*cdf0e10cSrcweir //CHINA001 ScCsvTableBox               maTableBox;
161*cdf0e10cSrcweir //CHINA001
162*cdf0e10cSrcweir //CHINA001 OKButton                    aBtnOk;
163*cdf0e10cSrcweir //CHINA001 CancelButton                aBtnCancel;
164*cdf0e10cSrcweir //CHINA001 HelpButton                  aBtnHelp;
165*cdf0e10cSrcweir //CHINA001
166*cdf0e10cSrcweir //CHINA001 String                      aCharSetUser;
167*cdf0e10cSrcweir //CHINA001 String                      aColumnUser;
168*cdf0e10cSrcweir //CHINA001 String                      aFldSepList;
169*cdf0e10cSrcweir //CHINA001 String                      aTextSepList;
170*cdf0e10cSrcweir //CHINA001
171*cdf0e10cSrcweir //CHINA001 // aPreviewLine contains the byte string as read from the file
172*cdf0e10cSrcweir //CHINA001 ByteString                  aPreviewLine[ CSV_PREVIEW_LINES ];
173*cdf0e10cSrcweir //CHINA001 // same for Unicode
174*cdf0e10cSrcweir //CHINA001 String                      aPreviewLineUnicode[ CSV_PREVIEW_LINES ];
175*cdf0e10cSrcweir //CHINA001
176*cdf0e10cSrcweir //CHINA001 CharSet                     meCharSet;          /// Selected char set.
177*cdf0e10cSrcweir //CHINA001 bool                        mbCharSetSystem;    /// Is System char set selected?
178*cdf0e10cSrcweir //CHINA001
179*cdf0e10cSrcweir //CHINA001 public:
180*cdf0e10cSrcweir //CHINA001 ScImportAsciiDlg(
181*cdf0e10cSrcweir //CHINA001 Window* pParent, String aDatName,
182*cdf0e10cSrcweir //CHINA001 SvStream* pInStream, sal_Unicode cSep = '\t' );
183*cdf0e10cSrcweir //CHINA001 ~ScImportAsciiDlg();
184*cdf0e10cSrcweir //CHINA001
185*cdf0e10cSrcweir //CHINA001 void                        GetOptions( ScAsciiOptions& rOpt );
186*cdf0e10cSrcweir //CHINA001
187*cdf0e10cSrcweir //CHINA001 private:
188*cdf0e10cSrcweir //CHINA001 /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
189*cdf0e10cSrcweir //CHINA001 void                        SetSelectedCharSet();
190*cdf0e10cSrcweir //CHINA001 /** Returns all separator characters in a string. */
191*cdf0e10cSrcweir //CHINA001 String                      GetSeparators() const;
192*cdf0e10cSrcweir //CHINA001
193*cdf0e10cSrcweir //CHINA001 /** Enables or disables all separator checkboxes and edit fields. */
194*cdf0e10cSrcweir //CHINA001 void                        SetupSeparatorCtrls();
195*cdf0e10cSrcweir //CHINA001
196*cdf0e10cSrcweir //CHINA001 void                        UpdateVertical( bool bSwitchToFromUnicode = false );
197*cdf0e10cSrcweir //CHINA001
198*cdf0e10cSrcweir //CHINA001 DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
199*cdf0e10cSrcweir //CHINA001 DECL_LINK( FirstRowHdl, NumericField* );
200*cdf0e10cSrcweir //CHINA001 DECL_LINK( RbSepFixHdl, RadioButton* );
201*cdf0e10cSrcweir //CHINA001 DECL_LINK( SeparatorHdl, Control* );
202*cdf0e10cSrcweir //CHINA001 DECL_LINK( LbColTypeHdl, ListBox* );
203*cdf0e10cSrcweir //CHINA001 DECL_LINK( UpdateTextHdl, ScCsvTableBox* );
204*cdf0e10cSrcweir //CHINA001 DECL_LINK( ColTypeHdl, ScCsvTableBox* );
205*cdf0e10cSrcweir //CHINA001 };
206*cdf0e10cSrcweir //CHINA001
207*cdf0e10cSrcweir //CHINA001
208*cdf0e10cSrcweir // ============================================================================
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir #endif
211*cdf0e10cSrcweir 
212