xref: /aoo41x/main/sc/source/filter/excel/frmbase.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "formel.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
~_ScRangeList()35cdf0e10cSrcweir _ScRangeList::~_ScRangeList()
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 	ScRange*	p = ( ScRange* ) First();
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 	while( p )
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir 		delete p;
42cdf0e10cSrcweir 		p = ( ScRange* ) Next();
43cdf0e10cSrcweir 	}
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 
_ScRangeListTabs(void)49cdf0e10cSrcweir _ScRangeListTabs::_ScRangeListTabs( void )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	ppTabLists = new _ScRangeList*[ MAXTAB + 1 ];
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	for( sal_uInt16 n = 0 ; n <= MAXTAB ; n++ )
54cdf0e10cSrcweir 		ppTabLists[ n ] = NULL;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	bHasRanges = sal_False;
57cdf0e10cSrcweir 	pAct = NULL;
58cdf0e10cSrcweir 	nAct = 0;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
~_ScRangeListTabs()62cdf0e10cSrcweir _ScRangeListTabs::~_ScRangeListTabs()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	if( bHasRanges )
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 		for( sal_uInt16 n = 0 ; n <= MAXTAB ; n++ )
67cdf0e10cSrcweir 		{
68cdf0e10cSrcweir 			if( ppTabLists[ n ] )
69cdf0e10cSrcweir 				delete ppTabLists[ n ];
70cdf0e10cSrcweir 		}
71cdf0e10cSrcweir 	}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	delete[] ppTabLists;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
Append(ScSingleRefData a,const sal_Bool b)77cdf0e10cSrcweir void _ScRangeListTabs::Append( ScSingleRefData a, const sal_Bool b )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	if( b )
80cdf0e10cSrcweir 	{
81cdf0e10cSrcweir 		if( a.nTab > MAXTAB )
82cdf0e10cSrcweir 			a.nTab = MAXTAB;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 		if( a.nCol > MAXCOL )
85cdf0e10cSrcweir 			a.nCol = MAXCOL;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		if( a.nRow > MAXROW )
88cdf0e10cSrcweir 			a.nRow = MAXROW;
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 	else
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir 		DBG_ASSERT( ValidTab(a.nTab), "-_ScRangeListTabs::Append(): Luegen haben kurze Abstuerze!" );
93cdf0e10cSrcweir 	}
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	bHasRanges = sal_True;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     if( a.nTab >= 0 )
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         _ScRangeList*   p = ppTabLists[ a.nTab ];
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         if( !p )
102cdf0e10cSrcweir             p = ppTabLists[ a.nTab ] = new _ScRangeList;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         p->Append( a );
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
Append(ScComplexRefData a,const sal_Bool b)109cdf0e10cSrcweir void _ScRangeListTabs::Append( ScComplexRefData a, const sal_Bool b )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	if( b )
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir         // #96263# ignore 3D ranges
114cdf0e10cSrcweir         if( a.Ref1.nTab != a.Ref2.nTab )
115cdf0e10cSrcweir             return;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		SCsTAB&	rTab = a.Ref1.nTab;
118cdf0e10cSrcweir 		if( rTab > MAXTAB )
119cdf0e10cSrcweir 			rTab = MAXTAB;
120cdf0e10cSrcweir 		else if( rTab < 0 )
121cdf0e10cSrcweir 			rTab = 0;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		SCsCOL&	rCol1 = a.Ref1.nCol;
124cdf0e10cSrcweir 		if( rCol1 > MAXCOL )
125cdf0e10cSrcweir 			rCol1 = MAXCOL;
126cdf0e10cSrcweir 		else if( rCol1 < 0 )
127cdf0e10cSrcweir 			rCol1 = 0;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		SCsROW&	rRow1 = a.Ref1.nRow;
130cdf0e10cSrcweir 		if( rRow1 > MAXROW )
131cdf0e10cSrcweir 			rRow1 = MAXROW;
132cdf0e10cSrcweir 		else if( rRow1 < 0 )
133cdf0e10cSrcweir 			rRow1 = 0;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		SCsCOL&	rCol2 = a.Ref2.nCol;
136cdf0e10cSrcweir 		if( rCol2 > MAXCOL )
137cdf0e10cSrcweir 			rCol2 = MAXCOL;
138cdf0e10cSrcweir 		else if( rCol2 < 0 )
139cdf0e10cSrcweir 			rCol2 = 0;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		SCsROW&	rRow2 = a.Ref2.nRow;
142cdf0e10cSrcweir 		if( rRow2 > MAXROW )
143cdf0e10cSrcweir 			rRow2 = MAXROW;
144cdf0e10cSrcweir 		else if( rRow2 < 0 )
145cdf0e10cSrcweir 			rRow2 = 0;
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 	else
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir 		DBG_ASSERT( ValidTab(a.Ref1.nTab),
150cdf0e10cSrcweir 			"-_ScRangeListTabs::Append(): Luegen haben kurze Abstuerze!" );
151cdf0e10cSrcweir 		DBG_ASSERT( a.Ref1.nTab == a.Ref2.nTab,
152cdf0e10cSrcweir 			"+_ScRangeListTabs::Append(): 3D-Ranges werden in SC nicht unterstuetzt!" );
153cdf0e10cSrcweir 	}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	bHasRanges = sal_True;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     if( a.Ref1.nTab >= 0 )
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         _ScRangeList*   p = ppTabLists[ a.Ref1.nTab ];
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         if( !p )
162cdf0e10cSrcweir             p = ppTabLists[ a.Ref1.nTab ] = new _ScRangeList;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         p->Append( a );
165cdf0e10cSrcweir     }
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
First(const sal_uInt16 n)169cdf0e10cSrcweir const ScRange* _ScRangeListTabs::First( const sal_uInt16 n )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	DBG_ASSERT( ValidTab(n), "-_ScRangeListTabs::First(): Und tschuessssssss!" );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	if( ppTabLists[ n ] )
174cdf0e10cSrcweir 	{
175cdf0e10cSrcweir 		pAct = ppTabLists[ n ];
176cdf0e10cSrcweir 		nAct = n;
177cdf0e10cSrcweir 		return pAct->First();
178cdf0e10cSrcweir 	}
179cdf0e10cSrcweir 	else
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		pAct = NULL;
182cdf0e10cSrcweir 		nAct = 0;
183cdf0e10cSrcweir 		return NULL;
184cdf0e10cSrcweir 	}
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
Next(void)188cdf0e10cSrcweir const ScRange* _ScRangeListTabs::Next( void )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	if( pAct )
191cdf0e10cSrcweir 		return pAct->Next();
192cdf0e10cSrcweir 	else
193cdf0e10cSrcweir 		return NULL;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
ConverterBase(sal_uInt16 nNewBuffer)199cdf0e10cSrcweir ConverterBase::ConverterBase( sal_uInt16 nNewBuffer ) :
200cdf0e10cSrcweir 	aEingPos( 0, 0, 0 ),
201cdf0e10cSrcweir     eStatus( ConvOK ),
202cdf0e10cSrcweir     nBufferSize( nNewBuffer )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir 	DBG_ASSERT( nNewBuffer > 0, "ConverterBase::ConverterBase - nNewBuffer == 0!" );
205cdf0e10cSrcweir 	pBuffer = new sal_Char[ nNewBuffer ];
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
~ConverterBase()208cdf0e10cSrcweir ConverterBase::~ConverterBase()
209cdf0e10cSrcweir {
210cdf0e10cSrcweir 	delete[] pBuffer;
211cdf0e10cSrcweir }
212cdf0e10cSrcweir 
Reset()213cdf0e10cSrcweir void ConverterBase::Reset()
214cdf0e10cSrcweir {
215cdf0e10cSrcweir 	eStatus = ConvOK;
216cdf0e10cSrcweir 	aPool.Reset();
217cdf0e10cSrcweir 	aStack.Reset();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 
ExcelConverterBase(sal_uInt16 nNewBuffer)223cdf0e10cSrcweir ExcelConverterBase::ExcelConverterBase( sal_uInt16 nNewBuffer ) :
224cdf0e10cSrcweir     ConverterBase( nNewBuffer )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
~ExcelConverterBase()228cdf0e10cSrcweir ExcelConverterBase::~ExcelConverterBase()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
Reset(const ScAddress & rEingPos)232cdf0e10cSrcweir void ExcelConverterBase::Reset( const ScAddress& rEingPos )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	ConverterBase::Reset();
235cdf0e10cSrcweir     aEingPos = rEingPos;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
Reset()238cdf0e10cSrcweir void ExcelConverterBase::Reset()
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	ConverterBase::Reset();
241cdf0e10cSrcweir 	aEingPos.Set( 0, 0, 0 );
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 
LotusConverterBase(SvStream & rStr,sal_uInt16 nNewBuffer)247cdf0e10cSrcweir LotusConverterBase::LotusConverterBase( SvStream &rStr, sal_uInt16 nNewBuffer ) :
248cdf0e10cSrcweir 	ConverterBase( nNewBuffer ),
249cdf0e10cSrcweir 	aIn( rStr ),
250cdf0e10cSrcweir 	nBytesLeft( 0 )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
~LotusConverterBase()254cdf0e10cSrcweir LotusConverterBase::~LotusConverterBase()
255cdf0e10cSrcweir {
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir //UNUSED2008-05  void LotusConverterBase::Reset( sal_Int32 nLen, const ScAddress& rEingPos )
259cdf0e10cSrcweir //UNUSED2008-05  {
260cdf0e10cSrcweir //UNUSED2008-05      ConverterBase::Reset();
261cdf0e10cSrcweir //UNUSED2008-05      nBytesLeft = nLen;
262cdf0e10cSrcweir //UNUSED2008-05      aEingPos = rEingPos;
263cdf0e10cSrcweir //UNUSED2008-05  }
264cdf0e10cSrcweir //UNUSED2008-05
265cdf0e10cSrcweir //UNUSED2008-05  void LotusConverterBase::Reset( sal_Int32 nLen )
266cdf0e10cSrcweir //UNUSED2008-05  {
267cdf0e10cSrcweir //UNUSED2008-05      ConverterBase::Reset();
268cdf0e10cSrcweir //UNUSED2008-05      nBytesLeft = nLen;
269cdf0e10cSrcweir //UNUSED2008-05      aEingPos.Set( 0, 0, 0 );
270cdf0e10cSrcweir //UNUSED2008-05  }
271cdf0e10cSrcweir 
Reset(const ScAddress & rEingPos)272cdf0e10cSrcweir void LotusConverterBase::Reset( const ScAddress& rEingPos )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	ConverterBase::Reset();
275cdf0e10cSrcweir 	nBytesLeft = 0;
276cdf0e10cSrcweir     aEingPos = rEingPos;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279