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>
51 using namespace ::
oox;
53 using ::com::sun::star::sheet::DataPilotFieldOrientation;
54 using ::com::sun::star::sheet::DataPilotFieldOrientation_ROW;
55 using ::com::sun::star::sheet::DataPilotFieldOrientation_COLUMN;
56 using ::com::sun::star::sheet::DataPilotFieldOrientation_PAGE;
57 using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
58 using ::com::sun::star::sheet::DataPilotFieldSortInfo;
59 using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
60 using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
61 using ::com::sun::star::sheet::DataPilotFieldReference;
68 const sal_uInt16 EXC_PCITEM_DATA_STRING = 0x0001;
69 const sal_uInt16 EXC_PCITEM_DATA_DOUBLE = 0x0002;
70 const sal_uInt16 EXC_PCITEM_DATA_INTEGER = 0x0004;
71 const sal_uInt16 EXC_PCITEM_DATA_DATE = 0x0008;
74 const sal_uInt16 spnPCItemFlags[] =
91 EXC_SXFIELD_DATA_DATE_STR
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" );
344 OUString aText = rDoc.GetString(aPos.
Col(), aPos.
Row(), aPos.
Tab());
345 if( rDoc.HasValueData( aPos.
Col(), aPos.
Row(), aPos.
Tab() ) )
347 double fValue = rDoc.GetValue( aPos );
348 SvNumFormatType nFmtType = rFormatter.
GetType( rDoc.GetNumberFormat( rDoc.GetNonThreadedContext(), 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 = rText.copy( 0, ::std::min(rText.getLength(),
EXC_PC_MAXSTRLEN ) );
512 OSL_ENSURE( rDPObj.
GetSheetDesc(),
"XclExpPCField::InsertNumDateGroupItems - cannot generate element list" );
523 const ScDPCache* pCache = pSrcDesc->CreateCache(pDimData);
533 const std::vector<SCROW>& aMemberIds = aTmpDim.
GetNumEntries(
534 static_cast<SCCOL>(nDim), pCache);
535 for (
SCROW nMemberId : aMemberIds)
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();
807 rStrm << aName << sal_uInt16(0);
851 std::size_t nRecSize = 0;
853 for( nPos = 0; nPos < nSize; ++nPos )
859 for( nPos = 0; nPos < nSize; ++nPos )
870 OUString 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)
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 )
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 )
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);
1615 void XclExpPivotRecWrapper::Save(
XclExpStream& rStrm )
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();
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.
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.
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.
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
OUString ScResId(TranslateId aId)
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.
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.
std::unique_ptr< sal_Int32[]> pData
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.
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
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
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...
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.
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.
constexpr OUStringLiteral EXC_STORAGE_PTCACHE
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 m_bDetectedRangeSegmentation false
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