23#include <com/sun/star/container/XIndexAccess.hpp>
24#include <com/sun/star/container/XNameAccess.hpp>
25#include <com/sun/star/sheet/CellFlags.hpp>
26#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
27#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
28#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
29#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
30#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
31#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
32#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
33#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
34#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
35#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
36#include <com/sun/star/sheet/GeneralFunction.hpp>
37#include <com/sun/star/sheet/XDataPilotDataLayoutFieldSupplier.hpp>
38#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
39#include <com/sun/star/sheet/XSheetOperation.hpp>
40#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
44#include <osl/diagnose.h>
51#include <oox/token/properties.hxx>
52#include <oox/token/tokens.hxx>
60#include <document.hxx>
73const sal_Int32 OOX_PT_DATALAYOUTFIELD = -2;
75const sal_Int32 OOX_PT_PREVIOUS_ITEM = 0x001000FC;
76const sal_Int32 OOX_PT_NEXT_ITEM = 0x001000FD;
78const sal_uInt32 BIFF12_PTFIELD_DATAFIELD = 0x00000008;
79const sal_uInt32 BIFF12_PTFIELD_DEFAULT = 0x00000100;
80const sal_uInt32 BIFF12_PTFIELD_SUM = 0x00000200;
81const sal_uInt32 BIFF12_PTFIELD_COUNTA = 0x00000400;
82const sal_uInt32 BIFF12_PTFIELD_AVERAGE = 0x00000800;
83const sal_uInt32 BIFF12_PTFIELD_MAX = 0x00001000;
84const sal_uInt32 BIFF12_PTFIELD_MIN = 0x00002000;
85const sal_uInt32 BIFF12_PTFIELD_PRODUCT = 0x00004000;
86const sal_uInt32 BIFF12_PTFIELD_COUNT = 0x00008000;
87const sal_uInt32 BIFF12_PTFIELD_STDDEV = 0x00010000;
88const sal_uInt32 BIFF12_PTFIELD_STDDEVP = 0x00020000;
89const sal_uInt32 BIFF12_PTFIELD_VAR = 0x00040000;
90const sal_uInt32 BIFF12_PTFIELD_VARP = 0x00080000;
92const sal_uInt32 BIFF12_PTFIELD_SHOWALL = 0x00000020;
93const sal_uInt32 BIFF12_PTFIELD_OUTLINE = 0x00000040;
94const sal_uInt32 BIFF12_PTFIELD_INSERTBLANKROW = 0x00000080;
95const sal_uInt32 BIFF12_PTFIELD_SUBTOTALTOP = 0x00000100;
96const sal_uInt32 BIFF12_PTFIELD_INSERTPAGEBREAK = 0x00000800;
97const sal_uInt32 BIFF12_PTFIELD_AUTOSORT = 0x00001000;
98const sal_uInt32 BIFF12_PTFIELD_SORTASCENDING = 0x00002000;
99const sal_uInt32 BIFF12_PTFIELD_AUTOSHOW = 0x00004000;
100const sal_uInt32 BIFF12_PTFIELD_AUTOSHOWTOP = 0x00008000;
101const sal_uInt32 BIFF12_PTFIELD_MULTIPAGEITEMS = 0x00080000;
103const sal_uInt16 BIFF12_PTFITEM_HIDDEN = 0x0001;
104const sal_uInt16 BIFF12_PTFITEM_HIDEDETAILS = 0x0002;
106const sal_uInt8 BIFF12_PTPAGEFIELD_HASNAME = 0x01;
107const sal_Int32 BIFF12_PTPAGEFIELD_MULTIITEMS = 0x001000FE;
109const sal_uInt16 BIFF12_PTFILTER_HASNAME = 0x0001;
110const sal_uInt16 BIFF12_PTFILTER_HASDESCRIPTION = 0x0002;
111const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE1 = 0x0004;
112const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE2 = 0x0008;
114const sal_uInt8 BIFF12_TOP10FILTER_TOP = 0x01;
115const sal_uInt8 BIFF12_TOP10FILTER_PERCENT = 0x02;
117const sal_uInt32 BIFF12_PTDEF_SHOWITEMS = 0x00000100;
118const sal_uInt32 BIFF12_PTDEF_DISABLEFIELDLIST = 0x00000400;
119const sal_uInt32 BIFF12_PTDEF_HIDECALCMEMBERS = 0x00001000;
120const sal_uInt32 BIFF12_PTDEF_WITHHIDDENTOTALS = 0x00002000;
121const sal_uInt32 BIFF12_PTDEF_HIDEDRILL = 0x00100000;
122const sal_uInt32 BIFF12_PTDEF_PRINTDRILL = 0x00200000;
123const sal_uInt32 BIFF12_PTDEF_HIDEHEADERS = 0x80000000;
125const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYROW = 0x00000004;
126const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYCOL = 0x00000008;
127const sal_uInt32 BIFF12_PTDEF_ENABLEDRILL = 0x00000020;
128const sal_uInt32 BIFF12_PTDEF_PRESERVEFORMATTING = 0x00000080;
129const sal_uInt32 BIFF12_PTDEF_USEAUTOFORMAT = 0x00000100;
130const sal_uInt32 BIFF12_PTDEF_SHOWERROR = 0x00000200;
131const sal_uInt32 BIFF12_PTDEF_SHOWMISSING = 0x00000400;
132const sal_uInt32 BIFF12_PTDEF_PAGEOVERTHENDOWN = 0x00000800;
133const sal_uInt32 BIFF12_PTDEF_SUBTOTALHIDDENITEMS = 0x00001000;
134const sal_uInt32 BIFF12_PTDEF_ROWGRANDTOTALS = 0x00002000;
135const sal_uInt32 BIFF12_PTDEF_COLGRANDTOTALS = 0x00004000;
136const sal_uInt32 BIFF12_PTDEF_FIELDPRINTTITLES = 0x00008000;
137const sal_uInt32 BIFF12_PTDEF_ITEMPRINTTITLES = 0x00020000;
138const sal_uInt32 BIFF12_PTDEF_MERGEITEM = 0x00040000;
139const sal_uInt32 BIFF12_PTDEF_HASDATACAPTION = 0x00080000;
140const sal_uInt32 BIFF12_PTDEF_HASGRANDTOTALCAPTION = 0x00100000;
141const sal_uInt32 BIFF12_PTDEF_HASPAGESTYLE = 0x00200000;
142const sal_uInt32 BIFF12_PTDEF_HASPIVOTTABLESTYLE = 0x00400000;
143const sal_uInt32 BIFF12_PTDEF_HASVACATEDSTYLE = 0x00800000;
144const sal_uInt32 BIFF12_PTDEF_APPLYNUMFMT = 0x01000000;
145const sal_uInt32 BIFF12_PTDEF_APPLYFONT = 0x02000000;
146const sal_uInt32 BIFF12_PTDEF_APPLYALIGNMENT = 0x04000000;
147const sal_uInt32 BIFF12_PTDEF_APPLYBORDER = 0x08000000;
148const sal_uInt32 BIFF12_PTDEF_APPLYFILL = 0x10000000;
149const sal_uInt32 BIFF12_PTDEF_APPLYPROTECTION = 0x20000000;
150const sal_uInt32 BIFF12_PTDEF_HASTAG = 0x40000000;
152const sal_uInt32 BIFF12_PTDEF_NOERRORCAPTION = 0x00000040;
153const sal_uInt32 BIFF12_PTDEF_NOMISSINGCAPTION = 0x00000080;
154const sal_uInt32 BIFF12_PTDEF_HASROWHEADERCAPTION = 0x00000400;
155const sal_uInt32 BIFF12_PTDEF_HASCOLHEADERCAPTION = 0x00000800;
156const sal_uInt32 BIFF12_PTDEF_FIELDLISTSORTASC = 0x00001000;
157const sal_uInt32 BIFF12_PTDEF_NOCUSTOMLISTSORT = 0x00004000;
167 mbShowDetails( true ),
174 static const sal_Int32 spnTypes[] = { XML_data, XML_default,
175 XML_sum, XML_countA, XML_avg, XML_max, XML_min, XML_product, XML_count,
176 XML_stdDev, XML_stdDevP, XML_var, XML_varP, XML_grand, XML_blank };
183 mnAutoShowItems( 10 ),
184 mnAutoShowRankBy( -1 ),
185 mnSortType( XML_manual ),
186 mnSortRefField( -1 ),
188 mbDataField( false ),
189 mbDefaultSubtotal( true ),
190 mbSumSubtotal( false ),
191 mbCountASubtotal( false ),
192 mbAverageSubtotal( false ),
193 mbMaxSubtotal( false ),
194 mbMinSubtotal( false ),
195 mbProductSubtotal( false ),
196 mbCountSubtotal( false ),
197 mbStdDevSubtotal( false ),
198 mbStdDevPSubtotal( false ),
199 mbVarSubtotal( false ),
200 mbVarPSubtotal( false ),
203 mbSubtotalTop( true ),
204 mbInsertBlankRow( false ),
205 mbInsertPageBreak( false ),
207 mbTopAutoShow( true ),
208 mbMultiPageItems( false )
228 mnItem( BIFF12_PTPAGEFIELD_MULTIITEMS )
234 mnSubtotal( XML_sum ),
235 mnShowDataAs( XML_normal ),
244 static const sal_Int32 spnSubtotals[] = { XML_sum, XML_count, XML_average, XML_max, XML_min, XML_product, XML_countNums, XML_stdDev, XML_stdDevp, XML_var, XML_varp };
250 static const sal_Int32 spnShowDataAs[] = { XML_normal, XML_difference, XML_percent, XML_percentDiff, XML_runTotal, XML_percentOfRow, XML_percentOfCol, XML_percentOfTotal, XML_index };
256 mrPivotTable( rPivotTable ),
257 mnFieldIndex( nFieldIndex )
320 sal_uInt32 nFlags1, nFlags2;
321 nFlags1 =
rStrm.readuInt32();
323 nFlags2 =
rStrm.readuInt32();
351 bool bAutoSort =
getFlag( nFlags2, BIFF12_PTFIELD_AUTOSORT );
352 bool bAscending =
getFlag( nFlags2, BIFF12_PTFIELD_SORTASCENDING );
353 maModel.
mnSortType = bAutoSort ? (bAscending ? XML_ascending : XML_descending) : XML_manual;
362 nFlags =
rStrm.readuInt16();
387 Reference< XDataPilotField > xDPField;
389 if( !((nDatabaseIdx >= 0) && rxDPDesc.is()) )
395 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
396 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
397 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
399 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeImport - no field name in source data found" );
405 if( pCacheField->hasNumericGrouping() )
407 pCacheField->convertNumericGrouping( xDPField );
409 else if( pCacheField->hasDateGrouping() )
412 pCacheField->createDateGroupField( xDPField );
416 else if( pCacheField->hasParentGrouping() )
420 ::std::vector< OUString > aItems;
421 pCacheField->getCacheItemNames( aItems );
423 for(
const auto& rItem : aItems )
424 aItemNames.emplace_back( rItem );
441 if( !pCacheField->isDatabaseField() && pCacheField->hasDateGrouping() && (pCacheField->getGroupBaseField() == nBaseFieldIdx) )
443 maDPFieldName = pCacheField->createDateGroupField( rxBaseDPField );
445 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeDateGroupingImport - cannot create date group field" );
463 for(
const auto& rItem :
maItems )
465 if ( rItem.mnType == XML_data && rItem.msCaption.getLength() )
466 captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
468 if ( !captionList.empty() )
483 Reference< XDataPilotField > xDPField;
485 if( (nDatabaseIdx >= 0) && rxDPDesc.is() )
try
488 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
489 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
490 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
492 SAL_WARN_IF(
maDPFieldName.isEmpty(),
"sc.filter",
"PivotTableField::finalizeImportBasedOnCache - no field name in source data found" );
501 if(!pCacheField->getFinalGroupName().isEmpty())
523 OSL_ENSURE( rPageField.
mnField ==
mnFieldIndex,
"PivotTableField::convertPageField - wrong field index" );
533 sal_Int32 nCacheItem = -1;
537 OSL_ENSURE( rPageField.
mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS,
"PivotTableField::convertPageField - unexpected cache item index" );
539 bool bHasMultiItems =
false;
540 for(
const auto& rItem :
maItems )
542 if( (rItem.mnType == XML_data) && !rItem.mbHidden )
544 bHasMultiItems = nCacheItem >= 0;
545 nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
564 if(
const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
570 aPropSet.
setProperty( PROP_SelectedPage, aSelectedPage );
577 OSL_ENSURE( rDataField.
mnField ==
mnFieldIndex,
"PivotTableField::convertDataField - wrong field index" );
578 OSL_ENSURE(
maModel.
mbDataField,
"PivotTableField::convertDataField - not a data field" );
586 aPropSet.
setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
588 if (!rDataField.
maName.isEmpty())
596 GeneralFunction eAggFunc = GeneralFunction_SUM;
599 case XML_sum: eAggFunc = GeneralFunction_SUM;
break;
600 case XML_count: eAggFunc = GeneralFunction_COUNT;
break;
601 case XML_average: eAggFunc = GeneralFunction_AVERAGE;
break;
602 case XML_max: eAggFunc = GeneralFunction_MAX;
break;
603 case XML_min: eAggFunc = GeneralFunction_MIN;
break;
604 case XML_product: eAggFunc = GeneralFunction_PRODUCT;
break;
605 case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;
break;
606 case XML_stdDev: eAggFunc = GeneralFunction_STDEV;
break;
607 case XML_stdDevp: eAggFunc = GeneralFunction_STDEVP;
break;
608 case XML_var: eAggFunc = GeneralFunction_VAR;
break;
609 case XML_varp: eAggFunc = GeneralFunction_VARP;
break;
610 default: OSL_FAIL(
"PivotTableField::convertDataField - unknown aggregation function" );
615 DataPilotFieldReference aReference;
619 case XML_difference: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;
break;
620 case XML_percent: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;
break;
621 case XML_percentDiff: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
break;
622 case XML_runTotal: aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;
break;
623 case XML_percentOfRow: aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;
break;
624 case XML_percentOfCol: aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
break;
625 case XML_percentOfTotal: aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
break;
626 case XML_index: aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;
break;
635 aReference.ReferenceField = pCacheField->
getName();
638 case OOX_PT_PREVIOUS_ITEM:
639 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
641 case OOX_PT_NEXT_ITEM:
642 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
645 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
647 aReference.ReferenceItemName = pCacheItem->getName();
649 aPropSet.
setProperty( PROP_Reference, aReference );
656 bool bDataLayout =
mnFieldIndex == OOX_PT_DATALAYOUTFIELD;
658 OSL_ENSURE( bDataLayout || (nAxis ==
maModel.
mnAxis),
"PivotTableField::convertRowColPageField - field axis mismatch" );
668 DataPilotFieldOrientation eFieldOrient = DataPilotFieldOrientation_HIDDEN;
671 case XML_axisRow: eFieldOrient = DataPilotFieldOrientation_ROW;
break;
672 case XML_axisCol: eFieldOrient = DataPilotFieldOrientation_COLUMN;
break;
673 case XML_axisPage: eFieldOrient = DataPilotFieldOrientation_PAGE;
break;
675 if( eFieldOrient != DataPilotFieldOrientation_HIDDEN )
676 aPropSet.
setProperty( PROP_Orientation, eFieldOrient );
686 ::std::vector< GeneralFunction > aSubtotals;
706 aSubtotals.push_back( GeneralFunction_AUTO );
712 (
maModel.
mbSubtotalTop ? DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP : DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM) :
713 DataPilotFieldLayoutMode::TABULAR_LAYOUT;
721 DataPilotFieldAutoShowInfo aAutoShowInfo;
722 aAutoShowInfo.IsEnabled =
true;
723 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopAutoShow ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
726 aAutoShowInfo.DataField = pCacheField->getName();
727 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
731 DataPilotFieldSortInfo aSortInfo;
735 aSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
743 aSortInfo.Mode = DataPilotFieldSortMode::DATA;
744 aSortInfo.Field = pCacheField->
getName();
748 aSortInfo.Mode = DataPilotFieldSortMode::NAME;
758 SAL_WARN_IF(!pDim,
"sc.filter",
"PivotTableField::convertRowColPageField - no Dimension found for: " << pCacheField->getName());
762 for(
const auto& rItem :
maItems )
764 if (rItem.mnType != XML_data)
767 const PivotCacheItem* pSharedItem = pCacheField->getCacheItem(rItem.mnCacheItem);
793 mnMemPropField( -1 ),
797 mnMeasureField( -1 ),
805 mrPivotTable( rPivotTable )
827 "PivotTableFilter::importTop10 - unexpected value of percent attribute" );
843 nFlags =
rStrm.readuInt16();
844 if(
getFlag( nFlags, BIFF12_PTFILTER_HASNAME ) )
846 if(
getFlag( nFlags, BIFF12_PTFILTER_HASDESCRIPTION ) )
848 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE1 ) )
850 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE2 ) )
853 static const sal_Int32 spnTypes[] =
857 XML_count, XML_percent, XML_sum,
859 XML_captionEqual, XML_captionNotEqual,
860 XML_captionBeginsWith, XML_captionNotBeginsWith, XML_captionEndsWith, XML_captionNotEndsWith,
861 XML_captionContains, XML_captionNotContains, XML_captionGreaterThan, XML_captionGreaterThanOrEqual,
862 XML_captionLessThan, XML_captionLessThanOrEqual, XML_captionBetween, XML_captionNotBetween,
864 XML_valueEqual, XML_valueNotEqual, XML_valueGreaterThan, XML_valueGreaterThanOrEqual,
865 XML_valueLessThan, XML_valueLessThanOrEqual, XML_valueBetween, XML_valueNotBetween,
867 XML_dateEqual, XML_dateOlderThan, XML_dateNewerThan, XML_dateBetween,
868 XML_tomorrow, XML_today, XML_yesterday, XML_nextWeek, XML_thisWeek, XML_lastWeek,
869 XML_nextMonth, XML_thisMonth, XML_lastMonth, XML_nextQuarter, XML_thisQuarter, XML_lastQuarter,
870 XML_nextYear, XML_thisYear, XML_lastYear, XML_yearToDate, XML_Q1, XML_Q2, XML_Q3, XML_Q4,
871 XML_M1, XML_M2, XML_M3, XML_M4, XML_M5, XML_M6, XML_M7, XML_M8, XML_M9, XML_M10, XML_M11, XML_M12,
872 XML_dateNotEqual, XML_dateOlderThanOrEqual, XML_dateNewerThanOrEqual, XML_dateNotBetween
880 nFlags =
rStrm.readuChar();
886 "PivotTableFilter::importTop10 - unexpected value of percent attribute");
899 DataPilotFieldAutoShowInfo aAutoShowInfo;
900 aAutoShowInfo.IsEnabled =
true;
901 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
904 aAutoShowInfo.DataField = pCacheField->getName();
905 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
915 mbDataOnRows( false ),
916 mbShowError( false ),
917 mbShowMissing( true ),
919 mbDisableFieldList( false ),
920 mbShowCalcMembers( true ),
921 mbVisualTotals( true ),
923 mbPrintDrill( false ),
924 mbEnableDrill( true ),
925 mbPreserveFormatting( true ),
926 mbUseAutoFormat( false ),
927 mbPageOverThenDown( false ),
928 mbSubtotalHiddenItems( false ),
929 mbRowGrandTotals( true ),
930 mbColGrandTotals( true ),
931 mbFieldPrintTitles( false ),
932 mbItemPrintTitles( false ),
933 mbMergeItem( false ),
934 mbShowEmptyRow( false ),
935 mbShowEmptyCol( false ),
936 mbShowHeaders( true ),
937 mbFieldListSortAsc( false ),
938 mbCustomListSort( true )
943 mnFirstHeaderRow( 0 ),
954 maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
955 mpPivotCache( nullptr )
1037 aModel.
mnItem = rAttribs.
getInteger( XML_item, BIFF12_PTPAGEFIELD_MULTIITEMS );
1059 css::uno::Sequence<css::xml::FastAttribute> aFast = xFastAttributeList->getFastAttributes();
1060 css::uno::Sequence<css::xml::Attribute> aUnk = xFastAttributeList->getUnknownAttributes();
1061 css::uno::Sequence<css::uno::Any> aVal{ css::uno::Any(aFast), css::uno::Any(aUnk) };
1068 sal_uInt32 nFlags1, nFlags2, nFlags3;
1070 nFlags1 =
rStrm.readuInt32();
1071 nFlags2 =
rStrm.readuInt32();
1072 nFlags3 =
rStrm.readuInt32();
1073 nDataAxis =
rStrm.readuChar();
1082 if(
getFlag( nFlags2, BIFF12_PTDEF_HASDATACAPTION ) )
1084 if(
getFlag( nFlags2, BIFF12_PTDEF_HASGRANDTOTALCAPTION ) )
1086 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOERRORCAPTION ) )
1088 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOMISSINGCAPTION ) )
1090 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPAGESTYLE ) )
1092 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPIVOTTABLESTYLE ) )
1094 if(
getFlag( nFlags2, BIFF12_PTDEF_HASVACATEDSTYLE ) )
1096 if(
getFlag( nFlags2, BIFF12_PTDEF_HASTAG ) )
1098 if(
getFlag( nFlags3, BIFF12_PTDEF_HASCOLHEADERCAPTION ) )
1100 if(
getFlag( nFlags3, BIFF12_PTDEF_HASROWHEADERCAPTION ) )
1104 (nDataAxis != BIFF12_PTDEF_ROWAXIS) && (nDataAxis != BIFF12_PTDEF_COLAXIS),
1106 "PivotTable::importPTDefinition - unexpected axis position for data field");
1170 nFlags =
rStrm.readuChar();
1171 if(
getFlag( nFlags, BIFF12_PTPAGEFIELD_HASNAME ) )
1179 sal_Int32 nSubtotal, nShowDataAs;
1182 nSubtotal =
rStrm.readInt32();
1183 nShowDataAs =
rStrm.readInt32();
1187 nHasName =
rStrm.readuChar();
1197 sal_Int32 nFieldIndex =
static_cast< sal_Int32
>(
maFields.size() );
1200 return *xTableField;
1207 return *xTableFilter;
1223 using namespace ::com::sun::star::sheet::CellFlags;
1234 Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
1235 mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
1237 CellRangeAddress aCellRangeAddress( aRange.
aStart.
Tab(),
1256 aDescProp.
setProperty( PROP_ShowFilterButton,
false );
1265 pField->convertRowField();
1270 pField->convertColField();
1275 pField->convertPageField( rPageField );
1278 ::std::set< sal_Int32 > aVisFields;
1282 aVisFields.insert( rPageField.mnField );
1286 if( aVisFields.count(
nIndex ) == 0 )
1287 rxField->convertHiddenField();
1296 if ( pCacheField-> getGroupBaseField() != -1 )
1297 rDataField.mnField = pCacheField-> getGroupBaseField();
1300 pField->convertDataField( rDataField );
1311 aPos.Row = ::std::max< sal_Int32 >(
static_cast< sal_Int32
>( aPos.Row -
maPageFields.size() - 1 ), 0 );
1321 TOOLS_WARN_EXCEPTION(
"sc",
"PivotTable::finalizeImport - exception while creating the DataPilot table" );
1337 assert(pDPCollection !=
nullptr);
1366 pParentTableField->finalizeParentGroupingImport( rxBaseDPField, rBaseCacheField, orItemNames );
1371 Reference< XDataPilotField > xDPField;
1374 Reference< XNameAccess > xDPFieldsNA(
mxDPDescriptor->getDataPilotFields(), UNO_QUERY_THROW );
1375 xDPField.set( xDPFieldsNA->getByName( rFieldName ), UNO_QUERY );
1385 Reference< XDataPilotField > xDPField;
1393 Reference< XDataPilotField > xDPField;
1396 Reference< XDataPilotDataLayoutFieldSupplier > xDPDataFieldSupp(
mxDPDescriptor, UNO_QUERY_THROW );
1397 xDPField = xDPDataFieldSupp->getDataLayoutField();
1435 orFields.push_back( rAttribs.
getInteger( XML_x, -1 ) );
1440 OSL_ENSURE( orFields.empty(),
"PivotTable::importFields - multiple record instances" );
1443 OSL_ENSURE( 4 *
nCount ==
rStrm.getRemaining(),
"PivotTable::importFields - invalid field count" );
1444 nCount =
static_cast< sal_Int32
>(
rStrm.getRemaining() / 4 );
1445 for( sal_Int32 nIdx = 0; nIdx <
nCount; ++nIdx )
1446 orFields.push_back(
rStrm.readInt32() );
SC_DLLPUBLIC bool GetReferenceGroups(const ScDPObject &rDPObj, const ScDPDimensionSaveData **pGroups) const
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
bool HasGroupDimensions() const
void ReloadGroupTableData()
ScDPSaveData * GetSaveData() const
void PutInteropGrabBag(std::map< OUString, css::uno::Any > &&val)
SC_DLLPUBLIC void SetDimensionData(const ScDPDimensionSaveData *pNew)
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
ScDPSaveMember * GetMemberByName(const OUString &rName)
Get a member object by its name.
SC_DLLPUBLIC void SetIsVisible(bool bSet)
SC_DLLPUBLIC void SetShowDetails(bool bSet)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC bool HasPivotTable() const
void RegroupFormulaCells(SCTAB nTab, SCCOL nCol)
SCTAB GetMaxTableNumber() const
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
std::optional< sal_uInt32 > getUnsigned(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
std::optional< bool > getBool(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
std::optional< double > getDouble(sal_Int32 nAttrToken) const
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
bool setProperty(sal_Int32 nPropId, const Type &rValue)
value_type get(sal_Int32 nIndex) const
void forEachMem(FuncType pFunc) const
container_type::value_type value_type
static bool convertToCellRangeUnchecked(ScRange &orRange, std::u16string_view aString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet limits.
PivotCache * importPivotCacheFragment(sal_Int32 nCacheId)
Imports and stores a pivot cache definition fragment on first call, returns the imported cache on sub...
OUString createParentGroupField(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames) const
Creates a new grouped DataPilot field and returns its name.
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the shared or group item with the specified index.
const OUString & getName() const
Returns the name of the cache field.
sal_Int32 getParentGroupField() const
Returns the index of the parent group field that groups the items of this field.
void applyItemCaptions(const IdCaptionPairList &vCaptions)
Apply user Captions to imported group data.
void setFinalGroupName(const OUString &rFinalGroupName)
Set the finalized group name of this field.
OUString getFormattedName(const ScDPSaveDimension &rSaveDim, ScDPObject *pObj, const DateTime &rNullDate) const
Returns the string representation of the item, using the actual formatting.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
const ScRange & getSourceRange() const
Returns the internal cell range the cache is based on.
bool isValidDataSource() const
Returns true, if the pivot cache is based on a valid data source, so that pivot tables can be created...
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the field with the passed index.
PivotTableBuffer(const WorkbookHelper &rHelper)
PivotTable & createPivotTable()
Creates and returns a new pivot table.
PivotTableVector maTables
void finalizeImport()
Inserts all pivot tables into the sheet.
void importPTReference(SequenceInputStream &rStrm)
Imports pivot field reference settings from the PTREFERENCE record.
sal_Int32 mnFieldIndex
Name of the field in DataPilot field collection.
void convertHiddenField()
Converts dimension and other settings for a hidden field.
void convertRowField()
Converts dimension and other settings for a row field.
void convertColField()
Converts dimension and other settings for a column field.
PivotTable & mrPivotTable
void finalizeImport(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
Finalizes the field after import, creates grouping and other settings.
void importPivotField(const AttributeList &rAttribs)
Imports pivot field settings from the pivotField element.
void convertPageField(const PTPageFieldModel &rPageField)
Converts dimension and other settings for a page field.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Finalizes the grouped date field after import.
void importReference(const AttributeList &rAttribs)
Imports pivot field reference settings from the reference element.
void importReferenceItem(const AttributeList &rAttribs)
Imports pivot field item reference settings from the x element.
void importPTFItem(SequenceInputStream &rStrm)
Imports settings of an item in this pivot field from the PTFITEM record.
void finalizeImportBasedOnCache(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Finalizes the grouped field after import.
OUString maDPFieldName
Pivot field settings.
void importItem(const AttributeList &rAttribs)
Imports settings of an item in this pivot field from the item element.
PivotTableField(PivotTable &rPivotTable, sal_Int32 nFieldIndex)
css::uno::Reference< css::sheet::XDataPilotField > convertRowColPageField(sal_Int32 nAxis)
Converts dimension and other settings for row, column, page, or hidden fields.
ItemModelVector maItems
The parent pivot table object.
void importPTReferenceItem(SequenceInputStream &rStrm)
Imports pivot field item reference settings from the PTREFERENCEITEM record.
void convertDataField(const PTDataFieldModel &rDataField)
Converts dimension and other settings for a data field.
void importPTField(SequenceInputStream &rStrm)
Imports pivot field settings from the PTFIELD record.
PTFieldModel maModel
All items of this field.
PivotTableFilter(const PivotTable &rPivotTable)
void importFilter(const AttributeList &rAttribs)
Reads the settings of a field filter from the filter element.
void finalizeImport()
Applies the filter to the associated pivot table field if possible.
void importTop10Filter(SequenceInputStream &rStrm)
Reads additional settings of a field filter from the TOP10FILTER record.
void importPTFilter(SequenceInputStream &rStrm)
Reads the settings of a field filter from the PTFILTER record.
const PivotTable & mrPivotTable
void importTop10(const AttributeList &rAttribs)
Reads additional settings of a field filter from the top10 element.
void importPTDataField(SequenceInputStream &rStrm)
Reads the settings of a field located in the data dimension from the PTDATAFIELD record.
void finalizeImport()
Inserts the pivot table into the sheet.
void importDataField(const AttributeList &rAttribs)
Reads the settings of a field located in the data dimension from the dataField element.
PTLocationModel maLocationModel
Global pivot table settings.
css::uno::Reference< css::sheet::XDataPilotField > getDataLayoutField() const
Returns the data layout field used to store all data fields in row/col dimension.
IndexVector maColFields
Indexes to fields in row dimension.
css::uno::Reference< css::sheet::XDataPilotField > getDataPilotField(const OUString &rFieldName) const
Returns the associated data pilot field for the specified pivot table field.
PivotTableField & createTableField()
Creates and returns a new pivot table field.
void importPivotTableDefinition(const AttributeList &rAttribs)
Reads global pivot table settings from the pivotTableDefinition element.
void importLocation(const AttributeList &rAttribs, sal_Int16 nSheet)
Reads the location of the pivot table from the location element.
::std::vector< sal_Int32 > IndexVector
static void importField(IndexVector &orFields, const AttributeList &rAttribs)
Reads a field index for the row or column dimension.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the pivot field with the passed index, or -1.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Creates all date group fields for the specified cache field after import.
PivotTableFilterVector maFilters
Settings for all fields in data area.
PivotTableFieldVector maFields
static void importFields(IndexVector &orFields, SequenceInputStream &rStrm)
Reads an array of field indexes for the row or column dimension.
DataFieldVector maDataFields
Settings for all fields in page dimension.
ScDPObject * getDPObject()
PivotTable(const WorkbookHelper &rHelper)
void putToInteropGrabBag(const OUString &sName, const AttributeList &rAttribs)
Puts the attributes to the named grab bag value.
void importPTLocation(SequenceInputStream &rStrm, sal_Int16 nSheet)
Reads the location of the pivot table from the PTLOCATION record.
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Creates all grouped fields for the specified cache field after import.
void importColField(const AttributeList &rAttribs)
Reads the index of a field located in the column dimension.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
PTDefinitionModel maDefModel
All field filters.
const PivotCacheField * getCacheFieldOfDataField(sal_Int32 nDataItemIdx) const
Returns the base cache field of the data field item with the specified index.
void importPTPageField(SequenceInputStream &rStrm)
Reads the settings of a field located in the page dimension from the PTPAGEFIELD record.
css::uno::Reference< css::sheet::XDataPilotDescriptor > mxDPDescriptor
The pivot cache this table is based on.
PivotCache * mpPivotCache
Location settings of the pivot table.
void importRowField(const AttributeList &rAttribs)
Reads the index of a field located in the row dimension.
PivotTableFilter & createTableFilter()
Creates and returns a new pivot table filter.
void importPTRowFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the row dimension from a PTROWFIELDS record.
void importPageField(const AttributeList &rAttribs)
Reads the settings of a field located in the page dimension from the pageField element.
IndexVector maRowFields
Data layout field.
std::map< OUString, css::uno::Any > maInteropGrabBag
Descriptor of the DataPilot object.
void importPTColFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the column dimension from a PTCOLFIELDS record.
PivotTableField * getTableField(sal_Int32 nFieldIdx)
Returns a pivot table field by its index.
void importPTDefinition(SequenceInputStream &rStrm)
Reads global pivot table settings from the PTDEFINITION record.
void finalizeFieldsImport()
Finalizes all fields, finds field names and creates grouping fields.
PageFieldVector maPageFields
Indexes to fields in column dimension.
PivotTableField maDataField
All pivot table fields.
Helper class to provide access to global workbook data.
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
ScDocumentImport & getDocImport()
#define TOOLS_WARN_EXCEPTION(area, stream)
@ EDITATTR
Drawing objects.
#define STATIC_ARRAY_SELECT(array, index, def)
#define SAL_WARN_IF(condition, area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::std::vector< IdCaptionPair > IdCaptionPairList
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
bool getFlag(Type nBitField, Type nMask)
const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE]
A 2D cell range address struct for binary filters.
sal_Int32 mnShowDataAs
Subtotal aggregation function.
sal_Int32 mnBaseField
Show data as, based on another field.
sal_Int32 mnSubtotal
Base pivot field.
void setBiffSubtotal(sal_Int32 nSubtotal)
Sets the subtotal aggregation function for BIFF import.
sal_Int32 mnBaseItem
Base field for 'show data as'.
void setBiffShowDataAs(sal_Int32 nShowDataAs)
Sets the 'show data as' type for BIFF import.
sal_Int32 mnField
Name of the data field.
sal_Int32 mnNumFmtId
Base item for 'show data as'.
PTDataFieldModel()
Number format for the result.
OUString maGrandTotalCaption
OUString maRowHeaderCaption
bool mbPreserveFormatting
bool mbSubtotalHiddenItems
OUString maColHeaderCaption
OUString maPivotTableStyle
OUString maMissingCaption
bool mbShowDetails
User caption of the item.
sal_Int32 mnType
Index to shared item in pivot cache.
PTFieldItemModel()
True = item is hidden.
OUString msCaption
Type of the item.
void setBiffType(sal_uInt16 nType)
Sets item type for BIFF import.
bool mbHidden
True = show item details (items of child fields).
bool mbVarSubtotal
True = show standard deviation of population subtotals.
bool mbCountASubtotal
True = show sum subtotals.
bool mbAutoShow
True = insert page breaks after items.
bool mbStdDevSubtotal
True = show count numbers subtotals.
bool mbVarPSubtotal
True = show variance subtotals.
bool mbProductSubtotal
True = show minimum subtotals.
bool mbTopAutoShow
True = auto show (top 10) filter enabled.
bool mbSumSubtotal
True = show default subtotals.
sal_Int32 mnSortRefField
Autosorting type.
void setBiffAxis(sal_uInt8 nAxisFlags)
Sets axis type for BIFF import.
sal_Int32 mnSortType
Index of the data field auto show filter is based on.
bool mbDataField
Item in reference field for autosorting.
sal_Int32 mnAutoShowRankBy
Number of items (or percent/sum) to be shown in auto show filter.
bool mbInsertPageBreak
True = insert blank rows after items.
bool mbStdDevPSubtotal
True = show standard deviation subtotals.
sal_Int32 mnNumFmtId
Axis this field is assigned to (none, row, column, page).
sal_Int32 mnSortRefItem
Reference field for autosorting.
bool mbSubtotalTop
True = show in outline view, false = show in tabular view.
bool mbCountSubtotal
True = show product subtotals.
bool mbMultiPageItems
True = auto show filter shows top entries, false = bottom.
bool mbDefaultSubtotal
True = field appears in data area.
bool mbOutline
True = show items without data.
sal_Int32 mnAutoShowItems
Number format for field items.
PTFieldModel()
True = multiple items selectable in page dimension.
bool mbInsertBlankRow
True = show subtotals on top of items in outline or compact mode.
bool mbAverageSubtotal
True = show count all subtotals.
bool mbShowAll
True = show variance of population subtotals.
bool mbMinSubtotal
True = show maximum subtotals.
bool mbMaxSubtotal
True = show average subtotals.
double mfValue
Second string value for label filter.
sal_Int32 mnMeasureHier
Data field for filter calculation.
sal_Int32 mnMemPropField
Base pivot field.
bool mbTopFilter
Hierarchy for filter calculation.
sal_Int32 mnEvalOrder
Filter type.
sal_Int32 mnId
Evaluation order index.
sal_Int32 mnType
Member property field.
PTFilterModel()
True = filter shows top entries, false = bottom.
OUString maStrValue2
First string value for label filter.
OUString maStrValue1
Description of the field filter.
sal_Int32 mnField
Number of items or percent or sum to be shown.
sal_Int32 mnMeasureField
Unique identifier.
OUString maDescription
Name of the field filter.
sal_Int32 mnRowPageCount
First column of data cells (relative in pivot table).
sal_Int32 mnFirstDataCol
First row of data cells (relative in pivot table).
sal_Int32 mnFirstHeaderRow
Target cell range for the pivot table.
sal_Int32 mnFirstDataRow
First row of header cells (relative in pivot table).
sal_Int32 mnColPageCount
Number of rows in page filter area.
PTLocationModel()
Number of columns in page filter area.
sal_Int32 mnItem
Base pivot field.
PTPageFieldModel()
Index of field item that is shown by the page field.
sal_Int32 mnField
Unique name of the page field.