xref: /aoo4110/main/sc/source/ui/inc/scuiasciiopt.hxx (revision b1cdbd2c)
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                      aTextSepList;
86     String                      maFieldSeparators;  // selected field separators
87 	sal_Unicode                 mcTextSep;
88     String                      maStrTextToColumns;
89 
90     CharSet                     meCharSet;          /// Selected char set.
91     bool                        mbCharSetSystem;    /// Is System char set selected?
92     bool                        mbFileImport;       /// Is this dialog involked for csv file import ?
93 
94 public:
95                                 ScImportAsciiDlg(
96                                     Window* pParent, String aDatName,
97 									SvStream* pInStream, sal_Unicode cSep = '\t' );
98                                 ~ScImportAsciiDlg();
99 
100     void                        GetOptions( ScAsciiOptions& rOpt );
101     void                        SetTextToColumnsMode();
102     void                        SaveParameters();
103 
104 private:
105     /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
106     void                        SetSelectedCharSet();
107     /** Returns all separator characters in a string. */
108     String                      GetSeparators() const;
109 
110     /** Enables or disables all separator checkboxes and edit fields. */
111     void                        SetupSeparatorCtrls();
112 
113 
114     bool                        GetLine( sal_uLong nLine, String &rText );
115 	void                        UpdateVertical();
116 	inline bool                 Seek( sal_uLong nPos ); // synced to and from mnStreamPos
117 
118                                 DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
119                                 DECL_LINK( FirstRowHdl, NumericField* );
120                                 DECL_LINK( RbSepFixHdl, RadioButton* );
121                                 DECL_LINK( SeparatorHdl, Control* );
122                                 DECL_LINK( LbColTypeHdl, ListBox* );
123                                 DECL_LINK( UpdateTextHdl, ScCsvTableBox* );
124                                 DECL_LINK( ColTypeHdl, ScCsvTableBox* );
125 };
126 
127 
Seek(sal_uLong nPos)128 inline bool ScImportAsciiDlg::Seek(sal_uLong nPos)
129 {
130     bool bSuccess = true;
131     if (nPos != mnStreamPos && mpDatStream)
132     {
133         if (mpDatStream->Seek( nPos ) != nPos)
134             bSuccess = false;
135         else
136             mnStreamPos = nPos;
137     }
138     return bSuccess;
139 }
140 
141 #endif
142 
143