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