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>
30 #include <osl/diagnose.h>
36 #include <oox/token/namespaces.hxx>
37 #include <oox/token/properties.hxx>
38 #include <oox/token/tokens.hxx>
48 #include <tools/datetime.hxx>
58 using ::oox::core::Relations;
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;
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;
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;
85 const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOSTART = 0x01;
86 const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOEND = 0x02;
87 const sal_uInt8 BIFF12_PCDFRANGEPR_DATEGROUP = 0x04;
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;
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;
103 const sal_uInt8 BIFF12_PCDWBSOURCE_HASRELID = 0x01;
104 const sal_uInt8 BIFF12_PCDWBSOURCE_HASSHEET = 0x02;
114 void lclAdjustBinDateTime( css::util::DateTime& orDateTime )
116 if( (orDateTime.Year == 1900) && (orDateTime.Month <= 2) )
118 OSL_ENSURE( (orDateTime.Month == 1) || ((orDateTime.Month == 2) && (orDateTime.Day > 0)),
"lclAdjustBinDateTime - invalid date" );
119 switch( orDateTime.Month )
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;
130 mnType( XML_m ), mbUnused( false )
185 css::util::DateTime aDateTime;
192 lclAdjustBinDateTime( aDateTime );
205 maValue <<= static_cast< sal_Int32 >( rStrm.
readuInt8() );
225 case XML_m:
return OUString();
226 case XML_s:
return maValue.get< OUString >();
227 case XML_n:
return OUString::number(
maValue.get<
double >() );
228 case XML_i:
return OUString::number(
maValue.get< sal_Int32 >() );
229 case XML_d:
return OUString();
230 case XML_b:
return OUString::boolean(
maValue.get<
bool >() );
231 case XML_e:
return OUString();
233 OSL_FAIL(
"PivotCacheItem::getName - invalid data type" );
241 case XML_m:
return OUString();
242 case XML_s:
return maValue.get< OUString >();
247 case XML_e:
return maValue.get< OUString >();
249 OSL_FAIL(
"PivotCacheItem::getFormattedName - invalid data type" );
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" );
296 default: OSL_FAIL(
"PivotCacheItemList::importItem - unknown record type" );
307 for(
const auto& [rId, rCaption] : vCaptions )
310 maItems[ rId ].setStringValue( rCaption );
317 orItemNames.reserve(
maItems.size() );
318 for(
const auto& rItem :
maItems )
319 orItemNames.push_back( rItem.getName() );
334 for( sal_Int32 nIdx = 0; !rStrm.
isEof() && (nIdx < nCount); ++nIdx )
343 OSL_FAIL(
"PivotCacheItemList::importArray - unknown data type" );
355 mbDatabaseField( true ),
356 mbServerField( false ),
357 mbUniqueList( true ),
358 mbMemberPropField( false )
363 mbHasSemiMixed( true ),
364 mbHasNonDate( true ),
369 mbIsNumeric( false ),
370 mbIsInteger( false ),
371 mbHasLongText( false )
381 mnGroupBy( XML_range ),
382 mbRangeGroup( false ),
383 mbDateGroup( false ),
391 static const sal_Int32 spnGroupBy[] = { XML_range,
392 XML_seconds, XML_minutes, XML_hours, XML_days, XML_months, XML_quarters, XML_years };
398 maSharedItems( rHelper ),
399 maGroupItems( rHelper )
423 OSL_ENSURE(
maSharedItems.
empty(),
"PivotCacheField::importSharedItems - multiple shared items elements" );
462 OSL_ENSURE( nElement == XLS_TOKEN(
x ),
"PivotCacheField::importDiscretePrItem - unexpected element" );
463 if( nElement == XLS_TOKEN(
x ) )
482 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASCAPTION ) )
484 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASFORMULA ) )
485 rStrm.
skip( ::std::max< sal_Int32 >( rStrm.
readInt32(), 0 ) );
487 rStrm.
skip( ::std::max< sal_Int32 >( rStrm.
readInt32(), 0 ) );
488 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASPROPERTYNAME ) )
548 OSL_ENSURE( nRecId ==
BIFF12_ID_PCITEM_INDEX,
"PivotCacheField::importPCDFDiscretePrItem - unexpected record" );
596 DataPilotFieldGroupInfo aGroupInfo;
599 aGroupInfo.HasDateValues =
false;
603 aGroupInfo.GroupBy = 0;
604 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
611 Reference< XDataPilotField > xDPGroupField;
617 DataPilotFieldGroupInfo aGroupInfo;
620 aGroupInfo.HasDateValues =
true;
625 using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
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" );
640 Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY_THROW );
641 xDPGroupField = xDPGrouping->createDateGroup( aGroupInfo );
648 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
649 return xFieldName.is() ? xFieldName->getName() : OUString();
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();
670 if ( pItem->isUnused() || ( pItem->getType() == XML_m ) || ( pItem->getType() == XML_e ) )
673 pItems->push_back( nIndex );
678 Reference< XDataPilotField > xDPGroupField;
680 for(
const auto& rItems : aItemMap )
682 SAL_WARN_IF( rItems.empty(),
"sc",
"PivotCacheField::createParentGroupField - item/group should not be empty" );
683 if( !rItems.empty() )
692 ::std::vector< OUString > aMembers;
693 for(
auto i : rItems )
695 if( ::std::find( aMembers.begin(), aMembers.end(),
pName->maGroupName ) == aMembers.end() )
696 aMembers.push_back(
pName->maGroupName );
700 if( !aMembers.empty() )
try
704 SAL_WARN_IF( xDPGroupField.is() == xDPNewField.is(),
"sc",
"PivotCacheField::createParentGroupField - missing group field" );
705 if( !xDPGroupField.is() )
706 xDPGroupField = xDPNewField;
709 DataPilotFieldGroupInfo aGroupInfo;
711 aPropSet.
getProperty( aGroupInfo, PROP_GroupInfo );
725 aFirstItem =
pName->maOrigName;
726 Reference< XNamed > xGroupName;
728 Reference< XIndexAccess > xGroupsIA( aGroupInfo.Groups, UNO_QUERY_THROW );
729 for( sal_Int32 nIdx = 0,
nCount = xGroupsIA->getCount(); (nIdx <
nCount) && (aAutoName.isEmpty()); ++nIdx )
try
732 if( xItemsNA->hasByName( aFirstItem ) )
734 xGroupName.set( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
735 aAutoName = xGroupName->getName();
742 SAL_WARN_IF( aAutoName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find auto-generated group name" );
747 aGroupName = pGroupItem->getName();
748 SAL_WARN_IF( aGroupName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find group name" );
749 if( aGroupName.isEmpty() )
750 aGroupName = aAutoName;
752 if( xGroupName.is() && !aGroupName.isEmpty() )
755 if( aAutoName != aGroupName )
757 xGroupName->setName( aGroupName );
758 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
761 for(
auto i : rItems )
763 pName->maGroupName = aGroupName;
774 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
775 return xFieldName.is() ? xFieldName->getName() : OUString();
787 bool bHasIndex = rItem.
getType() == XML_x;
788 OSL_ENSURE( bHasIndex !=
maSharedItems.
empty(),
"PivotCacheField::writeSourceDataCell - shared items missing or not expected" );
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" );
838 const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx )
const
845 mfRefreshedDate( 0.0 ),
847 mnMissItemsLimit( 0 ),
850 mbRefreshOnLoad( false ),
851 mbOptimizeMemory( false ),
852 mbEnableRefresh( true ),
853 mbBackgroundQuery( false ),
854 mbUpgradeOnRefresh( false ),
855 mbTupleCache( false ),
856 mbSupportSubquery( false ),
857 mbSupportDrill( false )
875 mbValidSource( false ),
876 mbDummySheet( false )
926 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASUSERNAME ) )
928 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASRELID ) )
945 sal_Int32 nSourceType;
948 static const sal_Int32 spnSourceTypes[] = { XML_worksheet, XML_external, XML_consolidation, XML_scenario };
954 sal_uInt8 nIsDefName, nIsBuiltinName, nFlags;
958 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASSHEET ) )
960 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASRELID ) )
964 if( nIsDefName == 0 )
974 if( nIsBuiltinName != 0 )
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 )
995 if( (*aIt)->isDatabaseField() )
997 OSL_ENSURE( (aIt ==
maFields.begin()) || (*(aIt - 1))->isDatabaseField(),
998 "PivotCache::finalizeImport - database field follows a calculated field" );
1007 OSL_ENSURE( !
maDatabaseFields.empty(),
"PivotCache::finalizeImport - no pivot cache source fields found" );
1017 OSL_ENSURE( bInternal || bExternal,
"PivotCache::finalizeImport - invalid external document URL" );
1020 else if( bExternal )
1028 case XML_consolidation:
1053 "PivotCache::writeSourceHeaderCells - source cell range width does not match number of source fields" );
1063 rxDatabaseField->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
1076 pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem );
1087 if( rStrm.
isEof() || (nCol > nMaxCol) )
1089 rxDatabaseField->importPCRecordItem( rStrm, rSheetHelper, nCol, nRow );
1114 mbValidSource = (pTable->getHeight() - pTable->getTotalsRows()) > 1;
1120 else if( nSheet >= 0 )
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() )
1217 rxCache = std::make_shared<PivotCache>( *this );
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.
FragmentPathMap maFragmentPaths
bool mbBackgroundQuery
True = refreshing cache is enabled in UI.
const sal_Int32 BIFF12_ID_PCITEMA_MISSING
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.
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.
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
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
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
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
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.
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.
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.
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
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.
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.
sal_Int32 mnGroupBy
Index of cache field this grouped field is based on.
PivotCacheBuffer(const WorkbookHelper &rHelper)
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
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.
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
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.
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
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
bool mbIsNumeric
True = has [(string|bool|error) and (number|date)] or (number and date).
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
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.
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
void applyItemCaptions(const IdCaptionPairList &vCaptions)
Apply user Captions to imported group data.
const sal_Int32 BIFF12_ID_PCITEM_BOOL
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
bool mbIsInteger
True = has numeric item(s), maybe other types except date.
const sal_Int32 BIFF12_ID_PCITEM_ERROR
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 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)
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
const sal_Int32 BIFF12_ID_PCITEMA_DOUBLE
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)
OUString GetFormattedString(std::u16string_view rDimName, const double fValue)
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.
const sal_Int32 BIFF12_ID_PCITEM_MISSING
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
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.
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.
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