/src/libreoffice/sc/source/ui/inc/asciiopt.hxx
Line | Count | Source |
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 <rtl/ustring.hxx> |
23 | | #include <i18nlangtag/lang.h> |
24 | | |
25 | | #include "csvcontrol.hxx" |
26 | | |
27 | | class ScAsciiOptions |
28 | | { |
29 | | private: |
30 | | bool bFixedLen; |
31 | | OUString aFieldSeps; |
32 | | bool bMergeFieldSeps; |
33 | | bool bRemoveSpace; |
34 | | bool bQuotedFieldAsText; |
35 | | bool bDetectSpecialNumber; |
36 | | bool bDetectScientificNumber; |
37 | | bool bEvaluateFormulas; |
38 | | bool bSkipEmptyCells; |
39 | | bool bSaveAsShown; |
40 | | bool bSaveFormulas; |
41 | | bool bIncludeBOM; |
42 | | sal_Unicode cTextSep; |
43 | | rtl_TextEncoding eCharSet; |
44 | | LanguageType eLang; |
45 | | bool bCharSetSystem; |
46 | | sal_Int32 nStartRow; |
47 | | std::vector<sal_Int32> mvColStart; |
48 | | std::vector<sal_uInt8> mvColFormat; |
49 | | |
50 | | public: |
51 | | ScAsciiOptions(); |
52 | | |
53 | | static const sal_Unicode cDefaultTextSep = '"'; |
54 | | |
55 | | void ReadFromString( std::u16string_view rString, SvStream* pStream4Detect = nullptr ); |
56 | | OUString WriteToString() const; |
57 | | |
58 | 0 | rtl_TextEncoding GetCharSet() const { return eCharSet; } |
59 | 0 | const OUString& GetFieldSeps() const { return aFieldSeps; } |
60 | 0 | bool IsMergeSeps() const { return bMergeFieldSeps; } |
61 | 0 | bool IsRemoveSpace() const { return bRemoveSpace; } |
62 | 0 | bool IsQuotedAsText() const { return bQuotedFieldAsText; } |
63 | 0 | bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; } |
64 | 0 | bool IsDetectScientificNumber() const { return bDetectScientificNumber; } |
65 | 0 | bool IsEvaluateFormulas() const { return bEvaluateFormulas; } |
66 | 0 | bool IsSkipEmptyCells() const { return bSkipEmptyCells; } |
67 | 0 | bool GetIncludeBOM() const { return bIncludeBOM; } |
68 | 0 | sal_Unicode GetTextSep() const { return cTextSep; } |
69 | 0 | bool IsFixedLen() const { return bFixedLen; } |
70 | 0 | sal_uInt16 GetInfoCount() const { return mvColStart.size(); } |
71 | 0 | const sal_Int32* GetColStart() const { return mvColStart.data(); } |
72 | 0 | const sal_uInt8* GetColFormat() const { return mvColFormat.data(); } |
73 | 0 | sal_Int32 GetStartRow() const { return nStartRow; } |
74 | 0 | LanguageType GetLanguage() const { return eLang; } |
75 | | |
76 | 0 | void SetCharSet( rtl_TextEncoding eNew ) { eCharSet = eNew; } |
77 | 0 | void SetCharSetSystem( bool bSet ) { bCharSetSystem = bSet; } |
78 | 0 | void SetFixedLen( bool bSet ) { bFixedLen = bSet; } |
79 | 0 | void SetFieldSeps( const OUString& rStr ) { aFieldSeps = rStr; } |
80 | 0 | void SetMergeSeps( bool bSet ) { bMergeFieldSeps = bSet; } |
81 | 0 | void SetRemoveSpace( bool bSet ) { bRemoveSpace = bSet; } |
82 | 0 | void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; } |
83 | 0 | void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; } |
84 | 0 | void SetDetectScientificNumber(bool bSet){ bDetectScientificNumber = bSet; } |
85 | 0 | void SetEvaluateFormulas(bool bSet) { bEvaluateFormulas = bSet; } |
86 | 0 | void SetSkipEmptyCells(bool bSet) { bSkipEmptyCells = bSet; } |
87 | 0 | void SetIncludeBOM(bool bVal) { bIncludeBOM = bVal; } |
88 | 0 | void SetTextSep( sal_Unicode c ) { cTextSep = c; } |
89 | 0 | void SetStartRow( sal_Int32 nRow) { nStartRow= nRow; } |
90 | 0 | void SetLanguage(LanguageType e) { eLang = e; } |
91 | | |
92 | | void SetColumnInfo( const ScCsvExpDataVec& rDataVec ); |
93 | | |
94 | | /** From the import field separators obtain the one most likely to be used |
95 | | for export, if multiple separators weighted comma, tab, semicolon, |
96 | | space and other. |
97 | | |
98 | | @param bDecodeNumbers |
99 | | If TRUE, the separators are encoded as numbers and need to be |
100 | | decoded before characters can be extracted, for example "59/44" |
101 | | to ";,". |
102 | | If FALSE, the string is taken as is and each character is |
103 | | expected to be one separator. |
104 | | */ |
105 | | static sal_Unicode GetWeightedFieldSep( const OUString & rFieldSeps, bool bDecodeNumbers ); |
106 | | }; |
107 | | |
108 | | /// How ScImportAsciiDlg is called |
109 | | enum ScImportAsciiCall { |
110 | | SC_IMPORTFILE, // with File > Open: Text - CSV |
111 | | SC_PASTETEXT, // with Paste > Unformatted Text |
112 | | SC_TEXTTOCOLUMNS }; // with Data > Text to Columns |
113 | | |
114 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |