1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dif.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <tools/debug.hxx>
36 #include <tools/list.hxx>
37 #include <tools/string.hxx>
39 #include "address.hxx"
43 class SvNumberFormatter
;
47 extern const sal_Unicode pKeyTABLE
[];
48 extern const sal_Unicode pKeyVECTORS
[];
49 extern const sal_Unicode pKeyTUPLES
[];
50 extern const sal_Unicode pKeyDATA
[];
51 extern const sal_Unicode pKeyBOT
[];
52 extern const sal_Unicode pKeyEOD
[];
53 extern const sal_Unicode pKeyTRUE
[];
54 extern const sal_Unicode pKeyFALSE
[];
55 extern const sal_Unicode pKeyNA
[];
56 extern const sal_Unicode pKeyV
[];
57 extern const sal_Unicode pKey1_0
[];
63 T_TABLE
, T_VECTORS
, T_TUPLES
, T_DATA
, T_LABEL
, T_COMMENT
, T_SIZE
,
64 T_PERIODICITY
, T_MAJORSTART
, T_MINORSTART
, T_TRUELENGTH
, T_UINITS
,
69 enum DATASET
{ D_BOT
, D_EOD
, D_NUMERIC
, D_STRING
, D_UNKNOWN
, D_SYNT_ERROR
};
82 SvNumberFormatter
* pNumFormatter
;
85 String aLookAheadLine
;
87 bool ReadNextLine( String
& rStr
);
89 DATASET
GetNumberDataset( const sal_Unicode
* pPossibleNumericData
);
90 static inline BOOL
IsBOT( const sal_Unicode
* pRef
);
91 static inline BOOL
IsEOD( const sal_Unicode
* pRef
);
92 static inline BOOL
Is1_0( const sal_Unicode
* pRef
);
94 DifParser( SvStream
&, const UINT32 nOption
, ScDocument
&, CharSet
);
96 TOPIC
GetNextTopic( void );
98 DATASET
GetNextDataset( void );
100 const sal_Unicode
* ScanIntVal( const sal_Unicode
* pStart
, UINT32
& rRet
);
101 BOOL
ScanFloatVal( const sal_Unicode
* pStart
);
103 inline BOOL
IsNumber( const sal_Unicode cChar
);
104 inline BOOL
IsNumberEnding( const sal_Unicode cChar
);
106 static inline BOOL
IsV( const sal_Unicode
* pRef
);
108 inline BOOL
IsPlain( void ) const;
112 inline BOOL
DifParser::IsBOT( const sal_Unicode
* pRef
)
114 return ( pRef
[ 0 ] == pKeyBOT
[0] &&
115 pRef
[ 1 ] == pKeyBOT
[1] &&
116 pRef
[ 2 ] == pKeyBOT
[2] &&
117 pRef
[ 3 ] == pKeyBOT
[3] );
121 inline BOOL
DifParser::IsEOD( const sal_Unicode
* pRef
)
123 return ( pRef
[ 0 ] == pKeyEOD
[0] &&
124 pRef
[ 1 ] == pKeyEOD
[1] &&
125 pRef
[ 2 ] == pKeyEOD
[2] &&
126 pRef
[ 3 ] == pKeyEOD
[3] );
130 inline BOOL
DifParser::Is1_0( const sal_Unicode
* pRef
)
132 return ( pRef
[ 0 ] == pKey1_0
[0] &&
133 pRef
[ 1 ] == pKey1_0
[1] &&
134 pRef
[ 2 ] == pKey1_0
[2] &&
135 pRef
[ 3 ] == pKey1_0
[3] );
139 inline BOOL
DifParser::IsV( const sal_Unicode
* pRef
)
141 return ( pRef
[ 0 ] == pKeyV
[0] &&
142 pRef
[ 1 ] == pKeyV
[1] );
146 inline BOOL
DifParser::IsNumber( const sal_Unicode cChar
)
148 return ( cChar
>= '0' && cChar
<= '9' );
152 inline BOOL
DifParser::IsNumberEnding( const sal_Unicode cChar
)
154 return ( cChar
== 0x00 );
158 inline BOOL
DifParser::IsPlain( void ) const
170 class DifColumn
: private List
173 friend class DifAttrCache
;
184 inline DifColumn( void );
186 void SetLogical( SCROW nRow
);
187 void SetNumFormat( SCROW nRow
, const UINT32 nNumFormat
);
188 void NewEntry( const SCROW nPos
, const UINT32 nNumFormat
);
189 void Apply( ScDocument
&, const SCCOL nCol
, const SCTAB nTab
, const ScPatternAttr
& );
190 void Apply( ScDocument
&rDoc
, const SCCOL nCol
, const SCTAB nTab
);
191 public: // geht niemanden etwas an...
195 inline DifColumn::DifColumn( void )
209 DifAttrCache( const BOOL bPlain
);
211 inline void SetLogical( const SCCOL nCol
, const SCROW nRow
);
212 void SetNumFormat( const SCCOL nCol
, const SCROW nRow
, const UINT32 nNumFormat
);
213 void Apply( ScDocument
&, SCTAB nTab
);
217 inline void DifAttrCache::SetLogical( const SCCOL nCol
, const SCROW nRow
)
219 DBG_ASSERT( ValidCol(nCol
), "-DifAttrCache::SetLogical(): Col zu gross!" );
220 DBG_ASSERT( bPlain
, "*DifAttrCache::SetLogical(): muss Plain sein!" );
222 if( !ppCols
[ nCol
] )
223 ppCols
[ nCol
] = new DifColumn
;
224 ppCols
[ nCol
]->SetLogical( nRow
);