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