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 "InternalData.hxx"
21 : #include "ResId.hxx"
22 : #include "Strings.hrc"
23 :
24 : #include <rtl/math.hxx>
25 : #if OSL_DEBUG_LEVEL > 1
26 : #define DEBUG_INTERNAL_DATA 1
27 : #endif
28 :
29 : #ifdef DEBUG_INTERNAL_DATA
30 : #include <svl/gridprinter.hxx>
31 : #endif
32 :
33 : #include <algorithm>
34 : #include <iterator>
35 :
36 : using ::com::sun::star::uno::Sequence;
37 :
38 : using namespace ::com::sun::star;
39 : using namespace ::std;
40 :
41 : namespace chart
42 : {
43 :
44 : namespace
45 : {
46 56 : struct lcl_NumberedStringGenerator
47 : {
48 56 : lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
49 : m_aStub( rStub ),
50 : m_nCounter( 0 ),
51 56 : m_nStubStartIndex( rStub.indexOf( rWildcard )),
52 112 : m_nWildcardLength( rWildcard.getLength())
53 : {
54 56 : }
55 196 : vector< uno::Any > operator()()
56 : {
57 196 : vector< uno::Any > aRet(1);
58 196 : aRet[0] = uno::makeAny( m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::number( ++m_nCounter )) );
59 196 : return aRet;
60 : }
61 : private:
62 : OUString m_aStub;
63 : sal_Int32 m_nCounter;
64 : const sal_Int32 m_nStubStartIndex;
65 : const sal_Int32 m_nWildcardLength;
66 : };
67 :
68 : template< typename T >
69 212621 : Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
70 : {
71 : // is there a more elegant way of conversion?
72 212621 : Sequence< T > aResult( rValarray.size());
73 2421293 : for( size_t i = 0; i < rValarray.size(); ++i )
74 2208672 : aResult[i] = rValarray[i];
75 212621 : return aResult;
76 : }
77 :
78 : } // anonymous namespace
79 :
80 472 : InternalData::InternalData()
81 : : m_nColumnCount( 0 )
82 : , m_nRowCount( 0 )
83 : , m_aRowLabels( 0 )
84 472 : , m_aColumnLabels( 0 )
85 472 : {}
86 :
87 : static const double fDefaultData[] = {
88 : 9.10, 3.20, 4.54,
89 : 2.40, 8.80, 9.65,
90 : 3.10, 1.50, 3.70,
91 : 4.30, 9.02, 6.20
92 : };
93 :
94 28 : void InternalData::createDefaultData()
95 : {
96 28 : const sal_Int32 nRowCount = 4;
97 28 : const sal_Int32 nColumnCount = 3;
98 :
99 28 : m_nRowCount = nRowCount;
100 28 : m_nColumnCount = nColumnCount;
101 28 : const sal_Int32 nSize = nColumnCount * nRowCount;
102 : // @todo: localize this!
103 28 : const OUString aRowName(SCH_RESSTR(STR_ROW_LABEL));
104 56 : const OUString aColName(SCH_RESSTR(STR_COLUMN_LABEL));
105 :
106 28 : m_aData.resize( nSize );
107 364 : for( sal_Int32 i=0; i<nSize; ++i )
108 336 : m_aData[i] = fDefaultData[i];
109 :
110 28 : m_aRowLabels.clear();
111 28 : m_aRowLabels.reserve( m_nRowCount );
112 : generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
113 28 : lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" ));
114 :
115 28 : m_aColumnLabels.clear();
116 28 : m_aColumnLabels.reserve( m_nColumnCount );
117 : generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
118 56 : lcl_NumberedStringGenerator( aColName, "%COLUMNNUMBER" ));
119 28 : }
120 :
121 0 : bool InternalData::isDefaultData()
122 : {
123 :
124 0 : if( m_nRowCount == 4 && m_nColumnCount == 3 )
125 : {
126 0 : for( sal_Int32 i=0; i<(4*3); ++i )
127 0 : if( m_aData[i] != fDefaultData[i] )
128 0 : return false;
129 :
130 0 : return true;
131 : }
132 0 : return false;
133 : }
134 :
135 188 : void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
136 : {
137 188 : m_nRowCount = rDataInRows.getLength();
138 188 : m_nColumnCount = (m_nRowCount ? rDataInRows[0].getLength() : 0);
139 :
140 188 : if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
141 178 : m_aRowLabels.resize( m_nRowCount );
142 188 : if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
143 178 : m_aColumnLabels.resize( m_nColumnCount );
144 :
145 188 : m_aData.resize( m_nRowCount * m_nColumnCount );
146 : double fNan;
147 188 : ::rtl::math::setNan( & fNan );
148 : // set all values to Nan
149 188 : m_aData = fNan;
150 :
151 1034 : for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
152 : {
153 846 : int nDataIdx = nRow*m_nColumnCount;
154 846 : const sal_Int32 nMax = ::std::min( rDataInRows[nRow].getLength(), m_nColumnCount );
155 3048 : for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
156 : {
157 2202 : m_aData[nDataIdx] = rDataInRows[nRow][nCol];
158 2202 : nDataIdx += 1;
159 : }
160 : }
161 188 : }
162 :
163 12 : Sequence< Sequence< double > > InternalData::getData() const
164 : {
165 12 : Sequence< Sequence< double > > aResult( m_nRowCount );
166 :
167 60 : for( sal_Int32 i=0; i<m_nRowCount; ++i )
168 96 : aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
169 144 : m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
170 :
171 12 : return aResult;
172 : }
173 :
174 212561 : Sequence< double > InternalData::getColumnValues( sal_Int32 nColumnIndex ) const
175 : {
176 212561 : if( nColumnIndex >= 0 && nColumnIndex < m_nColumnCount )
177 : return lcl_ValarrayToSequence< tDataType::value_type >(
178 212561 : m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] );
179 0 : return Sequence< double >();
180 : }
181 12 : Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
182 : {
183 12 : if( nRowIndex >= 0 && nRowIndex < m_nRowCount )
184 : return lcl_ValarrayToSequence< tDataType::value_type >(
185 12 : m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
186 0 : return Sequence< double >();
187 : }
188 :
189 772 : void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
190 : {
191 772 : if( nColumnIndex < 0 )
192 772 : return;
193 772 : enlargeData( nColumnIndex + 1, rNewData.size() );
194 :
195 772 : tDataType aSlice = m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
196 3990 : for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
197 3218 : aSlice[i] = rNewData[i];
198 772 : m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
199 : }
200 :
201 0 : void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & rNewData )
202 : {
203 0 : if( nRowIndex < 0 )
204 0 : return;
205 0 : enlargeData( rNewData.size(), nRowIndex+1 );
206 :
207 0 : tDataType aSlice = m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
208 0 : for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
209 0 : aSlice[i] = rNewData[i];
210 0 : m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
211 : }
212 :
213 718 : void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< uno::Any >& rComplexLabel )
214 : {
215 718 : if( nColumnIndex < 0 )
216 718 : return;
217 718 : if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
218 : {
219 0 : m_aColumnLabels.resize(nColumnIndex+1);
220 0 : enlargeData( nColumnIndex+1, 0 );
221 : }
222 718 : m_aColumnLabels[nColumnIndex]=rComplexLabel;
223 :
224 718 : dump();
225 : }
226 :
227 936 : void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel )
228 : {
229 936 : if( nRowIndex < 0 )
230 936 : return;
231 936 : if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
232 : {
233 834 : m_aRowLabels.resize(nRowIndex+1);
234 834 : enlargeData( 0, nRowIndex+1 );
235 : }
236 936 : m_aRowLabels[nRowIndex] = rComplexLabel;
237 : }
238 :
239 6998 : vector< uno::Any > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
240 : {
241 6998 : if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
242 6998 : return m_aColumnLabels[nColumnIndex];
243 : else
244 0 : return vector< uno::Any >();
245 : }
246 0 : vector< uno::Any > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
247 : {
248 0 : if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) )
249 0 : return m_aRowLabels[nRowIndex];
250 : else
251 0 : return vector< uno::Any >();
252 : }
253 :
254 0 : void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
255 : {
256 0 : if( nRowIndex < m_nRowCount - 1 )
257 : {
258 0 : const sal_Int32 nMax = m_nColumnCount;
259 0 : for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
260 : {
261 0 : size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount;
262 0 : size_t nIndex2 = nIndex1 + m_nColumnCount;
263 0 : double fTemp = m_aData[nIndex1];
264 0 : m_aData[nIndex1] = m_aData[nIndex2];
265 0 : m_aData[nIndex2] = fTemp;
266 : }
267 :
268 0 : vector< uno::Any > aTemp( m_aRowLabels[nRowIndex] );
269 0 : m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1];
270 0 : m_aRowLabels[nRowIndex + 1] = aTemp;
271 : }
272 0 : }
273 :
274 0 : void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
275 : {
276 0 : if( nColumnIndex < m_nColumnCount - 1 )
277 : {
278 0 : const sal_Int32 nMax = m_nRowCount;
279 0 : for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
280 : {
281 0 : size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount;
282 0 : size_t nIndex2 = nIndex1 + 1;
283 0 : double fTemp = m_aData[nIndex1];
284 0 : m_aData[nIndex1] = m_aData[nIndex2];
285 0 : m_aData[nIndex2] = fTemp;
286 : }
287 :
288 0 : vector< uno::Any > aTemp( m_aColumnLabels[nColumnIndex] );
289 0 : m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1];
290 0 : m_aColumnLabels[nColumnIndex + 1] = aTemp;
291 : }
292 0 : }
293 :
294 2020 : bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
295 : {
296 2020 : sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
297 2020 : sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
298 2020 : sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
299 :
300 2020 : bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
301 :
302 2020 : if( bGrow )
303 : {
304 : double fNan;
305 16 : ::rtl::math::setNan( &fNan );
306 16 : tDataType aNewData( fNan, nNewSize );
307 : // copy old data
308 36 : for( int nCol=0; nCol<m_nColumnCount; ++nCol )
309 : static_cast< tDataType >(
310 40 : aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
311 20 : m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
312 :
313 16 : m_aData.resize( nNewSize );
314 16 : m_aData = aNewData;
315 : }
316 2020 : m_nColumnCount = nNewColumnCount;
317 2020 : m_nRowCount = nNewRowCount;
318 2020 : return bGrow;
319 : }
320 :
321 772 : void InternalData::insertColumn( sal_Int32 nAfterIndex )
322 : {
323 : // note: -1 is allowed, as we insert after the given index
324 : OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
325 772 : if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
326 772 : return;
327 772 : sal_Int32 nNewColumnCount = m_nColumnCount + 1;
328 772 : sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
329 :
330 : double fNan;
331 772 : ::rtl::math::setNan( &fNan );
332 772 : tDataType aNewData( fNan, nNewSize );
333 :
334 : // copy old data
335 772 : int nCol=0;
336 2724 : for( ; nCol<=nAfterIndex; ++nCol )
337 3904 : aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
338 : static_cast< tDataType >(
339 1952 : m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
340 772 : for( ++nCol; nCol<nNewColumnCount; ++nCol )
341 0 : aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
342 : static_cast< tDataType >(
343 0 : m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
344 :
345 772 : m_nColumnCount = nNewColumnCount;
346 772 : m_aData.resize( nNewSize );
347 772 : m_aData = aNewData;
348 :
349 : // labels
350 772 : if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
351 772 : m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) );
352 :
353 772 : dump();
354 : }
355 :
356 772 : sal_Int32 InternalData::appendColumn()
357 : {
358 772 : insertColumn( getColumnCount() - 1 );
359 772 : return getColumnCount() - 1;
360 : }
361 :
362 0 : sal_Int32 InternalData::appendRow()
363 : {
364 0 : insertRow( getRowCount() - 1 );
365 0 : return getRowCount() - 1;
366 : }
367 :
368 6345 : sal_Int32 InternalData::getRowCount() const
369 : {
370 6345 : return m_nRowCount;
371 : }
372 :
373 3680 : sal_Int32 InternalData::getColumnCount() const
374 : {
375 3680 : return m_nColumnCount;
376 : }
377 :
378 0 : void InternalData::insertRow( sal_Int32 nAfterIndex )
379 : {
380 : // note: -1 is allowed, as we insert after the given index
381 : OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
382 0 : if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
383 0 : return;
384 0 : sal_Int32 nNewRowCount = m_nRowCount + 1;
385 0 : sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
386 :
387 : double fNan;
388 0 : ::rtl::math::setNan( &fNan );
389 0 : tDataType aNewData( fNan, nNewSize );
390 :
391 : // copy old data
392 0 : sal_Int32 nIndex = nAfterIndex + 1;
393 0 : aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
394 : static_cast< tDataType >(
395 0 : m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
396 :
397 0 : if( nIndex < m_nRowCount )
398 : {
399 0 : sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
400 0 : aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
401 : static_cast< tDataType >(
402 0 : m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
403 : }
404 :
405 0 : m_nRowCount = nNewRowCount;
406 0 : m_aData.resize( nNewSize );
407 0 : m_aData = aNewData;
408 :
409 : // labels
410 0 : if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
411 0 : m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1));
412 :
413 0 : dump();
414 : }
415 :
416 0 : void InternalData::deleteColumn( sal_Int32 nAtIndex )
417 : {
418 : OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
419 0 : if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
420 0 : return;
421 0 : sal_Int32 nNewColumnCount = m_nColumnCount - 1;
422 0 : sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
423 :
424 : double fNan;
425 0 : ::rtl::math::setNan( &fNan );
426 0 : tDataType aNewData( fNan, nNewSize );
427 :
428 : // copy old data
429 0 : int nCol=0;
430 0 : for( ; nCol<nAtIndex; ++nCol )
431 0 : aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
432 : static_cast< tDataType >(
433 0 : m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
434 0 : for( ; nCol<nNewColumnCount; ++nCol )
435 0 : aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
436 : static_cast< tDataType >(
437 0 : m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
438 :
439 0 : m_nColumnCount = nNewColumnCount;
440 0 : m_aData.resize( nNewSize );
441 0 : m_aData = aNewData;
442 :
443 : // labels
444 0 : if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
445 0 : m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
446 :
447 0 : dump();
448 : }
449 :
450 0 : void InternalData::deleteRow( sal_Int32 nAtIndex )
451 : {
452 : OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
453 0 : if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
454 0 : return;
455 0 : sal_Int32 nNewRowCount = m_nRowCount - 1;
456 0 : sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
457 :
458 : double fNan;
459 0 : ::rtl::math::setNan( &fNan );
460 0 : tDataType aNewData( fNan, nNewSize );
461 :
462 : // copy old data
463 0 : sal_Int32 nIndex = nAtIndex;
464 0 : if( nIndex )
465 0 : aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
466 : static_cast< tDataType >(
467 0 : m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
468 :
469 0 : if( nIndex < nNewRowCount )
470 : {
471 0 : sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
472 0 : aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
473 : static_cast< tDataType >(
474 0 : m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
475 : }
476 :
477 0 : m_nRowCount = nNewRowCount;
478 0 : m_aData.resize( nNewSize );
479 0 : m_aData = aNewData;
480 :
481 : // labels
482 0 : if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
483 0 : m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
484 :
485 0 : dump();
486 : }
487 :
488 234 : void InternalData::setComplexRowLabels( const vector< vector< uno::Any > >& rNewRowLabels )
489 : {
490 234 : m_aRowLabels = rNewRowLabels;
491 234 : sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
492 234 : if( nNewRowCount < m_nRowCount )
493 0 : m_aRowLabels.resize( m_nRowCount );
494 : else
495 234 : enlargeData( 0, nNewRowCount );
496 234 : }
497 :
498 7408 : InternalData::tVecVecAny InternalData::getComplexRowLabels() const
499 : {
500 7408 : return m_aRowLabels;
501 : }
502 :
503 180 : void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& rNewColumnLabels )
504 : {
505 180 : m_aColumnLabels = rNewColumnLabels;
506 180 : sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
507 180 : if( nNewColumnCount < m_nColumnCount )
508 0 : m_aColumnLabels.resize( m_nColumnCount );
509 : else
510 180 : enlargeData( nNewColumnCount, 0 );
511 180 : }
512 :
513 24 : InternalData::tVecVecAny InternalData::getComplexColumnLabels() const
514 : {
515 24 : return m_aColumnLabels;
516 : }
517 :
518 : #ifdef DEBUG_INTERNAL_DATA
519 : void InternalData::dump() const
520 : {
521 : // Header
522 : if (!m_aColumnLabels.empty())
523 : {
524 : svl::GridPrinter aPrinter(1, m_aColumnLabels.size(), true);
525 : for (size_t nCol = 0; nCol < m_aColumnLabels.size(); ++nCol)
526 : {
527 : if (m_aColumnLabels[nCol].empty())
528 : continue;
529 :
530 : OUString aStr;
531 : if (m_aColumnLabels[nCol][0] >>= aStr)
532 : aPrinter.set(0, nCol, aStr);
533 : }
534 : aPrinter.print("Header");
535 : }
536 :
537 : if (!m_aRowLabels.empty())
538 : {
539 : svl::GridPrinter aPrinter(m_aRowLabels.size(), m_aRowLabels[0].size());
540 : for (size_t nRow = 0; nRow < m_aRowLabels.size(); ++nRow)
541 : {
542 : for (size_t nCol = 0; nCol < m_aRowLabels[nRow].size(); ++nCol)
543 : {
544 : OUString aStr;
545 : if (m_aRowLabels[nRow].at(nCol) >>= aStr)
546 : aPrinter.set(nRow, nCol, aStr);
547 : }
548 : }
549 : aPrinter.print("Row labels");
550 : }
551 :
552 : svl::GridPrinter aPrinter(m_nRowCount, m_nColumnCount);
553 :
554 : for (sal_Int32 nRow = 0; nRow < m_nRowCount; ++nRow)
555 : {
556 : tDataType aSlice( m_aData[ ::std::slice( nRow*m_nColumnCount, m_nColumnCount, 1 ) ] );
557 : for (sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol)
558 : aPrinter.set(nRow, nCol, OUString::number(aSlice[nCol]));
559 : }
560 :
561 : aPrinter.print("Column data");
562 : }
563 : #else
564 1490 : void InternalData::dump() const {}
565 : #endif
566 :
567 : } // namespace chart
568 :
569 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|