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>
32#include <osl/diagnose.h>
38#include <oox/token/namespaces.hxx>
39#include <oox/token/properties.hxx>
40#include <oox/token/tokens.hxx>
50#include <tools/datetime.hxx>
60using ::oox::core::Relations;
64const sal_uInt16 BIFF12_PCDFIELD_SERVERFIELD = 0x0001;
65const sal_uInt16 BIFF12_PCDFIELD_NOUNIQUEITEMS = 0x0002;
66const sal_uInt16 BIFF12_PCDFIELD_DATABASEFIELD = 0x0004;
67const sal_uInt16 BIFF12_PCDFIELD_HASCAPTION = 0x0008;
68const sal_uInt16 BIFF12_PCDFIELD_MEMBERPROPFIELD = 0x0010;
69const sal_uInt16 BIFF12_PCDFIELD_HASFORMULA = 0x0100;
70const sal_uInt16 BIFF12_PCDFIELD_HASPROPERTYNAME = 0x0200;
72const sal_uInt16 BIFF12_PCDFSITEMS_HASSEMIMIXED = 0x0001;
73const sal_uInt16 BIFF12_PCDFSITEMS_HASNONDATE = 0x0002;
74const sal_uInt16 BIFF12_PCDFSITEMS_HASDATE = 0x0004;
75const sal_uInt16 BIFF12_PCDFSITEMS_HASSTRING = 0x0008;
76const sal_uInt16 BIFF12_PCDFSITEMS_HASBLANK = 0x0010;
77const sal_uInt16 BIFF12_PCDFSITEMS_HASMIXED = 0x0020;
78const sal_uInt16 BIFF12_PCDFSITEMS_ISNUMERIC = 0x0040;
79const sal_uInt16 BIFF12_PCDFSITEMS_ISINTEGER = 0x0080;
80const sal_uInt16 BIFF12_PCDFSITEMS_HASLONGTEXT = 0x0200;
82const sal_uInt16 BIFF12_PCITEM_ARRAY_DOUBLE = 0x0001;
83const sal_uInt16 BIFF12_PCITEM_ARRAY_STRING = 0x0002;
84const sal_uInt16 BIFF12_PCITEM_ARRAY_ERROR = 0x0010;
85const sal_uInt16 BIFF12_PCITEM_ARRAY_DATE = 0x0020;
87const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOSTART = 0x01;
88const sal_uInt8 BIFF12_PCDFRANGEPR_AUTOEND = 0x02;
89const sal_uInt8 BIFF12_PCDFRANGEPR_DATEGROUP = 0x04;
91const sal_uInt8 BIFF12_PCDEFINITION_SAVEDATA = 0x01;
92const sal_uInt8 BIFF12_PCDEFINITION_INVALID = 0x02;
93const sal_uInt8 BIFF12_PCDEFINITION_REFRESHONLOAD = 0x04;
94const sal_uInt8 BIFF12_PCDEFINITION_OPTIMIZEMEMORY = 0x08;
95const sal_uInt8 BIFF12_PCDEFINITION_ENABLEREFRESH = 0x10;
96const sal_uInt8 BIFF12_PCDEFINITION_BACKGROUNDQUERY = 0x20;
97const sal_uInt8 BIFF12_PCDEFINITION_UPGRADEONREFR = 0x40;
98const sal_uInt8 BIFF12_PCDEFINITION_TUPLECACHE = 0x80;
100const sal_uInt8 BIFF12_PCDEFINITION_HASUSERNAME = 0x01;
101const sal_uInt8 BIFF12_PCDEFINITION_HASRELID = 0x02;
102const sal_uInt8 BIFF12_PCDEFINITION_SUPPORTSUBQUERY = 0x04;
103const sal_uInt8 BIFF12_PCDEFINITION_SUPPORTDRILL = 0x08;
105const sal_uInt8 BIFF12_PCDWBSOURCE_HASRELID = 0x01;
106const sal_uInt8 BIFF12_PCDWBSOURCE_HASSHEET = 0x02;
116void lclAdjustBinDateTime( css::util::DateTime& orDateTime )
118 if( (orDateTime.Year == 1900) && (orDateTime.Month <= 2) )
120 OSL_ENSURE( (orDateTime.Month == 1) || ((orDateTime.Month == 2) && (orDateTime.Day > 0)),
"lclAdjustBinDateTime - invalid date" );
121 switch( orDateTime.Month )
123 case 2:
if( orDateTime.Day > 1 ) --orDateTime.Day;
else { orDateTime.Day += 30; --orDateTime.Month; }
break;
124 case 1:
if( orDateTime.Day > 1 ) --orDateTime.Day;
else { orDateTime.Day += 30; orDateTime.Month = 12; --orDateTime.Year; }
break;
132 mnType( XML_m ), mbUnused( false )
187 css::util::DateTime aDateTime;
188 aDateTime.Year =
rStrm.readuInt16();
189 aDateTime.Month =
rStrm.readuInt16();
190 aDateTime.Day =
rStrm.readuInt8();
191 aDateTime.Hours =
rStrm.readuInt8();
192 aDateTime.Minutes =
rStrm.readuInt8();
193 aDateTime.Seconds =
rStrm.readuInt8();
194 lclAdjustBinDateTime( aDateTime );
227 case XML_m:
return OUString();
228 case XML_s:
return maValue.get< OUString >();
229 case XML_n:
return OUString::number(
maValue.get<
double >() );
230 case XML_i:
return OUString::number(
maValue.get< sal_Int32 >() );
231 case XML_d:
return OUString();
232 case XML_b:
return OUString::boolean(
maValue.get<
bool >() );
233 case XML_e:
return OUString();
235 OSL_FAIL(
"PivotCacheItem::getName - invalid data type" );
243 case XML_m:
return OUString();
244 case XML_s:
return maValue.get< OUString >();
249 case XML_e:
return maValue.get< OUString >();
251 OSL_FAIL(
"PivotCacheItem::getFormattedName - invalid data type" );
265 case XLS_TOKEN(
m ):
break;
266 case XLS_TOKEN( s ): rItem.
readString( rAttribs );
break;
267 case XLS_TOKEN(
n ): rItem.
readNumeric( rAttribs );
break;
268 case XLS_TOKEN(
d ): rItem.
readDate( rAttribs );
break;
269 case XLS_TOKEN( b ): rItem.
readBool( rAttribs );
break;
270 case XLS_TOKEN( e ): rItem.
readError( rAttribs );
break;
271 default: OSL_FAIL(
"PivotCacheItemList::importItem - unknown element type" );
298 default: OSL_FAIL(
"PivotCacheItemList::importItem - unknown record type" );
309 for(
const auto& [rId, rCaption] : vCaptions )
312 maItems[ rId ].setStringValue( rCaption );
319 orItemNames.reserve(
maItems.size() );
320 for(
const auto& rItem :
maItems )
321 orItemNames.push_back( rItem.getName() );
336 for( sal_Int32 nIdx = 0; !
rStrm.isEof() && (nIdx <
nCount); ++nIdx )
345 OSL_FAIL(
"PivotCacheItemList::importArray - unknown data type" );
357 mbDatabaseField( true ),
358 mbServerField( false ),
359 mbUniqueList( true ),
360 mbMemberPropField( false )
365 mbHasSemiMixed( true ),
366 mbHasNonDate( true ),
371 mbIsNumeric( false ),
372 mbIsInteger( false ),
373 mbHasLongText( false )
383 mnGroupBy( XML_range ),
384 mbRangeGroup( false ),
385 mbDateGroup( false ),
393 static const sal_Int32 spnGroupBy[] = { XML_range,
394 XML_seconds, XML_minutes, XML_hours, XML_days, XML_months, XML_quarters, XML_years };
400 maSharedItems( rHelper ),
401 maGroupItems( rHelper )
425 OSL_ENSURE(
maSharedItems.
empty(),
"PivotCacheField::importSharedItems - multiple shared items elements" );
464 OSL_ENSURE( nElement == XLS_TOKEN(
x ),
"PivotCacheField::importDiscretePrItem - unexpected element" );
465 if( nElement == XLS_TOKEN(
x ) )
477 nFlags =
rStrm.readuInt16();
484 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASCAPTION ) )
486 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASFORMULA ) )
487 rStrm.skip( ::std::max< sal_Int32 >(
rStrm.readInt32(), 0 ) );
489 rStrm.skip( ::std::max< sal_Int32 >(
rStrm.readInt32(), 0 ) );
490 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASPROPERTYNAME ) )
502 nFlags =
rStrm.readuInt16();
528 nGroupBy =
rStrm.readuChar();
529 nFlags =
rStrm.readuChar();
550 OSL_ENSURE( nRecId ==
BIFF12_ID_PCITEM_INDEX,
"PivotCacheField::importPCDFDiscretePrItem - unexpected record" );
598 DataPilotFieldGroupInfo aGroupInfo;
601 aGroupInfo.HasDateValues =
false;
605 aGroupInfo.GroupBy = 0;
606 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
613 Reference< XDataPilotField > xDPGroupField;
619 DataPilotFieldGroupInfo aGroupInfo;
622 aGroupInfo.HasDateValues =
true;
627 using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
630 case XML_years: aGroupInfo.GroupBy = YEARS;
break;
631 case XML_quarters: aGroupInfo.GroupBy = QUARTERS;
break;
632 case XML_months: aGroupInfo.GroupBy = MONTHS;
break;
633 case XML_days: aGroupInfo.GroupBy = DAYS;
break;
634 case XML_hours: aGroupInfo.GroupBy = HOURS;
break;
635 case XML_minutes: aGroupInfo.GroupBy = MINUTES;
break;
636 case XML_seconds: aGroupInfo.GroupBy = SECONDS;
break;
637 default: OSL_FAIL(
"PivotCacheField::convertRangeGrouping - unknown date/time interval" );
642 Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY_THROW );
643 xDPGroupField = xDPGrouping->createDateGroup( aGroupInfo );
650 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
651 return xFieldName.is() ? xFieldName->getName() : OUString();
657 SAL_WARN_IF(
maDiscreteItems.size() != orItemNames.size(),
"sc",
"PivotCacheField::createParentGroupField - number of item names does not match grouping info" );
658 Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY );
659 if( !xDPGrouping.is() )
return OUString();
672 if ( pItem->isUnused() || ( pItem->getType() == XML_m ) || ( pItem->getType() == XML_e ) )
675 pItems->push_back(
nIndex );
680 Reference< XDataPilotField > xDPGroupField;
682 for(
const auto& rItems : aItemMap )
684 SAL_WARN_IF( rItems.empty(),
"sc",
"PivotCacheField::createParentGroupField - item/group should not be empty" );
685 if( !rItems.empty() )
694 ::std::vector< OUString > aMembers;
695 for(
auto i : rItems )
697 if( ::std::find( aMembers.begin(), aMembers.end(),
pName->maGroupName ) == aMembers.end() )
698 aMembers.push_back(
pName->maGroupName );
702 if( !aMembers.empty() )
try
706 SAL_WARN_IF( xDPGroupField.is() == xDPNewField.is(),
"sc",
"PivotCacheField::createParentGroupField - missing group field" );
707 if( !xDPGroupField.is() )
708 xDPGroupField = xDPNewField;
711 DataPilotFieldGroupInfo aGroupInfo;
713 aPropSet.
getProperty( aGroupInfo, PROP_GroupInfo );
727 aFirstItem =
pName->maOrigName;
728 Reference< XNamed > xGroupName;
730 Reference< XIndexAccess > xGroupsIA( aGroupInfo.Groups, UNO_QUERY_THROW );
731 for( sal_Int32 nIdx = 0,
nCount = xGroupsIA->getCount(); (nIdx <
nCount) && (aAutoName.isEmpty()); ++nIdx )
try
733 Reference< XNameAccess > xItemsNA( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
734 if( xItemsNA->hasByName( aFirstItem ) )
736 xGroupName.set( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
737 aAutoName = xGroupName->getName();
744 SAL_WARN_IF( aAutoName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find auto-generated group name" );
749 aGroupName = pGroupItem->getName();
750 SAL_WARN_IF( aGroupName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find group name" );
751 if( aGroupName.isEmpty() )
752 aGroupName = aAutoName;
754 if( xGroupName.is() && !aGroupName.isEmpty() )
757 if( aAutoName != aGroupName )
759 xGroupName->setName( aGroupName );
760 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
763 for(
auto i : rItems )
765 pName->maGroupName = aGroupName;
776 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
777 return xFieldName.is() ? xFieldName->getName() : OUString();
789 bool bHasIndex = rItem.
getType() == XML_x;
790 OSL_ENSURE( bHasIndex !=
maSharedItems.
empty(),
"PivotCacheField::writeSourceDataCell - shared items missing or not expected" );
835 default: OSL_FAIL(
"PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
840 const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx )
const
847 mfRefreshedDate( 0.0 ),
849 mnMissItemsLimit( 0 ),
852 mbRefreshOnLoad( false ),
853 mbOptimizeMemory( false ),
854 mbEnableRefresh( true ),
855 mbBackgroundQuery( false ),
856 mbUpgradeOnRefresh( false ),
857 mbTupleCache( false ),
858 mbSupportSubquery( false ),
859 mbSupportDrill( false )
877 mbValidSource( false ),
878 mbDummySheet( false )
923 nFlags1 =
rStrm.readuChar();
926 nFlags2 =
rStrm.readuChar();
928 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASUSERNAME ) )
930 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASRELID ) )
947 sal_Int32 nSourceType;
948 nSourceType =
rStrm.readInt32();
950 static const sal_Int32 spnSourceTypes[] = { XML_worksheet, XML_external, XML_consolidation, XML_scenario };
956 sal_uInt8 nIsDefName, nIsBuiltinName, nFlags;
957 nIsDefName =
rStrm.readuChar();
958 nIsBuiltinName =
rStrm.readuChar();
959 nFlags =
rStrm.readuChar();
960 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASSHEET ) )
962 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASRELID ) )
966 if( nIsDefName == 0 )
976 if( nIsBuiltinName != 0 )
994 OSL_ENSURE( !
maFields.empty(),
"PivotCache::finalizeImport - no pivot cache fields found" );
995 for( PivotCacheFieldVector::const_iterator aIt =
maFields.begin(), aEnd =
maFields.end(); aIt != aEnd; ++aIt )
997 if( (*aIt)->isDatabaseField() )
999 OSL_ENSURE( (aIt ==
maFields.begin()) || (*(aIt - 1))->isDatabaseField(),
1000 "PivotCache::finalizeImport - database field follows a calculated field" );
1009 OSL_ENSURE( !
maDatabaseFields.empty(),
"PivotCache::finalizeImport - no pivot cache source fields found" );
1019 OSL_ENSURE( bInternal || bExternal,
"PivotCache::finalizeImport - invalid external document URL" );
1022 else if( bExternal )
1030 case XML_consolidation:
1055 "PivotCache::writeSourceHeaderCells - source cell range width does not match number of source fields" );
1065 rxDatabaseField->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
1078 pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem );
1089 if(
rStrm.isEof() || (nCol > nMaxCol) )
1091 rxDatabaseField->importPCRecordItem(
rStrm, rSheetHelper, nCol, nRow );
1116 mbValidSource = (pTable->getHeight() - pTable->getTotalsRows()) > 1;
1122 else if( nSheet >= 0 )
1186 OSL_ENSURE( nCacheId >= 0,
"PivotCacheBuffer::registerPivotCacheFragment - invalid pivot cache identifier" );
1187 OSL_ENSURE(
maFragmentPaths.count( nCacheId ) == 0,
"PivotCacheBuffer::registerPivotCacheFragment - fragment path exists already" );
1188 if( (nCacheId >= 0) && !rFragmentPath.isEmpty() )
1219 rxCache = std::make_shared<PivotCache>( *
this );
OUString GetFormattedString(std::u16string_view rDimName, const double fValue)
const OUString & GetName() const
std::optional< css::util::DateTime > getDateTime(sal_Int32 nAttrToken) const
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
std::optional< bool > getBool(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
std::optional< double > getDouble(sal_Int32 nAttrToken) const
static VectorType::value_type * getVectorElementAccess(VectorType &rVector, sal_Int32 nIndex)
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
bool getProperty(Type &orValue, sal_Int32 nPropId) const
bool setProperty(sal_Int32 nPropId, const Type &rValue)
mapped_type get(key_type nKey) const
container_type::mapped_type mapped_type
value_type get(sal_Int32 nIndex) const
container_type::value_type value_type
void insert(const ValueRange &rRange)
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.
bool checkCellRange(const ScRange &rRange, bool bAllowOverflow, bool bTrackOverflow)
Checks the passed cell range if it fits into the spreadsheet limits.
const ScAddress & getMaxApiAddress() const
Returns the biggest valid cell address in the own Calc document.
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
std::vector< sal_Int32 > maCacheIds
PivotCache * importPivotCacheFragment(sal_Int32 nCacheId)
Imports and stores a pivot cache definition fragment on first call, returns the imported cache on sub...
void registerPivotCacheFragment(sal_Int32 nCacheId, const OUString &rFragmentPath)
Registers a pivot cache definition fragment.
PivotCache & createPivotCache(sal_Int32 nCacheId)
Creates and returns a new pivot cache object with the passed identifier.
PivotCacheBuffer(const WorkbookHelper &rHelper)
FragmentPathMap maFragmentPaths
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.
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 getCacheItemNames(::std::vector< OUString > &orItemNames) const
Returns the names of all shared or group items.
const PivotCacheItemList & getCacheItems() const
Returns shared or group items.
bool hasSharedItems() const
Returns true, if the field contains a list of shared items.
IndexVector maDiscreteItems
All group items of this field.
OUString createDateGroupField(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField) const
Creates inplace date grouping settings or a new date group field.
bool hasDateGrouping() const
Returns true, if the field has inplace date grouping settings.
void importPCDFSharedItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports one or more shared items from the passed record.
PCFieldGroupModel maFieldGroupModel
Settings for shared items.
void importPCDFGroupItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports one or more group items from the passed record.
PCSharedItemsModel maSharedItemsModel
Settings for this cache field.
void importFieldGroup(const AttributeList &rAttribs)
Imports grouping settings from the fieldGroup element.
PivotCacheItemList maGroupItems
All shared items of this field.
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the shared or group item with the specified index.
void importPCDFSharedItems(SequenceInputStream &rStrm)
Imports shared items settings from the PCDFSHAREDITEMS record.
void convertNumericGrouping(const css::uno::Reference< css::sheet::XDataPilotField > &rxDPField) const
Creates inplace numeric grouping settings.
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.
bool hasGroupItems() const
Returns true, if the field contains a list of grouping items.
void importGroupItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports a group item from the passed element.
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 importCacheField(const AttributeList &rAttribs)
Imports pivot cache field settings from the cacheField element.
PivotCacheItemList maSharedItems
bool hasNumericGrouping() const
Returns true, if the field has inplace numeric grouping settings.
void applyItemCaptions(const IdCaptionPairList &vCaptions)
Apply user Captions to imported group data.
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.
void importSharedItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports a shared item from the passed element.
void importDiscretePrItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports an item of the mapping between group items and base items from the passed element.
void importRangePr(const AttributeList &rAttribs)
Imports numeric grouping settings from the rangePr element.
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.
PCFieldModel maFieldModel
Mapping between group and base items.
void importPCDField(SequenceInputStream &rStrm)
Imports pivot cache field settings from the PCDFIELD record.
void importSharedItems(const AttributeList &rAttribs)
Imports shared items settings from the sharedItems element.
void importPCDFDiscretePrItem(sal_Int32 nRecId, SequenceInputStream &rStrm)
Imports an item of the mapping between group items and base items from the passed record.
void importPCDFRangePr(SequenceInputStream &rStrm)
Imports numeric grouping settings from the PCDFRANGEPR record.
PivotCacheField(const WorkbookHelper &rHelper, bool bIsDatabaseField)
void importPCDFieldGroup(SequenceInputStream &rStrm)
Imports grouping settings from the PCDFIELDGROUP record.
std::vector< PivotCacheItem > maItems
bool empty() const
Returns true, if this item list is empty.
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the specified item.
void applyItemCaptions(const IdCaptionPairList &vCaptions)
PivotCacheItemList(const WorkbookHelper &rHelper)
size_t size() const
Returns the size of the item list.
void getCacheItemNames(::std::vector< OUString > &orItemNames) const
Returns the names of all items.
void importItem(sal_Int32 nElement, const AttributeList &rAttribs)
Imports the item from the passed attribute list.
PivotCacheItem & createItem()
Creates and returns a new item at the end of the items list.
void importArray(SequenceInputStream &rStrm)
Imports an array of items from the PCITEM_ARRAY record.
void readString(const AttributeList &rAttribs)
Reads the string value from a pivot cache item.
sal_Int32 getType() const
Returns the type of the item.
void readBool(const AttributeList &rAttribs)
Reads the boolean value from a pivot cache item.
OUString getName() const
Returns the string representation of the item.
bool mbUnused
Value type (OOXML token identifier).
OUString getFormattedName(const ScDPSaveDimension &rSaveDim, ScDPObject *pObj, const DateTime &rNullDate) const
Returns the string representation of the item, using the actual formatting.
void readIndex(const AttributeList &rAttribs)
Reads the index of a shared item.
void readDate(const AttributeList &rAttribs)
Reads the date/time value from a pivot cache item.
void setStringValue(const OUString &sName)
const css::uno::Any & getValue() const
Returns the value of the item.
void readError(const AttributeList &rAttribs)
Reads the error code value from a pivot cache item.
sal_Int32 mnType
Value of the item.
void readNumeric(const AttributeList &rAttribs)
Reads the double value from a pivot cache item.
void readDouble(SequenceInputStream &rStrm)
Reads the double value from a pivot cache item.
void finalizeInternalSheetSource()
Finalizes the pivot cache if it is based on internal sheet data.
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.
void importPCDSheetSource(SequenceInputStream &rStrm, const ::oox::core::Relations &rRelations)
Reads sheet source settings from the PCDSHEETSOURCE record.
PCDefinitionModel maDefModel
Database field index for all fields.
PivotCacheFieldVector maDatabaseFields
All pivot cache fields.
ValueRangeSet maColSpans
Sheet source data if cache type is sheet.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
void importPivotCacheDefinition(const AttributeList &rAttribs)
Reads pivot cache global settings from the pivotCacheDefinition element.
void importPCRecord(SequenceInputStream &rStrm, const WorksheetHelper &rSheetHelper, sal_Int32 nRowIdx) const
Reads a PCRECORD record and writes all item values to the passed sheet.
void importPCDefinition(SequenceInputStream &rStrm)
Reads pivot cache global settings from the PCDEFINITION record.
sal_Int32 mnCurrRow
URL of an external source document.
PCSourceModel maSourceModel
Global pivot cache settings.
void importCacheSource(const AttributeList &rAttribs)
Reads cache source settings from the cacheSource element.
bool mbDummySheet
True = pivot cache is based on supported data source.
bool mbValidSource
Current row index in dummy sheet.
PCWorksheetSourceModel maSheetSrcModel
Pivot cache source settings.
OUString maTargetUrl
Column spans used by SheetDataBuffer for optimized cell import.
void finalizeExternalSheetSource()
Finalizes the pivot cache if it is based on sheet data of an external spreadsheet document.
PivotCacheField & createCacheField()
Creates and returns a new pivot cache field.
void finalizeImport()
Checks validity of source data and creates a dummy data sheet for external sheet sources.
void prepareSourceDataSheet()
Creates a dummy sheet that will be filled with the pivot cache data.
void importPCDSource(SequenceInputStream &rStrm)
Reads cache source settings from the PCDSOURCE record.
PivotCache(const WorkbookHelper &rHelper)
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the field with the passed index.
void importWorksheetSource(const AttributeList &rAttribs, const ::oox::core::Relations &rRelations)
Reads sheet source settings from the worksheetSource element.
void writeSourceHeaderCells(const WorksheetHelper &rSheetHelper) const
Writes the titles of all source fields into the passed sheet.
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.
IndexVector maDatabaseIndexes
All cache fields that are based on source data.
PivotCacheFieldVector maFields
Manages the cell contents and cell formatting of a sheet.
void setErrorCell(const CellModel &rModel, const OUString &rErrorCode)
Inserts an error cell from the passed error code into the sheet.
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
void setValueCell(const CellModel &rModel, double fValue)
Inserts a value cell into the sheet.
void setDateTimeCell(const CellModel &rModel, const css::util::DateTime &rDateTime)
Inserts a date/time cell into the sheet and adjusts number format.
void setBooleanCell(const CellModel &rModel, bool bValue)
Inserts a boolean cell into the sheet and adjusts number format.
void setStringCell(const CellModel &rModel, const OUString &rText)
Inserts a simple string cell into the sheet.
Helper class that provides functions to convert values from and to different units.
double calcSerialFromDateTime(const css::util::DateTime &rDateTime) const
Returns the serial value of the passed datetime, based on current nulldate.
OUString calcErrorString(sal_uInt8 nErrorCode) const
Returns an error string from the passed BIFF error code.
css::util::DateTime calcDateTimeFromSerial(double fSerial) const
Returns the datetime of the passed serial value, based on current nulldate.
Helper class to provide access to global workbook data.
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...
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
sal_Int16 getCalcSheetIndex(sal_Int32 nWorksheet) const
Returns the Calc index of the specified worksheet.
SheetDataBuffer & getSheetData() const
Returns the buffer for cell contents and cell formatting.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
#define TOOLS_WARN_EXCEPTION(area, stream)
#define STATIC_ARRAY_SELECT(array, index, def)
#define SAL_WARN_IF(condition, area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const sal_Int32 BIFF12_ID_PCITEMA_BOOL
const sal_Int32 BIFF12_ID_PCITEMA_DATE
::std::vector< IdCaptionPair > IdCaptionPairList
const sal_Int32 BIFF12_ID_PCITEM_ARRAY
const sal_Int32 BIFF12_ID_PCITEM_INDEX
const sal_Int32 BIFF12_ID_PCITEM_MISSING
const sal_Int32 BIFF12_ID_PCITEMA_ERROR
const sal_Int32 BIFF12_ID_PCITEMA_DOUBLE
const sal_Int32 BIFF12_ID_PCITEMA_STRING
const sal_Int32 BIFF12_ID_PCITEMA_MISSING
const sal_Int32 BIFF12_ID_PCITEM_BOOL
const sal_Int32 BIFF12_ID_PCITEM_DATE
const sal_Int32 BIFF12_ID_PCITEM_DOUBLE
const sal_Int32 BIFF12_ID_PCITEM_ERROR
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
const sal_Int32 BIFF12_ID_PCITEM_STRING
bool getFlag(Type nBitField, Type nMask)
A 2D cell range address struct for binary filters.
Stores basic data about cell values and formatting.
PCDefinitionModel()
True = data source supports drilldown.
OUString maRefreshedBy
Relation identifier for cache records fragment.
bool mbSaveData
True = cache needs refresh.
bool mbOptimizeMemory
True = try to refresh cache on load.
bool mbEnableRefresh
True = application may optimize memory usage.
bool mbTupleCache
True = application may upgrade cache version.
bool mbSupportDrill
True = data source supports subqueries.
bool mbBackgroundQuery
True = refreshing cache is enabled in UI.
bool mbSupportSubquery
True = cache stores OLAP functions.
double mfRefreshedDate
Name of user who last refreshed the cache.
bool mbInvalid
Limit for discarding unused items.
sal_Int32 mnMissItemsLimit
Number of data records in the cache.
bool mbUpgradeOnRefresh
True = application queries data asynchronously.
bool mbRefreshOnLoad
True = cached item values are present.
sal_Int32 mnRecords
Date/time of last refresh.
bool mbDateGroup
True = items are grouped by numeric ranges or date ranges.
sal_Int32 mnBaseField
Index of cache field that contains item groups based on this field.
PCFieldGroupModel()
Finalized group name of this field used in internal pivot table collection.
bool mbRangeGroup
Type of numeric or date range grouping.
sal_Int32 mnGroupBy
Index of cache field this grouped field is based on.
sal_Int32 mnParentField
Interval for numeric range grouping.
css::util::DateTime maEndDate
Manual or calculated start date for range grouping.
double mfInterval
Manual or calculated end value for range grouping.
bool mbAutoStart
True = items are grouped by date ranges or by item names.
void setBiffGroupBy(sal_uInt8 nGroupBy)
Sets the group-by value for BIFF import.
bool mbAutoEnd
True = start value for range groups is calculated from source data.
double mfStartValue
Manual or calculated end date for range grouping.
css::util::DateTime maStartDate
double mfEndValue
Manual or calculated start value for range grouping.
bool mbServerField
True = field from source data; false = calculated field.
OUString maPropertyName
Caption of the cache field.
sal_Int32 mnHierarchy
Data type from ODBC data source.
bool mbMemberPropField
True = list of unique ODBC items exists.
bool mbDatabaseField
Number of property mappings.
OUString maCaption
Fixed name of the cache field.
sal_Int32 mnNumFmtId
Formula of a calculated field.
sal_Int32 mnLevel
Hierarchy this field is part of.
bool mbUniqueList
True = ODBC server-based page field.
sal_Int32 mnMappingCount
Hierarchy level this field is part of.
sal_Int32 mnSqlType
Number format for all items.
PCFieldModel()
True = contains OLAP member properties.
OUString maFormula
OLAP property name.
bool mbHasDate
True = has non-date item(s), maybe date items.
PCSharedItemsModel()
True = contains strings with >255 characters.
bool mbHasString
True = has date item(s), maybe other types.
bool mbHasBlank
True = has (string|bool|error) item(s), maybe other types.
bool mbHasLongText
True = has numeric item(s) with only integers, maybe other types except date.
bool mbIsInteger
True = has numeric item(s), maybe other types except date.
bool mbHasMixed
True = has blank item(s), maybe other types.
bool mbHasNonDate
True = has (blank|string|bool|error) item(s), maybe other types.
bool mbIsNumeric
True = has [(string|bool|error) and (number|date)] or (number and date).
PCSourceModel()
Connection identifier for external data source.
sal_Int32 mnConnectionId
Type of the source data (sheet, consolidation, scenario, external).
PCWorksheetSourceModel()
Source cell range of the data.
OUString maSheet
Relation identifier for an external document URL.
ScRange maRange
Defined name containing a cell range if present.
OUString maDefName
Sheet name for cell range or sheet-local defined names.
Helper struct for mapping original item names from/to group item names.