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 SC_ASCIIOPT_HXX
21 : #define SC_ASCIIOPT_HXX
22 :
23 : #include <vcl/dialog.hxx>
24 : #include <vcl/button.hxx>
25 : #include <vcl/fixed.hxx>
26 : #include <vcl/lstbox.hxx>
27 : #include <vcl/combobox.hxx>
28 : #include <vcl/field.hxx>
29 : #include <tools/stream.hxx>
30 : #include <svx/txencbox.hxx>
31 : #include "csvtablebox.hxx"
32 : #include "i18nlangtag/lang.h"
33 :
34 : class ScAsciiOptions
35 : {
36 : private:
37 : bool bFixedLen;
38 : OUString aFieldSeps;
39 : bool bMergeFieldSeps;
40 : bool bQuotedFieldAsText;
41 : bool bDetectSpecialNumber;
42 : sal_Unicode cTextSep;
43 : rtl_TextEncoding eCharSet;
44 : LanguageType eLang;
45 : bool bCharSetSystem;
46 : long nStartRow;
47 : sal_uInt16 nInfoCount;
48 : sal_Int32* pColStart; //! TODO replace with vector
49 : sal_uInt8* pColFormat; //! TODO replace with vector
50 :
51 : public:
52 : ScAsciiOptions();
53 : ScAsciiOptions(const ScAsciiOptions& rOpt);
54 : ~ScAsciiOptions();
55 :
56 : static const sal_Unicode cDefaultTextSep = '"';
57 :
58 : ScAsciiOptions& operator=( const ScAsciiOptions& rCpy );
59 :
60 : bool operator==( const ScAsciiOptions& rCmp ) const;
61 :
62 : void ReadFromString( const OUString& rString );
63 : OUString WriteToString() const;
64 :
65 : void InterpretColumnList( const OUString& rString );
66 :
67 0 : rtl_TextEncoding GetCharSet() const { return eCharSet; }
68 : bool GetCharSetSystem() const { return bCharSetSystem; }
69 0 : const OUString& GetFieldSeps() const { return aFieldSeps; }
70 0 : bool IsMergeSeps() const { return bMergeFieldSeps; }
71 0 : bool IsQuotedAsText() const { return bQuotedFieldAsText; }
72 0 : bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
73 0 : sal_Unicode GetTextSep() const { return cTextSep; }
74 0 : bool IsFixedLen() const { return bFixedLen; }
75 0 : sal_uInt16 GetInfoCount() const { return nInfoCount; }
76 0 : const sal_Int32* GetColStart() const { return pColStart; }
77 0 : const sal_uInt8* GetColFormat() const { return pColFormat; }
78 0 : long GetStartRow() const { return nStartRow; }
79 0 : LanguageType GetLanguage() const { return eLang; }
80 :
81 0 : void SetCharSet( rtl_TextEncoding eNew ) { eCharSet = eNew; }
82 0 : void SetCharSetSystem( bool bSet ) { bCharSetSystem = bSet; }
83 0 : void SetFixedLen( bool bSet ) { bFixedLen = bSet; }
84 0 : void SetFieldSeps( const OUString& rStr ) { aFieldSeps = rStr; }
85 0 : void SetMergeSeps( bool bSet ) { bMergeFieldSeps = bSet; }
86 0 : void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; }
87 0 : void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; }
88 0 : void SetTextSep( sal_Unicode c ) { cTextSep = c; }
89 0 : void SetStartRow( long nRow) { nStartRow= nRow; }
90 0 : void SetLanguage(LanguageType e) { eLang = e; }
91 :
92 : void SetColInfo( sal_uInt16 nCount, const sal_Int32* pStart, const sal_uInt8* pFormat );
93 : void SetColumnInfo( const ScCsvExpDataVec& rDataVec );
94 :
95 : /** From the import field separators obtain the one most likely to be used
96 : for export, if multiple separators weighted comma, tab, semicolon,
97 : space and other.
98 :
99 : @param bDecodeNumbers
100 : If TRUE, the separators are encoded as numbers and need to be
101 : decoded before characters can be extracted, for example "59/44"
102 : to ";,".
103 : If FALSE, the string is taken as is and each character is
104 : expected to be one separator.
105 : */
106 : static sal_Unicode GetWeightedFieldSep( const OUString & rFieldSeps, bool bDecodeNumbers );
107 : };
108 :
109 : /// How ScImportAsciiDlg is called
110 : enum ScImportAsciiCall {
111 : SC_IMPORTFILE, // with File > Open: Text - CSV
112 : SC_PASTETEXT, // with Paste > Unformatted Text
113 : SC_TEXTTOCOLUMNS }; // with Data > Text to Columns
114 :
115 : #endif
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|