Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svl/zforlist.hxx>
30 : : #include <rtl/math.hxx>
31 : :
32 : : #include <com/sun/star/uno/Any.hxx>
33 : : #include <com/sun/star/uno/Sequence.hxx>
34 : : #include <comphelper/string.hxx>
35 : : #include "rangeseq.hxx"
36 : : #include "document.hxx"
37 : : #include "dociter.hxx"
38 : : #include "scmatrix.hxx"
39 : : #include "cell.hxx"
40 : :
41 : : using namespace com::sun::star;
42 : :
43 : : //------------------------------------------------------------------------
44 : :
45 : 0 : bool lcl_HasErrors( ScDocument* pDoc, const ScRange& rRange )
46 : : {
47 : : // no need to look at empty cells - just use ScCellIterator
48 [ # # ]: 0 : ScCellIterator aIter( pDoc, rRange );
49 [ # # ]: 0 : ScBaseCell* pCell = aIter.GetFirst();
50 [ # # ]: 0 : while (pCell)
51 : : {
52 [ # # ][ # # ]: 0 : if ( pCell->GetCellType() == CELLTYPE_FORMULA && static_cast<ScFormulaCell*>(pCell)->GetErrCode() != 0 )
[ # # ][ # # ]
[ # # ]
53 : 0 : return true;
54 [ # # ]: 0 : pCell = aIter.GetNext();
55 : : }
56 : 0 : return false; // no error found
57 : : }
58 : :
59 : 0 : long lcl_DoubleToLong( double fVal )
60 : : {
61 : : double fInt = (fVal >= 0.0) ? ::rtl::math::approxFloor( fVal ) :
62 [ # # ]: 0 : ::rtl::math::approxCeil( fVal );
63 [ # # ][ # # ]: 0 : if ( fInt >= LONG_MIN && fInt <= LONG_MAX )
64 : 0 : return (long)fInt;
65 : : else
66 : 0 : return 0; // out of range
67 : : }
68 : :
69 : 0 : sal_Bool ScRangeToSequence::FillLongArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange )
70 : : {
71 : 0 : SCTAB nTab = rRange.aStart.Tab();
72 : 0 : SCCOL nStartCol = rRange.aStart.Col();
73 : 0 : SCROW nStartRow = rRange.aStart.Row();
74 : 0 : long nColCount = rRange.aEnd.Col() + 1 - rRange.aStart.Col();
75 : 0 : long nRowCount = rRange.aEnd.Row() + 1 - rRange.aStart.Row();
76 : :
77 [ # # ]: 0 : uno::Sequence< uno::Sequence<sal_Int32> > aRowSeq( nRowCount );
78 [ # # ]: 0 : uno::Sequence<sal_Int32>* pRowAry = aRowSeq.getArray();
79 [ # # ]: 0 : for (long nRow = 0; nRow < nRowCount; nRow++)
80 : : {
81 [ # # ]: 0 : uno::Sequence<sal_Int32> aColSeq( nColCount );
82 [ # # ]: 0 : sal_Int32* pColAry = aColSeq.getArray();
83 [ # # ]: 0 : for (long nCol = 0; nCol < nColCount; nCol++)
84 : 0 : pColAry[nCol] = lcl_DoubleToLong( pDoc->GetValue(
85 [ # # ]: 0 : ScAddress( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ) ) );
86 : :
87 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
88 [ # # ]: 0 : }
89 : :
90 [ # # ]: 0 : rAny <<= aRowSeq;
91 [ # # ][ # # ]: 0 : return !lcl_HasErrors( pDoc, rRange );
92 : : }
93 : :
94 : :
95 : 0 : sal_Bool ScRangeToSequence::FillLongArray( uno::Any& rAny, const ScMatrix* pMatrix )
96 : : {
97 [ # # ]: 0 : if (!pMatrix)
98 : 0 : return false;
99 : :
100 : : SCSIZE nColCount;
101 : : SCSIZE nRowCount;
102 [ # # ]: 0 : pMatrix->GetDimensions( nColCount, nRowCount );
103 : :
104 [ # # ]: 0 : uno::Sequence< uno::Sequence<sal_Int32> > aRowSeq( static_cast<sal_Int32>(nRowCount) );
105 [ # # ]: 0 : uno::Sequence<sal_Int32>* pRowAry = aRowSeq.getArray();
106 [ # # ]: 0 : for (SCSIZE nRow = 0; nRow < nRowCount; nRow++)
107 : : {
108 [ # # ]: 0 : uno::Sequence<sal_Int32> aColSeq( static_cast<sal_Int32>(nColCount) );
109 [ # # ]: 0 : sal_Int32* pColAry = aColSeq.getArray();
110 [ # # ]: 0 : for (SCSIZE nCol = 0; nCol < nColCount; nCol++)
111 [ # # ][ # # ]: 0 : if ( pMatrix->IsString( nCol, nRow ) )
112 : 0 : pColAry[nCol] = 0;
113 : : else
114 [ # # ]: 0 : pColAry[nCol] = lcl_DoubleToLong( pMatrix->GetDouble( nCol, nRow ) );
115 : :
116 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
117 [ # # ]: 0 : }
118 : :
119 [ # # ]: 0 : rAny <<= aRowSeq;
120 [ # # ]: 0 : return sal_True;
121 : : }
122 : :
123 : : //------------------------------------------------------------------------
124 : :
125 : 0 : sal_Bool ScRangeToSequence::FillDoubleArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange )
126 : : {
127 : 0 : SCTAB nTab = rRange.aStart.Tab();
128 : 0 : SCCOL nStartCol = rRange.aStart.Col();
129 : 0 : SCROW nStartRow = rRange.aStart.Row();
130 : 0 : long nColCount = rRange.aEnd.Col() + 1 - rRange.aStart.Col();
131 : 0 : long nRowCount = rRange.aEnd.Row() + 1 - rRange.aStart.Row();
132 : :
133 [ # # ]: 0 : uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
134 [ # # ]: 0 : uno::Sequence<double>* pRowAry = aRowSeq.getArray();
135 [ # # ]: 0 : for (long nRow = 0; nRow < nRowCount; nRow++)
136 : : {
137 [ # # ]: 0 : uno::Sequence<double> aColSeq( nColCount );
138 [ # # ]: 0 : double* pColAry = aColSeq.getArray();
139 [ # # ]: 0 : for (long nCol = 0; nCol < nColCount; nCol++)
140 : 0 : pColAry[nCol] = pDoc->GetValue(
141 [ # # ]: 0 : ScAddress( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ) );
142 : :
143 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
144 [ # # ]: 0 : }
145 : :
146 [ # # ]: 0 : rAny <<= aRowSeq;
147 [ # # ][ # # ]: 0 : return !lcl_HasErrors( pDoc, rRange );
148 : : }
149 : :
150 : :
151 : 0 : sal_Bool ScRangeToSequence::FillDoubleArray( uno::Any& rAny, const ScMatrix* pMatrix )
152 : : {
153 [ # # ]: 0 : if (!pMatrix)
154 : 0 : return false;
155 : :
156 : : SCSIZE nColCount;
157 : : SCSIZE nRowCount;
158 [ # # ]: 0 : pMatrix->GetDimensions( nColCount, nRowCount );
159 : :
160 [ # # ]: 0 : uno::Sequence< uno::Sequence<double> > aRowSeq( static_cast<sal_Int32>(nRowCount) );
161 [ # # ]: 0 : uno::Sequence<double>* pRowAry = aRowSeq.getArray();
162 [ # # ]: 0 : for (SCSIZE nRow = 0; nRow < nRowCount; nRow++)
163 : : {
164 [ # # ]: 0 : uno::Sequence<double> aColSeq( static_cast<sal_Int32>(nColCount) );
165 [ # # ]: 0 : double* pColAry = aColSeq.getArray();
166 [ # # ]: 0 : for (SCSIZE nCol = 0; nCol < nColCount; nCol++)
167 [ # # ][ # # ]: 0 : if ( pMatrix->IsString( nCol, nRow ) )
168 : 0 : pColAry[nCol] = 0.0;
169 : : else
170 [ # # ]: 0 : pColAry[nCol] = pMatrix->GetDouble( nCol, nRow );
171 : :
172 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
173 [ # # ]: 0 : }
174 : :
175 [ # # ]: 0 : rAny <<= aRowSeq;
176 [ # # ]: 0 : return sal_True;
177 : : }
178 : :
179 : : //------------------------------------------------------------------------
180 : :
181 : 0 : sal_Bool ScRangeToSequence::FillStringArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange )
182 : : {
183 : 0 : SCTAB nTab = rRange.aStart.Tab();
184 : 0 : SCCOL nStartCol = rRange.aStart.Col();
185 : 0 : SCROW nStartRow = rRange.aStart.Row();
186 : 0 : long nColCount = rRange.aEnd.Col() + 1 - rRange.aStart.Col();
187 : 0 : long nRowCount = rRange.aEnd.Row() + 1 - rRange.aStart.Row();
188 : :
189 : 0 : bool bHasErrors = false;
190 : :
191 [ # # ]: 0 : uno::Sequence< uno::Sequence<rtl::OUString> > aRowSeq( nRowCount );
192 [ # # ]: 0 : uno::Sequence<rtl::OUString>* pRowAry = aRowSeq.getArray();
193 [ # # ]: 0 : for (long nRow = 0; nRow < nRowCount; nRow++)
194 : : {
195 [ # # ]: 0 : uno::Sequence<rtl::OUString> aColSeq( nColCount );
196 [ # # ]: 0 : rtl::OUString* pColAry = aColSeq.getArray();
197 [ # # ]: 0 : for (long nCol = 0; nCol < nColCount; nCol++)
198 : : {
199 : : sal_uInt16 nErrCode = pDoc->GetStringForFormula(
200 : : ScAddress((SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab),
201 [ # # ]: 0 : pColAry[nCol] );
202 [ # # ]: 0 : if ( nErrCode != 0 )
203 : 0 : bHasErrors = true;
204 : : }
205 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
206 [ # # ]: 0 : }
207 : :
208 [ # # ]: 0 : rAny <<= aRowSeq;
209 [ # # ]: 0 : return !bHasErrors;
210 : : }
211 : :
212 : :
213 : 0 : sal_Bool ScRangeToSequence::FillStringArray( uno::Any& rAny, const ScMatrix* pMatrix,
214 : : SvNumberFormatter* pFormatter )
215 : : {
216 [ # # ]: 0 : if (!pMatrix)
217 : 0 : return false;
218 : :
219 : : SCSIZE nColCount;
220 : : SCSIZE nRowCount;
221 [ # # ]: 0 : pMatrix->GetDimensions( nColCount, nRowCount );
222 : :
223 [ # # ]: 0 : uno::Sequence< uno::Sequence<rtl::OUString> > aRowSeq( static_cast<sal_Int32>(nRowCount) );
224 [ # # ]: 0 : uno::Sequence<rtl::OUString>* pRowAry = aRowSeq.getArray();
225 [ # # ]: 0 : for (SCSIZE nRow = 0; nRow < nRowCount; nRow++)
226 : : {
227 [ # # ]: 0 : uno::Sequence<rtl::OUString> aColSeq( static_cast<sal_Int32>(nColCount) );
228 [ # # ]: 0 : rtl::OUString* pColAry = aColSeq.getArray();
229 [ # # ]: 0 : for (SCSIZE nCol = 0; nCol < nColCount; nCol++)
230 : : {
231 [ # # ]: 0 : String aStr;
232 [ # # ][ # # ]: 0 : if ( pMatrix->IsString( nCol, nRow ) )
233 : : {
234 [ # # ][ # # ]: 0 : if ( !pMatrix->IsEmpty( nCol, nRow ) )
235 [ # # ][ # # ]: 0 : aStr = pMatrix->GetString( nCol, nRow );
236 : : }
237 [ # # ]: 0 : else if ( pFormatter )
238 : : {
239 [ # # ]: 0 : double fVal = pMatrix->GetDouble( nCol, nRow );
240 : : Color* pColor;
241 [ # # ]: 0 : pFormatter->GetOutputString( fVal, 0, aStr, &pColor );
242 : : }
243 [ # # ]: 0 : pColAry[nCol] = rtl::OUString( aStr );
244 [ # # ]: 0 : }
245 : :
246 [ # # ]: 0 : pRowAry[nRow] = aColSeq;
247 [ # # ]: 0 : }
248 : :
249 [ # # ]: 0 : rAny <<= aRowSeq;
250 [ # # ]: 0 : return sal_True;
251 : : }
252 : :
253 : : //------------------------------------------------------------------------
254 : :
255 : 133 : double lcl_GetValueFromCell( ScBaseCell& rCell )
256 : : {
257 : : //! ScBaseCell member function?
258 : :
259 : 133 : CellType eType = rCell.GetCellType();
260 [ + - ]: 133 : if ( eType == CELLTYPE_VALUE )
261 : 133 : return ((ScValueCell&)rCell).GetValue();
262 [ # # ]: 0 : else if ( eType == CELLTYPE_FORMULA )
263 : 0 : return ((ScFormulaCell&)rCell).GetValue(); // called only if result is value
264 : :
265 : : OSL_FAIL( "GetValueFromCell: wrong type" );
266 : 133 : return 0;
267 : : }
268 : :
269 : 20 : sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange,
270 : : sal_Bool bAllowNV )
271 : : {
272 : 20 : SCTAB nTab = rRange.aStart.Tab();
273 : 20 : SCCOL nStartCol = rRange.aStart.Col();
274 : 20 : SCROW nStartRow = rRange.aStart.Row();
275 : 20 : long nColCount = rRange.aEnd.Col() + 1 - rRange.aStart.Col();
276 : 20 : long nRowCount = rRange.aEnd.Row() + 1 - rRange.aStart.Row();
277 : :
278 [ + - ]: 20 : String aDocStr;
279 : 20 : sal_Bool bHasErrors = false;
280 : :
281 [ + - ]: 20 : uno::Sequence< uno::Sequence<uno::Any> > aRowSeq( nRowCount );
282 [ + - ]: 20 : uno::Sequence<uno::Any>* pRowAry = aRowSeq.getArray();
283 [ + + ]: 72 : for (long nRow = 0; nRow < nRowCount; nRow++)
284 : : {
285 [ + - ]: 52 : uno::Sequence<uno::Any> aColSeq( nColCount );
286 [ + - ]: 52 : uno::Any* pColAry = aColSeq.getArray();
287 [ + + ]: 296 : for (long nCol = 0; nCol < nColCount; nCol++)
288 : : {
289 : 244 : uno::Any& rElement = pColAry[nCol];
290 : :
291 : 244 : ScAddress aPos( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab );
292 [ + - ]: 244 : ScBaseCell* pCell = pDoc->GetCell( aPos );
293 [ + + ]: 244 : if ( pCell )
294 : : {
295 [ - + ][ # # ]: 224 : if ( pCell->GetCellType() == CELLTYPE_FORMULA &&
[ - + ]
296 [ # # ][ # # ]: 0 : ((ScFormulaCell*)pCell)->GetErrCode() != 0 )
297 : : {
298 : : // if NV is allowed, leave empty for errors
299 : 0 : bHasErrors = sal_True;
300 : : }
301 [ + - ][ + + ]: 224 : else if ( pCell->HasValueData() )
302 [ + - ][ + - ]: 133 : rElement <<= (double) lcl_GetValueFromCell( *pCell );
303 : : else
304 [ + - ][ + - ]: 91 : rElement <<= rtl::OUString( pCell->GetStringData() );
305 : : }
306 : : else
307 [ + - ]: 20 : rElement <<= rtl::OUString(); // empty: empty string
308 : : }
309 [ + - ]: 52 : pRowAry[nRow] = aColSeq;
310 [ + - ]: 52 : }
311 : :
312 [ + - ]: 20 : rAny <<= aRowSeq;
313 [ - + ][ # # ]: 20 : return bAllowNV || !bHasErrors;
[ + - ][ + - ]
314 : : }
315 : :
316 : :
317 : 6 : sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, const ScMatrix* pMatrix, bool bDataTypes )
318 : : {
319 [ - + ]: 6 : if (!pMatrix)
320 : 0 : return false;
321 : :
322 : : SCSIZE nColCount;
323 : : SCSIZE nRowCount;
324 [ + - ]: 6 : pMatrix->GetDimensions( nColCount, nRowCount );
325 : :
326 [ + - ]: 6 : uno::Sequence< uno::Sequence<uno::Any> > aRowSeq( static_cast<sal_Int32>(nRowCount) );
327 [ + - ]: 6 : uno::Sequence<uno::Any>* pRowAry = aRowSeq.getArray();
328 [ + + ]: 18 : for (SCSIZE nRow = 0; nRow < nRowCount; nRow++)
329 : : {
330 [ + - ]: 12 : uno::Sequence<uno::Any> aColSeq( static_cast<sal_Int32>(nColCount) );
331 [ + - ]: 12 : uno::Any* pColAry = aColSeq.getArray();
332 [ + + ]: 48 : for (SCSIZE nCol = 0; nCol < nColCount; nCol++)
333 : : {
334 [ + - ][ - + ]: 36 : if ( pMatrix->IsString( nCol, nRow ) )
335 : : {
336 [ # # ]: 0 : String aStr;
337 [ # # ][ # # ]: 0 : if ( !pMatrix->IsEmpty( nCol, nRow ) )
338 [ # # ][ # # ]: 0 : aStr = pMatrix->GetString( nCol, nRow );
339 [ # # ][ # # ]: 0 : pColAry[nCol] <<= rtl::OUString( aStr );
[ # # ]
340 : : }
341 : : else
342 : : {
343 [ + - ]: 36 : double fVal = pMatrix->GetDouble( nCol, nRow );
344 [ + - ][ + - ]: 36 : if (bDataTypes && pMatrix->IsBoolean( nCol, nRow ))
[ - + ][ - + ]
345 [ # # ]: 0 : pColAry[nCol] <<= (fVal ? true : false);
346 : : else
347 [ + - ]: 36 : pColAry[nCol] <<= fVal;
348 : : }
349 : : }
350 : :
351 [ + - ]: 12 : pRowAry[nRow] = aColSeq;
352 [ + - ]: 12 : }
353 : :
354 [ + - ]: 6 : rAny <<= aRowSeq;
355 [ + - ]: 6 : return sal_True;
356 : : }
357 : :
358 : : //------------------------------------------------------------------------
359 : :
360 : 18 : bool ScApiTypeConversion::ConvertAnyToDouble( double & o_fVal,
361 : : com::sun::star::uno::TypeClass & o_eClass,
362 : : const com::sun::star::uno::Any & rAny )
363 : : {
364 : 18 : bool bRet = false;
365 : 18 : o_eClass = rAny.getValueTypeClass();
366 [ + - ]: 18 : switch (o_eClass)
367 : : {
368 : : //! extract integer values
369 : : case uno::TypeClass_ENUM:
370 : : case uno::TypeClass_BOOLEAN:
371 : : case uno::TypeClass_CHAR:
372 : : case uno::TypeClass_BYTE:
373 : : case uno::TypeClass_SHORT:
374 : : case uno::TypeClass_UNSIGNED_SHORT:
375 : : case uno::TypeClass_LONG:
376 : : case uno::TypeClass_UNSIGNED_LONG:
377 : : case uno::TypeClass_FLOAT:
378 : : case uno::TypeClass_DOUBLE:
379 : 18 : rAny >>= o_fVal;
380 : 18 : bRet = true;
381 : 18 : break;
382 : : default:
383 : : ; // nothing, avoid warning
384 : : }
385 [ - + ]: 18 : if (!bRet)
386 : 0 : o_fVal = 0.0;
387 : 18 : return bRet;
388 : : }
389 : :
390 : : //------------------------------------------------------------------------
391 : :
392 : 3 : ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const com::sun::star::uno::Any & rAny )
393 : : {
394 : 3 : ScMatrixRef xMatrix;
395 [ + - ]: 3 : uno::Sequence< uno::Sequence< uno::Any > > aSequence;
396 [ + - ][ + - ]: 3 : if ( rAny >>= aSequence )
397 : : {
398 : 3 : sal_Int32 nRowCount = aSequence.getLength();
399 : 3 : const uno::Sequence<uno::Any>* pRowArr = aSequence.getConstArray();
400 : 3 : sal_Int32 nMaxColCount = 0;
401 : : sal_Int32 nCol, nRow;
402 [ + + ]: 9 : for (nRow=0; nRow<nRowCount; nRow++)
403 : : {
404 : 6 : sal_Int32 nTmp = pRowArr[nRow].getLength();
405 [ + + ]: 6 : if ( nTmp > nMaxColCount )
406 : 3 : nMaxColCount = nTmp;
407 : : }
408 [ + - ][ + - ]: 3 : if ( nMaxColCount && nRowCount )
409 : : {
410 : 3 : rtl::OUString aUStr;
411 : : xMatrix = new ScMatrix(
412 : : static_cast<SCSIZE>(nMaxColCount),
413 [ + - ][ + - ]: 3 : static_cast<SCSIZE>(nRowCount), 0.0);
[ + - ]
414 : : SCSIZE nCols, nRows;
415 [ + - ]: 3 : xMatrix->GetDimensions( nCols, nRows);
416 [ + - ][ - + ]: 3 : if (nCols != static_cast<SCSIZE>(nMaxColCount) || nRows != static_cast<SCSIZE>(nRowCount))
417 : : {
418 : : OSL_FAIL( "ScSequenceToMatrix::CreateMixedMatrix: matrix exceeded max size, returning NULL matrix");
419 : 0 : return NULL;
420 : : }
421 [ + + ]: 9 : for (nRow=0; nRow<nRowCount; nRow++)
422 : : {
423 : 6 : sal_Int32 nColCount = pRowArr[nRow].getLength();
424 : 6 : const uno::Any* pColArr = pRowArr[nRow].getConstArray();
425 [ + + ]: 24 : for (nCol=0; nCol<nColCount; nCol++)
426 : : {
427 : : double fVal;
428 : : uno::TypeClass eClass;
429 [ + - ]: 18 : if (ScApiTypeConversion::ConvertAnyToDouble( fVal, eClass, pColArr[nCol]))
430 : : {
431 [ - + ]: 18 : if (eClass == uno::TypeClass_BOOLEAN)
432 : : xMatrix->PutBoolean( (fVal ? true : false),
433 : : static_cast<SCSIZE>(nCol),
434 [ # # ]: 0 : static_cast<SCSIZE>(nRow) );
435 : : else
436 : : xMatrix->PutDouble( fVal,
437 : : static_cast<SCSIZE>(nCol),
438 [ + - ]: 18 : static_cast<SCSIZE>(nRow) );
439 : : }
440 : : else
441 : : {
442 : : // Try string, else use empty as last resort.
443 : :
444 [ # # ]: 0 : if ( pColArr[nCol] >>= aUStr )
445 : : xMatrix->PutString( String( aUStr ),
446 : : static_cast<SCSIZE>(nCol),
447 [ # # ][ # # ]: 0 : static_cast<SCSIZE>(nRow) );
[ # # ][ # # ]
448 : : else
449 : : xMatrix->PutEmpty(
450 : : static_cast<SCSIZE>(nCol),
451 [ # # ]: 0 : static_cast<SCSIZE>(nRow) );
452 : : }
453 : : }
454 [ - + ]: 6 : for (nCol=nColCount; nCol<nMaxColCount; nCol++)
455 : : {
456 : : xMatrix->PutEmpty(
457 : : static_cast<SCSIZE>(nCol),
458 [ # # ]: 0 : static_cast<SCSIZE>(nRow) );
459 : : }
460 [ + - ]: 3 : }
461 : : }
462 : : }
463 [ + - ][ + - ]: 3 : return xMatrix;
464 : : }
465 : :
466 : :
467 : : //------------------------------------------------------------------------
468 : :
469 : 5 : sal_Bool ScByteSequenceToString::GetString( String& rString, const uno::Any& rAny,
470 : : sal_uInt16 nEncoding )
471 : : {
472 [ + - ]: 5 : uno::Sequence<sal_Int8> aSeq;
473 [ + - ][ + - ]: 5 : if ( rAny >>= aSeq )
474 : : {
475 : 5 : rString = String( (const sal_Char*)aSeq.getConstArray(),
476 [ + - ][ + - ]: 10 : (xub_StrLen)aSeq.getLength(), nEncoding );
[ + - ]
477 [ + - ][ + - ]: 5 : rString = comphelper::string::stripEnd(rString, 0);
[ + - ]
478 : 5 : return sal_True;
479 : : }
480 [ + - ]: 5 : return false;
481 : : }
482 : :
483 : : //------------------------------------------------------------------------
484 : :
485 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|