1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
27 #include <rtl/ustring.hxx>
28 #include <rtl/ustrbuf.hxx>
33 class SvNumberFormatter
;
36 extern const sal_Unicode pKeyTABLE
[];
37 extern const sal_Unicode pKeyVECTORS
[];
38 extern const sal_Unicode pKeyTUPLES
[];
39 extern const sal_Unicode pKeyDATA
[];
40 extern const sal_Unicode pKeyBOT
[];
41 extern const sal_Unicode pKeyEOD
[];
42 extern const sal_Unicode pKeyTRUE
[];
43 extern const sal_Unicode pKeyFALSE
[];
44 extern const sal_Unicode pKeyNA
[];
45 extern const sal_Unicode pKeyV
[];
46 extern const sal_Unicode pKey1_0
[];
51 T_TABLE
, T_VECTORS
, T_TUPLES
, T_DATA
, T_LABEL
, T_COMMENT
, T_SIZE
,
52 T_PERIODICITY
, T_MAJORSTART
, T_MINORSTART
, T_TRUELENGTH
, T_UINITS
,
57 enum DATASET
{ D_BOT
, D_EOD
, D_NUMERIC
, D_STRING
, D_UNKNOWN
, D_SYNT_ERROR
};
62 OUStringBuffer m_aData
;
66 sal_uInt32 nNumFormat
;
68 SvNumberFormatter
* pNumFormatter
;
70 OUString aLookAheadLine
;
72 bool ReadNextLine( OUString
& rStr
);
74 DATASET
GetNumberDataset( const sal_Unicode
* pPossibleNumericData
);
75 static inline bool IsBOT( const sal_Unicode
* pRef
);
76 static inline bool IsEOD( const sal_Unicode
* pRef
);
77 static inline bool Is1_0( const sal_Unicode
* pRef
);
79 DifParser( SvStream
&, const ScDocument
&, rtl_TextEncoding
);
83 DATASET
GetNextDataset();
85 static const sal_Unicode
* ScanIntVal( const sal_Unicode
* pStart
, sal_uInt32
& rRet
);
87 static inline bool IsNumber( const sal_Unicode cChar
);
89 static inline bool IsV( const sal_Unicode
* pRef
);
92 inline bool DifParser::IsBOT( const sal_Unicode
* pRef
)
94 return ( pRef
[ 0 ] == pKeyBOT
[0] &&
95 pRef
[ 1 ] == pKeyBOT
[1] &&
96 pRef
[ 2 ] == pKeyBOT
[2] &&
97 pRef
[ 3 ] == pKeyBOT
[3] );
100 inline bool DifParser::IsEOD( const sal_Unicode
* pRef
)
102 return ( pRef
[ 0 ] == pKeyEOD
[0] &&
103 pRef
[ 1 ] == pKeyEOD
[1] &&
104 pRef
[ 2 ] == pKeyEOD
[2] &&
105 pRef
[ 3 ] == pKeyEOD
[3] );
108 inline bool DifParser::Is1_0( const sal_Unicode
* pRef
)
110 return ( pRef
[ 0 ] == pKey1_0
[0] &&
111 pRef
[ 1 ] == pKey1_0
[1] &&
112 pRef
[ 2 ] == pKey1_0
[2] &&
113 pRef
[ 3 ] == pKey1_0
[3] );
116 inline bool DifParser::IsV( const sal_Unicode
* pRef
)
118 return ( pRef
[ 0 ] == pKeyV
[0] &&
119 pRef
[ 1 ] == pKeyV
[1] );
122 inline bool DifParser::IsNumber( const sal_Unicode cChar
)
124 return ( cChar
>= '0' && cChar
<= '9' );
129 friend class DifAttrCache
;
133 sal_uInt32 nNumFormat
;
139 std::vector
<ENTRY
> maEntries
;
143 void SetNumFormat( SCROW nRow
, const sal_uInt32 nNumFormat
);
145 void NewEntry( const SCROW nPos
, const sal_uInt32 nNumFormat
);
147 void Apply( ScDocument
&rDoc
, const SCCOL nCol
, const SCTAB nTab
);
158 void SetNumFormat( const SCCOL nCol
, const SCROW nRow
, const sal_uInt32 nNumFormat
);
160 void Apply( ScDocument
&, SCTAB nTab
);
164 std::map
<SCCOL
, std::unique_ptr
<DifColumn
>> maColMap
;
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */