LibreOffice Module sc (master)  1
dif.hxx
Go to the documentation of this file.
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 INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
22 
23 #include <map>
24 #include <memory>
25 #include <vector>
26 
27 #include <rtl/ustring.hxx>
28 #include <rtl/ustrbuf.hxx>
29 
30 #include <types.hxx>
31 
32 class SvStream;
33 class SvNumberFormatter;
34 class ScDocument;
35 
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[];
47 
48 enum TOPIC
49 {
55 };
56 
58 
59 class DifParser
60 {
61 public:
62  OUStringBuffer m_aData;
63  double fVal;
64  sal_uInt32 nVector;
65  sal_uInt32 nVal;
66  sal_uInt32 nNumFormat;
67 private:
70  OUString aLookAheadLine;
71 
72  bool ReadNextLine( OUString& rStr );
73  bool LookAhead();
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 );
78 public:
79  DifParser( SvStream&, const ScDocument&, rtl_TextEncoding );
80 
82 
84 
85  static const sal_Unicode* ScanIntVal( const sal_Unicode* pStart, sal_uInt32& rRet );
86 
87  static inline bool IsNumber( const sal_Unicode cChar );
88 
89  static inline bool IsV( const sal_Unicode* pRef );
90 };
91 
92 inline bool DifParser::IsBOT( const sal_Unicode* pRef )
93 {
94  return ( pRef[ 0 ] == pKeyBOT[0] &&
95  pRef[ 1 ] == pKeyBOT[1] &&
96  pRef[ 2 ] == pKeyBOT[2] &&
97  pRef[ 3 ] == pKeyBOT[3] );
98 }
99 
100 inline bool DifParser::IsEOD( const sal_Unicode* pRef )
101 {
102  return ( pRef[ 0 ] == pKeyEOD[0] &&
103  pRef[ 1 ] == pKeyEOD[1] &&
104  pRef[ 2 ] == pKeyEOD[2] &&
105  pRef[ 3 ] == pKeyEOD[3] );
106 }
107 
108 inline bool DifParser::Is1_0( const sal_Unicode* pRef )
109 {
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] );
114 }
115 
116 inline bool DifParser::IsV( const sal_Unicode* pRef )
117 {
118  return ( pRef[ 0 ] == pKeyV[0] &&
119  pRef[ 1 ] == pKeyV[1] );
120 }
121 
122 inline bool DifParser::IsNumber( const sal_Unicode cChar )
123 {
124  return ( cChar >= '0' && cChar <= '9' );
125 }
126 
128 {
129  friend class DifAttrCache;
130 
131  struct ENTRY
132  {
133  sal_uInt32 nNumFormat;
136  };
137 
139  std::vector<ENTRY> maEntries;
140 
141  DifColumn();
142 
143  void SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat );
144 
145  void NewEntry( const SCROW nPos, const sal_uInt32 nNumFormat );
146 
147  void Apply( ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab );
148 };
149 
151 {
152 public:
153 
154  DifAttrCache();
155 
156  ~DifAttrCache();
157 
158  void SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat );
159 
160  void Apply( ScDocument&, SCTAB nTab );
161 
162 private:
163 
164  std::map<SCCOL, std::unique_ptr<DifColumn>> maColMap;
165 };
166 
167 #endif
168 
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsBOT(const sal_Unicode *pRef)
Definition: dif.hxx:92
TOPIC GetNextTopic()
Definition: difimp.cxx:243
Definition: dif.hxx:51
DATASET
Definition: dif.hxx:57
OUStringBuffer m_aData
Definition: dif.hxx:62
static bool IsNumber(const sal_Unicode cChar)
Definition: dif.hxx:122
Definition: dif.hxx:52
const sal_Unicode pKey1_0[]
Definition: difimp.cxx:46
const sal_Unicode pKeyEOD[]
Definition: difimp.cxx:40
Definition: dif.hxx:57
std::vector< ENTRY > maEntries
Definition: dif.hxx:139
sal_uInt16 sal_Unicode
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:675
DATASET GetNextDataset()
Definition: difimp.cxx:471
Definition: dif.hxx:51
bool LookAhead()
Definition: difimp.cxx:433
SvStream & rIn
Definition: dif.hxx:69
SCROW nStart
Definition: dif.hxx:134
const sal_Unicode pKeyFALSE[]
Definition: difimp.cxx:43
static bool Is1_0(const sal_Unicode *pRef)
Definition: dif.hxx:108
TOPIC
Definition: dif.hxx:48
sal_uInt32 nVal
Definition: dif.hxx:65
sal_Int16 SCCOL
Definition: types.hxx:22
OUString aLookAheadLine
Definition: dif.hxx:70
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
Definition: dif.hxx:164
const sal_Unicode pKeyTUPLES[]
Definition: difimp.cxx:37
Definition: dif.hxx:51
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:615
sal_uInt32 nVector
Definition: dif.hxx:64
const sal_Unicode pKeyNA[]
Definition: difimp.cxx:44
static bool IsV(const sal_Unicode *pRef)
Definition: dif.hxx:116
const sal_Unicode pKeyDATA[]
Definition: difimp.cxx:38
const sal_Unicode pKeyVECTORS[]
Definition: difimp.cxx:36
Definition: dif.hxx:51
sal_Int32 SCROW
Definition: types.hxx:18
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:640
sal_uInt32 nNumFormat
Definition: dif.hxx:133
Definition: dif.hxx:57
ENTRY * mpCurrent
Definition: dif.hxx:138
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
Definition: difimp.cxx:227
const sal_Unicode pKeyBOT[]
Definition: difimp.cxx:39
const sal_Unicode pKeyTRUE[]
Definition: difimp.cxx:42
SvNumberFormatter * pNumFormatter
Definition: dif.hxx:68
Definition: dif.hxx:51
const sal_Unicode pKeyV[]
Definition: difimp.cxx:45
SCROW nEnd
Definition: dif.hxx:135
Definition: dif.hxx:57
const sal_Unicode pKeyTABLE[]
Definition: difimp.cxx:35
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
Definition: difimp.cxx:649
DifColumn()
Definition: difimp.cxx:610
sal_uInt32 nNumFormat
Definition: dif.hxx:66
static bool IsEOD(const sal_Unicode *pRef)
Definition: dif.hxx:100
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
Definition: difimp.cxx:582
void Apply(ScDocument &, SCTAB nTab)
Definition: difimp.cxx:685
sal_Int16 SCTAB
Definition: types.hxx:23
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
Definition: difimp.cxx:397
Definition: dif.hxx:54
double fVal
Definition: dif.hxx:63
bool ReadNextLine(OUString &rStr)
Definition: difimp.cxx:417