LibreOffice Module sc (master)  1
frmbase.cxx
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 #include <formel.hxx>
21 
22 #include <osl/diagnose.h>
23 
25 {
26 }
27 
29 {
30 }
31 
32 void ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab )
33 {
34  ScAddress a = aSRD;
35 
36  if (a.Tab() > MAXTAB)
37  a.SetTab(MAXTAB);
38 
39  if (a.Col() > MAXCOL)
40  a.SetCol(MAXCOL);
41 
42  if (a.Row() > MAXROW)
43  a.SetRow(MAXROW);
44 
45  if( nTab == SCTAB_MAX)
46  return;
47  if( nTab < 0)
48  nTab = a.Tab();
49 
50  if (nTab < 0 || MAXTAB < nTab)
51  return;
52 
53  TabRangeType::iterator itr = m_TabRanges.find(nTab);
54  if (itr == m_TabRanges.end())
55  {
56  // No entry for this table yet. Insert a new one.
57  std::pair<TabRangeType::iterator, bool> r =
58  m_TabRanges.insert(std::make_pair(nTab, std::make_unique<RangeListType>()));
59 
60  if (!r.second)
61  // Insertion failed.
62  return;
63 
64  itr = r.first;
65  }
66  itr->second->push_back(ScRange(a.Col(),a.Row(),a.Tab()));
67 }
68 
69 void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
70 {
71  ScRange a = aCRD;
72 
73  // ignore 3D ranges
74  if (a.aStart.Tab() != a.aEnd.Tab())
75  return;
76 
77  if (a.aStart.Tab() > MAXTAB)
78  a.aStart.SetTab(MAXTAB);
79  else if (a.aStart.Tab() < 0)
80  a.aStart.SetTab(0);
81 
82  if (a.aStart.Col() > MAXCOL)
83  a.aStart.SetCol(MAXCOL);
84  else if (a.aStart.Col() < 0)
85  a.aStart.SetCol(0);
86 
87  if (a.aStart.Row() > MAXROW)
88  a.aStart.SetRow(MAXROW);
89  else if (a.aStart.Row() < 0)
90  a.aStart.SetRow(0);
91 
92  if (a.aEnd.Col() > MAXCOL)
93  a.aEnd.SetCol(MAXCOL);
94  else if (a.aEnd.Col() < 0)
95  a.aEnd.SetCol(0);
96 
97  if (a.aEnd.Row() > MAXROW)
98  a.aEnd.SetRow(MAXROW);
99  else if (a.aEnd.Row() < 0)
100  a.aEnd.SetRow(0);
101 
102  if( nTab == SCTAB_MAX)
103  return;
104 
105  if( nTab < -1)
106  nTab = a.aStart.Tab();
107 
108  if (nTab < 0 || MAXTAB < nTab)
109  return;
110 
111  TabRangeType::iterator itr = m_TabRanges.find(nTab);
112  if (itr == m_TabRanges.end())
113  {
114  // No entry for this table yet. Insert a new one.
115  std::pair<TabRangeType::iterator, bool> r =
116  m_TabRanges.insert(std::make_pair(nTab, std::make_unique<RangeListType>()));
117 
118  if (!r.second)
119  // Insertion failed.
120  return;
121 
122  itr = r.first;
123  }
124  itr->second->push_back(a);
125 }
126 
128 {
129  OSL_ENSURE( ValidTab(n), "-ScRangeListTabs::First(): Good bye!" );
130 
131  TabRangeType::iterator itr = m_TabRanges.find(n);
132  if (itr == m_TabRanges.end())
133  // No range list exists for this table.
134  return nullptr;
135 
136  const RangeListType& rList = *itr->second;
137  maItrCur = rList.begin();
138  maItrCurEnd = rList.end();
139  return rList.empty() ? nullptr : &(*maItrCur);
140 }
141 
143 {
144  ++maItrCur;
145  if (maItrCur == maItrCurEnd)
146  return nullptr;
147 
148  return &(*maItrCur);
149 }
150 
152  aPool(rSPool),
153  aEingPos( 0, 0, 0 )
154 {
155 }
156 
158 {
159 }
160 
162 {
163  aPool.Reset();
164  aStack.Reset();
165 }
166 
168  ConverterBase(rSPool)
169 {
170 }
171 
173 {
174 }
175 
176 void ExcelConverterBase::Reset( const ScAddress& rEingPos )
177 {
179  aEingPos = rEingPos;
180 }
181 
183 {
185  aEingPos.Set( 0, 0, 0 );
186 }
187 
189  ConverterBase(rSPool),
190  aIn( rStr ),
191  nBytesLeft( 0 )
192 {
193 }
194 
196 {
197 }
198 
199 void LotusConverterBase::Reset( const ScAddress& rEingPos )
200 {
202  nBytesLeft = 0;
203  aEingPos = rEingPos;
204 }
205 
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
LotusConverterBase(SvStream &rStr, svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:188
ScAddress aStart
Definition: address.hxx:500
SCROW Row() const
Definition: address.hxx:262
ScAddress aEnd
Definition: address.hxx:501
virtual ~LotusConverterBase() override
Definition: frmbase.cxx:195
ScAddress aEingPos
Definition: formel.hxx:81
virtual ~ExcelConverterBase() override
Definition: frmbase.cxx:172
::std::vector< ScRange > RangeListType
Definition: formel.hxx:57
const SCROW MAXROW
Definition: address.hxx:69
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
const ScRange * Next()
Definition: frmbase.cxx:142
TabRangeType m_TabRanges
Definition: formel.hxx:59
void SetCol(SCCOL nColP)
Definition: address.hxx:279
void Reset()
Definition: tokstack.hxx:328
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
uno_Any a
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:406
const ScRange * First(SCTAB nTab)
Definition: frmbase.cxx:127
const SCCOL MAXCOL
Definition: address.hxx:70
const SCTAB MAXTAB
Definition: address.hxx:71
RangeListType::const_iterator maItrCur
Definition: formel.hxx:60
SCCOL Col() const
Definition: address.hxx:267
TokenPool aPool
Definition: formel.hxx:79
virtual ~ConverterBase()
Definition: frmbase.cxx:157
TokenStack aStack
Definition: formel.hxx:80
void Append(const ScAddress &aSRD, SCTAB nTab)
Definition: frmbase.cxx:32
ConverterBase(svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:151
void Reset()
Definition: frmbase.cxx:161
ExcelConverterBase(svl::SharedStringPool &rSPool)
Definition: frmbase.cxx:167
void Reset()
Definition: tokstack.cxx:675
sal_Int32 nBytesLeft
Definition: formel.hxx:109
const SCTAB SCTAB_MAX
Definition: address.hxx:58
RangeListType::const_iterator maItrCurEnd
Definition: formel.hxx:61
bool ValidTab(SCTAB nTab)
Definition: address.hxx:105
sal_Int16 SCTAB
Definition: types.hxx:23