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 SCUI_ASCIIOPT_HXX 31 #define SCUI_ASCIIOPT_HXX 32 33 34 #include "asciiopt.hxx" 35 #include "svx/langbox.hxx" 36 37 // ============================================================================ 38 39 class ScImportAsciiDlg : public ModalDialog 40 { 41 SvStream* mpDatStream; 42 sal_uLong mnStreamPos; 43 sal_uLong* mpRowPosArray; 44 sal_uLong mnRowPosCount; 45 46 String maPreviewLine[ CSV_PREVIEW_LINES ]; 47 48 FixedLine aFlFieldOpt; 49 FixedText aFtCharSet; 50 SvxTextEncodingBox aLbCharSet; 51 FixedText aFtCustomLang; 52 SvxLanguageBox aLbCustomLang; 53 54 FixedText aFtRow; 55 NumericField aNfRow; 56 57 FixedLine aFlSepOpt; 58 RadioButton aRbFixed; 59 RadioButton aRbSeparated; 60 61 CheckBox aCkbTab; 62 CheckBox aCkbSemicolon; 63 CheckBox aCkbComma; 64 CheckBox aCkbSpace; 65 CheckBox aCkbOther; 66 Edit aEdOther; 67 CheckBox aCkbAsOnce; 68 69 FixedLine aFlOtherOpt; 70 71 FixedText aFtTextSep; 72 ComboBox aCbTextSep; 73 74 CheckBox aCkbQuotedAsText; 75 CheckBox aCkbDetectNumber; 76 77 FixedLine aFlWidth; 78 FixedText aFtType; 79 ListBox aLbType; 80 81 ScCsvTableBox maTableBox; 82 83 OKButton aBtnOk; 84 CancelButton aBtnCancel; 85 HelpButton aBtnHelp; 86 87 String aCharSetUser; 88 String aColumnUser; 89 String aFldSepList; 90 String aTextSepList; 91 String maFieldSeparators; // selected field separators 92 sal_Unicode mcTextSep; 93 String maStrTextToColumns; 94 95 CharSet meCharSet; /// Selected char set. 96 bool mbCharSetSystem; /// Is System char set selected? 97 bool mbFileImport; /// Is this dialog involked for csv file import ? 98 99 public: 100 ScImportAsciiDlg( 101 Window* pParent, String aDatName, 102 SvStream* pInStream, sal_Unicode cSep = '\t' ); 103 ~ScImportAsciiDlg(); 104 105 void GetOptions( ScAsciiOptions& rOpt ); 106 void SetTextToColumnsMode(); 107 void SaveParameters(); 108 109 private: 110 /** Sets the selected char set data to meCharSet and mbCharSetSystem. */ 111 void SetSelectedCharSet(); 112 /** Returns all separator characters in a string. */ 113 String GetSeparators() const; 114 115 /** Enables or disables all separator checkboxes and edit fields. */ 116 void SetupSeparatorCtrls(); 117 118 119 bool GetLine( sal_uLong nLine, String &rText ); 120 void UpdateVertical(); 121 inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos 122 123 DECL_LINK( CharSetHdl, SvxTextEncodingBox* ); 124 DECL_LINK( FirstRowHdl, NumericField* ); 125 DECL_LINK( RbSepFixHdl, RadioButton* ); 126 DECL_LINK( SeparatorHdl, Control* ); 127 DECL_LINK( LbColTypeHdl, ListBox* ); 128 DECL_LINK( UpdateTextHdl, ScCsvTableBox* ); 129 DECL_LINK( ColTypeHdl, ScCsvTableBox* ); 130 }; 131 132 133 inline bool ScImportAsciiDlg::Seek(sal_uLong nPos) 134 { 135 bool bSuccess = true; 136 if (nPos != mnStreamPos && mpDatStream) 137 { 138 if (mpDatStream->Seek( nPos ) != nPos) 139 bSuccess = false; 140 else 141 mnStreamPos = nPos; 142 } 143 return bSuccess; 144 } 145 146 #endif 147 148