xref: /aoo41x/main/sc/source/ui/inc/asciiopt.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // ============================================================================
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef SC_ASCIIOPT_HXX
27cdf0e10cSrcweir #define SC_ASCIIOPT_HXX
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <tools/string.hxx>
30cdf0e10cSrcweir #ifndef _DIALOG_HXX //autogen
31cdf0e10cSrcweir #include <vcl/dialog.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _BUTTON_HXX //autogen
34cdf0e10cSrcweir #include <vcl/button.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _FIXED_HXX //autogen
37cdf0e10cSrcweir #include <vcl/fixed.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _LSTBOX_HXX //autogen
40cdf0e10cSrcweir #include <vcl/lstbox.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _COMBOBOX_HXX //autogen
43cdf0e10cSrcweir #include <vcl/combobox.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _FIELD_HXX //autogen
46cdf0e10cSrcweir #include <vcl/field.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <tools/stream.hxx>
49cdf0e10cSrcweir #include <svx/txencbox.hxx>
50cdf0e10cSrcweir #include "csvtablebox.hxx"
51cdf0e10cSrcweir #include "i18npool/lang.h"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // ============================================================================
54cdf0e10cSrcweir 
55cdf0e10cSrcweir class ScAsciiOptions
56cdf0e10cSrcweir {
57cdf0e10cSrcweir private:
58cdf0e10cSrcweir 	sal_Bool		bFixedLen;
59cdf0e10cSrcweir 	String		aFieldSeps;
60cdf0e10cSrcweir 	sal_Bool		bMergeFieldSeps;
61cdf0e10cSrcweir     bool        bQuotedFieldAsText;
62cdf0e10cSrcweir     bool        bDetectSpecialNumber;
63cdf0e10cSrcweir 	sal_Unicode	cTextSep;
64cdf0e10cSrcweir 	CharSet		eCharSet;
65cdf0e10cSrcweir     LanguageType eLang;
66cdf0e10cSrcweir 	sal_Bool		bCharSetSystem;
67cdf0e10cSrcweir 	long		nStartRow;
68cdf0e10cSrcweir 	sal_uInt16		nInfoCount;
69cdf0e10cSrcweir     xub_StrLen* pColStart;  //! TODO replace with vector
70cdf0e10cSrcweir     sal_uInt8*       pColFormat; //! TODO replace with vector
71cdf0e10cSrcweir 
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir 					ScAsciiOptions();
74cdf0e10cSrcweir 					ScAsciiOptions(const ScAsciiOptions& rOpt);
75cdf0e10cSrcweir 					~ScAsciiOptions();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     static const sal_Unicode cDefaultTextSep = '"';
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	ScAsciiOptions&	operator=( const ScAsciiOptions& rCpy );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	sal_Bool			operator==( const ScAsciiOptions& rCmp ) const;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	void			ReadFromString( const String& rString );
84cdf0e10cSrcweir 	String			WriteToString() const;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	void			InterpretColumnList( const String& rString );
87cdf0e10cSrcweir 
GetCharSet() const88cdf0e10cSrcweir 	CharSet				GetCharSet() const		{ return eCharSet; }
GetCharSetSystem() const89cdf0e10cSrcweir 	sal_Bool				GetCharSetSystem() const	{ return bCharSetSystem; }
GetFieldSeps() const90cdf0e10cSrcweir 	const String&		GetFieldSeps() const	{ return aFieldSeps; }
IsMergeSeps() const91cdf0e10cSrcweir 	sal_Bool				IsMergeSeps() const		{ return bMergeFieldSeps; }
IsQuotedAsText() const92cdf0e10cSrcweir     bool                IsQuotedAsText() const  { return bQuotedFieldAsText; }
IsDetectSpecialNumber() const93cdf0e10cSrcweir     bool                IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
GetTextSep() const94cdf0e10cSrcweir 	sal_Unicode			GetTextSep() const		{ return cTextSep; }
IsFixedLen() const95cdf0e10cSrcweir 	sal_Bool				IsFixedLen() const		{ return bFixedLen; }
GetInfoCount() const96cdf0e10cSrcweir 	sal_uInt16				GetInfoCount() const	{ return nInfoCount; }
GetColStart() const97cdf0e10cSrcweir 	const xub_StrLen*	GetColStart() const		{ return pColStart; }
GetColFormat() const98cdf0e10cSrcweir 	const sal_uInt8*			GetColFormat() const	{ return pColFormat; }
GetStartRow() const99cdf0e10cSrcweir 	long				GetStartRow() const		{ return nStartRow; }
GetLanguage() const100cdf0e10cSrcweir     LanguageType        GetLanguage() const     { return eLang; }
101cdf0e10cSrcweir 
SetCharSet(CharSet eNew)102cdf0e10cSrcweir 	void	SetCharSet( CharSet eNew )			{ eCharSet = eNew; }
SetCharSetSystem(sal_Bool bSet)103cdf0e10cSrcweir 	void	SetCharSetSystem( sal_Bool bSet )		{ bCharSetSystem = bSet; }
SetFixedLen(sal_Bool bSet)104cdf0e10cSrcweir 	void	SetFixedLen( sal_Bool bSet )			{ bFixedLen = bSet; }
SetFieldSeps(const String & rStr)105cdf0e10cSrcweir 	void	SetFieldSeps( const String& rStr )	{ aFieldSeps = rStr; }
SetMergeSeps(sal_Bool bSet)106cdf0e10cSrcweir 	void	SetMergeSeps( sal_Bool bSet )			{ bMergeFieldSeps = bSet; }
SetQuotedAsText(bool bSet)107cdf0e10cSrcweir     void    SetQuotedAsText(bool bSet)          { bQuotedFieldAsText = bSet; }
SetDetectSpecialNumber(bool bSet)108cdf0e10cSrcweir     void    SetDetectSpecialNumber(bool bSet)   { bDetectSpecialNumber = bSet; }
SetTextSep(sal_Unicode c)109cdf0e10cSrcweir 	void	SetTextSep( sal_Unicode c )			{ cTextSep = c; }
SetStartRow(long nRow)110cdf0e10cSrcweir 	void	SetStartRow( long nRow)				{ nStartRow= nRow; }
SetLanguage(LanguageType e)111cdf0e10cSrcweir     void    SetLanguage(LanguageType e)         { eLang = e; }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	void	SetColInfo( sal_uInt16 nCount, const xub_StrLen* pStart, const sal_uInt8* pFormat );
114cdf0e10cSrcweir     void    SetColumnInfo( const ScCsvExpDataVec& rDataVec );
115cdf0e10cSrcweir };
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //CHINA001 // ============================================================================
119cdf0e10cSrcweir //CHINA001
120cdf0e10cSrcweir //CHINA001 class ScImportAsciiDlg : public ModalDialog
121cdf0e10cSrcweir //CHINA001 {
122cdf0e10cSrcweir //CHINA001 SvStream*                   pDatStream;
123cdf0e10cSrcweir //CHINA001 sal_uLong*                      pRowPosArray;
124cdf0e10cSrcweir //CHINA001 sal_uLong*                      pRowPosArrayUnicode;
125cdf0e10cSrcweir //CHINA001 sal_uInt16                      nArrayEndPos;
126cdf0e10cSrcweir //CHINA001 sal_uInt16                      nArrayEndPosUnicode;
127cdf0e10cSrcweir //CHINA001 sal_uLong                       nStreamPos;
128cdf0e10cSrcweir //CHINA001 sal_uLong                       nStreamPosUnicode;
129cdf0e10cSrcweir //CHINA001 sal_Bool                        bVFlag;
130cdf0e10cSrcweir //CHINA001
131cdf0e10cSrcweir //CHINA001 FixedLine                   aFlFieldOpt;
132cdf0e10cSrcweir //CHINA001 FixedText                   aFtCharSet;
133cdf0e10cSrcweir //CHINA001 SvxTextEncodingBox          aLbCharSet;
134cdf0e10cSrcweir //CHINA001
135cdf0e10cSrcweir //CHINA001 FixedText                   aFtRow;
136cdf0e10cSrcweir //CHINA001 NumericField                aNfRow;
137cdf0e10cSrcweir //CHINA001
138cdf0e10cSrcweir //CHINA001 FixedLine                   aFlSepOpt;
139cdf0e10cSrcweir //CHINA001 RadioButton                 aRbFixed;
140cdf0e10cSrcweir //CHINA001 RadioButton                 aRbSeparated;
141cdf0e10cSrcweir //CHINA001
142cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbTab;
143cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbSemicolon;
144cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbComma;
145cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbSpace;
146cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbOther;
147cdf0e10cSrcweir //CHINA001 Edit                        aEdOther;
148cdf0e10cSrcweir //CHINA001 CheckBox                    aCkbAsOnce;
149cdf0e10cSrcweir //CHINA001 FixedText                   aFtTextSep;
150cdf0e10cSrcweir //CHINA001 ComboBox                    aCbTextSep;
151cdf0e10cSrcweir //CHINA001
152cdf0e10cSrcweir //CHINA001 FixedLine                   aFlWidth;
153cdf0e10cSrcweir //CHINA001 FixedText                   aFtType;
154cdf0e10cSrcweir //CHINA001 ListBox                     aLbType;
155cdf0e10cSrcweir //CHINA001
156cdf0e10cSrcweir //CHINA001 ScCsvTableBox               maTableBox;
157cdf0e10cSrcweir //CHINA001
158cdf0e10cSrcweir //CHINA001 OKButton                    aBtnOk;
159cdf0e10cSrcweir //CHINA001 CancelButton                aBtnCancel;
160cdf0e10cSrcweir //CHINA001 HelpButton                  aBtnHelp;
161cdf0e10cSrcweir //CHINA001
162cdf0e10cSrcweir //CHINA001 String                      aCharSetUser;
163cdf0e10cSrcweir //CHINA001 String                      aColumnUser;
164cdf0e10cSrcweir //CHINA001 String                      aFldSepList;
165cdf0e10cSrcweir //CHINA001 String                      aTextSepList;
166cdf0e10cSrcweir //CHINA001
167cdf0e10cSrcweir //CHINA001 // aPreviewLine contains the byte string as read from the file
168cdf0e10cSrcweir //CHINA001 ByteString                  aPreviewLine[ CSV_PREVIEW_LINES ];
169cdf0e10cSrcweir //CHINA001 // same for Unicode
170cdf0e10cSrcweir //CHINA001 String                      aPreviewLineUnicode[ CSV_PREVIEW_LINES ];
171cdf0e10cSrcweir //CHINA001
172cdf0e10cSrcweir //CHINA001 CharSet                     meCharSet;          /// Selected char set.
173cdf0e10cSrcweir //CHINA001 bool                        mbCharSetSystem;    /// Is System char set selected?
174cdf0e10cSrcweir //CHINA001
175cdf0e10cSrcweir //CHINA001 public:
176cdf0e10cSrcweir //CHINA001 ScImportAsciiDlg(
177cdf0e10cSrcweir //CHINA001 Window* pParent, String aDatName,
178cdf0e10cSrcweir //CHINA001 SvStream* pInStream, sal_Unicode cSep = '\t' );
179cdf0e10cSrcweir //CHINA001 ~ScImportAsciiDlg();
180cdf0e10cSrcweir //CHINA001
181cdf0e10cSrcweir //CHINA001 void                        GetOptions( ScAsciiOptions& rOpt );
182cdf0e10cSrcweir //CHINA001
183cdf0e10cSrcweir //CHINA001 private:
184cdf0e10cSrcweir //CHINA001 /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
185cdf0e10cSrcweir //CHINA001 void                        SetSelectedCharSet();
186cdf0e10cSrcweir //CHINA001 /** Returns all separator characters in a string. */
187cdf0e10cSrcweir //CHINA001 String                      GetSeparators() const;
188cdf0e10cSrcweir //CHINA001
189cdf0e10cSrcweir //CHINA001 /** Enables or disables all separator checkboxes and edit fields. */
190cdf0e10cSrcweir //CHINA001 void                        SetupSeparatorCtrls();
191cdf0e10cSrcweir //CHINA001
192cdf0e10cSrcweir //CHINA001 void                        UpdateVertical( bool bSwitchToFromUnicode = false );
193cdf0e10cSrcweir //CHINA001
194cdf0e10cSrcweir //CHINA001 DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
195cdf0e10cSrcweir //CHINA001 DECL_LINK( FirstRowHdl, NumericField* );
196cdf0e10cSrcweir //CHINA001 DECL_LINK( RbSepFixHdl, RadioButton* );
197cdf0e10cSrcweir //CHINA001 DECL_LINK( SeparatorHdl, Control* );
198cdf0e10cSrcweir //CHINA001 DECL_LINK( LbColTypeHdl, ListBox* );
199cdf0e10cSrcweir //CHINA001 DECL_LINK( UpdateTextHdl, ScCsvTableBox* );
200cdf0e10cSrcweir //CHINA001 DECL_LINK( ColTypeHdl, ScCsvTableBox* );
201cdf0e10cSrcweir //CHINA001 };
202cdf0e10cSrcweir //CHINA001
203cdf0e10cSrcweir //CHINA001
204cdf0e10cSrcweir // ============================================================================
205cdf0e10cSrcweir 
206cdf0e10cSrcweir #endif
207cdf0e10cSrcweir 
208