1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // ============================================================================ 29 30 #ifndef SC_ASCIIOPT_HXX 31 #define SC_ASCIIOPT_HXX 32 33 #include <tools/string.hxx> 34 #ifndef _DIALOG_HXX //autogen 35 #include <vcl/dialog.hxx> 36 #endif 37 #ifndef _BUTTON_HXX //autogen 38 #include <vcl/button.hxx> 39 #endif 40 #ifndef _FIXED_HXX //autogen 41 #include <vcl/fixed.hxx> 42 #endif 43 #ifndef _LSTBOX_HXX //autogen 44 #include <vcl/lstbox.hxx> 45 #endif 46 #ifndef _COMBOBOX_HXX //autogen 47 #include <vcl/combobox.hxx> 48 #endif 49 #ifndef _FIELD_HXX //autogen 50 #include <vcl/field.hxx> 51 #endif 52 #include <tools/stream.hxx> 53 #include <svx/txencbox.hxx> 54 #include "csvtablebox.hxx" 55 #include "i18npool/lang.h" 56 57 // ============================================================================ 58 59 class ScAsciiOptions 60 { 61 private: 62 sal_Bool bFixedLen; 63 String aFieldSeps; 64 sal_Bool bMergeFieldSeps; 65 bool bQuotedFieldAsText; 66 bool bDetectSpecialNumber; 67 sal_Unicode cTextSep; 68 CharSet eCharSet; 69 LanguageType eLang; 70 sal_Bool bCharSetSystem; 71 long nStartRow; 72 sal_uInt16 nInfoCount; 73 xub_StrLen* pColStart; //! TODO replace with vector 74 sal_uInt8* pColFormat; //! TODO replace with vector 75 76 public: 77 ScAsciiOptions(); 78 ScAsciiOptions(const ScAsciiOptions& rOpt); 79 ~ScAsciiOptions(); 80 81 static const sal_Unicode cDefaultTextSep = '"'; 82 83 ScAsciiOptions& operator=( const ScAsciiOptions& rCpy ); 84 85 sal_Bool operator==( const ScAsciiOptions& rCmp ) const; 86 87 void ReadFromString( const String& rString ); 88 String WriteToString() const; 89 90 void InterpretColumnList( const String& rString ); 91 92 CharSet GetCharSet() const { return eCharSet; } 93 sal_Bool GetCharSetSystem() const { return bCharSetSystem; } 94 const String& GetFieldSeps() const { return aFieldSeps; } 95 sal_Bool IsMergeSeps() const { return bMergeFieldSeps; } 96 bool IsQuotedAsText() const { return bQuotedFieldAsText; } 97 bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; } 98 sal_Unicode GetTextSep() const { return cTextSep; } 99 sal_Bool IsFixedLen() const { return bFixedLen; } 100 sal_uInt16 GetInfoCount() const { return nInfoCount; } 101 const xub_StrLen* GetColStart() const { return pColStart; } 102 const sal_uInt8* GetColFormat() const { return pColFormat; } 103 long GetStartRow() const { return nStartRow; } 104 LanguageType GetLanguage() const { return eLang; } 105 106 void SetCharSet( CharSet eNew ) { eCharSet = eNew; } 107 void SetCharSetSystem( sal_Bool bSet ) { bCharSetSystem = bSet; } 108 void SetFixedLen( sal_Bool bSet ) { bFixedLen = bSet; } 109 void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; } 110 void SetMergeSeps( sal_Bool bSet ) { bMergeFieldSeps = bSet; } 111 void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } 112 void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; } 113 void SetTextSep( sal_Unicode c ) { cTextSep = c; } 114 void SetStartRow( long nRow) { nStartRow= nRow; } 115 void SetLanguage(LanguageType e) { eLang = e; } 116 117 void SetColInfo( sal_uInt16 nCount, const xub_StrLen* pStart, const sal_uInt8* pFormat ); 118 void SetColumnInfo( const ScCsvExpDataVec& rDataVec ); 119 }; 120 121 122 //CHINA001 // ============================================================================ 123 //CHINA001 124 //CHINA001 class ScImportAsciiDlg : public ModalDialog 125 //CHINA001 { 126 //CHINA001 SvStream* pDatStream; 127 //CHINA001 sal_uLong* pRowPosArray; 128 //CHINA001 sal_uLong* pRowPosArrayUnicode; 129 //CHINA001 sal_uInt16 nArrayEndPos; 130 //CHINA001 sal_uInt16 nArrayEndPosUnicode; 131 //CHINA001 sal_uLong nStreamPos; 132 //CHINA001 sal_uLong nStreamPosUnicode; 133 //CHINA001 sal_Bool bVFlag; 134 //CHINA001 135 //CHINA001 FixedLine aFlFieldOpt; 136 //CHINA001 FixedText aFtCharSet; 137 //CHINA001 SvxTextEncodingBox aLbCharSet; 138 //CHINA001 139 //CHINA001 FixedText aFtRow; 140 //CHINA001 NumericField aNfRow; 141 //CHINA001 142 //CHINA001 FixedLine aFlSepOpt; 143 //CHINA001 RadioButton aRbFixed; 144 //CHINA001 RadioButton aRbSeparated; 145 //CHINA001 146 //CHINA001 CheckBox aCkbTab; 147 //CHINA001 CheckBox aCkbSemicolon; 148 //CHINA001 CheckBox aCkbComma; 149 //CHINA001 CheckBox aCkbSpace; 150 //CHINA001 CheckBox aCkbOther; 151 //CHINA001 Edit aEdOther; 152 //CHINA001 CheckBox aCkbAsOnce; 153 //CHINA001 FixedText aFtTextSep; 154 //CHINA001 ComboBox aCbTextSep; 155 //CHINA001 156 //CHINA001 FixedLine aFlWidth; 157 //CHINA001 FixedText aFtType; 158 //CHINA001 ListBox aLbType; 159 //CHINA001 160 //CHINA001 ScCsvTableBox maTableBox; 161 //CHINA001 162 //CHINA001 OKButton aBtnOk; 163 //CHINA001 CancelButton aBtnCancel; 164 //CHINA001 HelpButton aBtnHelp; 165 //CHINA001 166 //CHINA001 String aCharSetUser; 167 //CHINA001 String aColumnUser; 168 //CHINA001 String aFldSepList; 169 //CHINA001 String aTextSepList; 170 //CHINA001 171 //CHINA001 // aPreviewLine contains the byte string as read from the file 172 //CHINA001 ByteString aPreviewLine[ CSV_PREVIEW_LINES ]; 173 //CHINA001 // same for Unicode 174 //CHINA001 String aPreviewLineUnicode[ CSV_PREVIEW_LINES ]; 175 //CHINA001 176 //CHINA001 CharSet meCharSet; /// Selected char set. 177 //CHINA001 bool mbCharSetSystem; /// Is System char set selected? 178 //CHINA001 179 //CHINA001 public: 180 //CHINA001 ScImportAsciiDlg( 181 //CHINA001 Window* pParent, String aDatName, 182 //CHINA001 SvStream* pInStream, sal_Unicode cSep = '\t' ); 183 //CHINA001 ~ScImportAsciiDlg(); 184 //CHINA001 185 //CHINA001 void GetOptions( ScAsciiOptions& rOpt ); 186 //CHINA001 187 //CHINA001 private: 188 //CHINA001 /** Sets the selected char set data to meCharSet and mbCharSetSystem. */ 189 //CHINA001 void SetSelectedCharSet(); 190 //CHINA001 /** Returns all separator characters in a string. */ 191 //CHINA001 String GetSeparators() const; 192 //CHINA001 193 //CHINA001 /** Enables or disables all separator checkboxes and edit fields. */ 194 //CHINA001 void SetupSeparatorCtrls(); 195 //CHINA001 196 //CHINA001 void UpdateVertical( bool bSwitchToFromUnicode = false ); 197 //CHINA001 198 //CHINA001 DECL_LINK( CharSetHdl, SvxTextEncodingBox* ); 199 //CHINA001 DECL_LINK( FirstRowHdl, NumericField* ); 200 //CHINA001 DECL_LINK( RbSepFixHdl, RadioButton* ); 201 //CHINA001 DECL_LINK( SeparatorHdl, Control* ); 202 //CHINA001 DECL_LINK( LbColTypeHdl, ListBox* ); 203 //CHINA001 DECL_LINK( UpdateTextHdl, ScCsvTableBox* ); 204 //CHINA001 DECL_LINK( ColTypeHdl, ScCsvTableBox* ); 205 //CHINA001 }; 206 //CHINA001 207 //CHINA001 208 // ============================================================================ 209 210 #endif 211 212