Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : // ============================================================================
21 :
22 : #ifndef SCUI_ASCIIOPT_HXX
23 : #define SCUI_ASCIIOPT_HXX
24 :
25 :
26 : #include "asciiopt.hxx"
27 : #include "svx/langbox.hxx"
28 :
29 : // ============================================================================
30 :
31 : class ScImportAsciiDlg : public ModalDialog
32 : {
33 : SvStream* mpDatStream;
34 : sal_uLong mnStreamPos;
35 : sal_uLong* mpRowPosArray;
36 : sal_uLong mnRowPosCount;
37 :
38 : rtl::OUString maPreviewLine[ CSV_PREVIEW_LINES ];
39 :
40 : FixedLine aFlFieldOpt;
41 : FixedText aFtCharSet;
42 : SvxTextEncodingBox aLbCharSet;
43 : FixedText aFtCustomLang;
44 : SvxLanguageBox aLbCustomLang;
45 :
46 : FixedText aFtRow;
47 : NumericField aNfRow;
48 :
49 : FixedLine aFlSepOpt;
50 : RadioButton aRbFixed;
51 : RadioButton aRbSeparated;
52 :
53 : CheckBox aCkbTab;
54 : CheckBox aCkbSemicolon;
55 : CheckBox aCkbComma;
56 : CheckBox aCkbSpace;
57 : CheckBox aCkbOther;
58 : Edit aEdOther;
59 : CheckBox aCkbAsOnce;
60 :
61 : FixedLine aFlOtherOpt;
62 :
63 : FixedText aFtTextSep;
64 : ComboBox aCbTextSep;
65 :
66 : CheckBox aCkbQuotedAsText;
67 : CheckBox aCkbDetectNumber;
68 :
69 : FixedLine aFlWidth;
70 : FixedText aFtType;
71 : ListBox aLbType;
72 :
73 : ScCsvTableBox maTableBox;
74 :
75 : OKButton aBtnOk;
76 : CancelButton aBtnCancel;
77 : HelpButton aBtnHelp;
78 :
79 : String aCharSetUser;
80 : String aColumnUser;
81 : String aTextSepList;
82 : String maFieldSeparators; // selected field separators
83 : sal_Unicode mcTextSep;
84 : String maStrTextToColumns;
85 :
86 : CharSet meCharSet; /// Selected char set.
87 : bool mbCharSetSystem; /// Is System char set selected?
88 : ScImportAsciiCall meCall; /// How the dialog is called (see asciiopt.hxx)
89 :
90 : public:
91 : ScImportAsciiDlg(
92 : Window* pParent, String aDatName,
93 : SvStream* pInStream, ScImportAsciiCall eCall );
94 : ~ScImportAsciiDlg();
95 :
96 : void GetOptions( ScAsciiOptions& rOpt );
97 : void SaveParameters();
98 :
99 : private:
100 : /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
101 : void SetSelectedCharSet();
102 : /** Set separators in ui from maFieldSeparators */
103 : void SetSeparators();
104 : /** Returns all separator characters in a string. */
105 : String GetSeparators() const;
106 :
107 : /** Enables or disables all separator checkboxes and edit fields. */
108 : void SetupSeparatorCtrls();
109 :
110 :
111 : bool GetLine( sal_uLong nLine, rtl::OUString &rText );
112 : void UpdateVertical();
113 : inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos
114 :
115 : DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
116 : DECL_LINK( FirstRowHdl, NumericField* );
117 : DECL_LINK( RbSepFixHdl, RadioButton* );
118 : DECL_LINK( SeparatorHdl, Control* );
119 : DECL_LINK( LbColTypeHdl, ListBox* );
120 : DECL_LINK(UpdateTextHdl, void *);
121 : DECL_LINK( ColTypeHdl, ScCsvTableBox* );
122 : };
123 :
124 :
125 0 : inline bool ScImportAsciiDlg::Seek(sal_uLong nPos)
126 : {
127 0 : bool bSuccess = true;
128 0 : if (nPos != mnStreamPos && mpDatStream)
129 : {
130 0 : if (mpDatStream->Seek( nPos ) != nPos)
131 0 : bSuccess = false;
132 : else
133 0 : mnStreamPos = nPos;
134 : }
135 0 : return bSuccess;
136 : }
137 :
138 : #endif
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|