LibreOffice Module sc (master) 1
scuiasciiopt.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <svx/langbox.hxx>
23#include <tools/solar.h>
24#include <tools/stream.hxx>
25#include <vcl/weld.hxx>
26
27#include "asciiopt.hxx"
28
29class ScCsvTableBox;
31
33{
36 std::unique_ptr<sal_uLong[]> mpRowPosArray;
38
40
41 OUString maFieldSeparators; // selected field separators
43
44 rtl_TextEncoding meCharSet;
48
49 std::unique_ptr<weld::Label> mxFtCharSet;
50 std::unique_ptr<SvxTextEncodingBox> mxLbCharSet;
51 std::unique_ptr<weld::Label> mxFtCustomLang;
52 std::unique_ptr<SvxLanguageBox> mxLbCustomLang;
53
54 std::unique_ptr<weld::Label> mxFtRow;
55 std::unique_ptr<weld::SpinButton> mxNfRow;
56
57 std::unique_ptr<weld::RadioButton> mxRbFixed;
58 std::unique_ptr<weld::RadioButton> mxRbSeparated;
59
60 std::unique_ptr<weld::CheckButton> mxCkbTab;
61 std::unique_ptr<weld::CheckButton> mxCkbSemicolon;
62 std::unique_ptr<weld::CheckButton> mxCkbComma;
63 std::unique_ptr<weld::CheckButton> mxCkbRemoveSpace;
64 std::unique_ptr<weld::CheckButton> mxCkbSpace;
65 std::unique_ptr<weld::CheckButton> mxCkbOther;
66 std::unique_ptr<weld::Entry> mxEdOther;
67 std::unique_ptr<weld::CheckButton> mxCkbAsOnce;
68
69 std::unique_ptr<weld::Label> mxFtTextSep;
70 std::unique_ptr<weld::ComboBox> mxCbTextSep;
71
72 std::unique_ptr<weld::CheckButton> mxCkbQuotedAsText;
73 std::unique_ptr<weld::CheckButton> mxCkbDetectNumber;
74 std::unique_ptr<weld::CheckButton> mxCkbDetectScientificNumber;
75 std::unique_ptr<weld::CheckButton> mxCkbEvaluateFormulas;
76 std::unique_ptr<weld::CheckButton> mxCkbSkipEmptyCells;
77
78 std::unique_ptr<weld::ComboBox> mxLbType;
79 std::unique_ptr<weld::Label> mxAltTitle;
80
81 std::unique_ptr<ScCsvTableBox> mxTableBox;
82
83public:
85 weld::Window* pParent, std::u16string_view aDatName,
86 SvStream* pInStream, ScImportAsciiCall eCall );
87 virtual ~ScImportAsciiDlg() override;
88
89 void GetOptions( ScAsciiOptions& rOpt );
90 void SaveParameters();
91
92private:
94 void SetSelectedCharSet();
97 void SetSeparators( sal_Unicode cSep );
99 OUString GetSeparators() const;
100
102 void SetupSeparatorCtrls();
103
104 bool GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep );
105 void UpdateVertical();
106 inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos
107 void RbSepFix();
108
109 DECL_LINK( CharSetHdl, weld::ComboBox&, void );
110 DECL_LINK( FirstRowHdl, weld::SpinButton&, void );
111 DECL_LINK( RbSepFixHdl, weld::Toggleable&, void );
112 DECL_LINK( SeparatorEditHdl, weld::Entry&, void );
113 DECL_LINK( SeparatorClickHdl, weld::Toggleable&, void );
114 DECL_LINK( OtherOptionsClickHdl, weld::Toggleable&, void );
115 DECL_LINK( SeparatorComboBoxHdl, weld::ComboBox&, void );
116 void SeparatorHdl(const weld::Widget*);
117 DECL_LINK( LbColTypeHdl, weld::ComboBox&, void );
118 DECL_LINK( UpdateTextHdl, ScCsvTableBox&, void );
119 DECL_LINK( ColTypeHdl, ScCsvTableBox&, void );
121
122};
123
125{
126 bool bSuccess = true;
127 if (nPos != mnStreamPos && mpDatStream)
128 {
129 if (mpDatStream->Seek( nPos ) != nPos)
130 bSuccess = false;
131 else
133 }
134 return bSuccess;
135}
136
137/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScImportAsciiCall
How ScImportAsciiDlg is called.
Definition: asciiopt.hxx:109
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
std::unique_ptr< weld::SpinButton > mxNfRow
DECL_LINK(SeparatorEditHdl, weld::Entry &, void)
std::unique_ptr< weld::CheckButton > mxCkbComma
std::unique_ptr< weld::CheckButton > mxCkbSkipEmptyCells
void SetupSeparatorCtrls()
Enables or disables all separator checkboxes and edit fields.
std::unique_ptr< weld::ComboBox > mxLbType
std::unique_ptr< weld::CheckButton > mxCkbDetectNumber
std::unique_ptr< weld::Label > mxFtRow
std::unique_ptr< weld::CheckButton > mxCkbQuotedAsText
OUString maPreviewLine[CSV_PREVIEW_LINES]
OUString maFieldSeparators
std::unique_ptr< weld::RadioButton > mxRbFixed
DECL_LINK(SeparatorComboBoxHdl, weld::ComboBox &, void)
void SetSelectedCharSet()
Sets the selected char set data to meCharSet and mbCharSetSystem.
bool GetLine(sal_uLong nLine, OUString &rText, sal_Unicode &rcDetectSep)
sal_Unicode mcTextSep
std::unique_ptr< weld::CheckButton > mxCkbDetectScientificNumber
OUString GetSeparators() const
Returns all separator characters in a string.
std::unique_ptr< weld::CheckButton > mxCkbSemicolon
std::unique_ptr< sal_uLong[]> mpRowPosArray
DECL_LINK(FirstRowHdl, weld::SpinButton &, void)
ScImportAsciiDlg(weld::Window *pParent, std::u16string_view aDatName, SvStream *pInStream, ScImportAsciiCall eCall)
std::unique_ptr< weld::CheckButton > mxCkbOther
bool mbDetectSep
How the dialog is called (see asciiopt.hxx)
DECL_LINK(OtherOptionsClickHdl, weld::Toggleable &, void)
DECL_LINK(ColTypeHdl, ScCsvTableBox &, void)
void GetOptions(ScAsciiOptions &rOpt)
void SetSeparators(sal_Unicode cSep)
Set separators in ui from maFieldSeparators or an optionally defined separator.
std::unique_ptr< weld::Entry > mxEdOther
DECL_LINK(SeparatorClickHdl, weld::Toggleable &, void)
std::unique_ptr< weld::CheckButton > mxCkbAsOnce
sal_uLong mnStreamPos
DECL_STATIC_LINK(ScImportAsciiDlg, InstallLOKNotifierHdl, void *, vcl::ILibreOfficeKitNotifier *)
std::unique_ptr< weld::CheckButton > mxCkbRemoveSpace
std::unique_ptr< weld::Label > mxFtTextSep
bool mbCharSetSystem
Selected char set.
ScImportAsciiCall meCall
Is System char set selected?
std::unique_ptr< weld::Label > mxFtCharSet
Whether to detect a possible separator.
DECL_LINK(LbColTypeHdl, weld::ComboBox &, void)
std::unique_ptr< weld::CheckButton > mxCkbEvaluateFormulas
bool Seek(sal_uLong nPos)
std::unique_ptr< weld::Label > mxFtCustomLang
void SeparatorHdl(const weld::Widget *)
std::unique_ptr< weld::CheckButton > mxCkbSpace
std::unique_ptr< ScCsvTableBox > mxTableBox
std::unique_ptr< weld::ComboBox > mxCbTextSep
DECL_LINK(UpdateTextHdl, ScCsvTableBox &, void)
std::unique_ptr< weld::Label > mxAltTitle
DECL_LINK(CharSetHdl, weld::ComboBox &, void)
DECL_LINK(RbSepFixHdl, weld::Toggleable &, void)
std::unique_ptr< SvxTextEncodingBox > mxLbCharSet
rtl_TextEncoding meCharSet
std::unique_ptr< weld::RadioButton > mxRbSeparated
sal_uLong mnRowPosCount
SvStream * mpDatStream
std::unique_ptr< weld::CheckButton > mxCkbTab
std::unique_ptr< SvxLanguageBox > mxLbCustomLang
virtual ~ScImportAsciiDlg() override
sal_uInt64 Seek(sal_uInt64 nPos)
const sal_Int32 CSV_PREVIEW_LINES
TODO make string array dynamic.
Definition: csvcontrol.hxx:42
sal_uInt16 nPos
sal_uIntPtr sal_uLong
sal_uInt16 sal_Unicode