bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / filter / excel / frmbase.cxx
blob936f41d9a3ffc62a11cfbc74cbda383172a183d8
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 .
21 #include "formel.hxx"
23 _ScRangeListTabs::_ScRangeListTabs()
27 _ScRangeListTabs::~_ScRangeListTabs()
32 void _ScRangeListTabs::Append( ScSingleRefData a, SCTAB nTab, const bool b )
34 if( b )
36 if( a.nTab > MAXTAB )
37 a.nTab = MAXTAB;
39 if( a.nCol > MAXCOL )
40 a.nCol = MAXCOL;
42 if( a.nRow > MAXROW )
43 a.nRow = MAXROW;
45 else
47 OSL_ENSURE( ValidTab(a.nTab), "-_ScRangeListTabs::Append(): A lie has no crash!" );
50 if( nTab == SCTAB_MAX)
51 return;
52 if( nTab < 0)
53 nTab = a.nTab;
55 if (nTab < 0 || MAXTAB < nTab)
56 return;
58 TabRangeType::iterator itr = maTabRanges.find(nTab);
59 if (itr == maTabRanges.end())
61 // No entry for this table yet. Insert a new one.
62 std::pair<TabRangeType::iterator, bool> r =
63 maTabRanges.insert(nTab, new RangeListType);
65 if (!r.second)
66 // Insertion failed.
67 return;
69 itr = r.first;
71 itr->second->push_back(ScRange(a.nCol,a.nRow,a.nTab));
74 void _ScRangeListTabs::Append( ScComplexRefData a, SCTAB nTab, bool b )
76 if( b )
78 // ignore 3D ranges
79 if( a.Ref1.nTab != a.Ref2.nTab )
80 return;
82 SCsTAB& rTab = a.Ref1.nTab;
83 if( rTab > MAXTAB )
84 rTab = MAXTAB;
85 else if( rTab < 0 )
86 rTab = 0;
88 SCsCOL& rCol1 = a.Ref1.nCol;
89 if( rCol1 > MAXCOL )
90 rCol1 = MAXCOL;
91 else if( rCol1 < 0 )
92 rCol1 = 0;
94 SCsROW& rRow1 = a.Ref1.nRow;
95 if( rRow1 > MAXROW )
96 rRow1 = MAXROW;
97 else if( rRow1 < 0 )
98 rRow1 = 0;
100 SCsCOL& rCol2 = a.Ref2.nCol;
101 if( rCol2 > MAXCOL )
102 rCol2 = MAXCOL;
103 else if( rCol2 < 0 )
104 rCol2 = 0;
106 SCsROW& rRow2 = a.Ref2.nRow;
107 if( rRow2 > MAXROW )
108 rRow2 = MAXROW;
109 else if( rRow2 < 0 )
110 rRow2 = 0;
112 else
114 OSL_ENSURE( ValidTab(a.Ref1.nTab),
115 "-_ScRangeListTabs::Append(): Luegen haben kurze Abstuerze!" );
116 OSL_ENSURE( a.Ref1.nTab == a.Ref2.nTab,
117 "+_ScRangeListTabs::Append(): 3D-Ranges werden in SC nicht unterstuetzt!" );
120 if( nTab == SCTAB_MAX)
121 return;
123 if( nTab < -1)
124 nTab = a.Ref1.nTab;
126 if (nTab < 0 || MAXTAB < nTab)
127 return;
129 TabRangeType::iterator itr = maTabRanges.find(nTab);
130 if (itr == maTabRanges.end())
132 // No entry for this table yet. Insert a new one.
133 std::pair<TabRangeType::iterator, bool> r =
134 maTabRanges.insert(nTab, new RangeListType);
136 if (!r.second)
137 // Insertion failed.
138 return;
140 itr = r.first;
142 itr->second->push_back(
143 ScRange(a.Ref1.nCol,a.Ref1.nRow,a.Ref1.nTab,
144 a.Ref2.nCol,a.Ref2.nRow,a.Ref2.nTab));
147 const ScRange* _ScRangeListTabs::First( SCTAB n )
149 OSL_ENSURE( ValidTab(n), "-_ScRangeListTabs::First(): Good bye!" );
151 TabRangeType::iterator itr = maTabRanges.find(n);
152 if (itr == maTabRanges.end())
153 // No range list exists for this table.
154 return NULL;
156 const RangeListType& rList = *itr->second;
157 maItrCur = rList.begin();
158 maItrCurEnd = rList.end();
159 return rList.empty() ? NULL : &(*maItrCur);
162 const ScRange* _ScRangeListTabs::Next ()
164 ++maItrCur;
165 if (maItrCur == maItrCurEnd)
166 return NULL;
168 return &(*maItrCur);
171 ConverterBase::ConverterBase( sal_uInt16 nNewBuffer ) :
172 aEingPos( 0, 0, 0 ),
173 eStatus( ConvOK ),
174 nBufferSize( nNewBuffer )
176 OSL_ENSURE( nNewBuffer > 0, "ConverterBase::ConverterBase - nNewBuffer == 0!" );
177 pBuffer = new sal_Char[ nNewBuffer ];
180 ConverterBase::~ConverterBase()
182 delete[] pBuffer;
185 void ConverterBase::Reset()
187 eStatus = ConvOK;
188 aPool.Reset();
189 aStack.Reset();
195 ExcelConverterBase::ExcelConverterBase( sal_uInt16 nNewBuffer ) :
196 ConverterBase( nNewBuffer )
200 ExcelConverterBase::~ExcelConverterBase()
204 void ExcelConverterBase::Reset( const ScAddress& rEingPos )
206 ConverterBase::Reset();
207 aEingPos = rEingPos;
210 void ExcelConverterBase::Reset()
212 ConverterBase::Reset();
213 aEingPos.Set( 0, 0, 0 );
219 LotusConverterBase::LotusConverterBase( SvStream &rStr, sal_uInt16 nNewBuffer ) :
220 ConverterBase( nNewBuffer ),
221 aIn( rStr ),
222 nBytesLeft( 0 )
226 LotusConverterBase::~LotusConverterBase()
230 void LotusConverterBase::Reset( const ScAddress& rEingPos )
232 ConverterBase::Reset();
233 nBytesLeft = 0;
234 aEingPos = rEingPos;
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */