Line data Source code
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 :
21 : #include "formel.hxx"
22 :
23 0 : _ScRangeListTabs::_ScRangeListTabs()
24 : {
25 0 : }
26 :
27 0 : _ScRangeListTabs::~_ScRangeListTabs()
28 : {
29 0 : }
30 :
31 :
32 0 : void _ScRangeListTabs::Append( const ScAddress& aSRD, SCTAB nTab, const bool b )
33 : {
34 0 : ScAddress a = aSRD;
35 :
36 0 : if( b )
37 : {
38 0 : if (a.Tab() > MAXTAB)
39 0 : a.SetTab(MAXTAB);
40 :
41 0 : if (a.Col() > MAXCOL)
42 0 : a.SetCol(MAXCOL);
43 :
44 0 : if (a.Row() > MAXROW)
45 0 : a.SetRow(MAXROW);
46 : }
47 : else
48 : {
49 : OSL_ENSURE( ValidTab(a.Tab()), "-_ScRangeListTabs::Append(): A lie has no crash!" );
50 : }
51 :
52 0 : if( nTab == SCTAB_MAX)
53 0 : return;
54 0 : if( nTab < 0)
55 0 : nTab = a.Tab();
56 :
57 0 : if (nTab < 0 || MAXTAB < nTab)
58 0 : return;
59 :
60 0 : TabRangeType::iterator itr = maTabRanges.find(nTab);
61 0 : if (itr == maTabRanges.end())
62 : {
63 : // No entry for this table yet. Insert a new one.
64 : std::pair<TabRangeType::iterator, bool> r =
65 0 : maTabRanges.insert(nTab, new RangeListType);
66 :
67 0 : if (!r.second)
68 : // Insertion failed.
69 0 : return;
70 :
71 0 : itr = r.first;
72 : }
73 0 : itr->second->push_back(ScRange(a.Col(),a.Row(),a.Tab()));
74 : }
75 :
76 0 : void _ScRangeListTabs::Append( const ScRange& aCRD, SCTAB nTab, bool b )
77 : {
78 0 : ScRange a = aCRD;
79 :
80 0 : if( b )
81 : {
82 : // ignore 3D ranges
83 0 : if (a.aStart.Tab() != a.aEnd.Tab())
84 0 : return;
85 :
86 0 : if (a.aStart.Tab() > MAXTAB)
87 0 : a.aStart.SetTab(MAXTAB);
88 0 : else if (a.aStart.Tab() < 0)
89 0 : a.aStart.SetTab(0);
90 :
91 0 : if (a.aStart.Col() > MAXCOL)
92 0 : a.aStart.SetCol(MAXCOL);
93 0 : else if (a.aStart.Col() < 0)
94 0 : a.aStart.SetCol(0);
95 :
96 0 : if (a.aStart.Row() > MAXROW)
97 0 : a.aStart.SetRow(MAXROW);
98 0 : else if (a.aStart.Row() < 0)
99 0 : a.aStart.SetRow(0);
100 :
101 0 : if (a.aEnd.Col() > MAXCOL)
102 0 : a.aEnd.SetCol(MAXCOL);
103 0 : else if (a.aEnd.Col() < 0)
104 0 : a.aEnd.SetCol(0);
105 :
106 0 : if (a.aEnd.Row() > MAXROW)
107 0 : a.aEnd.SetRow(MAXROW);
108 0 : else if (a.aEnd.Row() < 0)
109 0 : a.aEnd.SetRow(0);
110 : }
111 : #if 0 // no members 'Ref1' or 'Ref2' in 'ScRange'
112 : else
113 : {
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!" );
118 : }
119 : #endif
120 :
121 0 : if( nTab == SCTAB_MAX)
122 0 : return;
123 :
124 0 : if( nTab < -1)
125 0 : nTab = a.aStart.Tab();
126 :
127 0 : if (nTab < 0 || MAXTAB < nTab)
128 0 : return;
129 :
130 0 : TabRangeType::iterator itr = maTabRanges.find(nTab);
131 0 : if (itr == maTabRanges.end())
132 : {
133 : // No entry for this table yet. Insert a new one.
134 : std::pair<TabRangeType::iterator, bool> r =
135 0 : maTabRanges.insert(nTab, new RangeListType);
136 :
137 0 : if (!r.second)
138 : // Insertion failed.
139 0 : return;
140 :
141 0 : itr = r.first;
142 : }
143 0 : itr->second->push_back(a);
144 : }
145 :
146 0 : const ScRange* _ScRangeListTabs::First( SCTAB n )
147 : {
148 : OSL_ENSURE( ValidTab(n), "-_ScRangeListTabs::First(): Good bye!" );
149 :
150 0 : TabRangeType::iterator itr = maTabRanges.find(n);
151 0 : if (itr == maTabRanges.end())
152 : // No range list exists for this table.
153 0 : return NULL;
154 :
155 0 : const RangeListType& rList = *itr->second;
156 0 : maItrCur = rList.begin();
157 0 : maItrCurEnd = rList.end();
158 0 : return rList.empty() ? NULL : &(*maItrCur);
159 : }
160 :
161 0 : const ScRange* _ScRangeListTabs::Next ()
162 : {
163 0 : ++maItrCur;
164 0 : if (maItrCur == maItrCurEnd)
165 0 : return NULL;
166 :
167 0 : return &(*maItrCur);
168 : }
169 :
170 0 : ConverterBase::ConverterBase( sal_uInt16 nNewBuffer ) :
171 : aEingPos( 0, 0, 0 ),
172 : eStatus( ConvOK ),
173 0 : nBufferSize( nNewBuffer )
174 : {
175 : OSL_ENSURE( nNewBuffer > 0, "ConverterBase::ConverterBase - nNewBuffer == 0!" );
176 0 : pBuffer = new sal_Char[ nNewBuffer ];
177 0 : }
178 :
179 0 : ConverterBase::~ConverterBase()
180 : {
181 0 : delete[] pBuffer;
182 0 : }
183 :
184 0 : void ConverterBase::Reset()
185 : {
186 0 : eStatus = ConvOK;
187 0 : aPool.Reset();
188 0 : aStack.Reset();
189 0 : }
190 :
191 :
192 0 : ExcelConverterBase::ExcelConverterBase( sal_uInt16 nNewBuffer ) :
193 0 : ConverterBase( nNewBuffer )
194 : {
195 0 : }
196 :
197 0 : ExcelConverterBase::~ExcelConverterBase()
198 : {
199 0 : }
200 :
201 0 : void ExcelConverterBase::Reset( const ScAddress& rEingPos )
202 : {
203 0 : ConverterBase::Reset();
204 0 : aEingPos = rEingPos;
205 0 : }
206 :
207 0 : void ExcelConverterBase::Reset()
208 : {
209 0 : ConverterBase::Reset();
210 0 : aEingPos.Set( 0, 0, 0 );
211 0 : }
212 :
213 :
214 0 : LotusConverterBase::LotusConverterBase( SvStream &rStr, sal_uInt16 nNewBuffer ) :
215 : ConverterBase( nNewBuffer ),
216 : aIn( rStr ),
217 0 : nBytesLeft( 0 )
218 : {
219 0 : }
220 :
221 0 : LotusConverterBase::~LotusConverterBase()
222 : {
223 0 : }
224 :
225 0 : void LotusConverterBase::Reset( const ScAddress& rEingPos )
226 : {
227 0 : ConverterBase::Reset();
228 0 : nBytesLeft = 0;
229 0 : aEingPos = rEingPos;
230 0 : }
231 :
232 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|