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