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 <string_view>
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 std::u16string_view pKeyTABLE;
37 extern const std::u16string_view pKeyVECTORS;
38 extern const std::u16string_view pKeyTUPLES;
39 extern const std::u16string_view pKeyDATA;
40 extern const std::u16string_view pKeyBOT;
41 extern const std::u16string_view pKeyEOD;
42 
43 enum TOPIC
44 {
50 };
51 
53 
54 class DifParser
55 {
56 public:
57  OUStringBuffer m_aData;
58  double fVal;
59  sal_uInt32 nVector;
60  sal_uInt32 nVal;
61  sal_uInt32 nNumFormat;
62 private:
65  OUString aLookAheadLine;
66 
67  bool ReadNextLine( OUString& rStr );
68  bool LookAhead();
69  DATASET GetNumberDataset( const sal_Unicode* pPossibleNumericData );
70  static inline bool IsBOT( const sal_Unicode* pRef );
71  static inline bool IsEOD( const sal_Unicode* pRef );
72  static inline bool Is1_0( const sal_Unicode* pRef );
73 public:
74  DifParser( SvStream&, const ScDocument&, rtl_TextEncoding );
75 
77 
79 
80  static const sal_Unicode* ScanIntVal( const sal_Unicode* pStart, sal_uInt32& rRet );
81 
82  static inline bool IsNumber( const sal_Unicode cChar );
83 
84  static inline bool IsV( const sal_Unicode* pRef );
85 };
86 
87 inline bool DifParser::IsBOT( const sal_Unicode* pRef )
88 {
89  return pRef == pKeyBOT;
90 }
91 
92 inline bool DifParser::IsEOD( const sal_Unicode* pRef )
93 {
94  return pRef == pKeyEOD;
95 }
96 
97 inline bool DifParser::Is1_0( const sal_Unicode* pRef )
98 {
99  return pRef == std::u16string_view(u"1,0");
100 }
101 
102 inline bool DifParser::IsV( const sal_Unicode* pRef )
103 {
104  return pRef == std::u16string_view(u"V");
105 }
106 
107 inline bool DifParser::IsNumber( const sal_Unicode cChar )
108 {
109  return ( cChar >= '0' && cChar <= '9' );
110 }
111 
113 {
114  friend class DifAttrCache;
115 
116  struct ENTRY
117  {
118  sal_uInt32 nNumFormat;
121  };
122 
124  std::vector<ENTRY> maEntries;
125 
126  DifColumn();
127 
128  void SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat );
129 
130  void NewEntry( const SCROW nPos, const sal_uInt32 nNumFormat );
131 
132  void Apply( ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab );
133 };
134 
136 {
137 public:
138 
139  DifAttrCache();
140 
141  ~DifAttrCache();
142 
143  void SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat );
144 
145  void Apply( ScDocument&, SCTAB nTab );
146 
147 private:
148 
149  std::map<SCCOL, std::unique_ptr<DifColumn>> maColMap;
150 };
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsBOT(const sal_Unicode *pRef)
Definition: dif.hxx:87
TOPIC GetNextTopic()
Definition: difimp.cxx:236
Definition: dif.hxx:46
DATASET
Definition: dif.hxx:52
const std::u16string_view pKeyVECTORS
Definition: difimp.cxx:36
OUStringBuffer m_aData
Definition: dif.hxx:57
const std::u16string_view pKeyTUPLES
Definition: difimp.cxx:37
static bool IsNumber(const sal_Unicode cChar)
Definition: dif.hxx:107
Definition: dif.hxx:47
Definition: dif.hxx:52
const std::u16string_view pKeyTABLE
Definition: difimp.cxx:35
std::vector< ENTRY > maEntries
Definition: dif.hxx:124
sal_uInt16 sal_Unicode
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:655
DATASET GetNextDataset()
Definition: difimp.cxx:453
Definition: dif.hxx:46
bool LookAhead()
Definition: difimp.cxx:415
SvStream & rIn
Definition: dif.hxx:64
SCROW nStart
Definition: dif.hxx:119
static bool Is1_0(const sal_Unicode *pRef)
Definition: dif.hxx:97
TOPIC
Definition: dif.hxx:43
sal_uInt32 nVal
Definition: dif.hxx:60
sal_Int16 SCCOL
Definition: types.hxx:21
OUString aLookAheadLine
Definition: dif.hxx:65
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
Definition: dif.hxx:149
Definition: dif.hxx:46
float u
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:595
sal_uInt32 nVector
Definition: dif.hxx:59
static bool IsV(const sal_Unicode *pRef)
Definition: dif.hxx:102
const std::u16string_view pKeyDATA
Definition: difimp.cxx:38
Definition: dif.hxx:46
sal_Int32 SCROW
Definition: types.hxx:17
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:620
sal_uInt32 nNumFormat
Definition: dif.hxx:118
const std::u16string_view pKeyEOD
Definition: difimp.cxx:40
Definition: dif.hxx:52
ENTRY * mpCurrent
Definition: dif.hxx:123
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
Definition: difimp.cxx:220
const std::u16string_view pKeyBOT
Definition: difimp.cxx:39
SvNumberFormatter * pNumFormatter
Definition: dif.hxx:63
Definition: dif.hxx:46
SCROW nEnd
Definition: dif.hxx:120
Definition: dif.hxx:52
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
Definition: difimp.cxx:629
DifColumn()
Definition: difimp.cxx:590
sal_uInt32 nNumFormat
Definition: dif.hxx:61
static bool IsEOD(const sal_Unicode *pRef)
Definition: dif.hxx:92
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
Definition: difimp.cxx:562
void Apply(ScDocument &, SCTAB nTab)
Definition: difimp.cxx:665
sal_Int16 SCTAB
Definition: types.hxx:22
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
Definition: difimp.cxx:379
Definition: dif.hxx:49
double fVal
Definition: dif.hxx:58
bool ReadNextLine(OUString &rStr)
Definition: difimp.cxx:399