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>
32 #include <string_view>
34 #include <osl/diagnose.h>
36 #include <document.hxx>
43 #include <globstr.hrc>
50 using namespace ::
oox;
52 using ::com::sun::star::sheet::DataPilotFieldOrientation;
53 using ::com::sun::star::sheet::DataPilotFieldOrientation_ROW;
54 using ::com::sun::star::sheet::DataPilotFieldOrientation_COLUMN;
55 using ::com::sun::star::sheet::DataPilotFieldOrientation_PAGE;
56 using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
57 using ::com::sun::star::sheet::DataPilotFieldSortInfo;
58 using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
59 using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
60 using ::com::sun::star::sheet::DataPilotFieldReference;
67 const sal_uInt16 EXC_PCITEM_DATA_STRING = 0x0001;
68 const sal_uInt16 EXC_PCITEM_DATA_DOUBLE = 0x0002;
69 const sal_uInt16 EXC_PCITEM_DATA_INTEGER = 0x0004;
70 const sal_uInt16 EXC_PCITEM_DATA_DATE = 0x0008;
73 const sal_uInt16 spnPCItemFlags[] =
90 EXC_SXFIELD_DATA_DATE_STR
97 mnTypeFlag( EXC_PCITEM_DATA_STRING )
99 if( !rText.isEmpty() )
109 mnTypeFlag = (fValue - floor( fValue ) == 0.0) ?
110 EXC_PCITEM_DATA_INTEGER : EXC_PCITEM_DATA_DOUBLE;
122 mnTypeFlag( EXC_PCITEM_DATA_INTEGER )
129 mnTypeFlag( EXC_PCITEM_DATA_STRING )
156 if(
const OUString* pText =
GetText() )
160 else if(
const double* pfValue =
GetDouble() )
164 else if(
const sal_Int16* pnValue =
GetInteger() )
170 sal_uInt16 nYear =
static_cast< sal_uInt16
>( pDateTime->GetYear() );
171 sal_uInt16 nMonth = pDateTime->GetMonth();
176 if( nYear < 1900 ) { nYear = 1900; nMonth = 1; nDay = 0; }
177 rStrm << nYear << nMonth << nDay << nHour << nMin << nSec;
179 else if(
const bool* pbValue =
GetBool() )
181 rStrm << static_cast< sal_uInt16 >( *pbValue ? 1 : 0 );
186 OSL_ENSURE(
IsEmpty(),
"XclExpPCItem::WriteBody - no data found" );
191 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
211 "XclExpPCField::XclExpPCField - numeric and date grouping enabled" );
226 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
235 "XclExpPCField::FillFromGroup - wrong base cache field" );
257 "XclExpPCField::SetGroupChildIndex - field already has a grouping child field" );
277 return static_cast< sal_uInt16 >(
nPos );
295 rStrm << static_cast< sal_uInt8 >( nIndex );
301 OSL_ENSURE(
IsSupportedField(),
"XclExpPCField::Save - unknown field type" );
321 "XclExpPCField::GetVisItemList - unexpected additional items in standard field" );
327 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InitStandardField - only for standard fields" );
328 OSL_ENSURE( rRange.
aStart.
Col() == rRange.
aEnd.
Col(),
"XclExpPCField::InitStandardField - cell range with multiple columns" );
343 OUString aText = rDoc.GetString(aPos.
Col(), aPos.
Row(), aPos.
Tab());
344 if( rDoc.HasValueData( aPos.
Col(), aPos.
Row(), aPos.
Tab() ) )
346 double fValue = rDoc.GetValue( aPos );
347 SvNumFormatType nFmtType = rFormatter.
GetType( rDoc.GetNumberFormat( rDoc.GetNonThreadedContext(), aPos ) );
348 if( nFmtType == SvNumFormatType::LOGICAL )
350 else if( nFmtType & SvNumFormatType::DATETIME )
364 OSL_ENSURE(
IsGroupField(),
"XclExpPCField::InitStdGroupField - only for standard grouping fields" );
376 for(
size_t nElemIdx = 0, nElemCount = rGroupItem.
GetElementCount(); nElemIdx < nElemCount; ++nElemIdx )
381 sal_uInt16 nBaseItemIdx = rBaseField.
GetItemIndex( *pElemName );
405 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InitNumGroupField - only for standard fields" );
406 OSL_ENSURE( rNumInfo.
mbEnable,
"XclExpPCField::InitNumGroupField - numeric grouping not enabled" );
430 OSL_ENSURE( rDateInfo.
mbEnable,
"XclExpPCField::InitDateGroupField - date grouping not enabled" );
445 OSL_ENSURE(
IsStandardField(),
"XclExpPCField::InsertItemArrayIndex - only for standard fields" );
446 maIndexVec.push_back( static_cast< sal_uInt16 >( nListPos ) );
462 OUString aShortText = rText.copy( 0, ::std::min(rText.getLength(),
EXC_PC_MAXSTRLEN ) );
511 OSL_ENSURE( rDPObj.
GetSheetDesc(),
"XclExpPCField::InsertNumDateGroupItems - cannot generate element list" );
522 const ScDPCache* pCache = pSrcDesc->CreateCache(pDimData);
532 const std::vector<SCROW>& aMemberIds = aTmpDim.
GetNumEntries(
533 static_cast<SCCOL>(nDim), pCache);
534 for (
SCROW nMemberId : aMemberIds)
593 "XclExpPCField::WriteSxnumgroup - missing numeric grouping limits" );
601 "XclExpPCField::WriteSxgroupinfo - missing grouping info" );
618 mnListIdx( nListIdx ),
644 SCCOL nDocCol1, nDocCol2;
645 SCROW nDocRow1, nDocRow2;
654 if( 2 * (nDocRow2 - nDocRow1) < (nSrcRow2 - nSrcRow1) )
658 if( nSrcRow1 < nDocRow1 )
659 nSrcRow1 = nDocRow1 - 1;
660 if( nSrcRow2 > nDocRow2 )
661 nSrcRow2 = nDocRow2 + 1;
711 OSL_ENSURE(
mbValid,
"XclExpPivotCache::Save - invalid pivot cache" );
745 for(
SCCOL nScCol = rRange.
aStart.
Col(), nEndScCol = rRange.
aEnd.
Col(); nScCol <= nEndScCol; ++nScCol )
783 pLastGroupField = xNewGroupField.get();
806 rStrm << aName << sal_uInt16(0);
850 std::size_t nRecSize = 0;
852 for( nPos = 0; nPos < nSize; ++nPos )
858 for( nPos = 0; nPos < nSize; ++nPos )
869 OUString lclGetDataFieldCaption( std::u16string_view rFieldName,
ScGeneralFunction eFunc )
873 const char* pResIdx =
nullptr;
890 aCaption =
ScResId(pResIdx) +
" - ";
891 aCaption += rFieldName;
899 mpCacheItem( rCacheField.
GetItem( nCacheIdx ) )
908 mpCacheItem( nullptr )
928 const std::optional<OUString> & pVisName = rSaveMem.
GetLayoutName();
940 mpCacheField( rPTable.GetCacheField( nCacheIdx ) )
960 OSL_ENSURE( !
maDataInfoVec.empty(),
"XclExpPTField::GetLastDataInfoIndex - no data info found" );
962 return static_cast< sal_uInt16
>(
maDataInfoVec.size() - 1 );
969 return static_cast< sal_uInt16 >(
nPos );
983 sal_Int32
n = rName.getLength();
984 bool bEscaped =
false;
985 for (sal_Int32
i = 0;
i < n; ++
i)
988 if (!bEscaped && c ==
'\\')
997 return aBuf.makeStringAndClear();
1004 OSL_ENSURE( eOrient != DataPilotFieldOrientation_DATA,
"XclExpPTField::SetPropertiesFromDim - called for data field" );
1011 const std::optional<OUString> & pLayoutName = rSaveDim.
GetLayoutName();
1015 const std::optional<OUString> & pSubtotalName = rSaveDim.
GetSubtotalName();
1030 if(
const DataPilotFieldSortInfo* pSortInfo = rSaveDim.
GetSortInfo() )
1033 if( pSortInfo->Mode == css::sheet::DataPilotFieldSortMode::DATA )
1039 if(
const DataPilotFieldAutoShowInfo* pShowInfo = rSaveDim.
GetAutoShowInfo() )
1048 if(
const DataPilotFieldLayoutInfo* pLayoutInfo = rSaveDim.
GetLayoutInfo() )
1055 if( eOrient == DataPilotFieldOrientation_PAGE )
1063 for (
const auto& pMember : rMembers)
1065 pItem->SetPropertiesFromMember( *pMember );
1082 const std::optional<OUString> & pVisName = rSaveDim.
GetLayoutName();
1095 rDataInfo.
mnRefField = pRefField->GetFieldIndex();
1096 if( pFieldRef->ReferenceItemType == css::sheet::DataPilotFieldReferenceItemType::NAMED )
1097 rDataInfo.
mnRefItem = pRefField->GetItemIndex( pFieldRef->ReferenceItemName, 0 );
1127 OSL_ENSURE( nDataInfoIdx <
maDataInfoVec.size(),
"XclExpPTField::WriteSxdi - data field not found" );
1179 mrPCache( rPCache ),
1183 mbFilterBtn( false )
1208 for( sal_uInt16 nFieldIdx = 0, nFieldCount =
mrPCache.
GetFieldCount(); nFieldIdx < nFieldCount; ++nFieldIdx )
1215 for (
auto const& iter : rDimList)
1217 if (iter->GetOrientation() == DataPilotFieldOrientation_DATA)
1222 for (
auto const& iter : rDimList)
1224 if (iter->GetOrientation() != DataPilotFieldOrientation_DATA)
1257 return static_cast< sal_uInt16 >( std::distance(
maDataFields.begin(), aIt) );
1305 return aFieldName.isEmpty() ?
nullptr :
GetFieldAcc(aFieldName);
1339 if( bDataLayout && !bMultiData )
1344 case DataPilotFieldOrientation_ROW:
1349 case DataPilotFieldOrientation_COLUMN:
1354 case DataPilotFieldOrientation_PAGE:
1356 OSL_ENSURE( !bDataLayout,
"XclExpPivotTable::SetFieldPropertiesFromDim - wrong orientation for data fields" );
1358 case DataPilotFieldOrientation_DATA:
1359 OSL_FAIL(
"XclExpPivotTable::SetFieldPropertiesFromDim - called for data field" );
1370 pField->SetDataPropertiesFromDim( rSaveDim );
1372 maDataFields.emplace_back( pField->GetFieldIndex(), pField->GetLastDataInfoIndex() );
1401 if( pFieldVec && !pFieldVec->empty() && (pFieldVec->back() !=
EXC_SXIVD_DATA) )
1403 ScfUInt16Vec::const_iterator aIt = ::std::find( pFieldVec->begin(), pFieldVec->end(),
EXC_SXIVD_DATA );
1404 if( aIt != pFieldVec->end() )
1405 maPTInfo.
mnDataPos = static_cast< sal_uInt16 >( std::distance(pFieldVec->begin(), aIt) );
1435 if (bExtraHeaderRow)
1439 rnXclCol2 = ::std::max( rnXclCol2, rnDataXclCol );
1440 rnXclRow2 = ::std::max( rnXclRow2, rnDataXclRow );
1446 if (bExtraHeaderRow)
1461 if( !rFields.empty() )
1464 for(
const auto& rField : rFields )
1480 xField->WriteSxpiEntry( rStrm );
1488 for(
const auto& [rFieldIdx, rDataInfoIdx] :
maDataFields )
1492 xField->WriteSxdi( rStrm, rDataInfoIdx );
1498 if( nLineCount <= 0 )
1508 for( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
1511 rStrm << sal_uInt16( 0 )
1531 sal_uInt16
const nRecordType = 0x0802;
1532 sal_uInt16
const nDummyFlags = 0x0000;
1533 sal_uInt16
const nTableType = 1;
1535 rStrm << nRecordType << nDummyFlags << nTableType;
1538 sal_uInt16
const nFlags = 0x0001;
1541 sal_uInt16 nFlags = 0x0000;
1542 bool bEnableRefresh =
true;
1543 bool bPCacheInvalid =
false;
1544 bool bOlapPTReport =
false;
1546 if (bEnableRefresh) nFlags |= 0x0001;
1547 if (bPCacheInvalid) nFlags |= 0x0002;
1548 if (bOlapPTReport) nFlags |= 0x0004;
1554 sal_uInt32
const nOptions = 0x00000000;
1557 bool bNoStencil =
false;
1558 bool bHideTotal =
false;
1559 bool bEmptyRows =
false;
1560 bool bEmptyCols =
false;
1561 if (bNoStencil) nOptions |= 0x00000001;
1562 if (bHideTotal) nOptions |= 0x00000002;
1563 if (bEmptyRows) nOptions |= 0x00000008;
1564 if (bEmptyCols) nOptions |= 0x00000010;
1576 rStrm << static_cast<sal_uInt16>(0x0001);
1614 void XclExpPivotRecWrapper::Save(
XclExpStream& rStrm )
1616 if( mnScTab == EXC_PTMGR_PIVOTCACHES )
1617 mrPTMgr.WritePivotCaches( rStrm );
1619 mrPTMgr.WritePivotTables( rStrm, mnScTab );
1632 for(
size_t nDPObj = 0,
nCount = pDPColl->GetCount(); nDPObj <
nCount; ++nDPObj )
1642 return new XclExpPivotRecWrapper( *
this, EXC_PTMGR_PIVOTCACHES );
1647 return new XclExpPivotRecWrapper( *
this, nScTab );
1660 if( xPTable->GetScTab() == nScTab )
1661 xPTable->Save( rStrm );
1692 if( xNewPCache->IsValid() )
1695 return xNewPCache.get();
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
sal_uInt16 mnRefItem
Index to SXVD of referred field used for the results.
const XclExpPCField * mpCacheField
Parent pivot table containing this field.
static OUString EncodeUrl(const XclExpRoot &rRoot, const OUString &rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
void AppendSubtotalItems()
Appends special items describing the field subtotal entries.
void SetApiLayoutMode(sal_Int32 nLayoutMode)
Sets the layout mode represented by the passed API constant.
void InsertItemArrayIndex(size_t nListPos)
Inserts the passed index into the item index array of original items.
This class stores an unformatted or formatted string for Excel export.
const ScDPDimensionSaveData * GetExistingDimensionData() const
bool IsStdGroupField() const
Returns true, if this field is a grouping field.
sal_uInt16 GetItemCount() const
Returns the number of visible items of this field.
void SetPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with row/column/page properties from the passed save dimension.
const OUString & GetGroupDimName() const
const sal_uInt16 EXC_ID_SXPI
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
const sal_uInt16 EXC_SXFIELD_16BIT
sal_uInt16 mnFlags
Type of the item (e.g. data, function, grand total).
std::vector< XclPTDataFieldInfo > maDataInfoVec
Page field info (entry in SXPI record).
const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK
ScRange maExpSrcRange
The original sheet source range.
XclExpPTField maDataOrientField
Data field indexes.
bool HasAddFields() const
Returns true, if this pivot cache contains non-standard fields (e.g.
const std::optional< OUString > & GetLayoutName() const
bool IsGroupField() const
Returns true, if this field is a grouping field of any type.
bool HasEqualDataSource(const ScDPObject &rDPObj) const
Returns true, if the passed DP object has the same data source as this cache.
void WriteSxdiList(XclExpStream &rStrm) const
Writes all SXDI records containing info about the data fields.
XclExpPCItem(const OUString &rText)
const sal_uInt16 EXC_SXFIELD_DATA_DBL
Only integers, opt. with doubles.
void SetApiAggFunc(ScGeneralFunction eAggFunc)
Sets the aggregation function represented by the passed API enum.
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
void SetGroupChildField(const XclExpPCField &rChildField)
Sets the passed field as direct grouping child field of this field.
const double * GetDouble() const
Returns pointer to value, if the item type is 'double', otherwise 0.
const sal_uInt16 EXC_SXFIELD_DATA_NONE
virtual void Save(XclExpStream &rStrm) override
Writes the pivot cache field and all items and other related records.
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 IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
const sal_uInt16 EXC_ID_SXIVD
void SetScDateType(sal_Int32 nScType)
XclPTExtInfo maPTExtInfo
Info about the pivot table (SXVIEW record).
std::optional< OUString > mpFieldTotalName
This class is used to export Excel record streams.
sal_uInt16 mnSrcType
Number of all fields (standard, grouped, calculated).
const sal_uInt32 EXC_SXVDEX_AUTOSHOW
bool HasGroupDimensions() const
void SetFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table field with all properties from the passed save dimension.
std::unique_ptr< ContentProperties > pData
bool mbUseCache
The visible name, if used.
const MemberList & GetMembers() const
css::sheet::DataPilotFieldOrientation GetOrientation() const
ScfUInt16Vec maIndexVec
List with grouping items.
const sal_uInt16 EXC_ID_SXVS
const ScDPSaveGroupDimension * GetGroupDimForBase(const OUString &rBaseDimName) const
void AppendRecord(RecType *pRec)
Appends a record to the list.
sal_uInt16 mnCacheIdx
Number of items of this field.
sal_uInt16 mnRefField
Result reference type.
const sal_uInt16 EXC_SXPI_ALLITEMS
Implementation of ScDPTableData with sheet data.
const sal_uInt16 EXC_SXVI_HIDDEN
const sal_uInt16 EXC_SXVI_TYPE_STDDEVP
void SetDateTime(const DateTime &rDateTime, const OUString &rText=OUString())
Sets the item to 'date/time' type and adds the passed date.
void WriteSxpi(XclExpStream &rStrm) const
Writes the SXPI record containing page field info.
void CreatePivotTables()
Creates all pivot tables and caches from the Calc DataPilot objects.
bool GetIsVisible() const
ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const
XclExpPivotTable(const XclExpRoot &rRoot, const ScDPObject &rDPObj, const XclExpPivotCache &rPCache)
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
const bool * GetBool() const
Returns pointer to Boolean value, if the item type is 'boolean', otherwise 0.
Classes to save Data Pilot settings that create new dimensions (fields).
const OUString & GetGroupName() const
std::size_t GetIndexSize() const
Returns the size an item index needs to write out.
void WriteSxex(XclExpStream &rStrm) const
Writes the SXEX records containing additional pivot table info.
sal_uInt16 mnColFields
Number of row fields.
const XclExpPivotTable & mrPTable
void SetApiRefItemType(sal_Int32 nRefItemType)
Sets the result reference item type represented by the passed API constant.
const OUString & GetSourceDimName() const
const sal_uInt16 EXC_SXFIELD_DATA_DATE
Only strings and doubles, nothing else.
sal_uInt16 mnCacheIdx
Several flags.
const XclExpPCItem * mpCacheItem
XclExpPCItemList maGroupItemList
List with original items.
XclExpRecordList< XclExpPivotCache > maPCacheList
sal_uInt16 mnGroupItems
Number of visible items for this field.
static void WriteSxivd(XclExpStream &rStrm, const ScfUInt16Vec &rFields)
Writes an SXIVD record for row field or column field order.
void SetPropertiesFromMember(const ScDPSaveMember &rSaveMem)
Fills this item with properties from the passed save member.
void SetText(const OUString &rText)
Sets the item to 'text' type and adds the passed text.
const sal_uInt16 EXC_SXVD_AXIS_COL
XclAddress maDataXclPos
Output range.
numerical values are counted.
ScfUInt16Vec maRowFields
All fields in pivot cache order.
Standard field without grouping.
const sal_uInt16 EXC_SXVDEX_SHOW_NONE
void SetSubtotals(const XclPTSubtotalVec &rSubtotals)
Sets the subtotal functions contained in the passed sequence.
const sal_uInt16 EXC_ID_SXINDEXLIST
List index for step item in groupings.
sum of all numerical values is calculated.
bool mbFilterBtn
true = The pivot table is valid for export.
bool IsDataLayout() const
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
sal_uInt16 mnGroupChild
Various flags.
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
This class represents the cached data part of the datapilot cache table implementation.
const XclExpPCItem * GetItem(sal_uInt16 nItemIdx) const
Returns the specified pivot cache item (returns visible items in groupings).
Represents a field in a pivot cache.
const sal_uInt16 EXC_ID_DCONNAME
void SetBool(bool bValue, const OUString &rText=OUString())
Sets the item to 'boolean' type and adds the passed Boolean value.
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. ...
void Init(const ScDPObject &rDPObj)
void SetApiSortMode(sal_Int32 nSortMode)
Sets the sorting mode represented by the passed API constant.
void WriteSxpiEntry(XclExpStream &rStrm) const
Writes an entry for an SXPI record containing own page field info.
sal_uInt16 mnFlags
Number of columns containing data.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
void WritePivotTables(XclExpStream &rStrm, SCTAB nScTab)
Writes all pivot tables of the specified Calc sheet.
OUString GetFieldName() const
Returns the name of this field.
sal_uInt16 mnVisItems
Base field if this field contains grouping info.
XclExpRecordRef CreatePivotCachesRecord()
Creates a record wrapper for exporting all pivot caches.
const sal_uInt16 EXC_SXVI_TYPE_DATA
product of all numerical values is calculated.
const OUString & GetFieldName() const
Returns the name of this cache field.
const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM
const sal_uInt16 EXC_ID_SXLI
const sal_uInt16 EXC_SXVD_SUBT_STDDEV
const sal_uInt16 EXC_SXVD_SUBT_DEFAULT
XclPTPageFieldInfo maPageInfo
Extended field info (SXVDEX record).
const sal_uInt16 EXC_SXVI_HIDEDETAIL
virtual const ScDPItemData * GetMemberById(sal_Int32 nDim, sal_Int32 nId)
static OUString lcl_convertCalcSubtotalName(const OUString &rName)
Calc's subtotal names are escaped with backslashes ('\'), while Excel's are not escaped at all...
sal_uInt16 mnFields
Position of data fields.
const sal_uInt16 EXC_ID_SXGROUPINFO
ScfUInt16Vec maGroupOrder
Own field index in pivot cache.
Access to global data from other classes.
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table field.
XclExpPTItem(const XclExpPCField &rCacheField, sal_uInt16 nCacheIdx)
const ScRange & GetOutRange() const
const sal_uInt16 EXC_SXVI_TYPE_VARP
const sal_uInt16 EXC_SXVS_SHEET
sal_uInt16 mnStdFields
Records in a source database block.
SCTAB mnOutScTab
Special data field orientation field.
const XclExpPCField * GetField(sal_uInt16 nFieldIdx) const
Returns the specified pivot cache field.
XclExpRecordList< XclExpPTItem > maItemList
List of extended data field info (SXDI records).
const sal_uInt16 EXC_SXVI_TYPE_DEFAULT
XclExpPCItemList maOrigItemList
sal_uInt16 InsertGroupItem(XclExpPCItem *pNewItem)
Inserts an item into the grouping item list.
sal_uInt16 mnDataRows
Number of data fields.
void AddApiOrient(css::sheet::DataPilotFieldOrientation eOrient)
Adds the axis orientation represented by the passed API enum.
sal_uInt16 mnDataFields
Number of page fields.
const sal_uInt16 EXC_PC_NOITEM
bool HasItemIndexList() const
Returns true, if the item index list will be written.
void SetNumGroupLimit(const ScDPNumGroupInfo &rNumInfo)
Inserts the SXDOUBLE items that specify the limits for a numeric grouping.
void WriteSxvdex(XclExpStream &rStrm) const
Writes the SXVDEX record containing additional settings.
const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX
sal_uInt16 mnCacheIdx
First heading row.
variance is calculated based on the entire population.
const XclExpPivotCache * CreatePivotCache(const ScDPObject &rDPObj)
Finds an existing (if enabled in mbShareCaches) or creates a new pivot cache.
Base class for all Excel records.
sal_uInt16 mnShowField
Index to data field sorting bases on.
void WriteSxdi(XclExpStream &rStrm, sal_uInt16 nDataInfoIdx) const
Writes an SXDI records containing info about a data field.
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
ScGeneralFunction GetFunction() const
sal_uInt16 mnGroupBase
Field containing grouping info for this field.
const sal_uInt32 EXC_SXEX_DRILLDOWN
bool HasShowEmpty() const
void SetInteger(sal_Int16 nValue)
Sets the item to 'integer' type and adds the passed value.
First date grouping field (opt. with child grouping field).
bool EqualsDateTime(const DateTime &rDateTime) const
XclPTCachedName maVisName
sal_uInt16 GetTypeFlag() const
::std::vector< ScGeneralFunction > XclPTSubtotalVec
const sal_uInt16 EXC_SXVD_SUBT_MIN
sal_Int32 GetDatePart() const
const DateTime * GetDateTime() const
Returns pointer to date, if the item type is 'date/time', otherwise 0.
size_t GetElementCount() const
void InsertOrigDoubleItem(double fValue, const OUString &rText)
Inserts an original value item, if it is not contained already.
std::vector< ScDPSaveMember * > MemberList
sal_uInt16 mnStrmId
Records in source database.
virtual void Save(XclExpStream &rStrm)
Overwrite this method to do any operation while saving the record.
::std::pair< sal_uInt16, sal_uInt16 > XclPTDataFieldPos
Data field position specifying the pivot table field index (first) and data info index (second)...
const OUString * GetText() const
Returns pointer to text, if the item type is 'text', otherwise 0.
void SetSliceSize(sal_uInt16 nSize)
Sets data slice length.
sal_uInt16 mnPagePerRow
Number of SXSELECT records.
maximum value of all numerical values is calculated.
const sal_uInt16 EXC_ID_SXSTRING
void InitDateGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rDateInfo, sal_Int32 nDatePart)
Initializes a date grouping field.
const sal_uInt16 EXC_ID_SXDATETIME
void SetDateGroupLimit(const ScDPNumGroupInfo &rDateInfo, bool bUseStep)
Inserts the SXDATETIME/SXINTEGER items that specify the limits for a date grouping.
XclExpPivotTableList maPTableList
List of all pivot caches.
void SetDataFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table data field with all properties from the passed save dimension.
const sal_uInt16 EXC_SXVD_SUBT_SUM
const size_t EXC_PC_MAXITEMCOUNT
void WriteSxindexlistList(XclExpStream &rStrm) const
Writes the SXINDEXLIST record list containing the item index table.
XclPTFieldExtInfo maFieldExtInfo
General field info (SXVD record).
sal_uInt16 GetItemIndex(std::u16string_view rName, sal_uInt16 nDefaultIdx) const
Returns the list index of an item by its name.
const sal_uInt16 EXC_SXFIELD_NUMGROUP
const sal_uInt16 EXC_SXVIEW_DATALAST
const sal_uInt16 EXC_SXFDBTYPE_DEFAULT
OUString GetItemName() const
Returns the internal name of this item.
bool GetDrillDown() const
tools::Long GetGroupCount() const
XclExpPCItemList maNumGroupLimits
Indexes into maItemList.
sal_uInt16 mnOrigItems
Number of items in the base field.
void AddFields(const ScDPObject &rDPObj)
Adds all pivot cache fields.
standard deviation is calculated based on the entire population.
const sal_uInt16 EXC_SXFIELD_HASCHILD
sal_uInt16 mnFlags
Stream identifier.
void SetApiAutoShowCount(sal_Int32 nShowCount)
Sets the number of items to be shown in AutoShow mode.
const sal_uInt16 EXC_SXVDEX_SORT_OWN
void WriteSxview(XclExpStream &rStrm) const
Writes the SXVIEW record starting the pivot table.
void AppendSubtotalItem(sal_uInt16 nItemType)
Appends a special item describing a field subtotal entry.
const sal_uInt16 EXC_SXFIELD_HASITEMS
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
ScRange maOrigSrcRange
Range name for source data.
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
tools::Long GetSubTotalsCount() const
const OUString * GetElementByIndex(size_t nIndex) const
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
Represents a group dimension that introduces a new hierarchy for an existing dimension.
const sal_uInt16 EXC_SXDB_SAVEDATA
const sal_uInt16 EXC_ID_SXVI
void AddStdFields(const ScDPObject &rDPObj)
Adds all standard pivot cache fields based on source data.
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDataLayoutDimension() const
average of all numerical values is calculated.
bool IsEmpty() const
Returns true, if the item type is 'empty'.
void Finalize()
Initializes flags and item count fields.
sal_uInt16 GetItemIndex(std::u16string_view rItemName) const
Returns the index of a pivot cache item, or EXC_PC_NOITEM on error.
bool mbValid
List index in pivot cache buffer.
ScfUInt16Vec maColFields
Row field indexes.
const double EXC_SXDBEX_CREATION_DATE
const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN
The main class for pivot table export.
const sal_uInt16 EXC_SXVIEW_COLGRAND
static SC_DLLPUBLIC OUString getSourceDimensionName(const OUString &rName)
const sal_uInt16 EXC_ID_SXDOUBLE
sal_uInt16 mnSubtotals
Number of subtotal functions.
const sal_uInt16 EXC_ID_SXINTEGER
sal_uInt16 mnDataCols
Number of rows containing data.
const OUString & GetName() const
const sal_uInt16 EXC_SXVD_SUBT_VAR
sal_uInt16 mnSelItem
Base field for this page info.
virtual ~XclExpPCField() override
XclExpRecordRef CreatePivotTablesRecord(SCTAB nScTab)
Creates a record wrapper for exporting all pivot tables of the specified sheet.
const sal_uInt16 EXC_ID_SXEMPTY
void IncRow(SCROW nDelta=1)
const XclExpPCItemList & GetVisItemList() const
Returns the item list that contains the visible items.
sal_uInt16 mnRowFields
Number of all fields.
sal_uInt16 mnPageFields
Number of column fields.
void WriteIndex(XclExpStream &rStrm, sal_uInt32 nSrcRow) const
Writes the item index at the passed source row position as part of the SXINDEXLIST record...
OUString ScResId(const char *pId)
void EndRecord()
Checks and corrects real record length.
sal_uInt16 mnSortField
Several flags and number of items for AutoShow.
const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR
Dates with integers or doubles without strings.
XclExpPCFieldList maFieldList
Pivot cache settings (SXDB record).
const sal_uInt16 EXC_ID_SXDB
const sal_uInt16 EXC_ID_SXDBEX
void InsertOrigTextItem(const OUString &rText)
Inserts an original text item, if it is not contained already.
void InsertOrigItem(XclExpPCItem *pNewItem)
Inserts an original source item.
void WriteSxnumgroup(XclExpStream &rStrm)
Writes an SXNUMGROUP record and the additional items for a numeric grouping field.
ScDPSaveData * GetSaveData() const
void SetEmpty()
Sets the item to 'empty' type.
XclExpPTField(const XclExpPivotTable &rPTable, sal_uInt16 nCacheIdx)
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
const sal_uInt16 EXC_SXVD_SUBT_AVERAGE
const ScDPNumGroupInfo & GetDateInfo() const
const sal_Int16 * GetInteger() const
Returns pointer to integer, if the item type is 'integer', otherwise 0.
sal_uInt16 mnDataPos
Orientation of data fields.
#define EXC_STORAGE_PTCACHE
const sal_uInt16 EXC_ID_SXIDSTM
Contains data for a pivot table data field (SXDI record).
sal_uInt16 GetCacheIndex() const
Returns the list index of the cache used in pivot table records.
const sal_uInt16 EXC_SXFIELD_DATA_INT
Only strings, nothing else.
const sal_uInt32 EXC_SXVDEX_SORT_ASC
const sal_uInt16 EXC_SXVI_TYPE_STDDEV
XclExpPivotCache(const XclExpRoot &rRoot, const ScDPObject &rDPObj, sal_uInt16 nListIdx)
OUString maSrcRangeName
Name of source data sheet.
sal_uInt16 GetFieldIndex() const
Returns the index of this field in the containing pivot cache.
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
bool EqualsDouble(double fValue) const
void WriteCacheStream()
Creates the pivot cache storage stream and writes the cache.
void SetPropertiesFromDP(const ScDPSaveData &rSaveData)
Fills internal members with all properties from the passed save data.
bool ValidateRange(ScRange &rScRange, bool bWarn)
Checks and eventually crops the cell range to valid dimensions.
XclRange maOutXclRange
The visible name of the data field.
const sal_uInt16 EXC_ID_DCONREF
bool IsStandardField() const
Returns true, if this is a standard field build directly from source data.
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
const std::optional< OUString > & GetSubtotalName() const
bool GetFilterButton() const
ScRange maDocSrcRange
The exported sheet source range.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the SXVI record body describing the pivot table item.
const sal_uInt16 EXC_SXVI_TYPE_SUM
XclExpValueRecord< sal_uInt16 > XclExpUInt16Record
A record containing an unsigned 16-bit value.
bool Has16BitIndexes() const
Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values.
sal_uInt16 mnTotalFields
Number of standard pivot cache fields.
void Save(XclExpStream &rStrm)
Writes related records into Workbook stream and creates the pivot cache storage stream.
bool GetColumnGrand() const
XclPCFieldInfo maFieldInfo
const sal_uInt16 EXC_ID_SXDI
void WriteSxdb(XclExpStream &rStrm) const
Writes the SXDB record.
const sal_uInt16 EXC_ID_SXVD
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
const XclExpPivotCache & mrPCache
const sal_uInt16 EXC_SXVI_TYPE_PROD
bool EqualsBool(bool bValue) const
sal_uInt16 mnPagePerCol
Number of page fields per row.
const sal_uInt16 EXC_SXFIELD_DATA_STR_INT
Only doubles, nothing else.
Represents a data item in a pivot cache containing data of any type.
const sal_uInt16 EXC_ID_SXVIEW
const sal_uInt16 EXC_SXVD_SUBT_STDDEVP
OUString maDataName
The name of the pivot table.
void WriteSxvd(XclExpStream &rStrm) const
Writes the SXVD record introducing the field.
SC_DLLPUBLIC bool HasIsVisible() const
XclExpPCField(const XclExpRoot &rRoot, sal_uInt16 nFieldIdx, const ScDPObject &rDPObj, const ScRange &rRange)
Creates a standard pivot cache field, filled from sheet source data.
bool GetShowDetails() const
static void WriteSxli(XclExpStream &rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount)
Writes a dummy SXLI records containing item layout info.
void InsertOrigBoolItem(bool bValue, const OUString &rText)
Inserts an original boolean item, if it is not contained already.
const DimsType & GetDimensions() const
XclPTViewEx9Info maPTViewEx9Info
Extended info about the pivot table (SXEX record).
const sal_uInt16 EXC_ID_SXBOOLEAN
XclExpPTItem * GetItemAcc(std::u16string_view rName)
Returns an item by its name.
ScfUInt16Vec maPageFields
Column field indexes.
XclExpPivotTableManager(const XclExpRoot &rRoot)
const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL
Only strings and integers, opt. with doubles.
void WriteSxViewEx9(XclExpStream &rStrm) const
Writes the SX_AUTOFORMAT records with the autoformat id and header layout.
void InitStdGroupField(const XclExpPCField &rBaseField, const ScDPSaveGroupDimension &rGroupDim)
Initializes a standard grouping field.
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
bool GetShowEmpty() const
void AddGroupFields(const ScDPObject &rDPObj)
Adds all grouping pivot cache fields.
const sal_uInt16 EXC_SXIVD_DATA
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues.
const OUString & GetName() const
const sal_uInt16 EXC_SXVD_SUBT_MAX
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
const sal_uInt16 EXC_SXVI_TYPE_COUNT
variance is calculated based on a sample.
all values, including non-numerical values, are counted.
const ScSheetSourceDesc * GetSheetDesc() const
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID...
const OUString & GetRangeName() const
const OUString & ConvertToText() const
Returns the text representation of the item.
sal_uInt16 mnFlags
Name of the pivot cache field.
void WriteDConName(XclExpStream &rStrm) const
DCONNAME record contains range name source.
XclExpPTFieldList maFieldList
The selected autoformat (SXVIEWEX9)
const std::vector< SCROW > & GetNumEntries(SCCOL nSourceDim, const ScDPCache *pCache) const
XclPTInfo maPTInfo
The pivot cache this pivot table bases on.
void Finalize()
Initializes any data after processing the entire source DataPilot.
void InsertNumDateGroupItems(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo, sal_Int32 nDatePart=0)
Generates and inserts all visible items for numeric or date grouping.
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
XclPTFieldInfo maFieldInfo
The referred pivot cache field.
const sal_uInt16 EXC_SXVI_TYPE_VAR
const sal_uInt16 EXC_ID_SXEX
const sal_uInt16 EXC_SXVI_DEFAULT_CACHE
XclPTItemInfo maItemInfo
The referred pivot cache item.
const sal_uInt16 EXC_ID_SXNUMGROUP
void InitStandardField(const ScRange &rRange)
Initializes a standard field.
OUString maTabName
List of all pivot cache fields.
const sal_uInt32 EXC_SXVDEX_SHOWALL
const sal_uInt16 EXC_SXVI_TYPE_MIN
void SetApiRefType(sal_Int32 nRefType)
Sets the result reference type represented by the passed API constant.
minimum value of all numerical values is calculated.
static void WriteSxdbex(XclExpStream &rStrm)
Writes the SXDBEX record.
standard deviation is calculated based on a sample.
void StartRecord(sal_uInt16 nRecId, std::size_t nRecSize)
Starts a new record: writes header data, stores calculated record size.
const sal_uInt16 EXC_ID_SXFDBTYPE
void SetVisName(const OUString &rName)
Sets the visible name and enables usage of cache if name is empty.
bool IsDateGroupField() const
Returns true, if this field is a date/time grouping field.
const XclExpPCField * GetCacheField(sal_uInt16 nCacheIdx) const
Returns a pivot cache field.
void WritePivotCaches(XclExpStream &rStrm)
Writes all pivot caches (all Workbook records and cache streams).
void SetDataPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with data field properties from the passed save dimension.
const sal_uInt16 EXC_SXVD_AXIS_NONE
void SetApiAutoShowMode(sal_Int32 nShowMode)
Sets the AutoShow mode represented by the passed API constant.
const sal_uInt16 EXC_ID_SXFIELD
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table.
std::vector< XclPTDataFieldPos > maDataFields
Page field indexes.
const sal_uInt16 EXC_SXVI_TYPE_MAX
XclPCNumGroupInfo maNumGroupInfo
Order of items in a grouping field (SXGROUPINFO record).
void InsertOrigDateTimeItem(const DateTime &rDateTime, const OUString &rText)
Inserts an original date/time item, if it is not contained already.
const sal_uInt16 EXC_SXVD_AXIS_ROW
const sal_uInt16 EXC_SXDB_SRC_SHEET
bool IsNumGroupField() const
Returns true, if this field is a numeric grouping field.
static void SaveXml(XclExpXmlStream &rStrm)
const sal_uInt16 EXC_SXVD_SUBT_VARP
sal_uInt16 GetFieldCount() const
Returns the number of pivot cache fields.
sal_uInt16 GetFieldIndex() const
Returns the pivot table field list index of this field.
SC_DLLPUBLIC const std::optional< OUString > & GetLayoutName() const
const sal_uInt16 EXC_ID_SXVDEX
const XclExpPTField * GetField(sal_uInt16 nFieldIdx) const
Returns a pivot table field by its name.
const sal_uInt16 EXC_SXVIEW_ROWGRAND
void WriteDconref(XclExpStream &rStrm) const
Writes the DCONREF record containing the source range.
void SetDouble(double fValue, const OUString &rText=OUString())
Sets the item to 'double' type and adds the passed value.
sal_uInt16 mnBaseItems
Number of special items in a grouping field.
void WriteSxgroupinfo(XclExpStream &rStrm)
Writes an SXGROUPINFO record describing the item order in grouping fields.
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.
const sal_uInt16 EXC_SXFIELD_DATA_STR
Special state for groupings.
XclPCFieldType meFieldType
Pivot cache field info (SXFIELD record).
bool IsSupportedField() const
Returns true, if the type of the field is supported by Calc.
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the SXFIELD record for this field.
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
bool mbValid
Sheet index of the output range.
const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM
Dates and empty strings, nothing else (?).
const sal_uInt16 EXC_SXVI_TYPE_AVERAGE
const sal_uInt16 EXC_SXVD_SUBT_PROD
sal_uInt16 GetLastDataInfoIndex() const
Returns the index of the last inserted data info struct.
const sal_uInt16 EXC_ID_SXVIEWEX9
This class contains authoritative information on the internal reference used as the data source for d...
sal_uInt32 mnFlags
Number of page fields per column.
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
const sal_uInt16 EXC_SXVI_TYPE_COUNTNUM
void WriteQsiSxTag(XclExpStream &rStrm) const
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
void InitNumGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo)
Initializes a numeric grouping field.
XclExpPTField * GetFieldAcc(std::u16string_view rName)
Returns a pivot table field by its name.
Base class for single records with any content.
sal_uInt16 mnTypeFlags
List with limit values for numeric grouping.
const sal_Int32 EXC_PC_MAXSTRLEN
sal_uInt16 mnItemCount
Bitfield for subtotal functions.
sal_uInt16 mnFirstHeadRow
First cell containing data.
const sal_uInt16 EXC_SXVD_SUBT_COUNT
const sal_uInt16 EXC_SXLI_DEFAULTFLAGS
void WriteZeroBytes(std::size_t nBytes)
Writes a sequence of nBytes zero bytes (respects slice setting).
bool EqualsText(std::u16string_view rText) 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.
sal_uInt8 mnGridLayout
AutoFormat ID.
const sal_uInt16 EXC_ID_EOF
Internal use only.
sal_uInt16 mnDataAxis
0-based index of the pivot cache.
SC_DLLPUBLIC bool HasShowDetails() const