22#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
23#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
24#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
25#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
26#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
27#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
28#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
34#include <osl/diagnose.h>
36#include <document.hxx>
53using ::com::sun::star::sheet::DataPilotFieldOrientation;
54using ::com::sun::star::sheet::DataPilotFieldOrientation_ROW;
55using ::com::sun::star::sheet::DataPilotFieldOrientation_COLUMN;
56using ::com::sun::star::sheet::DataPilotFieldOrientation_PAGE;
57using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
58using ::com::sun::star::sheet::DataPilotFieldSortInfo;
59using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
60using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
61using ::com::sun::star::sheet::DataPilotFieldReference;
68const sal_uInt16 EXC_PCITEM_DATA_STRING = 0x0001;
69const sal_uInt16 EXC_PCITEM_DATA_DOUBLE = 0x0002;
70const sal_uInt16 EXC_PCITEM_DATA_INTEGER = 0x0004;
71const sal_uInt16 EXC_PCITEM_DATA_DATE = 0x0008;
74const sal_uInt16 spnPCItemFlags[] =
98 mnTypeFlag( EXC_PCITEM_DATA_STRING )
100 if( !rText.isEmpty() )
110 mnTypeFlag = (fValue - floor( fValue ) == 0.0) ?
111 EXC_PCITEM_DATA_INTEGER : EXC_PCITEM_DATA_DOUBLE;
123 mnTypeFlag( EXC_PCITEM_DATA_INTEGER )
130 mnTypeFlag( EXC_PCITEM_DATA_STRING )
157 if(
const OUString* pText =
GetText() )
161 else if(
const double* pfValue =
GetDouble() )
165 else if(
const sal_Int16* pnValue =
GetInteger() )
171 sal_uInt16 nYear =
static_cast< sal_uInt16
>( pDateTime->GetYear() );
172 sal_uInt16 nMonth = pDateTime->GetMonth();
177 if( nYear < 1900 ) { nYear = 1900; nMonth = 1; nDay = 0; }
178 rStrm << nYear << nMonth << nDay << nHour << nMin << nSec;
180 else if(
const bool* pbValue =
GetBool() )
182 rStrm << static_cast< sal_uInt16 >( *pbValue ? 1 : 0 );
187 OSL_ENSURE(
IsEmpty(),
"XclExpPCItem::WriteBody - no data found" );
192 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
212 "XclExpPCField::XclExpPCField - numeric and date grouping enabled" );
227 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
236 "XclExpPCField::FillFromGroup - wrong base cache field" );
258 "XclExpPCField::SetGroupChildIndex - field already has a grouping child field" );
278 return static_cast< sal_uInt16
>(
nPos );
296 rStrm << static_cast< sal_uInt8 >(
nIndex );
302 OSL_ENSURE(
IsSupportedField(),
"XclExpPCField::Save - unknown field type" );
322 "XclExpPCField::GetVisItemList - unexpected additional items in standard field" );
328 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InitStandardField - only for standard fields" );
329 OSL_ENSURE( rRange.
aStart.
Col() == rRange.
aEnd.
Col(),
"XclExpPCField::InitStandardField - cell range with multiple columns" );
347 double fValue = rDoc.
GetValue( aPos );
349 if( nFmtType == SvNumFormatType::LOGICAL )
351 else if( nFmtType & SvNumFormatType::DATETIME )
365 OSL_ENSURE(
IsGroupField(),
"XclExpPCField::InitStdGroupField - only for standard grouping fields" );
377 for(
size_t nElemIdx = 0, nElemCount = rGroupItem.
GetElementCount(); nElemIdx < nElemCount; ++nElemIdx )
382 sal_uInt16 nBaseItemIdx = rBaseField.
GetItemIndex( *pElemName );
406 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InitNumGroupField - only for standard fields" );
407 OSL_ENSURE( rNumInfo.
mbEnable,
"XclExpPCField::InitNumGroupField - numeric grouping not enabled" );
431 OSL_ENSURE( rDateInfo.
mbEnable,
"XclExpPCField::InitDateGroupField - date grouping not enabled" );
446 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InsertItemArrayIndex - only for standard fields" );
447 maIndexVec.push_back(
static_cast< sal_uInt16
>( nListPos ) );
463 OUString aShortText = aText.copy( 0, ::std::min(aText.getLength(),
EXC_PC_MAXSTRLEN ) );
512 OSL_ENSURE( rDPObj.
GetSheetDesc(),
"XclExpPCField::InsertNumDateGroupItems - cannot generate element list" );
533 const std::vector<SCROW>& aMemberIds = aTmpDim.
GetNumEntries(
534 static_cast<SCCOL>(nDim), pCache);
535 for (
SCROW nMemberId : aMemberIds)
561 sal_Int16 nStep = bUseStep ? limit_cast< sal_Int16 >( rDateInfo.
mfStep, 1,
SAL_MAX_INT16 ) : 1;
594 "XclExpPCField::WriteSxnumgroup - missing numeric grouping limits" );
602 "XclExpPCField::WriteSxgroupinfo - missing grouping info" );
619 mnListIdx( nListIdx ),
645 SCCOL nDocCol1, nDocCol2;
646 SCROW nDocRow1, nDocRow2;
655 if( 2 * (nDocRow2 - nDocRow1) < (nSrcRow2 - nSrcRow1) )
659 if( nSrcRow1 < nDocRow1 )
660 nSrcRow1 = nDocRow1 - 1;
661 if( nSrcRow2 > nDocRow2 )
662 nSrcRow2 = nDocRow2 + 1;
712 OSL_ENSURE(
mbValid,
"XclExpPivotCache::Save - invalid pivot cache" );
746 for(
SCCOL nScCol = rRange.
aStart.
Col(), nEndScCol = rRange.
aEnd.
Col(); nScCol <= nEndScCol; ++nScCol )
784 pLastGroupField = xNewGroupField.get();
851 std::size_t nRecSize = 0;
870OUString lclGetDataFieldCaption( std::u16string_view rFieldName,
ScGeneralFunction eFunc )
891 aCaption =
ScResId(pResIdx) +
" - ";
892 aCaption += rFieldName;
900 mpCacheItem( rCacheField.
GetItem( nCacheIdx ) )
909 mpCacheItem( nullptr )
929 const std::optional<OUString> & pVisName = rSaveMem.
GetLayoutName();
941 mpCacheField( rPTable.GetCacheField( nCacheIdx ) )
961 OSL_ENSURE( !
maDataInfoVec.empty(),
"XclExpPTField::GetLastDataInfoIndex - no data info found" );
963 return static_cast< sal_uInt16
>(
maDataInfoVec.size() - 1 );
970 return static_cast< sal_uInt16
>(
nPos );
984 sal_Int32
n = rName.getLength();
985 bool bEscaped =
false;
986 for (sal_Int32
i = 0;
i <
n; ++
i)
989 if (!bEscaped && c ==
'\\')
998 return aBuf.makeStringAndClear();
1005 OSL_ENSURE( eOrient != DataPilotFieldOrientation_DATA,
"XclExpPTField::SetPropertiesFromDim - called for data field" );
1012 const std::optional<OUString> & pLayoutName = rSaveDim.
GetLayoutName();
1016 const std::optional<OUString> & pSubtotalName = rSaveDim.
GetSubtotalName();
1031 if(
const DataPilotFieldSortInfo* pSortInfo = rSaveDim.
GetSortInfo() )
1034 if( pSortInfo->Mode == css::sheet::DataPilotFieldSortMode::DATA )
1040 if(
const DataPilotFieldAutoShowInfo* pShowInfo = rSaveDim.
GetAutoShowInfo() )
1049 if(
const DataPilotFieldLayoutInfo* pLayoutInfo = rSaveDim.
GetLayoutInfo() )
1056 if( eOrient == DataPilotFieldOrientation_PAGE )
1064 for (
const auto& pMember : rMembers)
1066 pItem->SetPropertiesFromMember( *pMember );
1083 const std::optional<OUString> & pVisName = rSaveDim.
GetLayoutName();
1096 rDataInfo.
mnRefField = pRefField->GetFieldIndex();
1097 if( pFieldRef->ReferenceItemType == css::sheet::DataPilotFieldReferenceItemType::NAMED )
1098 rDataInfo.
mnRefItem = pRefField->GetItemIndex( pFieldRef->ReferenceItemName, 0 );
1128 OSL_ENSURE( nDataInfoIdx <
maDataInfoVec.size(),
"XclExpPTField::WriteSxdi - data field not found" );
1180 mrPCache( rPCache ),
1184 mbFilterBtn( false )
1209 for( sal_uInt16 nFieldIdx = 0, nFieldCount =
mrPCache.
GetFieldCount(); nFieldIdx < nFieldCount; ++nFieldIdx )
1216 for (
auto const& iter : rDimList)
1218 if (iter->GetOrientation() == DataPilotFieldOrientation_DATA)
1223 for (
auto const& iter : rDimList)
1225 if (iter->GetOrientation() != DataPilotFieldOrientation_DATA)
1254 const XclExpPTField* pField = GetField( rDataField.first );
1255 return pField && pField->GetFieldName() == rName;
1258 return static_cast< sal_uInt16
>( std::distance(
maDataFields.begin(), aIt) );
1306 return aFieldName.isEmpty() ? nullptr :
GetFieldAcc(aFieldName);
1340 if( bDataLayout && !bMultiData )
1345 case DataPilotFieldOrientation_ROW:
1350 case DataPilotFieldOrientation_COLUMN:
1355 case DataPilotFieldOrientation_PAGE:
1357 OSL_ENSURE( !bDataLayout,
"XclExpPivotTable::SetFieldPropertiesFromDim - wrong orientation for data fields" );
1359 case DataPilotFieldOrientation_DATA:
1360 OSL_FAIL(
"XclExpPivotTable::SetFieldPropertiesFromDim - called for data field" );
1371 pField->SetDataPropertiesFromDim( rSaveDim );
1373 maDataFields.emplace_back( pField->GetFieldIndex(), pField->GetLastDataInfoIndex() );
1402 if( pFieldVec && !pFieldVec->empty() && (pFieldVec->back() !=
EXC_SXIVD_DATA) )
1404 ScfUInt16Vec::const_iterator aIt = ::std::find( pFieldVec->begin(), pFieldVec->end(),
EXC_SXIVD_DATA );
1405 if( aIt != pFieldVec->end() )
1406 maPTInfo.
mnDataPos =
static_cast< sal_uInt16
>( std::distance(pFieldVec->begin(), aIt) );
1436 if (bExtraHeaderRow)
1440 rnXclCol2 = ::std::max( rnXclCol2, rnDataXclCol );
1441 rnXclRow2 = ::std::max( rnXclRow2, rnDataXclRow );
1447 if (bExtraHeaderRow)
1462 if( !rFields.empty() )
1465 for(
const auto& rField : rFields )
1476 rStrm.SetSliceSize( 6 );
1481 xField->WriteSxpiEntry(
rStrm );
1489 for(
const auto& [rFieldIdx, rDataInfoIdx] :
maDataFields )
1493 xField->WriteSxdi(
rStrm, rDataInfoIdx );
1499 if( nLineCount <= 0 )
1509 for( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
1512 rStrm << sal_uInt16( 0 )
1530 rStrm.StartRecord( 0x0802, 32 );
1532 sal_uInt16
const nRecordType = 0x0802;
1533 sal_uInt16
const nDummyFlags = 0x0000;
1534 sal_uInt16
const nTableType = 1;
1536 rStrm << nRecordType << nDummyFlags << nTableType;
1539 sal_uInt16
const nFlags = 0x0001;
1542 sal_uInt16 nFlags = 0x0000;
1543 bool bEnableRefresh =
true;
1544 bool bPCacheInvalid =
false;
1545 bool bOlapPTReport =
false;
1547 if (bEnableRefresh) nFlags |= 0x0001;
1548 if (bPCacheInvalid) nFlags |= 0x0002;
1549 if (bOlapPTReport) nFlags |= 0x0004;
1555 sal_uInt32
const nOptions = 0x00000000;
1558 bool bNoStencil =
false;
1559 bool bHideTotal =
false;
1560 bool bEmptyRows =
false;
1561 bool bEmptyCols =
false;
1562 if (bNoStencil) nOptions |= 0x00000001;
1563 if (bHideTotal) nOptions |= 0x00000002;
1564 if (bEmptyRows) nOptions |= 0x00000008;
1565 if (bEmptyCols) nOptions |= 0x00000010;
1577 rStrm << static_cast<sal_uInt16>(0x0001);
1617 if( mnScTab == EXC_PTMGR_PIVOTCACHES )
1618 mrPTMgr.WritePivotCaches( rStrm );
1620 mrPTMgr.WritePivotTables( rStrm, mnScTab );
1633 for(
size_t nDPObj = 0,
nCount = pDPColl->GetCount(); nDPObj <
nCount; ++nDPObj )
1643 return new XclExpPivotRecWrapper( *
this, EXC_PTMGR_PIVOTCACHES );
1648 return new XclExpPivotRecWrapper( *
this, nScTab );
1661 if( xPTable->GetScTab() == nScTab )
1662 xPTable->Save(
rStrm );
1693 if( xNewPCache->IsValid() )
1696 return xNewPCache.get();
void IncRow(SCROW nDelta=1)
This class represents the cached data part of the datapilot cache table implementation.
OUString GetFormattedString(tools::Long nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
bool HasGroupDimensions() const
const ScDPSaveGroupDimension * GetGroupDimForBase(const OUString &rBaseDimName) const
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
const std::vector< SCROW > & GetNumEntries(SCCOL nSourceDim, const ScDPCache *pCache) const
const ScRange & GetOutRange() const
const ScSheetSourceDesc * GetSheetDesc() const
ScDPSaveData * GetSaveData() const
const OUString & GetName() const
bool GetDrillDown() const
bool GetFilterButton() const
bool GetColumnGrand() const
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDataLayoutDimension() const
const DimsType & GetDimensions() const
const ScDPDimensionSaveData * GetExistingDimensionData() const
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
bool HasShowEmpty() const
ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const
css::sheet::DataPilotFieldOrientation GetOrientation() const
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
const std::optional< OUString > & GetSubtotalName() const
const std::optional< OUString > & GetLayoutName() const
ScGeneralFunction GetFunction() const
tools::Long GetSubTotalsCount() const
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
const MemberList & GetMembers() const
std::vector< ScDPSaveMember * > MemberList
bool IsDataLayout() const
const OUString & GetName() const
bool GetShowEmpty() const
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
const OUString & GetSourceDimName() const
const OUString & GetGroupDimName() const
const ScDPNumGroupInfo & GetDateInfo() const
sal_Int32 GetDatePart() const
tools::Long GetGroupCount() const
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Classes to save Data Pilot settings that create new dimensions (fields).
size_t GetElementCount() const
const OUString & GetGroupName() const
const OUString * GetElementByIndex(size_t nIndex) const
SC_DLLPUBLIC bool HasShowDetails() const
bool GetShowDetails() const
SC_DLLPUBLIC bool HasIsVisible() const
bool GetIsVisible() const
SC_DLLPUBLIC const std::optional< OUString > & GetLayoutName() const
Represents a group dimension that introduces a new hierarchy for an existing dimension.
virtual const ScDPItemData * GetMemberById(sal_Int32 nDim, sal_Int32 nId)
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
ScInterpreterContext & GetNonThreadedContext() const
SC_DLLPUBLIC bool HasValueData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Implementation of ScDPTableData with sheet data.
This class contains authoritative information on the internal reference used as the data source for d...
const OUString & GetRangeName() const
SC_DLLPUBLIC const ScDPCache * CreateCache(const ScDPDimensionSaveData *pDimData) const
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
const OUString & GetFieldName() const
Returns the name of this cache field.
XclExpPCItemList maOrigItemList
void InsertOrigDateTimeItem(const DateTime &rDateTime, const OUString &rText)
Inserts an original date/time item, if it is not contained already.
void WriteIndex(XclExpStream &rStrm, sal_uInt32 nSrcRow) const
Writes the item index at the passed source row position as part of the SXINDEXLIST record.
sal_uInt16 GetItemCount() const
Returns the number of visible items of this field.
void InitStdGroupField(const XclExpPCField &rBaseField, const ScDPSaveGroupDimension &rGroupDim)
Initializes a standard grouping field.
XclExpPCItemList maGroupItemList
List with original items.
void InsertOrigBoolItem(bool bValue, const OUString &rText)
Inserts an original boolean item, if it is not contained already.
XclExpPCItemList maNumGroupLimits
Indexes into maItemList.
void InitStandardField(const ScRange &rRange)
Initializes a standard field.
void InitDateGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rDateInfo, sal_Int32 nDatePart)
Initializes a date grouping field.
XclExpPCField(const XclExpRoot &rRoot, sal_uInt16 nFieldIdx, const ScDPObject &rDPObj, const ScRange &rRange)
Creates a standard pivot cache field, filled from sheet source data.
void WriteSxgroupinfo(XclExpStream &rStrm)
Writes an SXGROUPINFO record describing the item order in grouping fields.
void InsertOrigItem(XclExpPCItem *pNewItem)
Inserts an original source item.
void InitNumGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo)
Initializes a numeric grouping field.
virtual ~XclExpPCField() override
void InsertOrigDoubleItem(double fValue, const OUString &rText)
Inserts an original value item, if it is not contained already.
sal_uInt16 mnTypeFlags
List with limit values for numeric grouping.
void WriteSxnumgroup(XclExpStream &rStrm)
Writes an SXNUMGROUP record and the additional items for a numeric grouping field.
std::size_t GetIndexSize() const
Returns the size an item index needs to write out.
virtual void Save(XclExpStream &rStrm) override
Writes the pivot cache field and all items and other related records.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the SXFIELD record for this field.
void InsertNumDateGroupItems(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo, sal_Int32 nDatePart=0)
Generates and inserts all visible items for numeric or date grouping.
void SetDateGroupLimit(const ScDPNumGroupInfo &rDateInfo, bool bUseStep)
Inserts the SXDATETIME/SXINTEGER items that specify the limits for a date grouping.
void SetGroupChildField(const XclExpPCField &rChildField)
Sets the passed field as direct grouping child field of this field.
void InsertItemArrayIndex(size_t nListPos)
Inserts the passed index into the item index array of original items.
sal_uInt16 InsertGroupItem(XclExpPCItem *pNewItem)
Inserts an item into the grouping item list.
void SetNumGroupLimit(const ScDPNumGroupInfo &rNumInfo)
Inserts the SXDOUBLE items that specify the limits for a numeric grouping.
sal_uInt16 GetItemIndex(std::u16string_view rItemName) const
Returns the index of a pivot cache item, or EXC_PC_NOITEM on error.
void Finalize()
Initializes flags and item count fields.
const XclExpPCItem * GetItem(sal_uInt16 nItemIdx) const
Returns the specified pivot cache item (returns visible items in groupings).
const XclExpPCItemList & GetVisItemList() const
Returns the item list that contains the visible items.
void InsertOrigTextItem(const OUString &rText)
Inserts an original text item, if it is not contained already.
ScfUInt16Vec maIndexVec
List with grouping items.
Represents a data item in a pivot cache containing data of any type.
sal_uInt16 GetTypeFlag() const
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
XclExpPCItem(const OUString &rText)
bool EqualsDouble(double fValue) const
bool EqualsDateTime(const DateTime &rDateTime) const
bool EqualsText(std::u16string_view rText) const
bool EqualsBool(bool bValue) const
XclPTFieldInfo maFieldInfo
The referred pivot cache field.
const XclExpPCField * mpCacheField
Parent pivot table containing this field.
void SetPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with row/column/page properties from the passed save dimension.
sal_uInt16 GetLastDataInfoIndex() const
Returns the index of the last inserted data info struct.
const XclExpPivotTable & mrPTable
XclExpPTItem * GetItemAcc(std::u16string_view rName)
Returns an item by its name.
XclExpPTField(const XclExpPivotTable &rPTable, sal_uInt16 nCacheIdx)
void WriteSxdi(XclExpStream &rStrm, sal_uInt16 nDataInfoIdx) const
Writes an SXDI records containing info about a data field.
void AppendSubtotalItem(sal_uInt16 nItemType)
Appends a special item describing a field subtotal entry.
XclPTFieldExtInfo maFieldExtInfo
General field info (SXVD record).
XclPTPageFieldInfo maPageInfo
Extended field info (SXVDEX record).
XclExpRecordList< XclExpPTItem > maItemList
List of extended data field info (SXDI records).
void WriteSxvd(XclExpStream &rStrm) const
Writes the SXVD record introducing the field.
OUString GetFieldName() const
Returns the name of this field.
void SetDataPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with data field properties from the passed save dimension.
std::vector< XclPTDataFieldInfo > maDataInfoVec
Page field info (entry in SXPI record).
void WriteSxvdex(XclExpStream &rStrm) const
Writes the SXVDEX record containing additional settings.
void WriteSxpiEntry(XclExpStream &rStrm) const
Writes an entry for an SXPI record containing own page field info.
void AppendSubtotalItems()
Appends special items describing the field subtotal entries.
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table field.
sal_uInt16 GetFieldIndex() const
Returns the pivot table field list index of this field.
sal_uInt16 GetItemIndex(std::u16string_view rName, sal_uInt16 nDefaultIdx) const
Returns the list index of an item by its name.
XclExpPTItem(const XclExpPCField &rCacheField, sal_uInt16 nCacheIdx)
OUString GetItemName() const
Returns the internal name of this item.
const XclExpPCItem * mpCacheItem
XclPTItemInfo maItemInfo
The referred pivot cache item.
void SetPropertiesFromMember(const ScDPSaveMember &rSaveMem)
Fills this item with properties from the passed save member.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the SXVI record body describing the pivot table item.
void AddGroupFields(const ScDPObject &rDPObj)
Adds all grouping pivot cache fields.
void WriteSxdb(XclExpStream &rStrm) const
Writes the SXDB record.
bool mbValid
List index in pivot cache buffer.
void WriteDconref(XclExpStream &rStrm) const
Writes the DCONREF record containing the source range.
void WriteCacheStream()
Creates the pivot cache storage stream and writes the cache.
sal_uInt16 GetCacheIndex() const
Returns the list index of the cache used in pivot table records.
bool HasEqualDataSource(const ScDPObject &rDPObj) const
Returns true, if the passed DP object has the same data source as this cache.
static void SaveXml(XclExpXmlStream &rStrm)
void AddStdFields(const ScDPObject &rDPObj)
Adds all standard pivot cache fields based on source data.
bool HasAddFields() const
Returns true, if this pivot cache contains non-standard fields (e.g.
void Save(XclExpStream &rStrm)
Writes related records into Workbook stream and creates the pivot cache storage stream.
void WriteSxindexlistList(XclExpStream &rStrm) const
Writes the SXINDEXLIST record list containing the item index table.
XclExpPivotCache(const XclExpRoot &rRoot, const ScDPObject &rDPObj, sal_uInt16 nListIdx)
ScRange maDocSrcRange
The exported sheet source range.
OUString maTabName
List of all pivot cache fields.
OUString maSrcRangeName
Name of source data sheet.
const XclExpPCField * GetField(sal_uInt16 nFieldIdx) const
Returns the specified pivot cache field.
bool HasItemIndexList() const
Returns true, if the item index list will be written.
sal_uInt16 GetFieldCount() const
Returns the number of pivot cache fields.
void AddFields(const ScDPObject &rDPObj)
Adds all pivot cache fields.
ScRange maExpSrcRange
The original sheet source range.
ScRange maOrigSrcRange
Range name for source data.
void WriteDConName(XclExpStream &rStrm) const
DCONNAME record contains range name source.
static void WriteSxdbex(XclExpStream &rStrm)
Writes the SXDBEX record.
XclExpPCFieldList maFieldList
Pivot cache settings (SXDB record).
The main class for pivot table export.
XclExpRecordRef CreatePivotCachesRecord()
Creates a record wrapper for exporting all pivot caches.
void CreatePivotTables()
Creates all pivot tables and caches from the Calc DataPilot objects.
XclExpRecordRef CreatePivotTablesRecord(SCTAB nScTab)
Creates a record wrapper for exporting all pivot tables of the specified sheet.
void WritePivotCaches(XclExpStream &rStrm)
Writes all pivot caches (all Workbook records and cache streams).
XclExpPivotTableList maPTableList
List of all pivot caches.
void WritePivotTables(XclExpStream &rStrm, SCTAB nScTab)
Writes all pivot tables of the specified Calc sheet.
const XclExpPivotCache * CreatePivotCache(const ScDPObject &rDPObj)
Finds an existing (if enabled in mbShareCaches) or creates a new pivot cache.
XclExpPivotTableManager(const XclExpRoot &rRoot)
XclExpRecordList< XclExpPivotCache > maPCacheList
void WriteSxdiList(XclExpStream &rStrm) const
Writes all SXDI records containing info about the data fields.
const XclExpPTField * GetField(sal_uInt16 nFieldIdx) const
Returns a pivot table field by its name.
const XclExpPCField * GetCacheField(sal_uInt16 nCacheIdx) const
Returns a pivot cache field.
void SetPropertiesFromDP(const ScDPSaveData &rSaveData)
Fills internal members with all properties from the passed save data.
std::vector< XclPTDataFieldPos > maDataFields
Page field indexes.
SCTAB mnOutScTab
Special data field orientation field.
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table.
void WriteSxview(XclExpStream &rStrm) const
Writes the SXVIEW record starting the pivot table.
bool mbValid
Sheet index of the output range.
ScfUInt16Vec maColFields
Row field indexes.
void WriteQsiSxTag(XclExpStream &rStrm) const
sal_uInt16 GetDataFieldIndex(const OUString &rName, sal_uInt16 nDefaultIdx) const
Returns the data-field-only index of the first data field with the passed name.
void Finalize()
Initializes any data after processing the entire source DataPilot.
bool mbFilterBtn
true = The pivot table is valid for export.
void WriteSxViewEx9(XclExpStream &rStrm) const
Writes the SX_AUTOFORMAT records with the autoformat id and header layout.
static void WriteSxivd(XclExpStream &rStrm, const ScfUInt16Vec &rFields)
Writes an SXIVD record for row field or column field order.
XclPTInfo maPTInfo
The pivot cache this pivot table bases on.
ScfUInt16Vec maRowFields
All fields in pivot cache order.
const XclExpPivotCache & mrPCache
static void WriteSxli(XclExpStream &rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount)
Writes a dummy SXLI records containing item layout info.
XclExpPTField * GetFieldAcc(std::u16string_view rName)
Returns a pivot table field by its name.
XclExpPTFieldList maFieldList
The selected autoformat (SXVIEWEX9)
XclExpPivotTable(const XclExpRoot &rRoot, const ScDPObject &rDPObj, const XclExpPivotCache &rPCache)
void WriteSxex(XclExpStream &rStrm) const
Writes the SXEX records containing additional pivot table info.
XclExpPTField maDataOrientField
Data field indexes.
void SetFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table field with all properties from the passed save dimension.
void SetDataFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table data field with all properties from the passed save dimension.
ScfUInt16Vec maPageFields
Column field indexes.
XclPTExtInfo maPTExtInfo
Info about the pivot table (SXVIEW record).
void WriteSxpi(XclExpStream &rStrm) const
Writes the SXPI record containing page field info.
XclPTViewEx9Info maPTViewEx9Info
Extended info about the pivot table (SXEX record).
Base class for all Excel records.
virtual void Save(XclExpStream &rStrm)
Overwrite this method to do any operation while saving the record.
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
void AppendRecord(RecType *pRec)
Appends a record to the list.
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Base class for single records with any content.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Access to global data from other classes.
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
This class is used to export Excel record streams.
This class stores an unformatted or formatted string for Excel export.
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
static OUString EncodeUrl(const XclExpRoot &rRoot, std::u16string_view rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
Represents a field in a pivot cache.
sal_uInt16 GetFieldIndex() const
Returns the index of this field in the containing pivot cache.
ScfUInt16Vec maGroupOrder
Own field index in pivot cache.
bool IsDateGroupField() const
Returns true, if this field is a date/time grouping field.
bool Has16BitIndexes() const
Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values.
bool IsSupportedField() const
Returns true, if the type of the field is supported by Calc.
bool IsNumGroupField() const
Returns true, if this field is a numeric grouping field.
XclPCFieldType meFieldType
Pivot cache field info (SXFIELD record).
bool IsGroupField() const
Returns true, if this field is a grouping field of any type.
bool IsStandardField() const
Returns true, if this is a standard field build directly from source data.
XclPCFieldInfo maFieldInfo
XclPCNumGroupInfo maNumGroupInfo
Order of items in a grouping field (SXGROUPINFO record).
bool IsStdGroupField() const
Returns true, if this field is a grouping field.
const bool * GetBool() const
Returns pointer to Boolean value, if the item type is 'boolean', otherwise 0.
const double * GetDouble() const
Returns pointer to value, if the item type is 'double', otherwise 0.
void SetEmpty()
Sets the item to 'empty' type.
void SetBool(bool bValue, const OUString &rText=OUString())
Sets the item to 'boolean' type and adds the passed Boolean value.
const OUString * GetText() const
Returns pointer to text, if the item type is 'text', otherwise 0.
void SetDateTime(const DateTime &rDateTime, const OUString &rText=OUString())
Sets the item to 'date/time' type and adds the passed date.
void SetDouble(double fValue, const OUString &rText=OUString())
Sets the item to 'double' type and adds the passed value.
bool IsEmpty() const
Returns true, if the item type is 'empty'.
void SetText(const OUString &rText)
Sets the item to 'text' type and adds the passed text.
void SetInteger(sal_Int16 nValue)
Sets the item to 'integer' type and adds the passed value.
const DateTime * GetDateTime() const
Returns pointer to date, if the item type is 'date/time', otherwise 0.
const OUString & ConvertToText() const
Returns the text representation of the item.
const sal_Int16 * GetInteger() const
Returns pointer to integer, if the item type is 'integer', otherwise 0.
tools::SvRef< SotStorage > OpenStorage(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrgName) const
Tries to open a storage as child of the specified storage for reading or writing.
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2,...
@ AVERAGE
average of all numerical values is calculated.
@ PRODUCT
product of all numerical values is calculated.
@ MAX
maximum value of all numerical values is calculated.
@ COUNT
all values, including non-numerical values, are counted.
@ VARP
variance is calculated based on the entire population.
@ SUM
sum of all numerical values is calculated.
@ STDEVP
standard deviation is calculated based on the entire population.
@ COUNTNUMS
numerical values are counted.
@ MIN
minimum value of all numerical values is calculated.
@ VAR
variance is calculated based on a sample.
@ STDEV
standard deviation is calculated based on a sample.
std::unique_ptr< sal_Int32[]> pData
OUString ScResId(TranslateId aId)
sal_uInt16 mnBaseItems
Number of special items in a grouping field.
sal_uInt16 mnGroupItems
Number of visible items for this field.
sal_uInt16 mnVisItems
Base field if this field contains grouping info.
sal_uInt16 mnGroupChild
Various flags.
sal_uInt16 mnFlags
Name of the pivot cache field.
sal_uInt16 mnOrigItems
Number of items in the base field.
sal_uInt16 mnGroupBase
Field containing grouping info for this field.
sal_uInt16 mnSrcType
Number of all fields (standard, grouped, calculated).
sal_uInt16 mnFlags
Stream identifier.
sal_uInt16 mnTotalFields
Number of standard pivot cache fields.
sal_uInt16 mnStrmId
Records in source database.
sal_uInt16 mnStdFields
Records in a source database block.
void SetScDateType(sal_Int32 nScType)
bool mbUseCache
The visible name, if used.
Contains data for a pivot table data field (SXDI record).
void SetApiRefItemType(sal_Int32 nRefItemType)
Sets the result reference item type represented by the passed API constant.
sal_uInt16 mnRefItem
Index to SXVD of referred field used for the results.
void SetApiRefType(sal_Int32 nRefType)
Sets the result reference type represented by the passed API constant.
sal_uInt16 mnRefField
Result reference type.
void SetApiAggFunc(ScGeneralFunction eAggFunc)
Sets the aggregation function represented by the passed API enum.
sal_uInt32 mnFlags
Number of page fields per column.
sal_uInt16 mnPagePerRow
Number of SXSELECT records.
sal_uInt16 mnPagePerCol
Number of page fields per row.
void SetApiAutoShowMode(sal_Int32 nShowMode)
Sets the AutoShow mode represented by the passed API constant.
void SetApiAutoShowCount(sal_Int32 nShowCount)
Sets the number of items to be shown in AutoShow mode.
void SetApiLayoutMode(sal_Int32 nLayoutMode)
Sets the layout mode represented by the passed API constant.
sal_uInt16 mnSortField
Several flags and number of items for AutoShow.
std::optional< OUString > mpFieldTotalName
void SetApiSortMode(sal_Int32 nSortMode)
Sets the sorting mode represented by the passed API constant.
sal_uInt16 mnShowField
Index to data field sorting bases on.
sal_uInt16 mnSubtotals
Number of subtotal functions.
sal_uInt16 mnCacheIdx
Number of items of this field.
sal_uInt16 mnItemCount
Bitfield for subtotal functions.
void SetSubtotals(const XclPTSubtotalVec &rSubtotals)
Sets the subtotal functions contained in the passed sequence.
void AddApiOrient(css::sheet::DataPilotFieldOrientation eOrient)
Adds the axis orientation represented by the passed API enum.
OUString maDataName
The name of the pivot table.
XclRange maOutXclRange
The visible name of the data field.
sal_uInt16 mnFlags
Number of columns containing data.
sal_uInt16 mnDataPos
Orientation of data fields.
sal_uInt16 mnPageFields
Number of column fields.
sal_uInt16 mnDataCols
Number of rows containing data.
sal_uInt16 mnDataRows
Number of data fields.
sal_uInt16 mnCacheIdx
First heading row.
XclAddress maDataXclPos
Output range.
sal_uInt16 mnFields
Position of data fields.
sal_uInt16 mnColFields
Number of row fields.
sal_uInt16 mnDataFields
Number of page fields.
sal_uInt16 mnDataAxis
0-based index of the pivot cache.
sal_uInt16 mnFirstHeadRow
First cell containing data.
sal_uInt16 mnRowFields
Number of all fields.
sal_uInt16 mnCacheIdx
Several flags.
sal_uInt16 mnFlags
Type of the item (e.g. data, function, grand total).
sal_uInt16 mnSelItem
Base field for this page info.
void Init(const ScDPObject &rDPObj)
sal_uInt8 mnGridLayout
AutoFormat ID.
XclPTCachedName maVisName
void SetVisName(const OUString &rName)
Sets the visible name and enables usage of cache if name is empty.
static OUString lcl_convertCalcSubtotalName(const OUString &rName)
Calc's subtotal names are escaped with backslashes ('\'), while Excel's are not escaped at all.
::std::pair< sal_uInt16, sal_uInt16 > XclPTDataFieldPos
Data field position specifying the pivot table field index (first) and data info index (second).
XclExpValueRecord< sal_uInt16 > XclExpUInt16Record
A record containing an unsigned 16-bit value.
const sal_uInt16 EXC_ID_EOF
Internal use only.
const sal_uInt32 EXC_SXVDEX_SHOWALL
const sal_uInt16 EXC_SXVI_TYPE_COUNTNUM
const sal_uInt16 EXC_ID_SXNUMGROUP
const sal_uInt16 EXC_SXVD_SUBT_COUNT
const sal_uInt16 EXC_SXVI_TYPE_COUNT
const sal_uInt16 EXC_ID_DCONNAME
const sal_uInt16 EXC_SXFIELD_DATA_DBL
Only integers, opt. with doubles.
const sal_uInt16 EXC_SXFIELD_DATA_STR
Special state for groupings.
const sal_uInt16 EXC_ID_SXPI
const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM
const sal_uInt32 EXC_SXVDEX_SORT_ASC
const sal_uInt16 EXC_ID_SXDATETIME
const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM
Dates and empty strings, nothing else (?).
const sal_uInt16 EXC_ID_SXIVD
@ EXC_PCFIELD_NUMGROUP
Standard grouping field.
@ EXC_PCFIELD_DATEGROUP
Numeric grouping field.
@ EXC_PCFIELD_STDGROUP
Standard field without grouping.
@ EXC_PCFIELD_DATECHILD
First date grouping field (opt. with child grouping field).
const sal_uInt16 EXC_SXVI_TYPE_AVERAGE
const sal_uInt16 EXC_SXVDEX_SHOW_NONE
const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL
Only strings and integers, opt. with doubles.
const sal_uInt16 EXC_SXVD_SUBT_MAX
const sal_uInt16 EXC_SXVI_TYPE_MIN
const sal_uInt16 EXC_SXVD_SUBT_DEFAULT
const sal_uInt16 EXC_SXFIELD_DATA_INT
Only strings, nothing else.
const sal_uInt16 EXC_SXVD_SUBT_STDDEVP
const double EXC_SXDBEX_CREATION_DATE
const sal_uInt16 EXC_SXFIELD_DATA_STR_INT
Only doubles, nothing else.
const sal_uInt16 EXC_SXVD_SUBT_VAR
const sal_uInt16 EXC_SXVI_DEFAULT_CACHE
const sal_uInt16 EXC_ID_SXEMPTY
const sal_uInt16 EXC_SXVD_AXIS_COL
const sal_uInt16 EXC_ID_SXINDEXLIST
List index for step item in groupings.
const sal_uInt16 EXC_ID_SXVS
const sal_uInt16 EXC_ID_SXEX
constexpr OUStringLiteral EXC_STORAGE_PTCACHE
const sal_uInt16 EXC_SXFIELD_NUMGROUP
const sal_uInt16 EXC_SXFIELD_HASITEMS
const sal_uInt16 EXC_SXLI_DEFAULTFLAGS
const sal_uInt16 EXC_SXVD_AXIS_NONE
const sal_uInt16 EXC_PC_NOITEM
const sal_uInt16 EXC_SXFIELD_16BIT
const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN
const sal_uInt16 EXC_SXVIEW_COLGRAND
const sal_uInt16 EXC_SXVI_TYPE_PROD
const sal_uInt16 EXC_ID_SXVDEX
const sal_uInt16 EXC_SXFDBTYPE_DEFAULT
const sal_uInt16 EXC_SXIVD_DATA
const sal_uInt16 EXC_SXVD_AXIS_ROW
const sal_uInt16 EXC_ID_SXDOUBLE
const sal_uInt16 EXC_ID_SXINTEGER
const sal_uInt16 EXC_ID_SXGROUPINFO
const sal_uInt16 EXC_ID_SXSTRING
const sal_uInt16 EXC_ID_SXIDSTM
const sal_uInt16 EXC_ID_SXVD
const sal_uInt16 EXC_ID_SXBOOLEAN
::std::vector< ScGeneralFunction > XclPTSubtotalVec
const sal_uInt16 EXC_SXVD_SUBT_AVERAGE
const sal_uInt16 EXC_SXVD_SUBT_SUM
const sal_uInt16 EXC_SXVI_HIDDEN
const sal_uInt16 EXC_ID_SXVI
const sal_uInt16 EXC_SXVD_SUBT_MIN
const sal_uInt16 EXC_SXVI_TYPE_VAR
const sal_uInt16 EXC_SXPI_ALLITEMS
const sal_uInt16 EXC_SXVD_SUBT_STDDEV
const size_t EXC_PC_MAXITEMCOUNT
const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK
const sal_uInt16 EXC_SXFIELD_DATA_NONE
const sal_uInt16 EXC_SXVI_TYPE_SUM
const sal_uInt16 EXC_SXVI_TYPE_MAX
const sal_uInt16 EXC_ID_DCONREF
const sal_uInt16 EXC_SXVD_SUBT_PROD
const sal_uInt16 EXC_ID_SXVIEWEX9
const sal_uInt16 EXC_ID_SXLI
const sal_uInt16 EXC_SXVDEX_SORT_OWN
const sal_uInt16 EXC_SXDB_SAVEDATA
const sal_uInt16 EXC_SXDB_SRC_SHEET
const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR
Dates with integers or doubles without strings.
const sal_uInt16 EXC_ID_SXDI
const sal_uInt16 EXC_SXFIELD_DATA_DATE
Only strings and doubles, nothing else.
const sal_uInt16 EXC_SXVI_HIDEDETAIL
const sal_uInt16 EXC_SXVIEW_DATALAST
const sal_uInt16 EXC_SXVI_TYPE_DATA
const sal_uInt32 EXC_SXEX_DRILLDOWN
const sal_uInt16 EXC_SXVI_TYPE_STDDEV
const sal_uInt32 EXC_SXVDEX_AUTOSHOW
const sal_uInt16 EXC_ID_SXFIELD
const sal_uInt16 EXC_SXFIELD_HASCHILD
const sal_Int32 EXC_PC_MAXSTRLEN
const sal_uInt16 EXC_SXVS_SHEET
const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX
const sal_uInt16 EXC_ID_SXDB
const sal_uInt16 EXC_SXVI_TYPE_DEFAULT
const sal_uInt16 EXC_SXVI_TYPE_STDDEVP
const sal_uInt16 EXC_ID_SXFDBTYPE
const sal_uInt16 EXC_ID_SXDBEX
const sal_uInt16 EXC_ID_SXVIEW
const sal_uInt16 EXC_SXVI_TYPE_VARP
const sal_uInt16 EXC_SXVD_SUBT_VARP
const sal_uInt16 EXC_SXVIEW_ROWGRAND