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 #pragma once
21 
22 #include <map>
23 #include <memory>
24 #include <vector>
25 
26 #include <rtl/ustring.hxx>
27 #include <rtl/ustrbuf.hxx>
28 
29 #include <types.hxx>
30 
31 class SvStream;
32 class SvNumberFormatter;
33 class ScDocument;
34 
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[];
46 
47 enum TOPIC
48 {
54 };
55 
57 
58 class DifParser
59 {
60 public:
61  OUStringBuffer m_aData;
62  double fVal;
63  sal_uInt32 nVector;
64  sal_uInt32 nVal;
65  sal_uInt32 nNumFormat;
66 private:
69  OUString aLookAheadLine;
70 
71  bool ReadNextLine( OUString& rStr );
72  bool LookAhead();
73  DATASET GetNumberDataset( const sal_Unicode* pPossibleNumericData );
74  static inline bool IsBOT( const sal_Unicode* pRef );
75  static inline bool IsEOD( const sal_Unicode* pRef );
76  static inline bool Is1_0( const sal_Unicode* pRef );
77 public:
78  DifParser( SvStream&, const ScDocument&, rtl_TextEncoding );
79 
81 
83 
84  static const sal_Unicode* ScanIntVal( const sal_Unicode* pStart, sal_uInt32& rRet );
85 
86  static inline bool IsNumber( const sal_Unicode cChar );
87 
88  static inline bool IsV( const sal_Unicode* pRef );
89 };
90 
91 inline bool DifParser::IsBOT( const sal_Unicode* pRef )
92 {
93  return ( pRef[ 0 ] == pKeyBOT[0] &&
94  pRef[ 1 ] == pKeyBOT[1] &&
95  pRef[ 2 ] == pKeyBOT[2] &&
96  pRef[ 3 ] == pKeyBOT[3] );
97 }
98 
99 inline bool DifParser::IsEOD( const sal_Unicode* pRef )
100 {
101  return ( pRef[ 0 ] == pKeyEOD[0] &&
102  pRef[ 1 ] == pKeyEOD[1] &&
103  pRef[ 2 ] == pKeyEOD[2] &&
104  pRef[ 3 ] == pKeyEOD[3] );
105 }
106 
107 inline bool DifParser::Is1_0( const sal_Unicode* pRef )
108 {
109  return ( pRef[ 0 ] == pKey1_0[0] &&
110  pRef[ 1 ] == pKey1_0[1] &&
111  pRef[ 2 ] == pKey1_0[2] &&
112  pRef[ 3 ] == pKey1_0[3] );
113 }
114 
115 inline bool DifParser::IsV( const sal_Unicode* pRef )
116 {
117  return ( pRef[ 0 ] == pKeyV[0] &&
118  pRef[ 1 ] == pKeyV[1] );
119 }
120 
121 inline bool DifParser::IsNumber( const sal_Unicode cChar )
122 {
123  return ( cChar >= '0' && cChar <= '9' );
124 }
125 
127 {
128  friend class DifAttrCache;
129 
130  struct ENTRY
131  {
132  sal_uInt32 nNumFormat;
135  };
136 
138  std::vector<ENTRY> maEntries;
139 
140  DifColumn();
141 
142  void SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat );
143 
144  void NewEntry( const SCROW nPos, const sal_uInt32 nNumFormat );
145 
146  void Apply( ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab );
147 };
148 
150 {
151 public:
152 
153  DifAttrCache();
154 
155  ~DifAttrCache();
156 
157  void SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat );
158 
159  void Apply( ScDocument&, SCTAB nTab );
160 
161 private:
162 
163  std::map<SCCOL, std::unique_ptr<DifColumn>> maColMap;
164 };
165 
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsBOT(const sal_Unicode *pRef)
Definition: dif.hxx:91
TOPIC GetNextTopic()
Definition: difimp.cxx:244
Definition: dif.hxx:50
DATASET
Definition: dif.hxx:56
OUStringBuffer m_aData
Definition: dif.hxx:61
static bool IsNumber(const sal_Unicode cChar)
Definition: dif.hxx:121
Definition: dif.hxx:51
const sal_Unicode pKey1_0[]
Definition: difimp.cxx:47
const sal_Unicode pKeyEOD[]
Definition: difimp.cxx:41
Definition: dif.hxx:56
std::vector< ENTRY > maEntries
Definition: dif.hxx:138
sal_uInt16 sal_Unicode
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:674
DATASET GetNextDataset()
Definition: difimp.cxx:472
Definition: dif.hxx:50
bool LookAhead()
Definition: difimp.cxx:434
SvStream & rIn
Definition: dif.hxx:68
SCROW nStart
Definition: dif.hxx:133
const sal_Unicode pKeyFALSE[]
Definition: difimp.cxx:44
static bool Is1_0(const sal_Unicode *pRef)
Definition: dif.hxx:107
TOPIC
Definition: dif.hxx:47
sal_uInt32 nVal
Definition: dif.hxx:64
sal_Int16 SCCOL
Definition: types.hxx:21
OUString aLookAheadLine
Definition: dif.hxx:69
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
Definition: dif.hxx:163
const sal_Unicode pKeyTUPLES[]
Definition: difimp.cxx:38
Definition: dif.hxx:50
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:614
sal_uInt32 nVector
Definition: dif.hxx:63
const sal_Unicode pKeyNA[]
Definition: difimp.cxx:45
static bool IsV(const sal_Unicode *pRef)
Definition: dif.hxx:115
const sal_Unicode pKeyDATA[]
Definition: difimp.cxx:39
const sal_Unicode pKeyVECTORS[]
Definition: difimp.cxx:37
Definition: dif.hxx:50
sal_Int32 SCROW
Definition: types.hxx:17
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:639
sal_uInt32 nNumFormat
Definition: dif.hxx:132
Definition: dif.hxx:56
ENTRY * mpCurrent
Definition: dif.hxx:137
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
Definition: difimp.cxx:228
const sal_Unicode pKeyBOT[]
Definition: difimp.cxx:40
const sal_Unicode pKeyTRUE[]
Definition: difimp.cxx:43
SvNumberFormatter * pNumFormatter
Definition: dif.hxx:67
Definition: dif.hxx:50
const sal_Unicode pKeyV[]
Definition: difimp.cxx:46
SCROW nEnd
Definition: dif.hxx:134
Definition: dif.hxx:56
const sal_Unicode pKeyTABLE[]
Definition: difimp.cxx:36
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
Definition: difimp.cxx:648
DifColumn()
Definition: difimp.cxx:609
sal_uInt32 nNumFormat
Definition: dif.hxx:65
static bool IsEOD(const sal_Unicode *pRef)
Definition: dif.hxx:99
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
Definition: difimp.cxx:581
void Apply(ScDocument &, SCTAB nTab)
Definition: difimp.cxx:684
sal_Int16 SCTAB
Definition: types.hxx:22
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
Definition: difimp.cxx:398
Definition: dif.hxx:53
double fVal
Definition: dif.hxx:62
bool ReadNextLine(OUString &rStr)
Definition: difimp.cxx:418