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 : OUString maPreviewLine[ CSV_PREVIEW_LINES ];
39 :
40 : FixedText* pFtCharSet;
41 :
42 : SvxTextEncodingBox* pLbCharSet;
43 :
44 : FixedText* pFtCustomLang;
45 :
46 : SvxLanguageBox* pLbCustomLang;
47 :
48 : FixedText* pFtRow;
49 : NumericField* pNfRow;
50 :
51 : RadioButton* pRbFixed;
52 : RadioButton* pRbSeparated;
53 :
54 : CheckBox* pCkbTab;
55 : CheckBox* pCkbSemicolon;
56 : CheckBox* pCkbComma;
57 : CheckBox* pCkbSpace;
58 : CheckBox* pCkbOther;
59 : Edit* pEdOther;
60 : CheckBox* pCkbAsOnce;
61 :
62 : FixedText* pFtTextSep;
63 : ComboBox* pCbTextSep;
64 :
65 : CheckBox* pCkbQuotedAsText;
66 : CheckBox* pCkbDetectNumber;
67 :
68 : FixedText* pFtType;
69 : ListBox* pLbType;
70 :
71 : ScCsvTableBox* mpTableBox;
72 :
73 : String aCharSetUser;
74 : String aColumnUser;
75 : String aTextSepList;
76 : String maFieldSeparators; // selected field separators
77 : sal_Unicode mcTextSep;
78 :
79 : CharSet meCharSet; /// Selected char set.
80 : bool mbCharSetSystem; /// Is System char set selected?
81 : ScImportAsciiCall meCall; /// How the dialog is called (see asciiopt.hxx)
82 :
83 : public:
84 : ScImportAsciiDlg(
85 : Window* pParent, String aDatName,
86 : SvStream* pInStream, ScImportAsciiCall eCall );
87 : ~ScImportAsciiDlg();
88 :
89 : void GetOptions( ScAsciiOptions& rOpt );
90 : void SaveParameters();
91 :
92 : private:
93 : /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
94 : void SetSelectedCharSet();
95 : /** Set separators in ui from maFieldSeparators */
96 : void SetSeparators();
97 : /** Returns all separator characters in a string. */
98 : String GetSeparators() const;
99 :
100 : /** Enables or disables all separator checkboxes and edit fields. */
101 : void SetupSeparatorCtrls();
102 :
103 :
104 : bool GetLine( sal_uLong nLine, OUString &rText );
105 : void UpdateVertical();
106 : inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos
107 :
108 : DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
109 : DECL_LINK( FirstRowHdl, NumericField* );
110 : DECL_LINK( RbSepFixHdl, RadioButton* );
111 : DECL_LINK( SeparatorHdl, Control* );
112 : DECL_LINK( LbColTypeHdl, ListBox* );
113 : DECL_LINK(UpdateTextHdl, void *);
114 : DECL_LINK( ColTypeHdl, ScCsvTableBox* );
115 : };
116 :
117 :
118 0 : inline bool ScImportAsciiDlg::Seek(sal_uLong nPos)
119 : {
120 0 : bool bSuccess = true;
121 0 : if (nPos != mnStreamPos && mpDatStream)
122 : {
123 0 : if (mpDatStream->Seek( nPos ) != nPos)
124 0 : bSuccess = false;
125 : else
126 0 : mnStreamPos = nPos;
127 : }
128 0 : return bSuccess;
129 : }
130 :
131 : #endif
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|