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