tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / scuiasciiopt.hxx
blob5b19b8c4d3eeba82c9d67bc8d22cddfa6459f0d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <svx/langbox.hxx>
23 #include <tools/solar.h>
24 #include <tools/stream.hxx>
25 #include <vcl/weld.hxx>
27 #include "asciiopt.hxx"
29 class ScCsvTableBox;
30 class SvxTextEncodingBox;
32 class ScImportAsciiDlg : public weld::GenericDialogController
34 SvStream* mpDatStream;
35 sal_uLong mnStreamPos;
36 sal_uLong mnStreamInitPos;
37 std::unique_ptr<sal_uLong[]> mpRowPosArray;
38 sal_uLong mnRowPosCount;
40 OUString maPreviewLine[ CSV_PREVIEW_LINES ];
42 OUString maFieldSeparators; // selected field separators
43 OUString maDetectedFieldSeps; // detected field seps
44 sal_Unicode mcTextSep;
46 rtl_TextEncoding meCharSet; /// Selected char set.
47 rtl_TextEncoding meDetectedCharSet; /// This is computed only once at initialization, so store it.
48 bool mbCharSetSystem; /// Is System char set selected?
49 bool mbCharSetDetect; /// Should we autodetect character set ?
50 ScImportAsciiCall meCall; /// How the dialog is called (see asciiopt.hxx)
52 std::unique_ptr<weld::Label> mxFtCharSet;
53 std::unique_ptr<SvxTextEncodingBox> mxLbCharSet;
54 std::unique_ptr<weld::Label> mxFtDetectedCharSet;
55 std::unique_ptr<weld::Label> mxFtCustomLang;
56 std::unique_ptr<SvxLanguageBox> mxLbCustomLang;
58 std::unique_ptr<weld::Label> mxFtRow;
59 std::unique_ptr<weld::SpinButton> mxNfRow;
61 std::unique_ptr<weld::RadioButton> mxRbDetectSep;
62 std::unique_ptr<weld::RadioButton> mxRbFixed;
63 std::unique_ptr<weld::RadioButton> mxRbSeparated;
65 std::unique_ptr<weld::CheckButton> mxCkbTab;
66 std::unique_ptr<weld::CheckButton> mxCkbSemicolon;
67 std::unique_ptr<weld::CheckButton> mxCkbComma;
68 std::unique_ptr<weld::CheckButton> mxCkbRemoveSpace;
69 std::unique_ptr<weld::CheckButton> mxCkbSpace;
70 std::unique_ptr<weld::CheckButton> mxCkbOther;
71 std::unique_ptr<weld::Entry> mxEdOther;
72 std::unique_ptr<weld::CheckButton> mxCkbAsOnce;
74 std::unique_ptr<weld::Label> mxFtTextSep;
75 std::unique_ptr<weld::ComboBox> mxCbTextSep;
77 std::unique_ptr<weld::CheckButton> mxCkbQuotedAsText;
78 std::unique_ptr<weld::CheckButton> mxCkbDetectNumber;
79 std::unique_ptr<weld::CheckButton> mxCkbDetectScientificNumber;
80 std::unique_ptr<weld::CheckButton> mxCkbEvaluateFormulas;
81 std::unique_ptr<weld::CheckButton> mxCkbSkipEmptyCells;
83 std::unique_ptr<weld::ComboBox> mxLbType;
84 std::unique_ptr<weld::Label> mxAltTitle;
86 std::unique_ptr<ScCsvTableBox> mxTableBox;
88 public:
89 ScImportAsciiDlg(
90 weld::Window* pParent, std::u16string_view aDatName,
91 SvStream* pInStream, ScImportAsciiCall eCall);
92 virtual ~ScImportAsciiDlg() override;
94 void GetOptions( ScAsciiOptions& rOpt );
95 void SaveParameters();
97 private:
98 /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
99 void SetSelectedCharSet();
100 /** Set separators in ui from maFieldSeparators or an optionally defined
101 separator. */
102 void SetSeparators( sal_Unicode cSep );
103 /** Returns all separator characters in a string. */
104 OUString GetSeparators() const;
105 OUString GetActiveSeparators() const;
106 void DetectCsvSeparators();
108 /** Enables or disables all separator checkboxes and edit fields. */
109 void SetupSeparatorCtrls();
111 bool GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep );
112 void UpdateVertical();
113 inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos
114 void RbSepFix();
116 DECL_LINK( CharSetHdl, weld::ComboBox&, void );
117 DECL_LINK( FirstRowHdl, weld::SpinButton&, void );
118 DECL_LINK( RbSepFixHdl, weld::Toggleable&, void );
119 DECL_LINK( SeparatorEditHdl, weld::Entry&, void );
120 DECL_LINK( SeparatorClickHdl, weld::Toggleable&, void );
121 DECL_LINK( OtherOptionsClickHdl, weld::Toggleable&, void );
122 DECL_LINK( SeparatorComboBoxHdl, weld::ComboBox&, void );
123 void SeparatorHdl(const weld::Widget*);
124 DECL_LINK( LbColTypeHdl, weld::ComboBox&, void );
125 DECL_LINK( UpdateTextHdl, ScCsvTableBox&, void );
126 DECL_LINK( ColTypeHdl, ScCsvTableBox&, void );
127 DECL_STATIC_LINK(ScImportAsciiDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*);
131 inline bool ScImportAsciiDlg::Seek(sal_uLong nPos)
133 bool bSuccess = true;
134 if (nPos != mnStreamPos && mpDatStream)
136 if (mpDatStream->Seek( nPos ) != nPos)
137 bSuccess = false;
138 else
139 mnStreamPos = nPos;
141 return bSuccess;
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */