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 >();
250 css::util::DateTime aDateTime(
maValue.get< css::util::DateTime >());
251 if (aDateTime.Year == 0)
253 SAL_WARN(
"sc",
"PivotCacheField::getFormattedName - invalid date");
258 case XML_e:
return maValue.get< OUString >();
260 OSL_FAIL(
"PivotCacheItem::getFormattedName - invalid data type" );
274 case XLS_TOKEN(
m ):
break;
275 case XLS_TOKEN( s ): rItem.
readString( rAttribs );
break;
276 case XLS_TOKEN(
n ): rItem.
readNumeric( rAttribs );
break;
277 case XLS_TOKEN(
d ): rItem.
readDate( rAttribs );
break;
278 case XLS_TOKEN( b ): rItem.
readBool( rAttribs );
break;
279 case XLS_TOKEN( e ): rItem.
readError( rAttribs );
break;
280 default: OSL_FAIL(
"PivotCacheItemList::importItem - unknown element type" );
307 default: OSL_FAIL(
"PivotCacheItemList::importItem - unknown record type" );
318 for(
const auto& [rId, rCaption] : vCaptions )
321 maItems[ rId ].setStringValue( rCaption );
328 orItemNames.reserve(
maItems.size() );
329 for(
const auto& rItem :
maItems )
330 orItemNames.push_back( rItem.getName() );
345 for( sal_Int32 nIdx = 0; !
rStrm.isEof() && (nIdx <
nCount); ++nIdx )
354 OSL_FAIL(
"PivotCacheItemList::importArray - unknown data type" );
366 mbDatabaseField( true ),
367 mbServerField( false ),
368 mbUniqueList( true ),
369 mbMemberPropField( false )
374 mbHasSemiMixed( true ),
375 mbHasNonDate( true ),
380 mbIsNumeric( false ),
381 mbIsInteger( false ),
382 mbHasLongText( false )
392 mnGroupBy( XML_range ),
393 mbRangeGroup( false ),
394 mbDateGroup( false ),
402 static const sal_Int32 spnGroupBy[] = { XML_range,
403 XML_seconds, XML_minutes, XML_hours, XML_days, XML_months, XML_quarters, XML_years };
409 maSharedItems( rHelper ),
410 maGroupItems( rHelper )
434 OSL_ENSURE(
maSharedItems.
empty(),
"PivotCacheField::importSharedItems - multiple shared items elements" );
473 OSL_ENSURE( nElement == XLS_TOKEN(
x ),
"PivotCacheField::importDiscretePrItem - unexpected element" );
474 if( nElement == XLS_TOKEN(
x ) )
486 nFlags =
rStrm.readuInt16();
493 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASCAPTION ) )
495 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASFORMULA ) )
496 rStrm.skip( ::std::max< sal_Int32 >(
rStrm.readInt32(), 0 ) );
498 rStrm.skip( ::std::max< sal_Int32 >(
rStrm.readInt32(), 0 ) );
499 if(
getFlag( nFlags, BIFF12_PCDFIELD_HASPROPERTYNAME ) )
511 nFlags =
rStrm.readuInt16();
537 nGroupBy =
rStrm.readuChar();
538 nFlags =
rStrm.readuChar();
559 OSL_ENSURE( nRecId ==
BIFF12_ID_PCITEM_INDEX,
"PivotCacheField::importPCDFDiscretePrItem - unexpected record" );
607 DataPilotFieldGroupInfo aGroupInfo;
610 aGroupInfo.HasDateValues =
false;
614 aGroupInfo.GroupBy = 0;
615 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
622 Reference< XDataPilotField > xDPGroupField;
628 DataPilotFieldGroupInfo aGroupInfo;
631 aGroupInfo.HasDateValues =
true;
636 using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
639 case XML_years: aGroupInfo.GroupBy = YEARS;
break;
640 case XML_quarters: aGroupInfo.GroupBy = QUARTERS;
break;
641 case XML_months: aGroupInfo.GroupBy = MONTHS;
break;
642 case XML_days: aGroupInfo.GroupBy = DAYS;
break;
643 case XML_hours: aGroupInfo.GroupBy = HOURS;
break;
644 case XML_minutes: aGroupInfo.GroupBy = MINUTES;
break;
645 case XML_seconds: aGroupInfo.GroupBy = SECONDS;
break;
646 default: OSL_FAIL(
"PivotCacheField::convertRangeGrouping - unknown date/time interval" );
651 Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY_THROW );
652 xDPGroupField = xDPGrouping->createDateGroup( aGroupInfo );
659 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
660 return xFieldName.is() ? xFieldName->getName() : OUString();
666 SAL_WARN_IF(
maDiscreteItems.size() != orItemNames.size(),
"sc",
"PivotCacheField::createParentGroupField - number of item names does not match grouping info" );
667 Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY );
668 if( !xDPGrouping.is() )
return OUString();
681 if ( pItem->isUnused() || ( pItem->getType() == XML_m ) || ( pItem->getType() == XML_e ) )
684 pItems->push_back(
nIndex );
689 Reference< XDataPilotField > xDPGroupField;
691 for(
const auto& rItems : aItemMap )
693 SAL_WARN_IF( rItems.empty(),
"sc",
"PivotCacheField::createParentGroupField - item/group should not be empty" );
694 if( !rItems.empty() )
703 ::std::vector< OUString > aMembers;
704 for(
auto i : rItems )
706 if( ::std::find( aMembers.begin(), aMembers.end(),
pName->maGroupName ) == aMembers.end() )
707 aMembers.push_back(
pName->maGroupName );
711 if( !aMembers.empty() )
try
715 SAL_WARN_IF( xDPGroupField.is() == xDPNewField.is(),
"sc",
"PivotCacheField::createParentGroupField - missing group field" );
716 if( !xDPGroupField.is() )
717 xDPGroupField = xDPNewField;
720 DataPilotFieldGroupInfo aGroupInfo;
722 aPropSet.
getProperty( aGroupInfo, PROP_GroupInfo );
736 aFirstItem =
pName->maOrigName;
737 Reference< XNamed > xGroupName;
739 Reference< XIndexAccess > xGroupsIA( aGroupInfo.Groups, UNO_QUERY_THROW );
740 for( sal_Int32 nIdx = 0,
nCount = xGroupsIA->getCount(); (nIdx <
nCount) && (aAutoName.isEmpty()); ++nIdx )
try
742 Reference< XNameAccess > xItemsNA( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
743 if( xItemsNA->hasByName( aFirstItem ) )
745 xGroupName.set( xGroupsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
746 aAutoName = xGroupName->getName();
753 SAL_WARN_IF( aAutoName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find auto-generated group name" );
758 aGroupName = pGroupItem->getName();
759 SAL_WARN_IF( aGroupName.isEmpty(),
"sc",
"PivotCacheField::createParentGroupField - cannot find group name" );
760 if( aGroupName.isEmpty() )
761 aGroupName = aAutoName;
763 if( xGroupName.is() && !aGroupName.isEmpty() )
766 if( aAutoName != aGroupName )
768 xGroupName->setName( aGroupName );
769 aPropSet.
setProperty( PROP_GroupInfo, aGroupInfo );
772 for(
auto i : rItems )
774 pName->maGroupName = aGroupName;
785 Reference< XNamed > xFieldName( xDPGroupField, UNO_QUERY );
786 return xFieldName.is() ? xFieldName->getName() : OUString();
798 bool bHasIndex = rItem.
getType() == XML_x;
799 OSL_ENSURE( bHasIndex !=
maSharedItems.
empty(),
"PivotCacheField::writeSourceDataCell - shared items missing or not expected" );
844 default: OSL_FAIL(
"PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
849 const WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx )
const
856 mfRefreshedDate( 0.0 ),
858 mnMissItemsLimit( 0 ),
861 mbRefreshOnLoad( false ),
862 mbOptimizeMemory( false ),
863 mbEnableRefresh( true ),
864 mbBackgroundQuery( false ),
865 mbUpgradeOnRefresh( false ),
866 mbTupleCache( false ),
867 mbSupportSubquery( false ),
868 mbSupportDrill( false )
886 mbValidSource( false ),
887 mbDummySheet( false )
932 nFlags1 =
rStrm.readuChar();
935 nFlags2 =
rStrm.readuChar();
937 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASUSERNAME ) )
939 if(
getFlag( nFlags2, BIFF12_PCDEFINITION_HASRELID ) )
956 sal_Int32 nSourceType;
957 nSourceType =
rStrm.readInt32();
959 static const sal_Int32 spnSourceTypes[] = { XML_worksheet, XML_external, XML_consolidation, XML_scenario };
965 sal_uInt8 nIsDefName, nIsBuiltinName, nFlags;
966 nIsDefName =
rStrm.readuChar();
967 nIsBuiltinName =
rStrm.readuChar();
968 nFlags =
rStrm.readuChar();
969 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASSHEET ) )
971 if(
getFlag( nFlags, BIFF12_PCDWBSOURCE_HASRELID ) )
975 if( nIsDefName == 0 )
985 if( nIsBuiltinName != 0 )
1003 OSL_ENSURE( !
maFields.empty(),
"PivotCache::finalizeImport - no pivot cache fields found" );
1004 for( PivotCacheFieldVector::const_iterator aIt =
maFields.begin(), aEnd =
maFields.end(); aIt != aEnd; ++aIt )
1006 if( (*aIt)->isDatabaseField() )
1008 OSL_ENSURE( (aIt ==
maFields.begin()) || (*(aIt - 1))->isDatabaseField(),
1009 "PivotCache::finalizeImport - database field follows a calculated field" );
1018 OSL_ENSURE( !
maDatabaseFields.empty(),
"PivotCache::finalizeImport - no pivot cache source fields found" );
1028 OSL_ENSURE( bInternal || bExternal,
"PivotCache::finalizeImport - invalid external document URL" );
1031 else if( bExternal )
1039 case XML_consolidation:
1064 "PivotCache::writeSourceHeaderCells - source cell range width does not match number of source fields" );
1074 rxDatabaseField->writeSourceHeaderCell( rSheetHelper, nCol, nRow );
1087 pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem );
1098 if(
rStrm.isEof() || (nCol > nMaxCol) )
1100 rxDatabaseField->importPCRecordItem(
rStrm, rSheetHelper, nCol, nRow );
1125 mbValidSource = (pTable->getHeight() - pTable->getTotalsRows()) > 1;
1131 else if( nSheet >= 0 )
1194 OSL_ENSURE( nCacheId >= 0,
"PivotCacheBuffer::registerPivotCacheFragment - invalid pivot cache identifier" );
1195 OSL_ENSURE(
maFragmentPaths.count( nCacheId ) == 0,
"PivotCacheBuffer::registerPivotCacheFragment - fragment path exists already" );
1196 if( (nCacheId >= 0) && !rFragmentPath.isEmpty() )
1227 rxCache = std::make_shared<PivotCache>( *
this );
static double Sub(const DateTime &rDateTime1, const DateTime &rDateTime2)
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)
bool checkCellRange(const ScRange &rRange, bool bAllowOverflow, bool bTrackOverflow)
Checks the passed cell range if it fits into the spreadsheet limits.
static bool convertToCellRangeUnchecked(ScRange &orRange, std::u16string_view aString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet 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 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 updateSourceDataRow(sal_Int32 nRow) const
Checks, if the row index has changed since last call, and initializes the sheet data buffer.
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 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)
#define SAL_WARN(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.