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 #ifndef INCLUDED_SC_SOURCE_UI_INC_SCUIASCIIOPT_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_SCUIASCIIOPT_HXX
22 
23 #include <svx/langbox.hxx>
24 #include <tools/solar.h>
25 #include <tools/stream.hxx>
26 #include <vcl/weld.hxx>
27 
28 #include "asciiopt.hxx"
29 
30 class ScCsvTableBox;
31 class SvxTextEncodingBox;
32 
34 {
37  std::unique_ptr<sal_uLong[]> mpRowPosArray;
39 
41 
42  OUString maFieldSeparators; // selected field separators
44 
45  rtl_TextEncoding meCharSet;
49 
50  std::unique_ptr<weld::Label> mxFtCharSet;
51  std::unique_ptr<SvxTextEncodingBox> mxLbCharSet;
52  std::unique_ptr<weld::Label> mxFtCustomLang;
53  std::unique_ptr<SvxLanguageBox> mxLbCustomLang;
54 
55  std::unique_ptr<weld::Label> mxFtRow;
56  std::unique_ptr<weld::SpinButton> mxNfRow;
57 
58  std::unique_ptr<weld::RadioButton> mxRbFixed;
59  std::unique_ptr<weld::RadioButton> mxRbSeparated;
60 
61  std::unique_ptr<weld::CheckButton> mxCkbTab;
62  std::unique_ptr<weld::CheckButton> mxCkbSemicolon;
63  std::unique_ptr<weld::CheckButton> mxCkbComma;
64  std::unique_ptr<weld::CheckButton> mxCkbRemoveSpace;
65  std::unique_ptr<weld::CheckButton> mxCkbSpace;
66  std::unique_ptr<weld::CheckButton> mxCkbOther;
67  std::unique_ptr<weld::Entry> mxEdOther;
68  std::unique_ptr<weld::CheckButton> mxCkbAsOnce;
69 
70  std::unique_ptr<weld::Label> mxFtTextSep;
71  std::unique_ptr<weld::ComboBox> mxCbTextSep;
72 
73  std::unique_ptr<weld::CheckButton> mxCkbQuotedAsText;
74  std::unique_ptr<weld::CheckButton> mxCkbDetectNumber;
75  std::unique_ptr<weld::CheckButton> mxCkbSkipEmptyCells;
76 
77  std::unique_ptr<weld::Label> mxFtType;
78  std::unique_ptr<weld::ComboBox> mxLbType;
79  std::unique_ptr<weld::Label> mxAltTitle;
80 
81  std::unique_ptr<ScCsvTableBox> mxTableBox;
82 
83 public:
85  weld::Window* pParent, const OUString& aDatName,
86  SvStream* pInStream, ScImportAsciiCall eCall );
87  virtual ~ScImportAsciiDlg() override;
88 
89  void GetOptions( ScAsciiOptions& rOpt );
90  void SaveParameters();
91 
92 private:
94  void SetSelectedCharSet();
96  void SetSeparators();
98  OUString GetSeparators() const;
99 
101  void SetupSeparatorCtrls();
102 
103  bool GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep );
104  void UpdateVertical();
105  inline bool Seek( sal_uLong nPos ); // synced to and from mnStreamPos
106 
107  DECL_LINK( CharSetHdl, weld::ComboBox&, void );
108  DECL_LINK( FirstRowHdl, weld::SpinButton&, void );
109  DECL_LINK( RbSepFixHdl, weld::Button&, void );
110  DECL_LINK( SeparatorEditHdl, weld::Entry&, void );
111  DECL_LINK( SeparatorClickHdl, weld::Button&, void );
112  DECL_LINK( SeparatorComboBoxHdl, weld::ComboBox&, void );
113  void SeparatorHdl(const weld::Widget*);
114  DECL_LINK( LbColTypeHdl, weld::ComboBox&, void );
115  DECL_LINK( UpdateTextHdl, ScCsvTableBox&, void );
116  DECL_LINK( ColTypeHdl, ScCsvTableBox&, void );
117 };
118 
120 {
121  bool bSuccess = true;
122  if (nPos != mnStreamPos && mpDatStream)
123  {
124  if (mpDatStream->Seek( nPos ) != nPos)
125  bSuccess = false;
126  else
127  mnStreamPos = nPos;
128  }
129  return bSuccess;
130 }
131 
132 #endif
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::ComboBox > mxLbType
OUString maFieldSeparators
virtual ~ScImportAsciiDlg() override
std::unique_ptr< weld::RadioButton > mxRbFixed
std::unique_ptr< weld::CheckButton > mxCkbOther
void SeparatorHdl(const weld::Widget *)
std::unique_ptr< weld::ComboBox > mxCbTextSep
OUString maPreviewLine[CSV_PREVIEW_LINES]
DECL_LINK(CharSetHdl, weld::ComboBox &, void)
void SetSeparators()
Set separators in ui from maFieldSeparators.
bool mbDetectSpaceSep
How the dialog is called (see asciiopt.hxx)
sal_Unicode mcTextSep
bool Seek(sal_uLong nPos)
sal_uIntPtr sal_uLong
sal_uInt64 Seek(sal_uInt64 nPos)
std::unique_ptr< weld::SpinButton > mxNfRow
void SetupSeparatorCtrls()
Enables or disables all separator checkboxes and edit fields.
bool GetLine(sal_uLong nLine, OUString &rText, sal_Unicode &rcDetectSep)
std::unique_ptr< weld::CheckButton > mxCkbQuotedAsText
std::unique_ptr< weld::RadioButton > mxRbSeparated
sal_uLong mnStreamPos
SvStream * mpDatStream
std::unique_ptr< weld::CheckButton > mxCkbSpace
sal_uInt16 sal_Unicode
std::unique_ptr< weld::CheckButton > mxCkbSkipEmptyCells
std::unique_ptr< weld::CheckButton > mxCkbSemicolon
std::unique_ptr< weld::CheckButton > mxCkbComma
OUString GetSeparators() const
Returns all separator characters in a string.
std::unique_ptr< weld::Label > mxFtCharSet
Whether to detect a possible space separator.
std::unique_ptr< weld::Label > mxFtRow
rtl_TextEncoding meCharSet
std::unique_ptr< ScCsvTableBox > mxTableBox
void SetSelectedCharSet()
Sets the selected char set data to meCharSet and mbCharSetSystem.
std::unique_ptr< weld::CheckButton > mxCkbTab
bool mbCharSetSystem
Selected char set.
std::unique_ptr< weld::CheckButton > mxCkbDetectNumber
std::unique_ptr< SvxTextEncodingBox > mxLbCharSet
void GetOptions(ScAsciiOptions &rOpt)
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::Label > mxFtTextSep
std::unique_ptr< sal_uLong[]> mpRowPosArray
std::unique_ptr< weld::Entry > mxEdOther
std::unique_ptr< weld::Label > mxAltTitle
ScImportAsciiCall
How ScImportAsciiDlg is called.
Definition: asciiopt.hxx:101
std::unique_ptr< weld::CheckButton > mxCkbAsOnce
sal_uLong mnRowPosCount
ScImportAsciiCall meCall
Is System char set selected?
std::unique_ptr< weld::CheckButton > mxCkbRemoveSpace
std::unique_ptr< SvxLanguageBox > mxLbCustomLang
ScImportAsciiDlg(weld::Window *pParent, const OUString &aDatName, SvStream *pInStream, ScImportAsciiCall eCall)
std::unique_ptr< weld::Label > mxFtCustomLang
const sal_Int32 CSV_PREVIEW_LINES
TODO make string array dynamic.
Definition: csvcontrol.hxx:43
std::unique_ptr< weld::Label > mxFtType