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>
43 #include <osl/diagnose.h>
50 #include <oox/token/properties.hxx>
51 #include <oox/token/tokens.hxx>
59 #include <document.hxx>
72 const sal_Int32 OOX_PT_DATALAYOUTFIELD = -2;
74 const sal_Int32 OOX_PT_PREVIOUS_ITEM = 0x001000FC;
75 const sal_Int32 OOX_PT_NEXT_ITEM = 0x001000FD;
77 const sal_uInt32 BIFF12_PTFIELD_DATAFIELD = 0x00000008;
78 const sal_uInt32 BIFF12_PTFIELD_DEFAULT = 0x00000100;
79 const sal_uInt32 BIFF12_PTFIELD_SUM = 0x00000200;
80 const sal_uInt32 BIFF12_PTFIELD_COUNTA = 0x00000400;
81 const sal_uInt32 BIFF12_PTFIELD_AVERAGE = 0x00000800;
82 const sal_uInt32 BIFF12_PTFIELD_MAX = 0x00001000;
83 const sal_uInt32 BIFF12_PTFIELD_MIN = 0x00002000;
84 const sal_uInt32 BIFF12_PTFIELD_PRODUCT = 0x00004000;
85 const sal_uInt32 BIFF12_PTFIELD_COUNT = 0x00008000;
86 const sal_uInt32 BIFF12_PTFIELD_STDDEV = 0x00010000;
87 const sal_uInt32 BIFF12_PTFIELD_STDDEVP = 0x00020000;
88 const sal_uInt32 BIFF12_PTFIELD_VAR = 0x00040000;
89 const sal_uInt32 BIFF12_PTFIELD_VARP = 0x00080000;
91 const sal_uInt32 BIFF12_PTFIELD_SHOWALL = 0x00000020;
92 const sal_uInt32 BIFF12_PTFIELD_OUTLINE = 0x00000040;
93 const sal_uInt32 BIFF12_PTFIELD_INSERTBLANKROW = 0x00000080;
94 const sal_uInt32 BIFF12_PTFIELD_SUBTOTALTOP = 0x00000100;
95 const sal_uInt32 BIFF12_PTFIELD_INSERTPAGEBREAK = 0x00000800;
96 const sal_uInt32 BIFF12_PTFIELD_AUTOSORT = 0x00001000;
97 const sal_uInt32 BIFF12_PTFIELD_SORTASCENDING = 0x00002000;
98 const sal_uInt32 BIFF12_PTFIELD_AUTOSHOW = 0x00004000;
99 const sal_uInt32 BIFF12_PTFIELD_AUTOSHOWTOP = 0x00008000;
100 const sal_uInt32 BIFF12_PTFIELD_MULTIPAGEITEMS = 0x00080000;
102 const sal_uInt16 BIFF12_PTFITEM_HIDDEN = 0x0001;
103 const sal_uInt16 BIFF12_PTFITEM_HIDEDETAILS = 0x0002;
105 const sal_uInt8 BIFF12_PTPAGEFIELD_HASNAME = 0x01;
106 const sal_Int32 BIFF12_PTPAGEFIELD_MULTIITEMS = 0x001000FE;
108 const sal_uInt16 BIFF12_PTFILTER_HASNAME = 0x0001;
109 const sal_uInt16 BIFF12_PTFILTER_HASDESCRIPTION = 0x0002;
110 const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE1 = 0x0004;
111 const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE2 = 0x0008;
113 const sal_uInt8 BIFF12_TOP10FILTER_TOP = 0x01;
114 const sal_uInt8 BIFF12_TOP10FILTER_PERCENT = 0x02;
116 const sal_uInt32 BIFF12_PTDEF_SHOWITEMS = 0x00000100;
117 const sal_uInt32 BIFF12_PTDEF_DISABLEFIELDLIST = 0x00000400;
118 const sal_uInt32 BIFF12_PTDEF_HIDECALCMEMBERS = 0x00001000;
119 const sal_uInt32 BIFF12_PTDEF_WITHHIDDENTOTALS = 0x00002000;
120 const sal_uInt32 BIFF12_PTDEF_HIDEDRILL = 0x00100000;
121 const sal_uInt32 BIFF12_PTDEF_PRINTDRILL = 0x00200000;
122 const sal_uInt32 BIFF12_PTDEF_HIDEHEADERS = 0x80000000;
124 const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYROW = 0x00000004;
125 const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYCOL = 0x00000008;
126 const sal_uInt32 BIFF12_PTDEF_ENABLEDRILL = 0x00000020;
127 const sal_uInt32 BIFF12_PTDEF_PRESERVEFORMATTING = 0x00000080;
128 const sal_uInt32 BIFF12_PTDEF_USEAUTOFORMAT = 0x00000100;
129 const sal_uInt32 BIFF12_PTDEF_SHOWERROR = 0x00000200;
130 const sal_uInt32 BIFF12_PTDEF_SHOWMISSING = 0x00000400;
131 const sal_uInt32 BIFF12_PTDEF_PAGEOVERTHENDOWN = 0x00000800;
132 const sal_uInt32 BIFF12_PTDEF_SUBTOTALHIDDENITEMS = 0x00001000;
133 const sal_uInt32 BIFF12_PTDEF_ROWGRANDTOTALS = 0x00002000;
134 const sal_uInt32 BIFF12_PTDEF_COLGRANDTOTALS = 0x00004000;
135 const sal_uInt32 BIFF12_PTDEF_FIELDPRINTTITLES = 0x00008000;
136 const sal_uInt32 BIFF12_PTDEF_ITEMPRINTTITLES = 0x00020000;
137 const sal_uInt32 BIFF12_PTDEF_MERGEITEM = 0x00040000;
138 const sal_uInt32 BIFF12_PTDEF_HASDATACAPTION = 0x00080000;
139 const sal_uInt32 BIFF12_PTDEF_HASGRANDTOTALCAPTION = 0x00100000;
140 const sal_uInt32 BIFF12_PTDEF_HASPAGESTYLE = 0x00200000;
141 const sal_uInt32 BIFF12_PTDEF_HASPIVOTTABLESTYLE = 0x00400000;
142 const sal_uInt32 BIFF12_PTDEF_HASVACATEDSTYLE = 0x00800000;
143 const sal_uInt32 BIFF12_PTDEF_APPLYNUMFMT = 0x01000000;
144 const sal_uInt32 BIFF12_PTDEF_APPLYFONT = 0x02000000;
145 const sal_uInt32 BIFF12_PTDEF_APPLYALIGNMENT = 0x04000000;
146 const sal_uInt32 BIFF12_PTDEF_APPLYBORDER = 0x08000000;
147 const sal_uInt32 BIFF12_PTDEF_APPLYFILL = 0x10000000;
148 const sal_uInt32 BIFF12_PTDEF_APPLYPROTECTION = 0x20000000;
149 const sal_uInt32 BIFF12_PTDEF_HASTAG = 0x40000000;
151 const sal_uInt32 BIFF12_PTDEF_NOERRORCAPTION = 0x00000040;
152 const sal_uInt32 BIFF12_PTDEF_NOMISSINGCAPTION = 0x00000080;
153 const sal_uInt32 BIFF12_PTDEF_HASROWHEADERCAPTION = 0x00000400;
154 const sal_uInt32 BIFF12_PTDEF_HASCOLHEADERCAPTION = 0x00000800;
155 const sal_uInt32 BIFF12_PTDEF_FIELDLISTSORTASC = 0x00001000;
156 const sal_uInt32 BIFF12_PTDEF_NOCUSTOMLISTSORT = 0x00004000;
158 const sal_uInt8 BIFF12_PTDEF_ROWAXIS = 1;
159 const sal_uInt8 BIFF12_PTDEF_COLAXIS = 2;
166 mbShowDetails( true ),
173 static const sal_Int32 spnTypes[] = { XML_data, XML_default,
174 XML_sum, XML_countA, XML_avg, XML_max, XML_min, XML_product, XML_count,
175 XML_stdDev, XML_stdDevP, XML_var, XML_varP, XML_grand, XML_blank };
182 mnAutoShowItems( 10 ),
183 mnAutoShowRankBy( -1 ),
184 mnSortType( XML_manual ),
185 mnSortRefField( -1 ),
187 mbDataField(
false ),
188 mbDefaultSubtotal( true ),
189 mbSumSubtotal(
false ),
190 mbCountASubtotal(
false ),
191 mbAverageSubtotal(
false ),
192 mbMaxSubtotal(
false ),
193 mbMinSubtotal(
false ),
194 mbProductSubtotal(
false ),
195 mbCountSubtotal(
false ),
196 mbStdDevSubtotal(
false ),
197 mbStdDevPSubtotal(
false ),
198 mbVarSubtotal(
false ),
199 mbVarPSubtotal(
false ),
202 mbSubtotalTop( true ),
203 mbInsertBlankRow(
false ),
204 mbInsertPageBreak(
false ),
206 mbTopAutoShow( true ),
207 mbMultiPageItems(
false )
227 mnItem( BIFF12_PTPAGEFIELD_MULTIITEMS )
233 mnSubtotal( XML_sum ),
234 mnShowDataAs( XML_normal ),
243 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 };
249 static const sal_Int32 spnShowDataAs[] = { XML_normal, XML_difference, XML_percent, XML_percentDiff, XML_runTotal, XML_percentOfRow, XML_percentOfCol, XML_percentOfTotal, XML_index };
255 mrPivotTable( rPivotTable ),
256 mnFieldIndex( nFieldIndex )
319 sal_uInt32 nFlags1, nFlags2;
350 bool bAutoSort =
getFlag( nFlags2, BIFF12_PTFIELD_AUTOSORT );
351 bool bAscending =
getFlag( nFlags2, BIFF12_PTFIELD_SORTASCENDING );
352 maModel.
mnSortType = bAutoSort ? (bAscending ? XML_ascending : XML_descending) : XML_manual;
386 Reference< XDataPilotField > xDPField;
388 if( !((nDatabaseIdx >= 0) && rxDPDesc.is()) )
394 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
395 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
396 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
398 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeImport - no field name in source data found" );
404 if( pCacheField->hasNumericGrouping() )
406 pCacheField->convertNumericGrouping( xDPField );
408 else if( pCacheField->hasDateGrouping() )
411 pCacheField->createDateGroupField( xDPField );
415 else if( pCacheField->hasParentGrouping() )
419 ::std::vector< OUString > aItems;
420 pCacheField->getCacheItemNames( aItems );
422 for(
const auto& rItem : aItems )
423 aItemNames.emplace_back( rItem );
440 if( !pCacheField->isDatabaseField() && pCacheField->hasDateGrouping() && (pCacheField->getGroupBaseField() == nBaseFieldIdx) )
442 maDPFieldName = pCacheField->createDateGroupField( rxBaseDPField );
444 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeDateGroupingImport - cannot create date group field" );
462 for(
const auto& rItem :
maItems )
464 if ( rItem.mnType == XML_data && rItem.msCaption.getLength() )
465 captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
467 if ( !captionList.empty() )
482 Reference< XDataPilotField > xDPField;
484 if( (nDatabaseIdx >= 0) && rxDPDesc.is() )
try
487 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
488 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
489 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
491 SAL_WARN_IF(
maDPFieldName.isEmpty(),
"sc.filter",
"PivotTableField::finalizeImportBasedOnCache - no field name in source data found" );
500 if(!pCacheField->getFinalGroupName().isEmpty())
522 OSL_ENSURE( rPageField.
mnField ==
mnFieldIndex,
"PivotTableField::convertPageField - wrong field index" );
532 sal_Int32 nCacheItem = -1;
536 OSL_ENSURE( rPageField.
mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS,
"PivotTableField::convertPageField - unexpected cache item index" );
538 bool bHasMultiItems =
false;
539 for(
const auto& rItem :
maItems )
541 if( (rItem.mnType == XML_data) && !rItem.mbHidden )
543 bHasMultiItems = nCacheItem >= 0;
544 nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
554 if( (0 <= rPageField.
mnItem) && (rPageField.
mnItem < static_cast< sal_Int32 >(
maItems.size() )) )
563 if(
const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
569 aPropSet.
setProperty( PROP_SelectedPage, aSelectedPage );
576 OSL_ENSURE( rDataField.
mnField ==
mnFieldIndex,
"PivotTableField::convertDataField - wrong field index" );
577 OSL_ENSURE(
maModel.
mbDataField,
"PivotTableField::convertDataField - not a data field" );
585 aPropSet.
setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
587 if (!rDataField.
maName.isEmpty())
595 GeneralFunction eAggFunc = GeneralFunction_SUM;
598 case XML_sum: eAggFunc = GeneralFunction_SUM;
break;
599 case XML_count: eAggFunc = GeneralFunction_COUNT;
break;
600 case XML_average: eAggFunc = GeneralFunction_AVERAGE;
break;
601 case XML_max: eAggFunc = GeneralFunction_MAX;
break;
602 case XML_min: eAggFunc = GeneralFunction_MIN;
break;
603 case XML_product: eAggFunc = GeneralFunction_PRODUCT;
break;
604 case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;
break;
605 case XML_stdDev: eAggFunc = GeneralFunction_STDEV;
break;
606 case XML_stdDevp: eAggFunc = GeneralFunction_STDEVP;
break;
607 case XML_var: eAggFunc = GeneralFunction_VAR;
break;
608 case XML_varp: eAggFunc = GeneralFunction_VARP;
break;
609 default: OSL_FAIL(
"PivotTableField::convertDataField - unknown aggregation function" );
614 DataPilotFieldReference aReference;
618 case XML_difference: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;
break;
619 case XML_percent: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;
break;
620 case XML_percentDiff: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
break;
621 case XML_runTotal: aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;
break;
622 case XML_percentOfRow: aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;
break;
623 case XML_percentOfCol: aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
break;
624 case XML_percentOfTotal: aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
break;
625 case XML_index: aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;
break;
634 aReference.ReferenceField = pCacheField->
getName();
637 case OOX_PT_PREVIOUS_ITEM:
638 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
640 case OOX_PT_NEXT_ITEM:
641 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
644 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
646 aReference.ReferenceItemName = pCacheItem->getName();
648 aPropSet.
setProperty( PROP_Reference, aReference );
655 bool bDataLayout =
mnFieldIndex == OOX_PT_DATALAYOUTFIELD;
657 OSL_ENSURE( bDataLayout || (nAxis ==
maModel.
mnAxis),
"PivotTableField::convertRowColPageField - field axis mismatch" );
667 DataPilotFieldOrientation eFieldOrient = DataPilotFieldOrientation_HIDDEN;
670 case XML_axisRow: eFieldOrient = DataPilotFieldOrientation_ROW;
break;
671 case XML_axisCol: eFieldOrient = DataPilotFieldOrientation_COLUMN;
break;
672 case XML_axisPage: eFieldOrient = DataPilotFieldOrientation_PAGE;
break;
674 if( eFieldOrient != DataPilotFieldOrientation_HIDDEN )
675 aPropSet.
setProperty( PROP_Orientation, eFieldOrient );
685 ::std::vector< GeneralFunction > aSubtotals;
705 aSubtotals.push_back( GeneralFunction_AUTO );
711 (
maModel.
mbSubtotalTop ? DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP : DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM) :
712 DataPilotFieldLayoutMode::TABULAR_LAYOUT;
714 aPropSet.
setProperty( PROP_LayoutInfo, aLayoutInfo );
720 DataPilotFieldAutoShowInfo aAutoShowInfo;
721 aAutoShowInfo.IsEnabled =
true;
722 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopAutoShow ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
725 aAutoShowInfo.DataField = pCacheField->getName();
726 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
730 DataPilotFieldSortInfo aSortInfo;
734 aSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
742 aSortInfo.Mode = DataPilotFieldSortMode::DATA;
743 aSortInfo.Field = pCacheField->
getName();
747 aSortInfo.Mode = DataPilotFieldSortMode::NAME;
760 for(
const auto& rItem :
maItems )
762 if (rItem.mnType != XML_data)
765 const PivotCacheItem* pSharedItem = pCacheField->getCacheItem(rItem.mnCacheItem);
791 mnMemPropField( -1 ),
795 mnMeasureField( -1 ),
803 mrPivotTable( rPivotTable )
825 "PivotTableFilter::importTop10 - unexpected value of percent attribute" );
842 if(
getFlag( nFlags, BIFF12_PTFILTER_HASNAME ) )
844 if(
getFlag( nFlags, BIFF12_PTFILTER_HASDESCRIPTION ) )
846 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE1 ) )
848 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE2 ) )
851 static const sal_Int32 spnTypes[] =
855 XML_count, XML_percent, XML_sum,
857 XML_captionEqual, XML_captionNotEqual,
858 XML_captionBeginsWith, XML_captionNotBeginsWith, XML_captionEndsWith, XML_captionNotEndsWith,
859 XML_captionContains, XML_captionNotContains, XML_captionGreaterThan, XML_captionGreaterThanOrEqual,
860 XML_captionLessThan, XML_captionLessThanOrEqual, XML_captionBetween, XML_captionNotBetween,
862 XML_valueEqual, XML_valueNotEqual, XML_valueGreaterThan, XML_valueGreaterThanOrEqual,
863 XML_valueLessThan, XML_valueLessThanOrEqual, XML_valueBetween, XML_valueNotBetween,
865 XML_dateEqual, XML_dateOlderThan, XML_dateNewerThan, XML_dateBetween,
866 XML_tomorrow, XML_today, XML_yesterday, XML_nextWeek, XML_thisWeek, XML_lastWeek,
867 XML_nextMonth, XML_thisMonth, XML_lastMonth, XML_nextQuarter, XML_thisQuarter, XML_lastQuarter,
868 XML_nextYear, XML_thisYear, XML_lastYear, XML_yearToDate, XML_Q1, XML_Q2, XML_Q3, XML_Q4,
869 XML_M1, XML_M2, XML_M3, XML_M4, XML_M5, XML_M6, XML_M7, XML_M8, XML_M9, XML_M10, XML_M11, XML_M12,
870 XML_dateNotEqual, XML_dateOlderThanOrEqual, XML_dateNewerThanOrEqual, XML_dateNotBetween
884 "PivotTableFilter::importTop10 - unexpected value of percent attribute");
897 DataPilotFieldAutoShowInfo aAutoShowInfo;
898 aAutoShowInfo.IsEnabled =
true;
899 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
902 aAutoShowInfo.DataField = pCacheField->getName();
903 aPropSet.setProperty( PROP_AutoShowInfo, aAutoShowInfo );
913 mbDataOnRows(
false ),
914 mbShowError(
false ),
915 mbShowMissing( true ),
917 mbDisableFieldList(
false ),
918 mbShowCalcMembers( true ),
919 mbVisualTotals( true ),
921 mbPrintDrill(
false ),
922 mbEnableDrill( true ),
923 mbPreserveFormatting( true ),
924 mbUseAutoFormat(
false ),
925 mbPageOverThenDown(
false ),
926 mbSubtotalHiddenItems(
false ),
927 mbRowGrandTotals( true ),
928 mbColGrandTotals( true ),
929 mbFieldPrintTitles(
false ),
930 mbItemPrintTitles(
false ),
931 mbMergeItem(
false ),
932 mbShowEmptyRow(
false ),
933 mbShowEmptyCol(
false ),
934 mbShowHeaders( true ),
935 mbFieldListSortAsc(
false ),
936 mbCustomListSort( true )
941 mnFirstHeaderRow( 0 ),
952 maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
953 mpPivotCache( nullptr )
1035 aModel.
mnItem = rAttribs.
getInteger( XML_item, BIFF12_PTPAGEFIELD_MULTIITEMS );
1057 css::uno::Sequence<css::xml::FastAttribute> aFast = xFastAttributeList->getFastAttributes();
1058 css::uno::Sequence<css::xml::Attribute> aUnk = xFastAttributeList->getUnknownAttributes();
1059 css::uno::Sequence<css::uno::Any> aVal{ css::uno::Any(aFast), css::uno::Any(aUnk) };
1066 sal_uInt32 nFlags1, nFlags2, nFlags3;
1080 if(
getFlag( nFlags2, BIFF12_PTDEF_HASDATACAPTION ) )
1082 if(
getFlag( nFlags2, BIFF12_PTDEF_HASGRANDTOTALCAPTION ) )
1084 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOERRORCAPTION ) )
1086 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOMISSINGCAPTION ) )
1088 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPAGESTYLE ) )
1090 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPIVOTTABLESTYLE ) )
1092 if(
getFlag( nFlags2, BIFF12_PTDEF_HASVACATEDSTYLE ) )
1094 if(
getFlag( nFlags2, BIFF12_PTDEF_HASTAG ) )
1096 if(
getFlag( nFlags3, BIFF12_PTDEF_HASCOLHEADERCAPTION ) )
1098 if(
getFlag( nFlags3, BIFF12_PTDEF_HASROWHEADERCAPTION ) )
1102 (nDataAxis != BIFF12_PTDEF_ROWAXIS) && (nDataAxis != BIFF12_PTDEF_COLAXIS),
1104 "PivotTable::importPTDefinition - unexpected axis position for data field");
1169 if(
getFlag( nFlags, BIFF12_PTPAGEFIELD_HASNAME ) )
1177 sal_Int32 nSubtotal, nShowDataAs;
1195 sal_Int32 nFieldIndex =
static_cast< sal_Int32
>(
maFields.size() );
1198 return *xTableField;
1205 return *xTableFilter;
1221 using namespace ::com::sun::star::sheet::CellFlags;
1232 Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
1233 mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
1235 CellRangeAddress aCellRangeAddress( aRange.
aStart.
Tab(),
1242 auto pImpl = comphelper::getFromUnoTunnel<ScDataPilotDescriptorBase>(
mxDPDescriptor);
1254 aDescProp.
setProperty( PROP_ShowFilterButton,
false );
1263 pField->convertRowField();
1268 pField->convertColField();
1273 pField->convertPageField( rPageField );
1276 ::std::set< sal_Int32 > aVisFields;
1277 aVisFields.insert( maRowFields.begin(), maRowFields.end() );
1278 aVisFields.insert( maColFields.begin(), maColFields.end() );
1279 for(
const auto& rPageField : maPageFields )
1280 aVisFields.insert( rPageField.mnField );
1284 if( aVisFields.count( nIndex ) == 0 )
1285 rxField->convertHiddenField();
1294 if ( pCacheField-> getGroupBaseField() != -1 )
1295 rDataField.mnField = pCacheField-> getGroupBaseField();
1298 pField->convertDataField( rDataField );
1308 if( !maPageFields.empty() )
1309 aPos.Row = ::std::max< sal_Int32 >( static_cast< sal_Int32 >( aPos.Row - maPageFields.size() - 1 ), 0 );
1319 TOOLS_WARN_EXCEPTION(
"sc",
"PivotTable::finalizeImport - exception while creating the DataPilot table" );
1335 assert(pDPCollection !=
nullptr);
1364 pParentTableField->finalizeParentGroupingImport( rxBaseDPField, rBaseCacheField, orItemNames );
1369 Reference< XDataPilotField > xDPField;
1373 xDPField.set( xDPFieldsNA->getByName( rFieldName ), UNO_QUERY );
1383 Reference< XDataPilotField > xDPField;
1391 Reference< XDataPilotField > xDPField;
1394 Reference< XDataPilotDataLayoutFieldSupplier > xDPDataFieldSupp(
mxDPDescriptor, UNO_QUERY_THROW );
1395 xDPField = xDPDataFieldSupp->getDataLayoutField();
1433 orFields.push_back( rAttribs.
getInteger( XML_x, -1 ) );
1438 OSL_ENSURE( orFields.empty(),
"PivotTable::importFields - multiple record instances" );
1441 OSL_ENSURE( 4 * nCount == rStrm.
getRemaining(),
"PivotTable::importFields - invalid field count" );
1442 nCount =
static_cast< sal_Int32
>( rStrm.
getRemaining() / 4 );
1443 for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
1444 orFields.push_back( rStrm.
readInt32() );
sal_Int32 mnEvalOrder
Filter type.
Helper class to provide access to global workbook data.
void convertHiddenField()
Converts dimension and other settings for a hidden field.
void setBiffType(sal_uInt16 nType)
Sets item type for BIFF import.
::std::vector< IdCaptionPair > IdCaptionPairList
bool mbProductSubtotal
True = show minimum subtotals.
void finalizeImport()
Inserts the pivot table into the sheet.
void ReloadGroupTableData()
bool mbTopFilter
Hierarchy for filter calculation.
std::map< OUString, css::uno::Any > maInteropGrabBag
Descriptor of the DataPilot object.
PivotCache * mpPivotCache
Location settings of the pivot table.
ScDocumentImport & getDocImport()
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.
ItemModelVector maItems
The parent pivot table object.
bool mbMultiPageItems
True = auto show filter shows top entries, false = bottom.
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
ScDPSaveMember * GetMemberByName(const OUString &rName)
Get a member object by its name.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
bool mbSubtotalHiddenItems
ScDPObject * getDPObject()
bool mbTopAutoShow
True = auto show (top 10) filter enabled.
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
bool HasGroupDimensions() const
sal_Int32 mnField
Unique name of the page field.
OptValue< OUString > getXString(sal_Int32 nAttrToken) const
OUString maGrandTotalCaption
OUString maRowHeaderCaption
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
void finalizeParentGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, const PivotCacheField &rBaseCacheField, PivotCacheGroupItemVector &orItemNames)
Finalizes the grouped field after import.
void finalizeImport()
Inserts all pivot tables into the sheet.
SC_DLLPUBLIC bool GetReferenceGroups(const ScDPObject &rDPObj, const ScDPDimensionSaveData **pGroups) const
sal_Int32 mnMeasureField
Unique identifier.
sal_Int32 mnSortRefItem
Reference field for autosorting.
A 2D cell range address struct for binary filters.
PTFilterModel()
True = filter shows top entries, false = bottom.
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
bool mbStdDevPSubtotal
True = show standard deviation subtotals.
OUString maPivotTableStyle
const PivotCacheItem * getCacheItem(sal_Int32 nItemIdx) const
Returns the shared or group item with the specified index.
void importRowField(const AttributeList &rAttribs)
Reads the index of a field located in the row dimension.
void importPTReferenceItem(SequenceInputStream &rStrm)
Imports pivot field item reference settings from the PTREFERENCEITEM record.
value_type get(sal_Int32 nIndex) const
void PutInteropGrabBag(std::map< OUString, css::uno::Any > &&val)
const ScRange & getSourceRange() const
Returns the internal cell range the cache is based on.
OptValue< double > getDouble(sal_Int32 nAttrToken) const
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
sal_Int32 mnFieldIndex
Name of the field in DataPilot field collection.
#define STATIC_ARRAY_SELECT(array, index, def)
OUString maStrValue2
First string value for label filter.
sal_Int32 mnFirstDataCol
First row of data cells (relative in pivot table).
::std::vector< sal_Int32 > IndexVector
OptValue< OUString > getString(sal_Int32 nAttrToken) const
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.
static bool convertToCellRangeUnchecked(ScRange &orRange, const OUString &rString, sal_Int16 nSheet)
Converts the passed string to a cell range address, without checking any sheet limits.
SC_DLLPUBLIC void SetIsVisible(bool bSet)
const PivotTable & mrPivotTable
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
void importColField(const AttributeList &rAttribs)
Reads the index of a field located in the column dimension.
css::uno::Reference< css::sheet::XDataPilotField > convertRowColPageField(sal_Int32 nAxis)
Converts dimension and other settings for row, column, page, or hidden fields.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the field with the passed index.
void importDataField(const AttributeList &rAttribs)
Reads the settings of a field located in the data dimension from the dataField element.
void forEachMem(FuncType pFunc) const
void importPTFItem(SequenceInputStream &rStrm)
Imports settings of an item in this pivot field from the PTFITEM record.
bool mbOutline
True = show items without data.
sal_Int32 mnItem
Base pivot field.
sal_Int32 mnSubtotal
Base pivot field.
PTFieldModel()
True = multiple items selectable in page dimension.
static void importFields(IndexVector &orFields, SequenceInputStream &rStrm)
Reads an array of field indexes for the row or column dimension.
sal_Int32 mnFirstDataRow
First row of header cells (relative in pivot table).
void importLocation(const AttributeList &rAttribs, sal_Int16 nSheet)
Reads the location of the pivot table from the location element.
sal_Int32 mnColPageCount
Number of rows in page filter area.
void finalizeImport(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
Finalizes the field after import, creates grouping and other settings.
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
css::uno::Reference< css::sheet::XDataPilotDescriptor > mxDPDescriptor
The pivot cache this table is based on.
sal_Int32 mnField
Number of items or percent or sum to be shown.
void setBiffSubtotal(sal_Int32 nSubtotal)
Sets the subtotal aggregation function for BIFF import.
void setBiffShowDataAs(sal_Int32 nShowDataAs)
Sets the 'show data as' type for BIFF import.
void importTop10Filter(SequenceInputStream &rStrm)
Reads additional settings of a field filter from the TOP10FILTER record.
void finalizeFieldsImport()
Finalizes all fields, finds field names and creates grouping fields.
OptValue< sal_uInt32 > getUnsigned(sal_Int32 nAttrToken) const
bool mbHidden
True = show item details (items of child fields).
bool getFlag(Type nBitField, Type nMask)
bool mbInsertBlankRow
True = show subtotals on top of items in outline or compact mode.
void importPivotTableDefinition(const AttributeList &rAttribs)
Reads global pivot table settings from the pivotTableDefinition element.
void importPageField(const AttributeList &rAttribs)
Reads the settings of a field located in the page dimension from the pageField element.
bool mbInsertPageBreak
True = insert blank rows after items.
bool mbCountASubtotal
True = show sum subtotals.
bool mbDataField
Item in reference field for autosorting.
sal_Int32 getCacheDatabaseIndex(sal_Int32 nFieldIdx) const
Returns the source column index of the pivot field with the passed index, or -1.
double mfValue
Second string value for label filter.
void importPTPageField(SequenceInputStream &rStrm)
Reads the settings of a field located in the page dimension from the PTPAGEFIELD record.
sal_Int32 mnFirstHeaderRow
Target cell range for the pivot table.
OUString maMissingCaption
const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE]
PTFieldItemModel()
True = item is hidden.
#define TOOLS_WARN_EXCEPTION(area, stream)
IndexVector maRowFields
Data layout field.
SC_DLLPUBLIC void SetDimensionData(const ScDPDimensionSaveData *pNew)
SC_DLLPUBLIC bool HasPivotTable() const
void importFilter(const AttributeList &rAttribs)
Reads the settings of a field filter from the filter element.
container_type::value_type value_type
bool mbAutoShow
True = insert page breaks after items.
PTLocationModel maLocationModel
Global pivot table settings.
static void importField(IndexVector &orFields, const AttributeList &rAttribs)
Reads a field index for the row or column dimension.
PivotTableFieldVector maFields
const PivotCacheField * getCacheFieldOfDataField(sal_Int32 nDataItemIdx) const
Returns the base cache field of the data field item with the specified index.
PivotTable(const WorkbookHelper &rHelper)
void finalizeImport()
Applies the filter to the associated pivot table field if possible.
void setFinalGroupName(const OUString &rFinalGroupName)
Set the finalized group name of this field.
sal_Int32 mnShowDataAs
Subtotal aggregation function.
ScDPSaveData * GetSaveData() const
sal_Int32 mnNumFmtId
Base item for 'show data as'.
void applyItemCaptions(const IdCaptionPairList &vCaptions)
Apply user Captions to imported group data.
bool mbSubtotalTop
True = show in outline view, false = show in tabular view.
void putToInteropGrabBag(const OUString &sName, const AttributeList &rAttribs)
Puts the attributes to the named grab bag value.
void importPTRowFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the row dimension from a PTROWFIELDS record.
bool mbShowAll
True = show variance of population subtotals.
PivotTableVector maTables
sal_Int32 mnAutoShowRankBy
Number of items (or percent/sum) to be shown in auto show filter.
css::uno::Reference< css::sheet::XDataPilotField > getDataPilotField(const OUString &rFieldName) const
Returns the associated data pilot field for the specified pivot table field.
sal_Int32 mnType
Member property field.
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 importPTDefinition(SequenceInputStream &rStrm)
Reads global pivot table settings from the PTDEFINITION record.
void convertPageField(const PTPageFieldModel &rPageField)
Converts dimension and other settings for a page field.
SC_DLLPUBLIC void SetShowDetails(bool bSet)
void setBiffAxis(sal_uInt8 nAxisFlags)
Sets axis type for BIFF import.
css::uno::Reference< css::sheet::XDataPilotField > getDataLayoutField() const
Returns the data layout field used to store all data fields in row/col dimension. ...
bool mbStdDevSubtotal
True = show count numbers subtotals.
bool mbMaxSubtotal
True = show average subtotals.
OUString maDPFieldName
Pivot field settings.
PTPageFieldModel()
Index of field item that is shown by the page field.
PivotTableField & createTableField()
Creates and returns a new pivot table field.
void importPTLocation(SequenceInputStream &rStrm, sal_Int16 nSheet)
Reads the location of the pivot table from the PTLOCATION record.
void importPTDataField(SequenceInputStream &rStrm)
Reads the settings of a field located in the data dimension from the PTDATAFIELD record.
sal_Int64 getRemaining() const
bool mbVarSubtotal
True = show standard deviation of population subtotals.
PivotTableFilterVector maFilters
Settings for all fields in data area.
void convertDataField(const PTDataFieldModel &rDataField)
Converts dimension and other settings for a data field.
OUString maColHeaderCaption
sal_Int32 mnMeasureHier
Data field for filter calculation.
DataFieldVector maDataFields
Settings for all fields in page dimension.
sal_Int32 mnBaseField
Show data as, based on another field.
void importPTField(SequenceInputStream &rStrm)
Imports pivot field settings from the PTFIELD record.
PivotCacheField * getCacheField(sal_Int32 nFieldIdx)
Returns the cache field with the specified index.
void importTop10(const AttributeList &rAttribs)
Reads additional settings of a field filter from the top10 element.
#define SAL_WARN_IF(condition, area, stream)
bool mbShowDetails
User caption of the item.
sal_Int32 mnSortType
Index of the data field auto show filter is based on.
sal_Int32 mnNumFmtId
Axis this field is assigned to (none, row, column, page).
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
PivotTableField maDataField
All pivot table fields.
OUString msCaption
Type of the item.
void importItem(const AttributeList &rAttribs)
Imports settings of an item in this pivot field from the item element.
sal_Int32 mnRowPageCount
First column of data cells (relative in pivot table).
void convertColField()
Converts dimension and other settings for a column field.
void importReferenceItem(const AttributeList &rAttribs)
Imports pivot field item reference settings from the x element.
PTDefinitionModel maDefModel
All field filters.
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
bool mbVarPSubtotal
True = show variance subtotals.
bool mbSumSubtotal
True = show default subtotals.
bool isValidDataSource() const
Returns true, if the pivot cache is based on a valid data source, so that pivot tables can be created...
PivotTable & createPivotTable()
Creates and returns a new pivot table.
OUString maStrValue1
Description of the field filter.
sal_Int32 mnAutoShowItems
Number format for field items.
IndexVector maColFields
Indexes to fields in row dimension.
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.
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
sal_Int32 mnId
Evaluation order index.
void importReference(const AttributeList &rAttribs)
Imports pivot field reference settings from the reference element.
sal_Int32 mnMemPropField
Base pivot field.
sal_Int32 mnSortRefField
Autosorting type.
void finalizeDateGroupingImport(const css::uno::Reference< css::sheet::XDataPilotField > &rxBaseDPField, sal_Int32 nBaseFieldIdx)
Finalizes the grouped date field after import.
sal_Int32 mnField
Name of the data field.
PTDataFieldModel()
Number format for the result.
PivotTableBuffer(const WorkbookHelper &rHelper)
bool mbAverageSubtotal
True = show count all subtotals.
PivotTableFilter & createTableFilter()
Creates and returns a new pivot table filter.
void finalizeImportBasedOnCache(const css::uno::Reference< css::sheet::XDataPilotDescriptor > &rxDPDesc)
PivotTableField * getTableField(sal_Int32 nFieldIdx)
Returns a pivot table field by its index.
void importPTReference(SequenceInputStream &rStrm)
Imports pivot field reference settings from the PTREFERENCE record.
bool mbPreserveFormatting
void importPTFilter(SequenceInputStream &rStrm)
Reads the settings of a field filter from the PTFILTER record.
void importPivotField(const AttributeList &rAttribs)
Imports pivot field settings from the pivotField element.
bool mbCountSubtotal
True = show product subtotals.
PageFieldVector maPageFields
Indexes to fields in column dimension.
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
PTFieldModel maModel
All items of this field.
sal_Int32 mnBaseItem
Base field for 'show data as'.
OUString maDescription
Name of the field filter.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
sal_Int32 getParentGroupField() const
Returns the index of the parent group field that groups the items of this field.
void convertRowField()
Converts dimension and other settings for a row field.
PTLocationModel()
Number of columns in page filter area.
bool mbMinSubtotal
True = show maximum subtotals.
PivotTableField(PivotTable &rPivotTable, sal_Int32 nFieldIndex)
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
void importPTColFields(SequenceInputStream &rStrm)
Reads the indexes of all fields located in the column dimension from a PTCOLFIELDS record...
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector
bool mbDefaultSubtotal
True = field appears in data area.
PivotCache * importPivotCacheFragment(sal_Int32 nCacheId)
Imports and stores a pivot cache definition fragment on first call, returns the imported cache on sub...
PivotTableFilter(const PivotTable &rPivotTable)
const OUString & getName() const
Returns the name of the cache field.
bool m_bDetectedRangeSegmentation false
PivotTable & mrPivotTable
sal_Int32 mnType
Index to shared item in pivot cache.