Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / excel / frmbase.cxx
blob35bba553997e886e4269ea2ef16286539fad672f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <formel.hxx>
22 #include <osl/diagnose.h>
24 ScRangeListTabs::ScRangeListTabs()
28 ScRangeListTabs::~ScRangeListTabs()
32 void ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab )
34 ScAddress a = aSRD;
36 if (a.Tab() > MAXTAB)
37 a.SetTab(MAXTAB);
39 if (a.Col() > MAXCOL)
40 a.SetCol(MAXCOL);
42 if (a.Row() > MAXROW)
43 a.SetRow(MAXROW);
45 if( nTab == SCTAB_MAX)
46 return;
47 if( nTab < 0)
48 nTab = a.Tab();
50 if (nTab < 0 || MAXTAB < nTab)
51 return;
53 TabRangeType::iterator itr = m_TabRanges.find(nTab);
54 if (itr == m_TabRanges.end())
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>()));
60 if (!r.second)
61 // Insertion failed.
62 return;
64 itr = r.first;
66 itr->second->push_back(ScRange(a.Col(),a.Row(),a.Tab()));
69 void ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab )
71 ScRange a = aCRD;
73 // ignore 3D ranges
74 if (a.aStart.Tab() != a.aEnd.Tab())
75 return;
77 if (a.aStart.Tab() > MAXTAB)
78 a.aStart.SetTab(MAXTAB);
79 else if (a.aStart.Tab() < 0)
80 a.aStart.SetTab(0);
82 if (a.aStart.Col() > MAXCOL)
83 a.aStart.SetCol(MAXCOL);
84 else if (a.aStart.Col() < 0)
85 a.aStart.SetCol(0);
87 if (a.aStart.Row() > MAXROW)
88 a.aStart.SetRow(MAXROW);
89 else if (a.aStart.Row() < 0)
90 a.aStart.SetRow(0);
92 if (a.aEnd.Col() > MAXCOL)
93 a.aEnd.SetCol(MAXCOL);
94 else if (a.aEnd.Col() < 0)
95 a.aEnd.SetCol(0);
97 if (a.aEnd.Row() > MAXROW)
98 a.aEnd.SetRow(MAXROW);
99 else if (a.aEnd.Row() < 0)
100 a.aEnd.SetRow(0);
102 if( nTab == SCTAB_MAX)
103 return;
105 if( nTab < -1)
106 nTab = a.aStart.Tab();
108 if (nTab < 0 || MAXTAB < nTab)
109 return;
111 TabRangeType::iterator itr = m_TabRanges.find(nTab);
112 if (itr == m_TabRanges.end())
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>()));
118 if (!r.second)
119 // Insertion failed.
120 return;
122 itr = r.first;
124 itr->second->push_back(a);
127 const ScRange* ScRangeListTabs::First( SCTAB n )
129 OSL_ENSURE( ValidTab(n), "-ScRangeListTabs::First(): Good bye!" );
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;
136 const RangeListType& rList = *itr->second;
137 maItrCur = rList.begin();
138 maItrCurEnd = rList.end();
139 return rList.empty() ? nullptr : &(*maItrCur);
142 const ScRange* ScRangeListTabs::Next ()
144 ++maItrCur;
145 if (maItrCur == maItrCurEnd)
146 return nullptr;
148 return &(*maItrCur);
151 ConverterBase::ConverterBase( svl::SharedStringPool& rSPool ) :
152 aPool(rSPool),
153 aEingPos( 0, 0, 0 )
157 ConverterBase::~ConverterBase()
161 void ConverterBase::Reset()
163 aPool.Reset();
164 aStack.Reset();
167 ExcelConverterBase::ExcelConverterBase( svl::SharedStringPool& rSPool ) :
168 ConverterBase(rSPool)
172 ExcelConverterBase::~ExcelConverterBase()
176 void ExcelConverterBase::Reset( const ScAddress& rEingPos )
178 ConverterBase::Reset();
179 aEingPos = rEingPos;
182 void ExcelConverterBase::Reset()
184 ConverterBase::Reset();
185 aEingPos.Set( 0, 0, 0 );
188 LotusConverterBase::LotusConverterBase( SvStream &rStr, svl::SharedStringPool& rSPool ) :
189 ConverterBase(rSPool),
190 aIn( rStr ),
191 nBytesLeft( 0 )
195 LotusConverterBase::~LotusConverterBase()
199 void LotusConverterBase::Reset( const ScAddress& rEingPos )
201 ConverterBase::Reset();
202 nBytesLeft = 0;
203 aEingPos = rEingPos;
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */