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
32class SvStream;
34class ScDocument;
35
36extern const std::u16string_view pKeyTABLE;
37extern const std::u16string_view pKeyVECTORS;
38extern const std::u16string_view pKeyTUPLES;
39extern const std::u16string_view pKeyDATA;
40extern const std::u16string_view pKeyBOT;
41extern const std::u16string_view pKeyEOD;
42
44{
49 T_END
50};
51
53
55{
56public:
57 OUStringBuffer m_aData;
58 double fVal;
59 sal_uInt32 nVector;
60 sal_uInt32 nVal;
61 sal_uInt32 nNumFormat;
62private:
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 );
73public:
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
87inline bool DifParser::IsBOT( const sal_Unicode* pRef )
88{
89 return pRef == pKeyBOT;
90}
91
92inline bool DifParser::IsEOD( const sal_Unicode* pRef )
93{
94 return pRef == pKeyEOD;
95}
96
97inline bool DifParser::Is1_0( const sal_Unicode* pRef )
98{
99 return pRef == std::u16string_view(u"1,0");
100}
101
102inline bool DifParser::IsV( const sal_Unicode* pRef )
103{
104 return pRef == std::u16string_view(u"V");
105}
106
107inline 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{
137public:
138
139 DifAttrCache();
140
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
147private:
148
149 std::map<SCCOL, std::unique_ptr<DifColumn>> maColMap;
150};
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
Definition: dif.hxx:149
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:655
void Apply(ScDocument &, SCTAB nTab)
Definition: difimp.cxx:665
ENTRY * mpCurrent
Definition: dif.hxx:123
DifColumn()
Definition: difimp.cxx:590
std::vector< ENTRY > maEntries
Definition: dif.hxx:124
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:620
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:595
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
Definition: difimp.cxx:629
double fVal
Definition: dif.hxx:58
TOPIC GetNextTopic()
Definition: difimp.cxx:236
OUStringBuffer m_aData
Definition: dif.hxx:57
SvStream & rIn
Definition: dif.hxx:64
bool LookAhead()
Definition: difimp.cxx:415
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
Definition: difimp.cxx:379
static bool IsBOT(const sal_Unicode *pRef)
Definition: dif.hxx:87
sal_uInt32 nVector
Definition: dif.hxx:59
static bool Is1_0(const sal_Unicode *pRef)
Definition: dif.hxx:97
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
Definition: difimp.cxx:220
sal_uInt32 nVal
Definition: dif.hxx:60
static bool IsNumber(const sal_Unicode cChar)
Definition: dif.hxx:107
static bool IsEOD(const sal_Unicode *pRef)
Definition: dif.hxx:92
sal_uInt32 nNumFormat
Definition: dif.hxx:61
OUString aLookAheadLine
Definition: dif.hxx:65
bool ReadNextLine(OUString &rStr)
Definition: difimp.cxx:399
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
Definition: difimp.cxx:562
DATASET GetNextDataset()
Definition: difimp.cxx:453
static bool IsV(const sal_Unicode *pRef)
Definition: dif.hxx:102
SvNumberFormatter * pNumFormatter
Definition: dif.hxx:63
const std::u16string_view pKeyTABLE
Definition: difimp.cxx:35
const std::u16string_view pKeyVECTORS
Definition: difimp.cxx:36
const std::u16string_view pKeyTUPLES
Definition: difimp.cxx:37
const std::u16string_view pKeyDATA
Definition: difimp.cxx:38
const std::u16string_view pKeyEOD
Definition: difimp.cxx:40
TOPIC
Definition: dif.hxx:44
@ T_UINITS
Definition: dif.hxx:47
@ T_PERIODICITY
Definition: dif.hxx:47
@ T_TABLE
Definition: dif.hxx:46
@ T_TRUELENGTH
Definition: dif.hxx:47
@ T_TUPLES
Definition: dif.hxx:46
@ T_VECTORS
Definition: dif.hxx:46
@ T_LABEL
Definition: dif.hxx:46
@ T_END
Definition: dif.hxx:49
@ T_UNKNOWN
Definition: dif.hxx:45
@ T_MAJORSTART
Definition: dif.hxx:47
@ T_SIZE
Definition: dif.hxx:46
@ T_COMMENT
Definition: dif.hxx:46
@ T_DATA
Definition: dif.hxx:46
@ T_DISPLAYUNITS
Definition: dif.hxx:48
@ T_MINORSTART
Definition: dif.hxx:47
const std::u16string_view pKeyBOT
Definition: difimp.cxx:39
DATASET
Definition: dif.hxx:52
@ D_UNKNOWN
Definition: dif.hxx:52
@ D_EOD
Definition: dif.hxx:52
@ D_BOT
Definition: dif.hxx:52
@ D_SYNT_ERROR
Definition: dif.hxx:52
@ D_STRING
Definition: dif.hxx:52
@ D_NUMERIC
Definition: dif.hxx:52
float u
sal_uInt32 nNumFormat
Definition: dif.hxx:118
SCROW nEnd
Definition: dif.hxx:120
SCROW nStart
Definition: dif.hxx:119
sal_uInt16 sal_Unicode
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17