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 ),
205 mbInsertBlankRow( false ),
206 mbInsertPageBreak( false ),
208 mbTopAutoShow( true ),
209 mbMultiPageItems( false )
229 mnItem( BIFF12_PTPAGEFIELD_MULTIITEMS )
235 mnSubtotal( XML_sum ),
236 mnShowDataAs( XML_normal ),
245 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 };
251 static const sal_Int32 spnShowDataAs[] = { XML_normal, XML_difference, XML_percent, XML_percentDiff, XML_runTotal, XML_percentOfRow, XML_percentOfCol, XML_percentOfTotal, XML_index };
257 mrPivotTable( rPivotTable ),
258 mnFieldIndex( nFieldIndex )
322 sal_uInt32 nFlags1, nFlags2;
323 nFlags1 =
rStrm.readuInt32();
325 nFlags2 =
rStrm.readuInt32();
353 bool bAutoSort =
getFlag( nFlags2, BIFF12_PTFIELD_AUTOSORT );
354 bool bAscending =
getFlag( nFlags2, BIFF12_PTFIELD_SORTASCENDING );
355 maModel.
mnSortType = bAutoSort ? (bAscending ? XML_ascending : XML_descending) : XML_manual;
364 nFlags =
rStrm.readuInt16();
389 Reference< XDataPilotField > xDPField;
391 if( !((nDatabaseIdx >= 0) && rxDPDesc.is()) )
397 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
398 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
399 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
401 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeImport - no field name in source data found" );
407 if( pCacheField->hasNumericGrouping() )
409 pCacheField->convertNumericGrouping( xDPField );
411 else if( pCacheField->hasDateGrouping() )
414 pCacheField->createDateGroupField( xDPField );
418 else if( pCacheField->hasParentGrouping() )
422 ::std::vector< OUString > aItems;
423 pCacheField->getCacheItemNames( aItems );
425 for(
const auto& rItem : aItems )
426 aItemNames.emplace_back( rItem );
443 if( !pCacheField->isDatabaseField() && pCacheField->hasDateGrouping() && (pCacheField->getGroupBaseField() == nBaseFieldIdx) )
445 maDPFieldName = pCacheField->createDateGroupField( rxBaseDPField );
447 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeDateGroupingImport - cannot create date group field" );
465 for(
const auto& rItem :
maItems )
467 if ( rItem.mnType == XML_data && rItem.msCaption.getLength() )
468 captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
470 if ( !captionList.empty() )
485 Reference< XDataPilotField > xDPField;
487 if( (nDatabaseIdx >= 0) && rxDPDesc.is() )
try
490 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
491 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
492 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
494 SAL_WARN_IF(
maDPFieldName.isEmpty(),
"sc.filter",
"PivotTableField::finalizeImportBasedOnCache - no field name in source data found" );
503 if(!pCacheField->getFinalGroupName().isEmpty())
525 OSL_ENSURE( rPageField.
mnField ==
mnFieldIndex,
"PivotTableField::convertPageField - wrong field index" );
535 sal_Int32 nCacheItem = -1;
539 OSL_ENSURE( rPageField.
mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS,
"PivotTableField::convertPageField - unexpected cache item index" );
541 bool bHasMultiItems =
false;
542 for(
const auto& rItem :
maItems )
544 if( (rItem.mnType == XML_data) && !rItem.mbHidden )
546 bHasMultiItems = nCacheItem >= 0;
547 nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
566 if(
const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
572 aPropSet.
setProperty( PROP_SelectedPage, aSelectedPage );
579 OSL_ENSURE( rDataField.
mnField ==
mnFieldIndex,
"PivotTableField::convertDataField - wrong field index" );
580 OSL_ENSURE(
maModel.
mbDataField,
"PivotTableField::convertDataField - not a data field" );
588 aPropSet.
setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
590 if (!rDataField.
maName.isEmpty())
598 GeneralFunction eAggFunc = GeneralFunction_SUM;
601 case XML_sum: eAggFunc = GeneralFunction_SUM;
break;
602 case XML_count: eAggFunc = GeneralFunction_COUNT;
break;
603 case XML_average: eAggFunc = GeneralFunction_AVERAGE;
break;
604 case XML_max: eAggFunc = GeneralFunction_MAX;
break;
605 case XML_min: eAggFunc = GeneralFunction_MIN;
break;
606 case XML_product: eAggFunc = GeneralFunction_PRODUCT;
break;
607 case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;
break;
608 case XML_stdDev: eAggFunc = GeneralFunction_STDEV;
break;
609 case XML_stdDevp: eAggFunc = GeneralFunction_STDEVP;
break;
610 case XML_var: eAggFunc = GeneralFunction_VAR;
break;
611 case XML_varp: eAggFunc = GeneralFunction_VARP;
break;
612 default: OSL_FAIL(
"PivotTableField::convertDataField - unknown aggregation function" );
617 DataPilotFieldReference aReference;
621 case XML_difference: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;
break;
622 case XML_percent: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;
break;
623 case XML_percentDiff: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
break;
624 case XML_runTotal: aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;
break;
625 case XML_percentOfRow: aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;
break;
626 case XML_percentOfCol: aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
break;
627 case XML_percentOfTotal: aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
break;
628 case XML_index: aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;
break;
637 aReference.ReferenceField = pCacheField->
getName();
640 case OOX_PT_PREVIOUS_ITEM:
641 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
643 case OOX_PT_NEXT_ITEM:
644 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
647 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
649 aReference.ReferenceItemName = pCacheItem->getName();
651 aPropSet.
setProperty( PROP_Reference, aReference );
658 bool bDataLayout =
mnFieldIndex == OOX_PT_DATALAYOUTFIELD;
660 OSL_ENSURE( bDataLayout || (nAxis ==
maModel.
mnAxis),
"PivotTableField::convertRowColPageField - field axis mismatch" );
670 DataPilotFieldOrientation eFieldOrient = DataPilotFieldOrientation_HIDDEN;
673 case XML_axisRow: eFieldOrient = DataPilotFieldOrientation_ROW;
break;
674 case XML_axisCol: eFieldOrient = DataPilotFieldOrientation_COLUMN;
break;
675 case XML_axisPage: eFieldOrient = DataPilotFieldOrientation_PAGE;
break;
677 if( eFieldOrient != DataPilotFieldOrientation_HIDDEN )
678 aPropSet.
setProperty( PROP_Orientation, eFieldOrient );
688 ::std::vector< GeneralFunction > aSubtotals;
708 aSubtotals.push_back( GeneralFunction_AUTO );
715 aLayoutInfo.LayoutMode = DataPilotFieldLayoutMode::COMPACT_LAYOUT;
720 aLayoutInfo.LayoutMode = DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP;
722 aLayoutInfo.LayoutMode = DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
726 aLayoutInfo.LayoutMode = DataPilotFieldLayoutMode::TABULAR_LAYOUT;
736 DataPilotFieldAutoShowInfo aAutoShowInfo;
737 aAutoShowInfo.IsEnabled =
true;
738 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopAutoShow ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
741 aAutoShowInfo.DataField = pCacheField->getName();
742 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
746 DataPilotFieldSortInfo aSortInfo;
750 aSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
758 aSortInfo.Mode = DataPilotFieldSortMode::DATA;
759 aSortInfo.Field = pCacheField->
getName();
763 aSortInfo.Mode = DataPilotFieldSortMode::NAME;
773 SAL_WARN_IF(!pDim,
"sc.filter",
"PivotTableField::convertRowColPageField - no Dimension found for: " << pCacheField->getName());
777 for(
const auto& rItem :
maItems )
779 if (rItem.mnType != XML_data)
782 const PivotCacheItem* pSharedItem = pCacheField->getCacheItem(rItem.mnCacheItem);
808 mnMemPropField( -1 ),
812 mnMeasureField( -1 ),
820 mrPivotTable( rPivotTable )
842 "PivotTableFilter::importTop10 - unexpected value of percent attribute" );
858 nFlags =
rStrm.readuInt16();
859 if(
getFlag( nFlags, BIFF12_PTFILTER_HASNAME ) )
861 if(
getFlag( nFlags, BIFF12_PTFILTER_HASDESCRIPTION ) )
863 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE1 ) )
865 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE2 ) )
868 static const sal_Int32 spnTypes[] =
872 XML_count, XML_percent, XML_sum,
874 XML_captionEqual, XML_captionNotEqual,
875 XML_captionBeginsWith, XML_captionNotBeginsWith, XML_captionEndsWith, XML_captionNotEndsWith,
876 XML_captionContains, XML_captionNotContains, XML_captionGreaterThan, XML_captionGreaterThanOrEqual,
877 XML_captionLessThan, XML_captionLessThanOrEqual, XML_captionBetween, XML_captionNotBetween,
879 XML_valueEqual, XML_valueNotEqual, XML_valueGreaterThan, XML_valueGreaterThanOrEqual,
880 XML_valueLessThan, XML_valueLessThanOrEqual, XML_valueBetween, XML_valueNotBetween,
882 XML_dateEqual, XML_dateOlderThan, XML_dateNewerThan, XML_dateBetween,
883 XML_tomorrow, XML_today, XML_yesterday, XML_nextWeek, XML_thisWeek, XML_lastWeek,
884 XML_nextMonth, XML_thisMonth, XML_lastMonth, XML_nextQuarter, XML_thisQuarter, XML_lastQuarter,
885 XML_nextYear, XML_thisYear, XML_lastYear, XML_yearToDate, XML_Q1, XML_Q2, XML_Q3, XML_Q4,
886 XML_M1, XML_M2, XML_M3, XML_M4, XML_M5, XML_M6, XML_M7, XML_M8, XML_M9, XML_M10, XML_M11, XML_M12,
887 XML_dateNotEqual, XML_dateOlderThanOrEqual, XML_dateNewerThanOrEqual, XML_dateNotBetween
895 nFlags =
rStrm.readuChar();
901 "PivotTableFilter::importTop10 - unexpected value of percent attribute");
914 DataPilotFieldAutoShowInfo aAutoShowInfo;
915 aAutoShowInfo.IsEnabled =
true;
916 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
919 aAutoShowInfo.DataField = pCacheField->getName();
920 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
930 mbDataOnRows( false ),
931 mbShowError( false ),
932 mbShowMissing( true ),
934 mbDisableFieldList( false ),
935 mbShowCalcMembers( true ),
936 mbVisualTotals( true ),
938 mbPrintDrill( false ),
939 mbEnableDrill( true ),
940 mbPreserveFormatting( true ),
941 mbUseAutoFormat( false ),
942 mbPageOverThenDown( false ),
943 mbSubtotalHiddenItems( false ),
944 mbRowGrandTotals( true ),
945 mbColGrandTotals( true ),
946 mbFieldPrintTitles( false ),
947 mbItemPrintTitles( false ),
948 mbMergeItem( false ),
949 mbShowEmptyRow( false ),
950 mbShowEmptyCol( false ),
951 mbShowHeaders( true ),
952 mbFieldListSortAsc( false ),
953 mbCustomListSort( true )
958 mnFirstHeaderRow( 0 ),
969 maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
970 mpPivotCache( nullptr )
1052 aModel.
mnItem = rAttribs.
getInteger( XML_item, BIFF12_PTPAGEFIELD_MULTIITEMS );
1074 css::uno::Sequence<css::xml::FastAttribute> aFast = xFastAttributeList->getFastAttributes();
1075 css::uno::Sequence<css::xml::Attribute> aUnk = xFastAttributeList->getUnknownAttributes();
1076 css::uno::Sequence<css::uno::Any> aVal{ css::uno::Any(aFast), css::uno::Any(aUnk) };
1083 sal_uInt32 nFlags1, nFlags2, nFlags3;
1085 nFlags1 =
rStrm.readuInt32();
1086 nFlags2 =
rStrm.readuInt32();
1087 nFlags3 =
rStrm.readuInt32();
1088 nDataAxis =
rStrm.readuChar();
1097 if(
getFlag( nFlags2, BIFF12_PTDEF_HASDATACAPTION ) )
1099 if(
getFlag( nFlags2, BIFF12_PTDEF_HASGRANDTOTALCAPTION ) )
1101 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOERRORCAPTION ) )
1103 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOMISSINGCAPTION ) )
1105 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPAGESTYLE ) )
1107 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPIVOTTABLESTYLE ) )
1109 if(
getFlag( nFlags2, BIFF12_PTDEF_HASVACATEDSTYLE ) )
1111 if(
getFlag( nFlags2, BIFF12_PTDEF_HASTAG ) )
1113 if(
getFlag( nFlags3, BIFF12_PTDEF_HASCOLHEADERCAPTION ) )
1115 if(
getFlag( nFlags3, BIFF12_PTDEF_HASROWHEADERCAPTION ) )
1119 (nDataAxis != BIFF12_PTDEF_ROWAXIS) && (nDataAxis != BIFF12_PTDEF_COLAXIS),
1121 "PivotTable::importPTDefinition - unexpected axis position for data field");
1185 nFlags =
rStrm.readuChar();
1186 if(
getFlag( nFlags, BIFF12_PTPAGEFIELD_HASNAME ) )
1194 sal_Int32 nSubtotal, nShowDataAs;
1197 nSubtotal =
rStrm.readInt32();
1198 nShowDataAs =
rStrm.readInt32();
1202 nHasName =
rStrm.readuChar();
1212 sal_Int32 nFieldIndex =
static_cast< sal_Int32
>(
maFields.size() );
1215 return *xTableField;
1222 return *xTableFilter;
1238 using namespace ::com::sun::star::sheet::CellFlags;
1249 Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
1250 mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
1252 CellRangeAddress aCellRangeAddress( aRange.
aStart.
Tab(),
1271 aDescProp.
setProperty( PROP_ShowFilterButton,
false );
1283 pField->convertRowField();
1288 pField->convertColField();
1293 pField->convertPageField( rPageField );
1296 ::std::set< sal_Int32 > aVisFields;
1300 aVisFields.insert( rPageField.mnField );
1304 if( aVisFields.count(
nIndex ) == 0 )
1305 rxField->convertHiddenField();
1314 if ( pCacheField-> getGroupBaseField() != -1 )
1315 rDataField.mnField = pCacheField-> getGroupBaseField();
1318 pField->convertDataField( rDataField );
1329 aPos.Row = ::std::max< sal_Int32 >(
static_cast< sal_Int32
>( aPos.Row -
maPageFields.size() - 1 ), 0 );
1339 TOOLS_WARN_EXCEPTION(
"sc",
"PivotTable::finalizeImport - exception while creating the DataPilot table" );
1355 assert(pDPCollection !=
nullptr);
1384 pParentTableField->finalizeParentGroupingImport( rxBaseDPField, rBaseCacheField, orItemNames );
1389 Reference< XDataPilotField > xDPField;
1392 Reference< XNameAccess > xDPFieldsNA(
mxDPDescriptor->getDataPilotFields(), UNO_QUERY_THROW );
1393 xDPField.set( xDPFieldsNA->getByName( rFieldName ), UNO_QUERY );
1403 Reference< XDataPilotField > xDPField;
1411 Reference< XDataPilotField > xDPField;
1414 Reference< XDataPilotDataLayoutFieldSupplier > xDPDataFieldSupp(
mxDPDescriptor, UNO_QUERY_THROW );
1415 xDPField = xDPDataFieldSupp->getDataLayoutField();
1453 orFields.push_back( rAttribs.
getInteger( XML_x, -1 ) );
1458 OSL_ENSURE( orFields.empty(),
"PivotTable::importFields - multiple record instances" );
1461 OSL_ENSURE( 4 *
nCount ==
rStrm.getRemaining(),
"PivotTable::importFields - invalid field count" );
1462 nCount =
static_cast< sal_Int32
>(
rStrm.getRemaining() / 4 );
1463 for( sal_Int32 nIdx = 0; nIdx <
nCount; ++nIdx )
1464 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 in compact view, false = show in either outline or tabular view.
bool mbAverageSubtotal
True = show count all subtotals.
bool mbShowAll
True = show variance of population subtotals.
bool mbMinSubtotal
True = show maximum subtotals.
bool mbCompact
True = show subtotals on top of items in outline or compact mode.
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.