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 : // ============================================================================
21 :
22 : #ifndef SC_ASCIIOPT_HXX
23 : #define SC_ASCIIOPT_HXX
24 :
25 : #include <tools/string.hxx>
26 : #include <vcl/dialog.hxx>
27 : #include <vcl/button.hxx>
28 : #include <vcl/fixed.hxx>
29 : #include <vcl/lstbox.hxx>
30 : #include <vcl/combobox.hxx>
31 : #include <vcl/field.hxx>
32 : #include <tools/stream.hxx>
33 : #include <svx/txencbox.hxx>
34 : #include "csvtablebox.hxx"
35 : #include "i18npool/lang.h"
36 :
37 : // ============================================================================
38 :
39 : class ScAsciiOptions
40 : {
41 : private:
42 : sal_Bool bFixedLen;
43 : String aFieldSeps;
44 : sal_Bool bMergeFieldSeps;
45 : bool bQuotedFieldAsText;
46 : bool bDetectSpecialNumber;
47 : sal_Unicode cTextSep;
48 : CharSet eCharSet;
49 : LanguageType eLang;
50 : sal_Bool bCharSetSystem;
51 : long nStartRow;
52 : sal_uInt16 nInfoCount;
53 : sal_Int32* pColStart; //! TODO replace with vector
54 : sal_uInt8* pColFormat; //! TODO replace with vector
55 :
56 : public:
57 : ScAsciiOptions();
58 : ScAsciiOptions(const ScAsciiOptions& rOpt);
59 : ~ScAsciiOptions();
60 :
61 : static const sal_Unicode cDefaultTextSep = '"';
62 :
63 : ScAsciiOptions& operator=( const ScAsciiOptions& rCpy );
64 :
65 : sal_Bool operator==( const ScAsciiOptions& rCmp ) const;
66 :
67 : void ReadFromString( const String& rString );
68 : String WriteToString() const;
69 :
70 : void InterpretColumnList( const String& rString );
71 :
72 2 : CharSet GetCharSet() const { return eCharSet; }
73 : sal_Bool GetCharSetSystem() const { return bCharSetSystem; }
74 4 : const String& GetFieldSeps() const { return aFieldSeps; }
75 2 : sal_Bool IsMergeSeps() const { return bMergeFieldSeps; }
76 2 : bool IsQuotedAsText() const { return bQuotedFieldAsText; }
77 2 : bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
78 2 : sal_Unicode GetTextSep() const { return cTextSep; }
79 2 : sal_Bool IsFixedLen() const { return bFixedLen; }
80 2 : sal_uInt16 GetInfoCount() const { return nInfoCount; }
81 2 : const sal_Int32* GetColStart() const { return pColStart; }
82 2 : const sal_uInt8* GetColFormat() const { return pColFormat; }
83 2 : long GetStartRow() const { return nStartRow; }
84 2 : LanguageType GetLanguage() const { return eLang; }
85 :
86 2 : void SetCharSet( CharSet eNew ) { eCharSet = eNew; }
87 0 : void SetCharSetSystem( sal_Bool bSet ) { bCharSetSystem = bSet; }
88 0 : void SetFixedLen( sal_Bool bSet ) { bFixedLen = bSet; }
89 2 : void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; }
90 0 : void SetMergeSeps( sal_Bool bSet ) { bMergeFieldSeps = bSet; }
91 0 : void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; }
92 0 : void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; }
93 2 : void SetTextSep( sal_Unicode c ) { cTextSep = c; }
94 0 : void SetStartRow( long nRow) { nStartRow= nRow; }
95 0 : void SetLanguage(LanguageType e) { eLang = e; }
96 :
97 : void SetColInfo( sal_uInt16 nCount, const sal_Int32* pStart, const sal_uInt8* pFormat );
98 : void SetColumnInfo( const ScCsvExpDataVec& rDataVec );
99 : };
100 :
101 : /// How ScImportAsciiDlg is called
102 : enum ScImportAsciiCall {
103 : SC_IMPORTFILE, // with File > Open: Text - CSV
104 : SC_PASTETEXT, // with Paste > Unformatted Text
105 : SC_TEXTTOCOLUMNS }; // with Data > Text to Columns
106 :
107 : #endif
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|