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
23 #include <boost/ptr_container/ptr_vector.hpp>
25 #include <rtl/ustring.hxx>
27 #include "address.hxx"
31 class SvNumberFormatter
;
35 extern const sal_Unicode pKeyTABLE
[];
36 extern const sal_Unicode pKeyVECTORS
[];
37 extern const sal_Unicode pKeyTUPLES
[];
38 extern const sal_Unicode pKeyDATA
[];
39 extern const sal_Unicode pKeyBOT
[];
40 extern const sal_Unicode pKeyEOD
[];
41 extern const sal_Unicode pKeyTRUE
[];
42 extern const sal_Unicode pKeyFALSE
[];
43 extern const sal_Unicode pKeyNA
[];
44 extern const sal_Unicode pKeyV
[];
45 extern const sal_Unicode pKey1_0
[];
50 T_TABLE
, T_VECTORS
, T_TUPLES
, T_DATA
, T_LABEL
, T_COMMENT
, T_SIZE
,
51 T_PERIODICITY
, T_MAJORSTART
, T_MINORSTART
, T_TRUELENGTH
, T_UINITS
,
56 enum DATASET
{ D_BOT
, D_EOD
, D_NUMERIC
, D_STRING
, D_UNKNOWN
, D_SYNT_ERROR
};
68 sal_uInt32 nNumFormat
;
69 rtl_TextEncoding eCharSet
;
71 SvNumberFormatter
* pNumFormatter
;
74 OUString aLookAheadLine
;
76 bool ReadNextLine( OUString
& rStr
);
78 DATASET
GetNumberDataset( const sal_Unicode
* pPossibleNumericData
);
79 static inline bool IsBOT( const sal_Unicode
* pRef
);
80 static inline bool IsEOD( const sal_Unicode
* pRef
);
81 static inline bool Is1_0( const sal_Unicode
* pRef
);
83 DifParser( SvStream
&, const sal_uInt32 nOption
, ScDocument
&, rtl_TextEncoding
);
87 DATASET
GetNextDataset();
89 static const sal_Unicode
* ScanIntVal( const sal_Unicode
* pStart
, sal_uInt32
& rRet
);
90 bool ScanFloatVal( const sal_Unicode
* pStart
);
92 static inline bool IsNumber( const sal_Unicode cChar
);
93 static inline bool IsNumberEnding( const sal_Unicode cChar
);
95 static inline bool IsV( const sal_Unicode
* pRef
);
97 inline bool IsPlain() const;
100 inline bool DifParser::IsBOT( const sal_Unicode
* pRef
)
102 return ( pRef
[ 0 ] == pKeyBOT
[0] &&
103 pRef
[ 1 ] == pKeyBOT
[1] &&
104 pRef
[ 2 ] == pKeyBOT
[2] &&
105 pRef
[ 3 ] == pKeyBOT
[3] );
108 inline bool DifParser::IsEOD( const sal_Unicode
* pRef
)
110 return ( pRef
[ 0 ] == pKeyEOD
[0] &&
111 pRef
[ 1 ] == pKeyEOD
[1] &&
112 pRef
[ 2 ] == pKeyEOD
[2] &&
113 pRef
[ 3 ] == pKeyEOD
[3] );
116 inline bool DifParser::Is1_0( const sal_Unicode
* pRef
)
118 return ( pRef
[ 0 ] == pKey1_0
[0] &&
119 pRef
[ 1 ] == pKey1_0
[1] &&
120 pRef
[ 2 ] == pKey1_0
[2] &&
121 pRef
[ 3 ] == pKey1_0
[3] );
124 inline bool DifParser::IsV( const sal_Unicode
* pRef
)
126 return ( pRef
[ 0 ] == pKeyV
[0] &&
127 pRef
[ 1 ] == pKeyV
[1] );
130 inline bool DifParser::IsNumber( const sal_Unicode cChar
)
132 return ( cChar
>= '0' && cChar
<= '9' );
135 inline bool DifParser::IsNumberEnding( const sal_Unicode cChar
)
137 return ( cChar
== 0x00 );
140 inline bool DifParser::IsPlain() const
147 friend class DifAttrCache
;
151 sal_uInt32 nNumFormat
;
157 boost::ptr_vector
<ENTRY
> aEntries
;
161 void SetLogical( SCROW nRow
);
163 void SetNumFormat( SCROW nRow
, const sal_uInt32 nNumFormat
);
165 void NewEntry( const SCROW nPos
, const sal_uInt32 nNumFormat
);
167 void Apply( ScDocument
&, const SCCOL nCol
, const SCTAB nTab
, const ScPatternAttr
& );
169 void Apply( ScDocument
&rDoc
, const SCCOL nCol
, const SCTAB nTab
);
176 DifAttrCache( const bool bPlain
);
180 void SetLogical( const SCCOL nCol
, const SCROW nRow
);
182 void SetNumFormat( const SCCOL nCol
, const SCROW nRow
, const sal_uInt32 nNumFormat
);
184 void Apply( ScDocument
&, SCTAB nTab
);
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */