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