LibreOffice Module sc (master)  1
pivotcachebuffer.cxx
Go to the documentation of this file.
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 <pivotcachebuffer.hxx>
21 
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/container/XIndexAccess.hpp>
24 #include <com/sun/star/container/XNameAccess.hpp>
25 #include <com/sun/star/container/XNamed.hpp>
26 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
27 #include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp>
28 #include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
29 #include <o3tl/safeint.hxx>
30 #include <osl/diagnose.h>
31 #include <sal/log.hxx>
36 #include <oox/token/namespaces.hxx>
37 #include <oox/token/properties.hxx>
38 #include <oox/token/tokens.hxx>
39 #include <tools/diagnose_ex.h>
40 #include <defnamesbuffer.hxx>
41 #include <pivotcachefragment.hxx>
42 #include <sheetdatabuffer.hxx>
43 #include <tablebuffer.hxx>
44 #include <unitconverter.hxx>
45 #include <worksheetbuffer.hxx>
46 #include <dpobject.hxx>
47 #include <dpsave.hxx>
48 #include <tools/datetime.hxx>
49 #include <addressconverter.hxx>
50 #include <biffhelper.hxx>
51 
52 namespace oox::xls {
53 
54 using namespace ::com::sun::star::container;
55 using namespace ::com::sun::star::sheet;
56 using namespace ::com::sun::star::uno;
57 
58 using ::oox::core::Relations;
59 
60 namespace {
61 
62 const sal_uInt16 BIFF12_PCDFIELD_SERVERFIELD = 0x0001;
63 const sal_uInt16 BIFF12_PCDFIELD_NOUNIQUEITEMS = 0x0002;
64 const sal_uInt16 BIFF12_PCDFIELD_DATABASEFIELD = 0x0004;
65 const sal_uInt16 BIFF12_PCDFIELD_HASCAPTION = 0x0008;
66 const sal_uInt16 BIFF12_PCDFIELD_MEMBERPROPFIELD = 0x0010;
67 const sal_uInt16 BIFF12_PCDFIELD_HASFORMULA = 0x0100;
68 const sal_uInt16 BIFF12_PCDFIELD_HASPROPERTYNAME = 0x0200;
69 
70 const sal_uInt16 BIFF12_PCDFSITEMS_HASSEMIMIXED = 0x0001;
71 const sal_uInt16 BIFF12_PCDFSITEMS_HASNONDATE = 0x0002;
72 const sal_uInt16 BIFF12_PCDFSITEMS_HASDATE = 0x0004;
73 const sal_uInt16 BIFF12_PCDFSITEMS_HASSTRING = 0x0008;
74 const sal_uInt16 BIFF12_PCDFSITEMS_HASBLANK = 0x0010;
75 const sal_uInt16 BIFF12_PCDFSITEMS_HASMIXED = 0x0020;
76 const sal_uInt16 BIFF12_PCDFSITEMS_ISNUMERIC = 0x0040;
77 const sal_uInt16 BIFF12_PCDFSITEMS_ISINTEGER = 0x0080;
78 const sal_uInt16 BIFF12_PCDFSITEMS_HASLONGTEXT = 0x0200;
79 
80 const sal_uInt16 BIFF12_PCITEM_ARRAY_DOUBLE = 0x0001;
81 const sal_uInt16 BIFF12_PCITEM_ARRAY_STRING = 0x0002;
82 const sal_uInt16 BIFF12_PCITEM_ARRAY_ERROR = 0x0010;
83 const sal_uInt16 BIFF12_PCITEM_ARRAY_DATE = 0x0020;
84 
85 const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOSTART = 0x01;
86 const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOEND = 0x02;
87 const sal_uInt8 BIFF12_PCDFRANGEPR_DATEGROUP = 0x04;
88 
89 const sal_uInt8 BIFF12_PCDEFINITION_SAVEDATA = 0x01;
90 const sal_uInt8 BIFF12_PCDEFINITION_INVALID = 0x02;
91 const sal_uInt8 BIFF12_PCDEFINITION_REFRESHONLOAD = 0x04;
92 const sal_uInt8 BIFF12_PCDEFINITION_OPTIMIZEMEMORY = 0x08;
93 const sal_uInt8 BIFF12_PCDEFINITION_ENABLEREFRESH = 0x10;
94 const sal_uInt8 BIFF12_PCDEFINITION_BACKGROUNDQUERY = 0x20;
95 const sal_uInt8 BIFF12_PCDEFINITION_UPGRADEONREFR = 0x40;
96 const sal_uInt8 BIFF12_PCDEFINITION_TUPLECACHE = 0x80;
97 
98 const sal_uInt8 BIFF12_PCDEFINITION_HASUSERNAME = 0x01;
99 const sal_uInt8 BIFF12_PCDEFINITION_HASRELID = 0x02;
100 const sal_uInt8 BIFF12_PCDEFINITION_SUPPORTSUBQUERY = 0x04;
101 const sal_uInt8 BIFF12_PCDEFINITION_SUPPORTDRILL = 0x08;
102 
103 const sal_uInt8 BIFF12_PCDWBSOURCE_HASRELID = 0x01;
104 const sal_uInt8 BIFF12_PCDWBSOURCE_HASSHEET = 0x02;
105 
106 
114 void lclAdjustBinDateTime( css::util::DateTime& orDateTime )
115 {
116  if( (orDateTime.Year == 1900) && (orDateTime.Month <= 2) )
117  {
118  OSL_ENSURE( (orDateTime.Month == 1) || ((orDateTime.Month == 2) && (orDateTime.Day > 0)), "lclAdjustBinDateTime - invalid date" );
119  switch( orDateTime.Month )
120  {
121  case 2: if( orDateTime.Day > 1 ) --orDateTime.Day; else { orDateTime.Day += 30; --orDateTime.Month; } break;
122  case 1: if( orDateTime.Day > 1 ) --orDateTime.Day; else { orDateTime.Day += 30; orDateTime.Month = 12; --orDateTime.Year; } break;
123  }
124  }
125 }
126 
127 } // namespace
128 
130  mnType( XML_m ), mbUnused( false )
131 {
132 }
133 
135 {
136  maValue <<= rAttribs.getXString( XML_v, OUString() );
137  mnType = XML_s;
138 }
139 
141 {
142  maValue <<= rAttribs.getDouble( XML_v, 0.0 );
143  mnType = XML_n;
144  mbUnused = rAttribs.getBool( XML_u, false );
145 }
146 
148 {
149  maValue <<= rAttribs.getDateTime( XML_v, css::util::DateTime() );
150  mnType = XML_d;
151 }
152 
154 {
155  maValue <<= rAttribs.getBool( XML_v, false );
156  mnType = XML_b;
157 }
158 
160 {
161  maValue <<= rAttribs.getXString( XML_v, OUString() );
162  mnType = XML_e;
163 }
164 
166 {
167  maValue <<= rAttribs.getInteger( XML_v, -1 );
168  mnType = XML_x;
169 }
170 
172 {
173  maValue <<= BiffHelper::readString( rStrm );
174  mnType = XML_s;
175 }
176 
178 {
179  maValue <<= rStrm.readDouble();
180  mnType = XML_n;
181 }
182 
184 {
185  css::util::DateTime aDateTime;
186  aDateTime.Year = rStrm.readuInt16();
187  aDateTime.Month = rStrm.readuInt16();
188  aDateTime.Day = rStrm.readuInt8();
189  aDateTime.Hours = rStrm.readuInt8();
190  aDateTime.Minutes = rStrm.readuInt8();
191  aDateTime.Seconds = rStrm.readuInt8();
192  lclAdjustBinDateTime( aDateTime );
193  maValue <<= aDateTime;
194  mnType = XML_d;
195 }
196 
198 {
199  maValue <<= (rStrm.readuInt8() != 0);
200  mnType = XML_b;
201 }
202 
204 {
205  maValue <<= static_cast< sal_Int32 >( rStrm.readuInt8() );
206  mnType = XML_e;
207 }
208 
210 {
211  maValue <<= rStrm.readInt32();
212  mnType = XML_x;
213 }
214 
215 void PivotCacheItem::setStringValue( const OUString& sString )
216 {
217  mnType = XML_s;
218  maValue <<= sString;
219 }
220 
221 OUString PivotCacheItem::getName() const
222 {
223  switch( mnType )
224  {
225  case XML_m: return OUString();
226  case XML_s: return maValue.get< OUString >();
227  case XML_n: return OUString::number( maValue.get< double >() ); // !TODO
228  case XML_i: return OUString::number( maValue.get< sal_Int32 >() );
229  case XML_d: return OUString(); // !TODO
230  case XML_b: return OUString::boolean( maValue.get< bool >() ); // !TODO
231  case XML_e: return OUString(); // !TODO
232  }
233  OSL_FAIL( "PivotCacheItem::getName - invalid data type" );
234  return OUString();
235 }
236 
237 OUString PivotCacheItem::getFormattedName(const ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const DateTime& rNullDate) const
238 {
239  switch( mnType )
240  {
241  case XML_m: return OUString();
242  case XML_s: return maValue.get< OUString >();
243  case XML_n: return pObj->GetFormattedString(rSaveDim.GetName(), maValue.get<double>());
244  case XML_i: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< sal_Int32 >()));
245  case XML_b: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< bool >()));
246  case XML_d: return pObj->GetFormattedString(rSaveDim.GetName(), maValue.get< css::util::DateTime >() - rNullDate);
247  case XML_e: return maValue.get< OUString >();
248  }
249  OSL_FAIL( "PivotCacheItem::getFormattedName - invalid data type" );
250  return OUString();
251 }
252 
254  WorkbookHelper( rHelper )
255 {
256 }
257 
258 void PivotCacheItemList::importItem( sal_Int32 nElement, const AttributeList& rAttribs )
259 {
260  PivotCacheItem& rItem = createItem();
261  switch( nElement )
262  {
263  case XLS_TOKEN( m ): break;
264  case XLS_TOKEN( s ): rItem.readString( rAttribs ); break;
265  case XLS_TOKEN( n ): rItem.readNumeric( rAttribs ); break;
266  case XLS_TOKEN( d ): rItem.readDate( rAttribs ); break;
267  case XLS_TOKEN( b ): rItem.readBool( rAttribs ); break;
268  case XLS_TOKEN( e ): rItem.readError( rAttribs ); break;
269  default: OSL_FAIL( "PivotCacheItemList::importItem - unknown element type" );
270  }
271 }
272 
273 void PivotCacheItemList::importItem( sal_Int32 nRecId, SequenceInputStream& rStrm )
274 {
275  if( nRecId == BIFF12_ID_PCITEM_ARRAY )
276  {
277  importArray( rStrm );
278  return;
279  }
280 
281  PivotCacheItem& rItem = createItem();
282  switch( nRecId )
283  {
285  case BIFF12_ID_PCITEMA_MISSING: break;
287  case BIFF12_ID_PCITEMA_STRING: rItem.readString( rStrm ); break;
289  case BIFF12_ID_PCITEMA_DOUBLE: rItem.readDouble( rStrm ); break;
291  case BIFF12_ID_PCITEMA_DATE: rItem.readDate( rStrm ); break;
293  case BIFF12_ID_PCITEMA_BOOL: rItem.readBool( rStrm ); break;
295  case BIFF12_ID_PCITEMA_ERROR: rItem.readError( rStrm ); break;
296  default: OSL_FAIL( "PivotCacheItemList::importItem - unknown record type" );
297  }
298 }
299 
300 const PivotCacheItem* PivotCacheItemList::getCacheItem( sal_Int32 nItemIdx ) const
301 {
302  return ContainerHelper::getVectorElement( maItems, nItemIdx );
303 }
304 
306 {
307  for( const auto& [rId, rCaption] : vCaptions )
308  {
309  if ( o3tl::make_unsigned( rId ) < maItems.size() )
310  maItems[ rId ].setStringValue( rCaption );
311  }
312 }
313 
314 void PivotCacheItemList::getCacheItemNames( ::std::vector< OUString >& orItemNames ) const
315 {
316  orItemNames.clear();
317  orItemNames.reserve( maItems.size() );
318  for( const auto& rItem : maItems )
319  orItemNames.push_back( rItem.getName() );
320 }
321 
322 // private --------------------------------------------------------------------
323 
325 {
326  maItems.emplace_back();
327  return maItems.back();
328 }
329 
331 {
332  sal_uInt16 nType = rStrm.readuInt16();
333  sal_Int32 nCount = rStrm.readInt32();
334  for( sal_Int32 nIdx = 0; !rStrm.isEof() && (nIdx < nCount); ++nIdx )
335  {
336  switch( nType )
337  {
338  case BIFF12_PCITEM_ARRAY_DOUBLE: createItem().readDouble( rStrm ); break;
339  case BIFF12_PCITEM_ARRAY_STRING: createItem().readString( rStrm ); break;
340  case BIFF12_PCITEM_ARRAY_ERROR: createItem().readError( rStrm ); break;
341  case BIFF12_PCITEM_ARRAY_DATE: createItem().readDate( rStrm ); break;
342  default:
343  OSL_FAIL( "PivotCacheItemList::importArray - unknown data type" );
344  return;
345  }
346  }
347 }
348 
350  mnNumFmtId( 0 ),
351  mnSqlType( 0 ),
352  mnHierarchy( 0 ),
353  mnLevel( 0 ),
354  mnMappingCount( 0 ),
355  mbDatabaseField( true ),
356  mbServerField( false ),
357  mbUniqueList( true ),
358  mbMemberPropField( false )
359 {
360 }
361 
363  mbHasSemiMixed( true ),
364  mbHasNonDate( true ),
365  mbHasDate( false ),
366  mbHasString( true ),
367  mbHasBlank( false ),
368  mbHasMixed( false ),
369  mbIsNumeric( false ),
370  mbIsInteger( false ),
371  mbHasLongText( false )
372 {
373 }
374 
376  mfStartValue( 0.0 ),
377  mfEndValue( 0.0 ),
378  mfInterval( 1.0 ),
379  mnParentField( -1 ),
380  mnBaseField( -1 ),
381  mnGroupBy( XML_range ),
382  mbRangeGroup( false ),
383  mbDateGroup( false ),
384  mbAutoStart( true ),
385  mbAutoEnd( true )
386 {
387 }
388 
390 {
391  static const sal_Int32 spnGroupBy[] = { XML_range,
392  XML_seconds, XML_minutes, XML_hours, XML_days, XML_months, XML_quarters, XML_years };
393  mnGroupBy = STATIC_ARRAY_SELECT( spnGroupBy, nGroupBy, XML_range );
394 }
395 
396 PivotCacheField::PivotCacheField( const WorkbookHelper& rHelper, bool bIsDatabaseField ) :
397  WorkbookHelper( rHelper ),
398  maSharedItems( rHelper ),
399  maGroupItems( rHelper )
400 {
401  maFieldModel.mbDatabaseField = bIsDatabaseField;
402 }
403 
405 {
406  maFieldModel.maName = rAttribs.getXString( XML_name, OUString() );
407  maFieldModel.maCaption = rAttribs.getXString( XML_caption, OUString() );
408  maFieldModel.maPropertyName = rAttribs.getXString( XML_propertyName, OUString() );
409  maFieldModel.maFormula = rAttribs.getXString( XML_formula, OUString() );
410  maFieldModel.mnNumFmtId = rAttribs.getInteger( XML_numFmtId, 0 );
411  maFieldModel.mnSqlType = rAttribs.getInteger( XML_sqlType, 0 );
412  maFieldModel.mnHierarchy = rAttribs.getInteger( XML_hierarchy, 0 );
413  maFieldModel.mnLevel = rAttribs.getInteger( XML_level, 0 );
414  maFieldModel.mnMappingCount = rAttribs.getInteger( XML_mappingCount, 0 );
415  maFieldModel.mbDatabaseField = rAttribs.getBool( XML_databaseField, true );
416  maFieldModel.mbServerField = rAttribs.getBool( XML_serverField, false );
417  maFieldModel.mbUniqueList = rAttribs.getBool( XML_uniqueList, true );
418  maFieldModel.mbMemberPropField = rAttribs.getBool( XML_memberPropertyField, false );
419 }
420 
422 {
423  OSL_ENSURE( maSharedItems.empty(), "PivotCacheField::importSharedItems - multiple shared items elements" );
424  maSharedItemsModel.mbHasSemiMixed = rAttribs.getBool( XML_containsSemiMixedTypes, true );
425  maSharedItemsModel.mbHasNonDate = rAttribs.getBool( XML_containsNonDate, true );
426  maSharedItemsModel.mbHasDate = rAttribs.getBool( XML_containsDate, false );
427  maSharedItemsModel.mbHasString = rAttribs.getBool( XML_containsString, true );
428  maSharedItemsModel.mbHasBlank = rAttribs.getBool( XML_containsBlank, false );
429  maSharedItemsModel.mbHasMixed = rAttribs.getBool( XML_containsMixedTypes, false );
430  maSharedItemsModel.mbIsNumeric = rAttribs.getBool( XML_containsNumber, false );
431  maSharedItemsModel.mbIsInteger = rAttribs.getBool( XML_containsInteger, false );
432  maSharedItemsModel.mbHasLongText = rAttribs.getBool( XML_longText, false );
433 }
434 
435 void PivotCacheField::importSharedItem( sal_Int32 nElement, const AttributeList& rAttribs )
436 {
437  maSharedItems.importItem( nElement, rAttribs );
438 }
439 
441 {
442  maFieldGroupModel.mnParentField = rAttribs.getInteger( XML_par, -1 );
443  maFieldGroupModel.mnBaseField = rAttribs.getInteger( XML_base, -1 );
444 }
445 
447 {
448  maFieldGroupModel.maStartDate = rAttribs.getDateTime( XML_startDate, css::util::DateTime() );
449  maFieldGroupModel.maEndDate = rAttribs.getDateTime( XML_endDate, css::util::DateTime() );
450  maFieldGroupModel.mfStartValue = rAttribs.getDouble( XML_startNum, 0.0 );
451  maFieldGroupModel.mfEndValue = rAttribs.getDouble( XML_endNum, 0.0 );
452  maFieldGroupModel.mfInterval = rAttribs.getDouble( XML_groupInterval, 1.0 );
453  maFieldGroupModel.mnGroupBy = rAttribs.getToken( XML_groupBy, XML_range );
456  maFieldGroupModel.mbAutoStart = rAttribs.getBool( XML_autoStart, true );
457  maFieldGroupModel.mbAutoEnd = rAttribs.getBool( XML_autoEnd, true );
458 }
459 
460 void PivotCacheField::importDiscretePrItem( sal_Int32 nElement, const AttributeList& rAttribs )
461 {
462  OSL_ENSURE( nElement == XLS_TOKEN( x ), "PivotCacheField::importDiscretePrItem - unexpected element" );
463  if( nElement == XLS_TOKEN( x ) )
464  maDiscreteItems.push_back( rAttribs.getInteger( XML_v, -1 ) );
465 }
466 
467 void PivotCacheField::importGroupItem( sal_Int32 nElement, const AttributeList& rAttribs )
468 {
469  maGroupItems.importItem( nElement, rAttribs );
470 }
471 
473 {
474  sal_uInt16 nFlags;
475  nFlags = rStrm.readuInt16();
477  maFieldModel.mnSqlType = rStrm.readInt16();
479  maFieldModel.mnLevel = rStrm.readInt32();
481  rStrm >> maFieldModel.maName;
482  if( getFlag( nFlags, BIFF12_PCDFIELD_HASCAPTION ) )
483  rStrm >> maFieldModel.maCaption;
484  if( getFlag( nFlags, BIFF12_PCDFIELD_HASFORMULA ) )
485  rStrm.skip( ::std::max< sal_Int32 >( rStrm.readInt32(), 0 ) );
486  if( maFieldModel.mnMappingCount > 0 )
487  rStrm.skip( ::std::max< sal_Int32 >( rStrm.readInt32(), 0 ) );
488  if( getFlag( nFlags, BIFF12_PCDFIELD_HASPROPERTYNAME ) )
489  rStrm >> maFieldModel.maPropertyName;
490 
491  maFieldModel.mbDatabaseField = getFlag( nFlags, BIFF12_PCDFIELD_DATABASEFIELD );
492  maFieldModel.mbServerField = getFlag( nFlags, BIFF12_PCDFIELD_SERVERFIELD );
493  maFieldModel.mbUniqueList = !getFlag( nFlags, BIFF12_PCDFIELD_NOUNIQUEITEMS );
494  maFieldModel.mbMemberPropField = getFlag( nFlags, BIFF12_PCDFIELD_MEMBERPROPFIELD );
495 }
496 
498 {
499  sal_uInt16 nFlags;
500  nFlags = rStrm.readuInt16();
501  maSharedItemsModel.mbHasSemiMixed = getFlag( nFlags, BIFF12_PCDFSITEMS_HASSEMIMIXED );
502  maSharedItemsModel.mbHasNonDate = getFlag( nFlags, BIFF12_PCDFSITEMS_HASNONDATE );
503  maSharedItemsModel.mbHasDate = getFlag( nFlags, BIFF12_PCDFSITEMS_HASDATE );
504  maSharedItemsModel.mbHasString = getFlag( nFlags, BIFF12_PCDFSITEMS_HASSTRING );
505  maSharedItemsModel.mbHasBlank = getFlag( nFlags, BIFF12_PCDFSITEMS_HASBLANK );
506  maSharedItemsModel.mbHasMixed = getFlag( nFlags, BIFF12_PCDFSITEMS_HASMIXED );
507  maSharedItemsModel.mbIsNumeric = getFlag( nFlags, BIFF12_PCDFSITEMS_ISNUMERIC );
508  maSharedItemsModel.mbIsInteger = getFlag( nFlags, BIFF12_PCDFSITEMS_ISINTEGER );
509  maSharedItemsModel.mbHasLongText = getFlag( nFlags, BIFF12_PCDFSITEMS_HASLONGTEXT );
510 }
511 
513 {
514  maSharedItems.importItem( nRecId, rStrm );
515 }
516 
518 {
521 }
522 
524 {
525  sal_uInt8 nGroupBy, nFlags;
526  nGroupBy = rStrm.readuChar();
527  nFlags = rStrm.readuChar();
531 
532  maFieldGroupModel.setBiffGroupBy( nGroupBy );
534  maFieldGroupModel.mbDateGroup = getFlag( nFlags, BIFF12_PCDFRANGEPR_DATEGROUP );
535  maFieldGroupModel.mbAutoStart = getFlag( nFlags, BIFF12_PCDFRANGEPR_AUTOSTART );
536  maFieldGroupModel.mbAutoEnd = getFlag( nFlags, BIFF12_PCDFRANGEPR_AUTOEND );
537 
538  OSL_ENSURE( maFieldGroupModel.mbDateGroup == (maFieldGroupModel.mnGroupBy != XML_range), "PivotCacheField::importPCDFRangePr - wrong date flag" );
540  {
543  }
544 }
545 
547 {
548  OSL_ENSURE( nRecId == BIFF12_ID_PCITEM_INDEX, "PivotCacheField::importPCDFDiscretePrItem - unexpected record" );
549  if( nRecId == BIFF12_ID_PCITEM_INDEX )
550  maDiscreteItems.push_back( rStrm.readInt32() );
551 }
552 
554 {
555  maGroupItems.importItem( nRecId, rStrm );
556 }
557 
558 const PivotCacheItem* PivotCacheField::getCacheItem( sal_Int32 nItemIdx ) const
559 {
560  if( hasGroupItems() )
561  return maGroupItems.getCacheItem( nItemIdx );
562  if( hasSharedItems() )
563  return maSharedItems.getCacheItem( nItemIdx );
564  return nullptr;
565 }
566 
568 {
569  if( hasGroupItems() )
570  maGroupItems.applyItemCaptions( vCaptions );
571  if( hasSharedItems() )
572  maSharedItems.applyItemCaptions( vCaptions );
573 }
574 
575 void PivotCacheField::getCacheItemNames( ::std::vector< OUString >& orItemNames ) const
576 {
577  if( hasGroupItems() )
578  maGroupItems.getCacheItemNames( orItemNames );
579  else if( hasSharedItems() )
580  maSharedItems.getCacheItemNames( orItemNames );
581 }
582 
584 {
585  if( hasGroupItems() )
586  return maGroupItems;
587  return maSharedItems;
588 }
589 
590 void PivotCacheField::convertNumericGrouping( const Reference< XDataPilotField >& rxDPField ) const
591 {
592  OSL_ENSURE( hasGroupItems() && hasNumericGrouping(), "PivotCacheField::convertNumericGrouping - not a numeric group field" );
593  PropertySet aPropSet( rxDPField );
594  if( hasGroupItems() && hasNumericGrouping() && aPropSet.is() )
595  {
596  DataPilotFieldGroupInfo aGroupInfo;
597  aGroupInfo.HasAutoStart = maFieldGroupModel.mbAutoStart;
598  aGroupInfo.HasAutoEnd = maFieldGroupModel.mbAutoEnd;
599  aGroupInfo.HasDateValues = false;
600  aGroupInfo.Start = maFieldGroupModel.mfStartValue;
601  aGroupInfo.End = maFieldGroupModel.mfEndValue;
602  aGroupInfo.Step = maFieldGroupModel.mfInterval;
603  aGroupInfo.GroupBy = 0;
604  aPropSet.setProperty( PROP_GroupInfo, aGroupInfo );
605  }
606 }
607 
608 OUString PivotCacheField::createDateGroupField( const Reference< XDataPilotField >& rxBaseDPField ) const
609 {
610  OSL_ENSURE( hasGroupItems() && hasDateGrouping(), "PivotCacheField::createDateGroupField - not a numeric group field" );
611  Reference< XDataPilotField > xDPGroupField;
612  PropertySet aPropSet( rxBaseDPField );
613  if( hasGroupItems() && hasDateGrouping() && aPropSet.is() )
614  {
615  bool bDayRanges = (maFieldGroupModel.mnGroupBy == XML_days) && (maFieldGroupModel.mfInterval >= 2.0);
616 
617  DataPilotFieldGroupInfo aGroupInfo;
618  aGroupInfo.HasAutoStart = maFieldGroupModel.mbAutoStart;
619  aGroupInfo.HasAutoEnd = maFieldGroupModel.mbAutoEnd;
620  aGroupInfo.HasDateValues = true;
623  aGroupInfo.Step = bDayRanges ? maFieldGroupModel.mfInterval : 0.0;
624 
625  using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
626  switch( maFieldGroupModel.mnGroupBy )
627  {
628  case XML_years: aGroupInfo.GroupBy = YEARS; break;
629  case XML_quarters: aGroupInfo.GroupBy = QUARTERS; break;
630  case XML_months: aGroupInfo.GroupBy = MONTHS; break;
631  case XML_days: aGroupInfo.GroupBy = DAYS; break;
632  case XML_hours: aGroupInfo.GroupBy = HOURS; break;
633  case XML_minutes: aGroupInfo.GroupBy = MINUTES; break;
634  case XML_seconds: aGroupInfo.GroupBy = SECONDS; break;
635  default: OSL_FAIL( "PivotCacheField::convertRangeGrouping - unknown date/time interval" );
636  }
637 
638  try
639  {
640  Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY_THROW );
641  xDPGroupField = xDPGrouping->createDateGroup( aGroupInfo );
642  }
643  catch( Exception& )
644  {
645  }
646  }
647 
648  Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
649  return xFieldName.is() ? xFieldName->getName() : OUString();
650 }
651 
652 OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotField >& rxBaseDPField, const PivotCacheField& rBaseCacheField, PivotCacheGroupItemVector& orItemNames ) const
653 {
654  SAL_WARN_IF( !hasGroupItems() || maDiscreteItems.empty(), "sc", "PivotCacheField::createParentGroupField - not a group field" );
655  SAL_WARN_IF( maDiscreteItems.size() != orItemNames.size(), "sc", "PivotCacheField::createParentGroupField - number of item names does not match grouping info" );
656  Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY );
657  if( !xDPGrouping.is() ) return OUString();
658 
659  // map the group item indexes from maGroupItems to all item indexes from maDiscreteItems
660  std::vector< std::vector<sal_Int32> > aItemMap( maGroupItems.size() );
661  sal_Int32 nIndex = -1;
662  for( const auto& rDiscreteItem : maDiscreteItems )
663  {
664  ++nIndex;
665  if( std::vector<sal_Int32>* pItems = ContainerHelper::getVectorElementAccess( aItemMap, rDiscreteItem ) )
666  {
667  if ( const PivotCacheItem* pItem = rBaseCacheField.getCacheItems().getCacheItem( nIndex ) )
668  {
669  // Skip unspecified or unused entries or errors
670  if ( pItem->isUnused() || ( pItem->getType() == XML_m ) || ( pItem->getType() == XML_e ) )
671  continue;
672  }
673  pItems->push_back( nIndex );
674  }
675  }
676 
677  // process all groups
678  Reference< XDataPilotField > xDPGroupField;
679  nIndex = 0;
680  for( const auto& rItems : aItemMap )
681  {
682  SAL_WARN_IF( rItems.empty(), "sc", "PivotCacheField::createParentGroupField - item/group should not be empty" );
683  if( !rItems.empty() )
684  {
685  /* Insert the names of the items that are part of this group. Calc
686  expects the names of the members of the field whose members are
687  grouped (which may be the names of groups too). Excel provides
688  the names of the base field items instead (no group names
689  involved). Therefore, the passed collection of current item
690  names as they are already grouped is used here to resolve the
691  item names. */
692  ::std::vector< OUString > aMembers;
693  for( auto i : rItems )
694  if( const PivotCacheGroupItem* pName = ContainerHelper::getVectorElement( orItemNames, i ) )
695  if( ::std::find( aMembers.begin(), aMembers.end(), pName->maGroupName ) == aMembers.end() )
696  aMembers.push_back( pName->maGroupName );
697 
698  /* Check again, that this is not just a group that is not grouped
699  further with other items. */
700  if( !aMembers.empty() ) try
701  {
702  // only the first call of createNameGroup() returns the new field
703  Reference< XDataPilotField > xDPNewField = xDPGrouping->createNameGroup( ContainerHelper::vectorToSequence( aMembers ) );
704  SAL_WARN_IF( xDPGroupField.is() == xDPNewField.is(), "sc", "PivotCacheField::createParentGroupField - missing group field" );
705  if( !xDPGroupField.is() )
706  xDPGroupField = xDPNewField;
707 
708  // get current grouping info
709  DataPilotFieldGroupInfo aGroupInfo;
710  PropertySet aPropSet( xDPGroupField );
711  aPropSet.getProperty( aGroupInfo, PROP_GroupInfo );
712 
713  /* Find the group object and the auto-generated group name.
714  The returned field contains all groups derived from the
715  previous field if that is grouped too. To find the correct
716  group, the first item used to create the group is searched.
717  Calc provides the original item names of the base field
718  when the group is querried for its members. Its does not
719  provide the names of members that are already groups in the
720  field used to create the new groups. (Is this a bug?)
721  Therefore, a name from the passed list of original item
722  names is used to find the correct group. */
723  OUString aFirstItem;
724  if( const PivotCacheGroupItem* pName = ContainerHelper::getVectorElement( orItemNames, rItems.front() ) )
725  aFirstItem = pName->maOrigName;
726  Reference< XNamed > xGroupName;
727  OUString aAutoName;
728  Reference< XIndexAccess > xGroupsIA( aGroupInfo.Groups, UNO_QUERY_THROW );
729  for( sal_Int32 nIdx = 0, nCount = xGroupsIA->getCount(); (nIdx < nCount) && (aAutoName.isEmpty()); ++nIdx ) try
730  {
731  Reference< XNameAccess > xItemsNA( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
732  if( xItemsNA->hasByName( aFirstItem ) )
733  {
734  xGroupName.set( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
735  aAutoName = xGroupName->getName();
736  }
737  }
738  catch( Exception const & )
739  {
740  TOOLS_WARN_EXCEPTION("sc", "PivotCacheField::createParentGroupField" );
741  }
742  SAL_WARN_IF( aAutoName.isEmpty(), "sc", "PivotCacheField::createParentGroupField - cannot find auto-generated group name" );
743 
744  // get the real group name from the list of group items
745  OUString aGroupName;
746  if( const PivotCacheItem* pGroupItem = maGroupItems.getCacheItem( nIndex ) )
747  aGroupName = pGroupItem->getName();
748  SAL_WARN_IF( aGroupName.isEmpty(), "sc", "PivotCacheField::createParentGroupField - cannot find group name" );
749  if( aGroupName.isEmpty() )
750  aGroupName = aAutoName;
751 
752  if( xGroupName.is() && !aGroupName.isEmpty() )
753  {
754  // replace the auto-generated group name with the real name
755  if( aAutoName != aGroupName )
756  {
757  xGroupName->setName( aGroupName );
758  aPropSet.setProperty( PROP_GroupInfo, aGroupInfo );
759  }
760  // replace original item names in passed vector with group name
761  for( auto i : rItems )
763  pName->maGroupName = aGroupName;
764  }
765  }
766  catch( Exception const & )
767  {
768  TOOLS_WARN_EXCEPTION("sc", "PivotCacheField::createParentGroupField" );
769  }
770  }
771  ++nIndex;
772  }
773 
774  Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
775  return xFieldName.is() ? xFieldName->getName() : OUString();
776 }
777 
778 void PivotCacheField::writeSourceHeaderCell( const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const
779 {
780  CellModel aModel;
781  aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), rSheetHelper.getSheetIndex() );
782  rSheetHelper.getSheetData().setStringCell( aModel, maFieldModel.maName );
783 }
784 
785 void PivotCacheField::writeSourceDataCell( const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem& rItem ) const
786 {
787  bool bHasIndex = rItem.getType() == XML_x;
788  OSL_ENSURE( bHasIndex != maSharedItems.empty(), "PivotCacheField::writeSourceDataCell - shared items missing or not expected" );
789  if( bHasIndex )
790  writeSharedItemToSourceDataCell( rSheetHelper, nCol, nRow, rItem.getValue().get< sal_Int32 >() );
791  else
792  writeItemToSourceDataCell( rSheetHelper, nCol, nRow, rItem );
793 }
794 
795 void PivotCacheField::importPCRecordItem( SequenceInputStream& rStrm, const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const
796 {
797  if( hasSharedItems() )
798  {
799  writeSharedItemToSourceDataCell( rSheetHelper, nCol, nRow, rStrm.readInt32() );
800  }
801  else
802  {
803  PivotCacheItem aItem;
805  aItem.readDouble( rStrm );
807  aItem.readDate( rStrm );
808  else
809  aItem.readString( rStrm );
810  writeItemToSourceDataCell( rSheetHelper, nCol, nRow, aItem );
811  }
812 }
813 
814 // private --------------------------------------------------------------------
815 
817  sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem& rItem )
818 {
819  if( rItem.getType() == XML_m )
820  return;
821 
822  CellModel aModel;
823  aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), rSheetHelper.getSheetIndex() );
824  SheetDataBuffer& rSheetData = rSheetHelper.getSheetData();
825  switch( rItem.getType() )
826  {
827  case XML_s: rSheetData.setStringCell( aModel, rItem.getValue().get< OUString >() ); break;
828  case XML_n: rSheetData.setValueCell( aModel, rItem.getValue().get< double >() ); break;
829  case XML_i: rSheetData.setValueCell( aModel, rItem.getValue().get< sal_Int16 >() ); break;
830  case XML_d: rSheetData.setDateTimeCell( aModel, rItem.getValue().get< css::util::DateTime >() ); break;
831  case XML_b: rSheetData.setBooleanCell( aModel, rItem.getValue().get< bool >() ); break;
832  case XML_e: rSheetData.setErrorCell( aModel, static_cast< sal_uInt8 >( rItem.getValue().get< sal_Int32 >() ) ); break;
833  default: OSL_FAIL( "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
834  }
835 }
836 
838  const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx ) const
839 {
840  if( const PivotCacheItem* pCacheItem = maSharedItems.getCacheItem( nItemIdx ) )
841  writeItemToSourceDataCell( rSheetHelper, nCol, nRow, *pCacheItem );
842 }
843 
845  mfRefreshedDate( 0.0 ),
846  mnRecords( 0 ),
847  mnMissItemsLimit( 0 ),
848  mbInvalid( false ),
849  mbSaveData( true ),
850  mbRefreshOnLoad( false ),
851  mbOptimizeMemory( false ),
852  mbEnableRefresh( true ),
853  mbBackgroundQuery( false ),
854  mbUpgradeOnRefresh( false ),
855  mbTupleCache( false ),
856  mbSupportSubquery( false ),
857  mbSupportDrill( false )
858 {
859 }
860 
862  mnSourceType( XML_TOKEN_INVALID ),
863  mnConnectionId( 0 )
864 {
865 }
866 
868 {
870 }
871 
873  WorkbookHelper( rHelper ),
874  mnCurrRow( -1 ),
875  mbValidSource( false ),
876  mbDummySheet( false )
877 {
878 }
879 
881 {
882  maDefModel.maRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
883  maDefModel.maRefreshedBy = rAttribs.getXString( XML_refreshedBy, OUString() );
884  maDefModel.mfRefreshedDate = rAttribs.getDouble( XML_refreshedDate, 0.0 );
885  maDefModel.mnRecords = rAttribs.getInteger( XML_recordCount, 0 );
886  maDefModel.mnMissItemsLimit = rAttribs.getInteger( XML_missingItemsLimit, 0 );
887  maDefModel.mbInvalid = rAttribs.getBool( XML_invalid, false );
888  maDefModel.mbSaveData = rAttribs.getBool( XML_saveData, true );
889  maDefModel.mbRefreshOnLoad = rAttribs.getBool( XML_refreshOnLoad, false );
890  maDefModel.mbOptimizeMemory = rAttribs.getBool( XML_optimizeMemory, false );
891  maDefModel.mbEnableRefresh = rAttribs.getBool( XML_enableRefresh, true );
892  maDefModel.mbBackgroundQuery = rAttribs.getBool( XML_backgroundQuery, false );
893  maDefModel.mbUpgradeOnRefresh = rAttribs.getBool( XML_upgradeOnRefresh, false );
894  maDefModel.mbTupleCache = rAttribs.getBool( XML_tupleCache, false );
895  maDefModel.mbSupportSubquery = rAttribs.getBool( XML_supportSubquery, false );
896  maDefModel.mbSupportDrill = rAttribs.getBool( XML_supportAdvancedDrill, false );
897 }
898 
900 {
901  maSourceModel.mnSourceType = rAttribs.getToken( XML_type, XML_TOKEN_INVALID );
902  maSourceModel.mnConnectionId = rAttribs.getInteger( XML_connectionId, 0 );
903 }
904 
905 void PivotCache::importWorksheetSource( const AttributeList& rAttribs, const Relations& rRelations )
906 {
907  maSheetSrcModel.maRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
908  maSheetSrcModel.maSheet = rAttribs.getXString( XML_sheet, OUString() );
909  maSheetSrcModel.maDefName = rAttribs.getXString( XML_name, OUString() );
910 
911  // resolve URL of external document
912  maTargetUrl = rRelations.getExternalTargetFromRelId( maSheetSrcModel.maRelId );
913  // store range address unchecked with sheet index 0, will be resolved/checked later
915 }
916 
918 {
919  sal_uInt8 nFlags1, nFlags2;
920  rStrm.skip( 3 ); // create/refresh version id's
921  nFlags1 = rStrm.readuChar();
924  nFlags2 = rStrm.readuChar();
925  maDefModel.mnRecords = rStrm.readInt32();
926  if( getFlag( nFlags2, BIFF12_PCDEFINITION_HASUSERNAME ) )
927  rStrm >> maDefModel.maRefreshedBy;
928  if( getFlag( nFlags2, BIFF12_PCDEFINITION_HASRELID ) )
929  rStrm >> maDefModel.maRelId;
930 
931  maDefModel.mbInvalid = getFlag( nFlags1, BIFF12_PCDEFINITION_INVALID );
932  maDefModel.mbSaveData = getFlag( nFlags1, BIFF12_PCDEFINITION_SAVEDATA );
933  maDefModel.mbRefreshOnLoad = getFlag( nFlags1, BIFF12_PCDEFINITION_REFRESHONLOAD );
934  maDefModel.mbOptimizeMemory = getFlag( nFlags1, BIFF12_PCDEFINITION_OPTIMIZEMEMORY );
935  maDefModel.mbEnableRefresh = getFlag( nFlags1, BIFF12_PCDEFINITION_ENABLEREFRESH );
936  maDefModel.mbBackgroundQuery = getFlag( nFlags1, BIFF12_PCDEFINITION_BACKGROUNDQUERY );
937  maDefModel.mbUpgradeOnRefresh = getFlag( nFlags1, BIFF12_PCDEFINITION_UPGRADEONREFR );
938  maDefModel.mbTupleCache = getFlag( nFlags1, BIFF12_PCDEFINITION_TUPLECACHE );
939  maDefModel.mbSupportSubquery = getFlag( nFlags2, BIFF12_PCDEFINITION_SUPPORTSUBQUERY );
940  maDefModel.mbSupportDrill = getFlag( nFlags2, BIFF12_PCDEFINITION_SUPPORTDRILL );
941 }
942 
944 {
945  sal_Int32 nSourceType;
946  nSourceType = rStrm.readInt32();
948  static const sal_Int32 spnSourceTypes[] = { XML_worksheet, XML_external, XML_consolidation, XML_scenario };
949  maSourceModel.mnSourceType = STATIC_ARRAY_SELECT( spnSourceTypes, nSourceType, XML_TOKEN_INVALID );
950 }
951 
952 void PivotCache::importPCDSheetSource( SequenceInputStream& rStrm, const Relations& rRelations )
953 {
954  sal_uInt8 nIsDefName, nIsBuiltinName, nFlags;
955  nIsDefName = rStrm.readuChar();
956  nIsBuiltinName = rStrm.readuChar();
957  nFlags = rStrm.readuChar();
958  if( getFlag( nFlags, BIFF12_PCDWBSOURCE_HASSHEET ) )
959  rStrm >> maSheetSrcModel.maSheet;
960  if( getFlag( nFlags, BIFF12_PCDWBSOURCE_HASRELID ) )
961  rStrm >> maSheetSrcModel.maRelId;
962 
963  // read cell range or defined name
964  if( nIsDefName == 0 )
965  {
966  BinRange aBinRange;
967  rStrm >> aBinRange;
968  // store range address unchecked with sheet index 0, will be resolved/checked later
970  }
971  else
972  {
973  rStrm >> maSheetSrcModel.maDefName;
974  if( nIsBuiltinName != 0 )
976  }
977 
978  // resolve URL of external document
979  maTargetUrl = rRelations.getExternalTargetFromRelId( maSheetSrcModel.maRelId );
980 }
981 
983 {
984  PivotCacheFieldVector::value_type xCacheField = std::make_shared<PivotCacheField>( *this, true/*bIsDatabaseField*/ );
985  maFields.push_back( xCacheField );
986  return *xCacheField;
987 }
988 
990 {
991  // collect all fields that are based on source data (needed to finalize source data below)
992  OSL_ENSURE( !maFields.empty(), "PivotCache::finalizeImport - no pivot cache fields found" );
993  for( PivotCacheFieldVector::const_iterator aIt = maFields.begin(), aEnd = maFields.end(); aIt != aEnd; ++aIt )
994  {
995  if( (*aIt)->isDatabaseField() )
996  {
997  OSL_ENSURE( (aIt == maFields.begin()) || (*(aIt - 1))->isDatabaseField(),
998  "PivotCache::finalizeImport - database field follows a calculated field" );
999  maDatabaseIndexes.push_back( static_cast< sal_Int32 >( maDatabaseFields.size() ) );
1000  maDatabaseFields.push_back( *aIt );
1001  }
1002  else
1003  {
1004  maDatabaseIndexes.push_back( -1 );
1005  }
1006  }
1007  OSL_ENSURE( !maDatabaseFields.empty(), "PivotCache::finalizeImport - no pivot cache source fields found" );
1008 
1009  // finalize source data depending on source type
1010  switch( maSourceModel.mnSourceType )
1011  {
1012  case XML_worksheet:
1013  {
1014  // decide whether an external document is used
1015  bool bInternal = maTargetUrl.isEmpty() && maSheetSrcModel.maRelId.isEmpty();
1016  bool bExternal = !maTargetUrl.isEmpty(); // relation ID may be empty, e.g. BIFF import
1017  OSL_ENSURE( bInternal || bExternal, "PivotCache::finalizeImport - invalid external document URL" );
1018  if( bInternal )
1020  else if( bExternal )
1022  }
1023  break;
1024 
1025  // currently, we only support worksheet data sources
1026  case XML_external:
1027  break;
1028  case XML_consolidation:
1029  break;
1030  case XML_scenario:
1031  break;
1032  }
1033 }
1034 
1036 {
1037  return maFields.get( nFieldIdx ).get();
1038 }
1039 
1040 const PivotCacheField* PivotCache::getCacheField( sal_Int32 nFieldIdx ) const
1041 {
1042  return maFields.get( nFieldIdx ).get();
1043 }
1044 
1045 sal_Int32 PivotCache::getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const
1046 {
1047  return ContainerHelper::getVectorElement( maDatabaseIndexes, nFieldIdx, -1 );
1048 }
1049 
1050 void PivotCache::writeSourceHeaderCells( const WorksheetHelper& rSheetHelper ) const
1051 {
1052  OSL_ENSURE( static_cast< size_t >( maSheetSrcModel.maRange.aEnd.Col() - maSheetSrcModel.maRange.aStart.Col() + 1 ) == maDatabaseFields.size(),
1053  "PivotCache::writeSourceHeaderCells - source cell range width does not match number of source fields" );
1057  mnCurrRow = -1;
1058  updateSourceDataRow( rSheetHelper, nRow );
1059  for( const auto& rxDatabaseField : maDatabaseFields )
1060  {
1061  if (nCol > nMaxCol)
1062  break;
1063  rxDatabaseField->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
1064  ++nCol;
1065  }
1066 }
1067 
1068 void PivotCache::writeSourceDataCell( const WorksheetHelper& rSheetHelper, sal_Int32 nColIdx, sal_Int32 nRowIdx, const PivotCacheItem& rItem ) const
1069 {
1070  SCCOL nCol = maSheetSrcModel.maRange.aStart.Col() + nColIdx;
1071  OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Col() <= nCol ) && ( nCol <= maSheetSrcModel.maRange.aEnd.Col() ), "PivotCache::writeSourceDataCell - invalid column index" );
1072  SCROW nRow = maSheetSrcModel.maRange.aStart.Row() + nRowIdx;
1073  OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Row() < nRow ) && ( nRow <= maSheetSrcModel.maRange.aEnd.Row() ), "PivotCache::writeSourceDataCell - invalid row index" );
1074  updateSourceDataRow( rSheetHelper, nRow );
1075  if( const PivotCacheField* pCacheField = maDatabaseFields.get( nColIdx ).get() )
1076  pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem );
1077 }
1078 
1079 void PivotCache::importPCRecord( SequenceInputStream& rStrm, const WorksheetHelper& rSheetHelper, sal_Int32 nRowIdx ) const
1080 {
1081  SCROW nRow = maSheetSrcModel.maRange.aStart.Row() + nRowIdx;
1082  OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Row() < nRow ) && ( nRow <= maSheetSrcModel.maRange.aEnd.Row() ), "PivotCache::importPCRecord - invalid row index" );
1085  for( const auto& rxDatabaseField : maDatabaseFields )
1086  {
1087  if( rStrm.isEof() || (nCol > nMaxCol) )
1088  break;
1089  rxDatabaseField->importPCRecordItem( rStrm, rSheetHelper, nCol, nRow );
1090  ++nCol;
1091  }
1092 }
1093 
1094 // private --------------------------------------------------------------------
1095 
1097 {
1098  // resolve sheet name to sheet index
1099  sal_Int16 nSheet = getWorksheets().getCalcSheetIndex( maSheetSrcModel.maSheet );
1100 
1101  // if cache is based on a defined name or table, try to resolve to cell range
1102  if( !maSheetSrcModel.maDefName.isEmpty() )
1103  {
1104  // local or global defined name
1105  if( const DefinedName* pDefName = getDefinedNames().getByModelName( maSheetSrcModel.maDefName, nSheet ).get() )
1106  {
1107  mbValidSource = pDefName->getAbsoluteRange( maSheetSrcModel.maRange );
1108  }
1109  // table
1110  else if( const Table* pTable = getTables().getTable( maSheetSrcModel.maDefName ).get() )
1111  {
1112  // get original range from table, but exclude the totals row(s)
1113  maSheetSrcModel.maRange = pTable->getOriginalRange();
1114  mbValidSource = (pTable->getHeight() - pTable->getTotalsRows()) > 1;
1115  if( mbValidSource )
1116  maSheetSrcModel.maRange.aEnd.SetRow( maSheetSrcModel.maRange.aEnd.Row() - pTable->getTotalsRows() );
1117  }
1118  }
1119  // else try the cell range (if the sheet exists)
1120  else if( nSheet >= 0 )
1121  {
1122  // insert sheet index into the range, range address will be checked below
1124  mbValidSource = true;
1125  }
1126  // else sheet has been deleted, generate the source data from cache
1127  else if( !maSheetSrcModel.maSheet.isEmpty() )
1128  {
1130  // return here to skip the source range check below
1131  return;
1132  }
1133 
1134  // check range location, do not allow ranges that overflow the sheet partly
1138 }
1139 
1141 {
1142  /* If pivot cache is based on external sheet data, try to restore sheet
1143  data from cache records. No support for external defined names or tables,
1144  sheet name and path to cache records fragment (OOXML only) are required. */
1145  bool bHasRelation = !maDefModel.maRelId.isEmpty();
1146  if( bHasRelation && maSheetSrcModel.maDefName.isEmpty() && !maSheetSrcModel.maSheet.isEmpty() )
1148 }
1149 
1151 {
1152  ScRange& rRange = maSheetSrcModel.maRange;
1153  // data will be inserted in top-left cell, sheet index is still set to 0 (will be set below)
1154  rRange.aEnd.SetCol( rRange.aEnd.Col() - rRange.aStart.Col() );
1155  rRange.aStart.SetCol( 0 );
1156  rRange.aEnd.SetRow( rRange.aEnd.Row() - rRange.aStart.Row() );
1157  rRange.aStart.SetRow( 0 );
1158  // check range location, do not allow ranges that overflow the sheet partly
1159  if( getAddressConverter().checkCellRange( rRange, false, true ) )
1160  {
1161  maColSpans.insert( ValueRange( rRange.aStart.Col(), rRange.aEnd.Col() ) );
1162  OUString aSheetName = "DPCache_" + maSheetSrcModel.maSheet;
1163  rRange.aStart.SetTab( getWorksheets().insertEmptySheet( aSheetName ) );
1164  mbValidSource = mbDummySheet = rRange.aStart.Tab() >= 0;
1165  }
1166 }
1167 
1168 void PivotCache::updateSourceDataRow( const WorksheetHelper& rSheetHelper, sal_Int32 nRow ) const
1169 {
1170  if( mnCurrRow != nRow )
1171  {
1172  rSheetHelper.getSheetData().setColSpans( nRow, maColSpans );
1173  mnCurrRow = nRow;
1174  }
1175 }
1176 
1178  WorkbookHelper( rHelper )
1179 {
1180 }
1181 
1182 void PivotCacheBuffer::registerPivotCacheFragment( sal_Int32 nCacheId, const OUString& rFragmentPath )
1183 {
1184  OSL_ENSURE( nCacheId >= 0, "PivotCacheBuffer::registerPivotCacheFragment - invalid pivot cache identifier" );
1185  OSL_ENSURE( maFragmentPaths.count( nCacheId ) == 0, "PivotCacheBuffer::registerPivotCacheFragment - fragment path exists already" );
1186  if( (nCacheId >= 0) && !rFragmentPath.isEmpty() )
1187  maFragmentPaths[ nCacheId ] = rFragmentPath;
1188 }
1189 
1191 {
1192  /* OOXML/BIFF12 filter: On first call for the cache ID, the pivot
1193  cache object is created and inserted into maCaches. Then, the cache
1194  definition fragment is read and the cache is returned. On
1195  subsequent calls, the created cache will be found in maCaches and
1196  returned immediately. */
1197  // try to find an imported pivot cache
1198  if( PivotCache* pCache = maCaches.get( nCacheId ).get() )
1199  return pCache;
1200 
1201  // check if a fragment path exists for the passed cache identifier
1202  FragmentPathMap::iterator aIt = maFragmentPaths.find( nCacheId );
1203  if( aIt == maFragmentPaths.end() )
1204  return nullptr;
1205 
1206  /* Import the cache fragment. This may create a dummy data sheet
1207  for external sheet sources. */
1208  PivotCache& rCache = createPivotCache( nCacheId );
1209  importOoxFragment( new PivotCacheDefinitionFragment( *this, aIt->second, rCache ) );
1210  return &rCache;
1211 }
1212 
1214 {
1215  maCacheIds.push_back( nCacheId );
1216  PivotCacheMap::mapped_type& rxCache = maCaches[ nCacheId ];
1217  rxCache = std::make_shared<PivotCache>( *this );
1218  return *rxCache;
1219 }
1220 
1221 } // namespace oox
1222 
1223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
bool checkCellRange(const ScRange &rRange, bool bAllowOverflow, bool bTrackOverflow)
Checks the passed cell range if it fits into the spreadsheet limits.
void importDiscretePrItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports an item of the mapping between group items and base items from the passed element...
::std::vector< IdCaptionPair > IdCaptionPairList
void importPCDFGroupItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports one or more group items from the passed record.
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the specified item.
bool mbBackgroundQuery
True = refreshing cache is enabled in UI.
sal_Int32 nIndex
const sal_Int32 BIFF12_ID_PCITEMA_MISSING
Definition: biffhelper.hxx:178
ScAddress aStart
Definition: address.hxx:500
SheetDataBuffer & getSheetData() const
Returns the buffer for cell contents and cell formatting.
OUString createParentGroupField(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames) const
Creates a new grouped DataPilot field and returns its name.
virtual void skip(sal_Int32 nBytes, size_t nAtomSize=1) override
bool hasSharedItems() const
Returns true, if the field contains a list of shared items.
bool mbServerField
True = field from source data; false = calculated field.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
bool mbDummySheet
True = pivot cache is based on supported data source.
void setBiffGroupBy(sal_uInt8 nGroupBy)
Sets the group-by value for BIFF import.
void importSharedItems(const AttributeList &rAttribs)
Imports shared items settings from the sharedItems element.
void importPCDFSharedItems(SequenceInputStream &rStrm)
Imports shared items settings from the PCDFSHAREDITEMS record.
SCROW Row() const
Definition: address.hxx:262
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
PCFieldModel maFieldModel
Mapping between group and base items.
bool mbEnableRefresh
True = application may optimize memory usage.
bool getProperty(Type &orValue, sal_Int32 nPropId) const
double mfRefreshedDate
Name of user who last refreshed the cache.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
const sal_Int32 BIFF12_ID_PCITEMA_DATE
Definition: biffhelper.hxx:175
sal_Int32 mnMissItemsLimit
Number of data records in the cache.
css::util::DateTime maEndDate
Manual or calculated start date for range grouping.
OptValue< OUString > getXString(sal_Int32 nAttrToken) const
sal_Int16 mnLevel
sal_Int32 mnNumFmtId
void importPCDefinition(SequenceInputStream &rStrm)
Reads pivot cache global settings from the PCDEFINITION record.
bool mbHasLongText
True = has numeric item(s) with only integers, maybe other types except date.
void writeSourceDataCell(const WorksheetHelper &rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem &rItem) const
Writes a source field item value into the passed sheet.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
PivotCacheFieldVector maDatabaseFields
All pivot cache fields.
PivotCacheField & createCacheField()
Creates and returns a new pivot cache field.
A 2D cell range address struct for binary filters.
bool hasDateGrouping() const
Returns true, if the field has inplace date grouping settings.
const sal_Int32 BIFF12_ID_PCITEMA_STRING
Definition: biffhelper.hxx:179
sal_Int64 n
void importPCDSource(SequenceInputStream &rStrm)
Reads cache source settings from the PCDSOURCE record.
IndexVector maDatabaseIndexes
All cache fields that are based on source data.
const ScAddress & getMaxApiAddress() const
Returns the biggest valid cell address in the own Calc document.
bool mbAutoStart
True = items are grouped by date ranges or by item names.
const sal_Int32 BIFF12_ID_PCITEM_STRING
Definition: biffhelper.hxx:173
PCFieldModel()
True = contains OLAP member properties.
sal_Int32 mnNumFmtId
Formula of a calculated field.
PCDefinitionModel maDefModel
Database field index for all fields.
bool mbUniqueList
True = ODBC server-based page field.
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the shared or group item with the specified index.
DefinedNameRef getByModelName(const OUString &rModelName, sal_Int16 nCalcSheet=-1) const
Returns a defined name by its model name.
bool hasGroupItems() const
Returns true, if the field contains a list of grouping items.
value_type get(sal_Int32 nIndex) const
std::vector< PivotCacheItem > maItems
void writeSourceDataCell(const WorksheetHelper &rSheetHelper, sal_Int32 nColIdx, sal_Int32 nRowIdx, const PivotCacheItem &rItem) const
Writes a source field item value into the passed sheet.
ScAddress aEnd
Definition: address.hxx:501
OptValue< double > getDouble(sal_Int32 nAttrToken) const
PCSharedItemsModel maSharedItemsModel
Settings for this cache field.
double mfEndValue
Manual or calculated start value for range grouping.
bool mbDatabaseField
Number of property mappings.
#define STATIC_ARRAY_SELECT(array, index, def)
OptValue< OUString > getString(sal_Int32 nAttrToken) const
OUString maDefName
Sheet name for cell range or sheet-local defined names.
unsigned char readuChar()
void finalizeExternalSheetSource()
Finalizes the pivot cache if it is based on sheet data of an external spreadsheet document...
void writeSharedItemToSourceDataCell(const WorksheetHelper &rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx) const
Tries to write the value of a shared item to the passed sheet position.
float x
static bool convertToCellRangeUnchecked(ScRange &orRange, const OUString &rString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet limits.
PivotCacheItem & createItem()
Creates and returns a new item at the end of the items list.
void getCacheItemNames(::std::vector< OUString > &orItemNames) const
Returns the names of all items.
void registerPivotCacheFragment(sal_Int32 nCacheId, const OUString &rFragmentPath)
Registers a pivot cache definition fragment.
const sal_Int32 BIFF12_ID_PCITEMA_BOOL
Definition: biffhelper.hxx:174
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
void importItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports the item from the passed attribute list.
void applyItemCaptions(const IdCaptionPairList &vCaptions)
void importWorksheetSource(const AttributeList &rAttribs, const ::oox::core::Relations &rRelations)
Reads sheet source settings from the worksheetSource element.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the field with the passed index.
sal_Int32 mnType
Value of the item.
void importGroupItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports a group item from the passed element.
double calcSerialFromDateTime(const css::util::DateTime &rDateTime) const
Returns the serial value of the passed datetime, based on current nulldate.
bool mbSaveData
True = cache needs refresh.
sal_uInt16 readuInt16()
static void writeItemToSourceDataCell(const WorksheetHelper &rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem &rItem)
Tries to write the passed value to the passed sheet position.
PivotCache(const WorkbookHelper &rHelper)
bool mbAutoEnd
True = start value for range groups is calculated from source data.
sal_Int32 mnHierarchy
Data type from ODBC data source.
void importPivotCacheDefinition(const AttributeList &rAttribs)
Reads pivot cache global settings from the pivotCacheDefinition element.
PivotCacheItemList(const WorkbookHelper &rHelper)
css::util::DateTime calcDateTimeFromSerial(double fSerial) const
Returns the datetime of the passed serial value, based on current nulldate.
bool mbSupportDrill
True = data source supports subqueries.
OUString maPropertyName
Caption of the cache field.
PCWorksheetSourceModel maSheetSrcModel
Pivot cache source settings.
void readNumeric(const AttributeList &rAttribs)
Reads the double value from a pivot cache item.
bool hasNumericGrouping() const
Returns true, if the field has inplace numeric grouping settings.
int nCount
sal_Int32 mnGroupBy
Index of cache field this grouped field is based on.
SCTAB Tab() const
Definition: address.hxx:271
PivotCacheBuffer(const WorkbookHelper &rHelper)
void SetRow(SCROW nRowP)
Definition: address.hxx:275
OptValue< css::util::DateTime > getDateTime(sal_Int32 nAttrToken) const
void finalizeInternalSheetSource()
Finalizes the pivot cache if it is based on internal sheet data.
const sal_Int32 BIFF12_ID_PCITEM_ARRAY
Definition: biffhelper.hxx:166
void importFieldGroup(const AttributeList &rAttribs)
Imports grouping settings from the fieldGroup element.
PCFieldGroupModel()
Finalized group name of this field used in internal pivot table collection.
double d
void SetCol(SCCOL nColP)
Definition: address.hxx:279
void importPCRecordItem(SequenceInputStream &rStrm, const WorksheetHelper &rSheetHelper, sal_Int32 nCol, sal_Int32 nRow) const
Reads an item from the PCRECORD record and writes it to the passed sheet.
void updateSourceDataRow(const WorksheetHelper &rSheetHelper, sal_Int32 nRow) const
Checks, if the row index has changed since last call, and initializes the sheet data buffer...
bool getFlag(Type nBitField, Type nMask)
IndexVector maDiscreteItems
All group items of this field.
bool mbUpgradeOnRefresh
True = application queries data asynchronously.
PCWorksheetSourceModel()
Source cell range of the data.
ValueRangeSet maColSpans
Sheet source data if cache type is sheet.
bool mbOptimizeMemory
True = try to refresh cache on load.
PivotCacheItemList maGroupItems
All shared items of this field.
const sal_Int32 BIFF12_ID_PCITEMA_ERROR
Definition: biffhelper.hxx:177
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
sal_uInt16 char * pName
Definition: callform.cxx:58
void writeSourceHeaderCell(const WorksheetHelper &rSheetHelper, sal_Int32 nCol, sal_Int32 nRow) const
Writes the title of the field into the passed sheet at the passed address.
void importRangePr(const AttributeList &rAttribs)
Imports numeric grouping settings from the rangePr element.
void readDouble(SequenceInputStream &rStrm)
Reads the double value from a pivot cache item.
#define TOOLS_WARN_EXCEPTION(area, stream)
const PivotCacheItemList & getCacheItems() const
Returns shared or group items.
bool mbHasNonDate
True = has (blank|string|bool|error) item(s), maybe other types.
PCSourceModel maSourceModel
Global pivot cache settings.
Stores basic data about cell values and formatting.
int i
bool empty() const
Returns true, if this item list is empty.
void convertNumericGrouping(const css::uno::Reference< css::sheet::XDataPilotField > &rxDPField) const
Creates inplace numeric grouping settings.
void importPCDFieldGroup(SequenceInputStream &rStrm)
Imports grouping settings from the PCDFIELDGROUP record.
container_type::value_type value_type
sal_Int32 mnType
OUString GetFormattedString(const OUString &rDimName, const double fValue)
Definition: dpobject.cxx:1429
sal_Int16 SCCOL
Definition: types.hxx:22
OUString maCaption
Fixed name of the cache field.
double mfInterval
Manual or calculated end value for range grouping.
bool mbHasDate
True = has non-date item(s), maybe date items.
const sal_Int32 BIFF12_ID_PCITEM_DOUBLE
Definition: biffhelper.hxx:169
bool mbIsNumeric
True = has [(string|bool|error) and (number|date)] or (number and date).
bool is() const
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:78
OUString maTargetUrl
Column spans used by SheetDataBuffer for optimized cell import.
container_type::mapped_type mapped_type
sal_Int32 mnSqlType
Number format for all items.
bool mbRefreshOnLoad
True = cached item values are present.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool mbMemberPropField
True = list of unique ODBC items exists.
OUString maFormula
OLAP property name.
void importSharedItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports a shared item from the passed element.
bool mbTupleCache
True = application may upgrade cache version.
XML_TOKEN_INVALID
PivotCacheFieldVector maFields
sal_Int32 mnParentField
Interval for numeric range grouping.
bool mbDateGroup
True = items are grouped by numeric ranges or date ranges.
void importCacheSource(const AttributeList &rAttribs)
Reads cache source settings from the cacheSource element.
const sal_Int32 BIFF12_ID_PCITEM_DATE
Definition: biffhelper.hxx:168
void applyItemCaptions(const IdCaptionPairList &vCaptions)
Apply user Captions to imported group data.
const sal_Int32 BIFF12_ID_PCITEM_BOOL
Definition: biffhelper.hxx:167
void readBool(const AttributeList &rAttribs)
Reads the boolean value from a pivot cache item.
void setStringValue(const OUString &sName)
OUString getName() const
Returns the string representation of the item.
size_t size() const
Returns the size of the item list.
sal_Int32 getType() const
Returns the type of the item.
std::vector< sal_Int32 > maCacheIds
void SetInvalid()
Definition: address.hxx:542
bool mbIsInteger
True = has numeric item(s), maybe other types except date.
const sal_Int32 BIFF12_ID_PCITEM_ERROR
Definition: biffhelper.hxx:170
SCCOL Col() const
Definition: address.hxx:267
PCSourceModel()
Connection identifier for external data source.
void writeSourceHeaderCells(const WorksheetHelper &rSheetHelper) const
Writes the titles of all source fields into the passed sheet.
bool mbHasMixed
True = has blank item(s), maybe other types.
void readError(const AttributeList &rAttribs)
Reads the error code value from a pivot cache item.
sal_Int16 getCalcSheetIndex(sal_Int32 nWorksheet) const
Returns the Calc index of the specified worksheet.
OUString maSheet
Relation identifier for an external document URL.
void importPCDField(SequenceInputStream &rStrm)
Imports pivot cache field settings from the PCDFIELD record.
sal_Int32 SCROW
Definition: types.hxx:18
sal_Int32 mnMappingCount
Hierarchy level this field is part of.
PCDefinitionModel()
True = data source supports drilldown.
Helper struct for mapping original item names from/to group item names.
mapped_type get(key_type nKey) const
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
OUString maRefreshedBy
Relation identifier for cache records fragment.
bool mbHasBlank
True = has (string|bool|error) item(s), maybe other types.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
PivotCacheItemList maSharedItems
#define SAL_WARN_IF(condition, area, stream)
unsigned char sal_uInt8
void importPCDFRangePr(SequenceInputStream &rStrm)
Imports numeric grouping settings from the PCDFRANGEPR record.
void readIndex(const AttributeList &rAttribs)
Reads the index of a shared item.
bool mbHasString
True = has date item(s), maybe other types.
void finalizeImport()
Checks validity of source data and creates a dummy data sheet for external sheet sources.
bool mbInvalid
Limit for discarding unused items.
const OUString & GetName() const
Definition: dpsave.hxx:140
const sal_Int32 BIFF12_ID_PCITEMA_DOUBLE
Definition: biffhelper.hxx:176
void prepareSourceDataSheet()
Creates a dummy sheet that will be filled with the pivot cache data.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
PCFieldGroupModel maFieldGroupModel
Settings for shared items.
void insert(const ValueRange &rRange)
const css::uno::Any & getValue() const
Returns the value of the item.
OUString createDateGroupField(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField) const
Creates inplace date grouping settings or a new date group field.
double mfStartValue
Manual or calculated end date for range grouping.
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
const sal_Int32 BIFF12_ID_PCITEM_MISSING
Definition: biffhelper.hxx:172
static css::uno::Sequence< typename VectorType::value_type > vectorToSequence(const VectorType &rVector)
OUString getFormattedName(const ScDPSaveDimension &rSaveDim, ScDPObject *pObj, const DateTime &rNullDate) const
Returns the string representation of the item, using the actual formatting.
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
const sal_Int32 BIFF12_ID_PCITEM_INDEX
Definition: biffhelper.hxx:171
sal_Int32 mnLevel
Hierarchy this field is part of.
void importPCRecord(SequenceInputStream &rStrm, const WorksheetHelper &rSheetHelper, sal_Int32 nRowIdx) const
Reads a PCRECORD record and writes all item values to the passed sheet.
bool mbUnused
Value type (OOXML token identifier).
void readDate(const AttributeList &rAttribs)
Reads the date/time value from a pivot cache item.
PCSharedItemsModel()
True = contains strings with >255 characters.
sal_Int32 mnCurrRow
URL of an external source document.
bool isEof() const
sal_Int32 mnRecords
Date/time of last refresh.
void importCacheField(const AttributeList &rAttribs)
Imports pivot cache field settings from the cacheField element.
bool mbSupportSubquery
True = cache stores OLAP functions.
tuple m
void importPCDFSharedItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports one or more shared items from the passed record.
PivotCacheField(const WorkbookHelper &rHelper, bool bIsDatabaseField)
void importArray(SequenceInputStream &rStrm)
Imports an array of items from the PCITEM_ARRAY record.
static VectorType::value_type * getVectorElementAccess(VectorType &rVector, sal_Int32 nIndex)
ScRange maRange
Defined name containing a cell range if present.
void setStringCell(const CellModel &rModel, const OUString &rText)
Inserts a simple string cell into the sheet.
void importPCDFDiscretePrItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports an item of the mapping between group items and base items from the passed record...
bool mbValidSource
Current row index in dummy sheet.
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Manages the cell contents and cell formatting of a sheet.
void getCacheItemNames(::std::vector< OUString > &orItemNames) const
Returns the names of all shared or group items.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
void importPCDSheetSource(SequenceInputStream &rStrm, const ::oox::core::Relations &rRelations)
Reads sheet source settings from the PCDSHEETSOURCE record.
PivotCache * importPivotCacheFragment(sal_Int32 nCacheId)
Imports and stores a pivot cache definition fragment on first call, returns the imported cache on sub...
sal_Int32 mnConnectionId
Type of the source data (sheet, consolidation, scenario, external).
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
sal_Int32 mnBaseField
Index of cache field that contains item groups based on this field.
PivotCache & createPivotCache(sal_Int32 nCacheId)
Creates and returns a new pivot cache object with the passed identifier.
bool mbRangeGroup
Type of numeric or date range grouping.
void readString(const AttributeList &rAttribs)
Reads the string value from a pivot cache item.
css::util::DateTime maStartDate