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>
41 #include <osl/diagnose.h>
48 #include <oox/token/properties.hxx>
49 #include <oox/token/tokens.hxx>
57 #include <document.hxx>
70 const sal_Int32 OOX_PT_DATALAYOUTFIELD = -2;
72 const sal_Int32 OOX_PT_PREVIOUS_ITEM = 0x001000FC;
73 const sal_Int32 OOX_PT_NEXT_ITEM = 0x001000FD;
75 const sal_uInt32 BIFF12_PTFIELD_DATAFIELD = 0x00000008;
76 const sal_uInt32 BIFF12_PTFIELD_DEFAULT = 0x00000100;
77 const sal_uInt32 BIFF12_PTFIELD_SUM = 0x00000200;
78 const sal_uInt32 BIFF12_PTFIELD_COUNTA = 0x00000400;
79 const sal_uInt32 BIFF12_PTFIELD_AVERAGE = 0x00000800;
80 const sal_uInt32 BIFF12_PTFIELD_MAX = 0x00001000;
81 const sal_uInt32 BIFF12_PTFIELD_MIN = 0x00002000;
82 const sal_uInt32 BIFF12_PTFIELD_PRODUCT = 0x00004000;
83 const sal_uInt32 BIFF12_PTFIELD_COUNT = 0x00008000;
84 const sal_uInt32 BIFF12_PTFIELD_STDDEV = 0x00010000;
85 const sal_uInt32 BIFF12_PTFIELD_STDDEVP = 0x00020000;
86 const sal_uInt32 BIFF12_PTFIELD_VAR = 0x00040000;
87 const sal_uInt32 BIFF12_PTFIELD_VARP = 0x00080000;
89 const sal_uInt32 BIFF12_PTFIELD_SHOWALL = 0x00000020;
90 const sal_uInt32 BIFF12_PTFIELD_OUTLINE = 0x00000040;
91 const sal_uInt32 BIFF12_PTFIELD_INSERTBLANKROW = 0x00000080;
92 const sal_uInt32 BIFF12_PTFIELD_SUBTOTALTOP = 0x00000100;
93 const sal_uInt32 BIFF12_PTFIELD_INSERTPAGEBREAK = 0x00000800;
94 const sal_uInt32 BIFF12_PTFIELD_AUTOSORT = 0x00001000;
95 const sal_uInt32 BIFF12_PTFIELD_SORTASCENDING = 0x00002000;
96 const sal_uInt32 BIFF12_PTFIELD_AUTOSHOW = 0x00004000;
97 const sal_uInt32 BIFF12_PTFIELD_AUTOSHOWTOP = 0x00008000;
98 const sal_uInt32 BIFF12_PTFIELD_MULTIPAGEITEMS = 0x00080000;
100 const sal_uInt16 BIFF12_PTFITEM_HIDDEN = 0x0001;
101 const sal_uInt16 BIFF12_PTFITEM_HIDEDETAILS = 0x0002;
103 const sal_uInt8 BIFF12_PTPAGEFIELD_HASNAME = 0x01;
104 const sal_Int32 BIFF12_PTPAGEFIELD_MULTIITEMS = 0x001000FE;
106 const sal_uInt16 BIFF12_PTFILTER_HASNAME = 0x0001;
107 const sal_uInt16 BIFF12_PTFILTER_HASDESCRIPTION = 0x0002;
108 const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE1 = 0x0004;
109 const sal_uInt16 BIFF12_PTFILTER_HASSTRVALUE2 = 0x0008;
111 const sal_uInt8 BIFF12_TOP10FILTER_TOP = 0x01;
112 const sal_uInt8 BIFF12_TOP10FILTER_PERCENT = 0x02;
114 const sal_uInt32 BIFF12_PTDEF_SHOWITEMS = 0x00000100;
115 const sal_uInt32 BIFF12_PTDEF_DISABLEFIELDLIST = 0x00000400;
116 const sal_uInt32 BIFF12_PTDEF_HIDECALCMEMBERS = 0x00001000;
117 const sal_uInt32 BIFF12_PTDEF_WITHHIDDENTOTALS = 0x00002000;
118 const sal_uInt32 BIFF12_PTDEF_HIDEDRILL = 0x00100000;
119 const sal_uInt32 BIFF12_PTDEF_PRINTDRILL = 0x00200000;
120 const sal_uInt32 BIFF12_PTDEF_HIDEHEADERS = 0x80000000;
122 const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYROW = 0x00000004;
123 const sal_uInt32 BIFF12_PTDEF_SHOWEMPTYCOL = 0x00000008;
124 const sal_uInt32 BIFF12_PTDEF_ENABLEDRILL = 0x00000020;
125 const sal_uInt32 BIFF12_PTDEF_PRESERVEFORMATTING = 0x00000080;
126 const sal_uInt32 BIFF12_PTDEF_USEAUTOFORMAT = 0x00000100;
127 const sal_uInt32 BIFF12_PTDEF_SHOWERROR = 0x00000200;
128 const sal_uInt32 BIFF12_PTDEF_SHOWMISSING = 0x00000400;
129 const sal_uInt32 BIFF12_PTDEF_PAGEOVERTHENDOWN = 0x00000800;
130 const sal_uInt32 BIFF12_PTDEF_SUBTOTALHIDDENITEMS = 0x00001000;
131 const sal_uInt32 BIFF12_PTDEF_ROWGRANDTOTALS = 0x00002000;
132 const sal_uInt32 BIFF12_PTDEF_COLGRANDTOTALS = 0x00004000;
133 const sal_uInt32 BIFF12_PTDEF_FIELDPRINTTITLES = 0x00008000;
134 const sal_uInt32 BIFF12_PTDEF_ITEMPRINTTITLES = 0x00020000;
135 const sal_uInt32 BIFF12_PTDEF_MERGEITEM = 0x00040000;
136 const sal_uInt32 BIFF12_PTDEF_HASDATACAPTION = 0x00080000;
137 const sal_uInt32 BIFF12_PTDEF_HASGRANDTOTALCAPTION = 0x00100000;
138 const sal_uInt32 BIFF12_PTDEF_HASPAGESTYLE = 0x00200000;
139 const sal_uInt32 BIFF12_PTDEF_HASPIVOTTABLESTYLE = 0x00400000;
140 const sal_uInt32 BIFF12_PTDEF_HASVACATEDSTYLE = 0x00800000;
141 const sal_uInt32 BIFF12_PTDEF_APPLYNUMFMT = 0x01000000;
142 const sal_uInt32 BIFF12_PTDEF_APPLYFONT = 0x02000000;
143 const sal_uInt32 BIFF12_PTDEF_APPLYALIGNMENT = 0x04000000;
144 const sal_uInt32 BIFF12_PTDEF_APPLYBORDER = 0x08000000;
145 const sal_uInt32 BIFF12_PTDEF_APPLYFILL = 0x10000000;
146 const sal_uInt32 BIFF12_PTDEF_APPLYPROTECTION = 0x20000000;
147 const sal_uInt32 BIFF12_PTDEF_HASTAG = 0x40000000;
149 const sal_uInt32 BIFF12_PTDEF_NOERRORCAPTION = 0x00000040;
150 const sal_uInt32 BIFF12_PTDEF_NOMISSINGCAPTION = 0x00000080;
151 const sal_uInt32 BIFF12_PTDEF_HASROWHEADERCAPTION = 0x00000400;
152 const sal_uInt32 BIFF12_PTDEF_HASCOLHEADERCAPTION = 0x00000800;
153 const sal_uInt32 BIFF12_PTDEF_FIELDLISTSORTASC = 0x00001000;
154 const sal_uInt32 BIFF12_PTDEF_NOCUSTOMLISTSORT = 0x00004000;
156 const sal_uInt8 BIFF12_PTDEF_ROWAXIS = 1;
157 const sal_uInt8 BIFF12_PTDEF_COLAXIS = 2;
164 mbShowDetails( true ),
171 static const sal_Int32 spnTypes[] = { XML_data, XML_default,
172 XML_sum, XML_countA, XML_avg, XML_max, XML_min, XML_product, XML_count,
173 XML_stdDev, XML_stdDevP, XML_var, XML_varP, XML_grand, XML_blank };
180 mnAutoShowItems( 10 ),
181 mnAutoShowRankBy( -1 ),
182 mnSortType( XML_manual ),
183 mnSortRefField( -1 ),
185 mbDataField( false ),
186 mbDefaultSubtotal( true ),
187 mbSumSubtotal( false ),
188 mbCountASubtotal( false ),
189 mbAverageSubtotal( false ),
190 mbMaxSubtotal( false ),
191 mbMinSubtotal( false ),
192 mbProductSubtotal( false ),
193 mbCountSubtotal( false ),
194 mbStdDevSubtotal( false ),
195 mbStdDevPSubtotal( false ),
196 mbVarSubtotal( false ),
197 mbVarPSubtotal( false ),
200 mbSubtotalTop( true ),
201 mbInsertBlankRow( false ),
202 mbInsertPageBreak( false ),
204 mbTopAutoShow( true ),
205 mbMultiPageItems( false )
225 mnItem( BIFF12_PTPAGEFIELD_MULTIITEMS )
231 mnSubtotal( XML_sum ),
232 mnShowDataAs( XML_normal ),
241 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 };
247 static const sal_Int32 spnShowDataAs[] = { XML_normal, XML_difference, XML_percent, XML_percentDiff, XML_runTotal, XML_percentOfRow, XML_percentOfCol, XML_percentOfTotal, XML_index };
253 mrPivotTable( rPivotTable ),
254 mnFieldIndex( nFieldIndex )
317 sal_uInt32 nFlags1, nFlags2;
348 bool bAutoSort =
getFlag( nFlags2, BIFF12_PTFIELD_AUTOSORT );
349 bool bAscending =
getFlag( nFlags2, BIFF12_PTFIELD_SORTASCENDING );
350 maModel.
mnSortType = bAutoSort ? (bAscending ? XML_ascending : XML_descending) : XML_manual;
384 Reference< XDataPilotField > xDPField;
386 if( !((nDatabaseIdx >= 0) && rxDPDesc.is()) )
392 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
393 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
394 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
396 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeImport - no field name in source data found" );
402 if( pCacheField->hasNumericGrouping() )
404 pCacheField->convertNumericGrouping( xDPField );
406 else if( pCacheField->hasDateGrouping() )
409 pCacheField->createDateGroupField( xDPField );
413 else if( pCacheField->hasParentGrouping() )
417 ::std::vector< OUString > aItems;
418 pCacheField->getCacheItemNames( aItems );
420 for(
const auto& rItem : aItems )
421 aItemNames.emplace_back( rItem );
438 if( !pCacheField->isDatabaseField() && pCacheField->hasDateGrouping() && (pCacheField->getGroupBaseField() == nBaseFieldIdx) )
440 maDPFieldName = pCacheField->createDateGroupField( rxBaseDPField );
442 OSL_ENSURE( !
maDPFieldName.isEmpty(),
"PivotTableField::finalizeDateGroupingImport - cannot create date group field" );
460 for(
const auto& rItem :
maItems )
462 if ( rItem.mnType == XML_data && rItem.msCaption.getLength() )
463 captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
465 if ( !captionList.empty() )
480 Reference< XDataPilotField > xDPField;
482 if( (nDatabaseIdx >= 0) && rxDPDesc.is() )
try
485 Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
486 xDPField.set( xDPFieldsIA->getByIndex( nDatabaseIdx ), UNO_QUERY_THROW );
487 Reference< XNamed > xDPFieldName( xDPField, UNO_QUERY_THROW );
489 SAL_WARN_IF(
maDPFieldName.isEmpty(),
"sc.filter",
"PivotTableField::finalizeImportBasedOnCache - no field name in source data found" );
498 if(!pCacheField->getFinalGroupName().isEmpty())
520 OSL_ENSURE( rPageField.
mnField ==
mnFieldIndex,
"PivotTableField::convertPageField - wrong field index" );
530 sal_Int32 nCacheItem = -1;
534 OSL_ENSURE( rPageField.
mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS,
"PivotTableField::convertPageField - unexpected cache item index" );
536 bool bHasMultiItems =
false;
537 for(
const auto& rItem :
maItems )
539 if( (rItem.mnType == XML_data) && !rItem.mbHidden )
541 bHasMultiItems = nCacheItem >= 0;
542 nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
552 if( (0 <= rPageField.
mnItem) && (rPageField.
mnItem < static_cast< sal_Int32 >(
maItems.size() )) )
561 if(
const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
567 aPropSet.
setProperty( PROP_SelectedPage, aSelectedPage );
574 OSL_ENSURE( rDataField.
mnField ==
mnFieldIndex,
"PivotTableField::convertDataField - wrong field index" );
575 OSL_ENSURE(
maModel.
mbDataField,
"PivotTableField::convertDataField - not a data field" );
583 aPropSet.
setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
585 if (!rDataField.
maName.isEmpty())
593 GeneralFunction eAggFunc = GeneralFunction_SUM;
596 case XML_sum: eAggFunc = GeneralFunction_SUM;
break;
597 case XML_count: eAggFunc = GeneralFunction_COUNT;
break;
598 case XML_average: eAggFunc = GeneralFunction_AVERAGE;
break;
599 case XML_max: eAggFunc = GeneralFunction_MAX;
break;
600 case XML_min: eAggFunc = GeneralFunction_MIN;
break;
601 case XML_product: eAggFunc = GeneralFunction_PRODUCT;
break;
602 case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;
break;
603 case XML_stdDev: eAggFunc = GeneralFunction_STDEV;
break;
604 case XML_stdDevp: eAggFunc = GeneralFunction_STDEVP;
break;
605 case XML_var: eAggFunc = GeneralFunction_VAR;
break;
606 case XML_varp: eAggFunc = GeneralFunction_VARP;
break;
607 default: OSL_FAIL(
"PivotTableField::convertDataField - unknown aggregation function" );
612 DataPilotFieldReference aReference;
616 case XML_difference: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;
break;
617 case XML_percent: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;
break;
618 case XML_percentDiff: aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
break;
619 case XML_runTotal: aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;
break;
620 case XML_percentOfRow: aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;
break;
621 case XML_percentOfCol: aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
break;
622 case XML_percentOfTotal: aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
break;
623 case XML_index: aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;
break;
632 aReference.ReferenceField = pCacheField->
getName();
635 case OOX_PT_PREVIOUS_ITEM:
636 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
638 case OOX_PT_NEXT_ITEM:
639 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
642 aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
644 aReference.ReferenceItemName = pCacheItem->getName();
646 aPropSet.
setProperty( PROP_Reference, aReference );
653 bool bDataLayout =
mnFieldIndex == OOX_PT_DATALAYOUTFIELD;
655 OSL_ENSURE( bDataLayout || (nAxis ==
maModel.
mnAxis),
"PivotTableField::convertRowColPageField - field axis mismatch" );
665 DataPilotFieldOrientation eFieldOrient = DataPilotFieldOrientation_HIDDEN;
668 case XML_axisRow: eFieldOrient = DataPilotFieldOrientation_ROW;
break;
669 case XML_axisCol: eFieldOrient = DataPilotFieldOrientation_COLUMN;
break;
670 case XML_axisPage: eFieldOrient = DataPilotFieldOrientation_PAGE;
break;
672 if( eFieldOrient != DataPilotFieldOrientation_HIDDEN )
673 aPropSet.
setProperty( PROP_Orientation, eFieldOrient );
683 ::std::vector< GeneralFunction > aSubtotals;
703 aSubtotals.push_back( GeneralFunction_AUTO );
709 (
maModel.
mbSubtotalTop ? DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP : DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM) :
710 DataPilotFieldLayoutMode::TABULAR_LAYOUT;
712 aPropSet.
setProperty( PROP_LayoutInfo, aLayoutInfo );
718 DataPilotFieldAutoShowInfo aAutoShowInfo;
719 aAutoShowInfo.IsEnabled =
true;
720 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopAutoShow ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
723 aAutoShowInfo.DataField = pCacheField->getName();
724 aPropSet.
setProperty( PROP_AutoShowInfo, aAutoShowInfo );
728 DataPilotFieldSortInfo aSortInfo;
732 aSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
740 aSortInfo.Mode = DataPilotFieldSortMode::DATA;
741 aSortInfo.Field = pCacheField->
getName();
745 aSortInfo.Mode = DataPilotFieldSortMode::NAME;
758 for(
const auto& rItem :
maItems )
760 if (rItem.mnType != XML_data)
763 const PivotCacheItem* pSharedItem = pCacheField->getCacheItem(rItem.mnCacheItem);
789 mnMemPropField( -1 ),
793 mnMeasureField( -1 ),
801 mrPivotTable( rPivotTable )
823 "PivotTableFilter::importTop10 - unexpected value of percent attribute" );
840 if(
getFlag( nFlags, BIFF12_PTFILTER_HASNAME ) )
842 if(
getFlag( nFlags, BIFF12_PTFILTER_HASDESCRIPTION ) )
844 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE1 ) )
846 if(
getFlag( nFlags, BIFF12_PTFILTER_HASSTRVALUE2 ) )
849 static const sal_Int32 spnTypes[] =
853 XML_count, XML_percent, XML_sum,
855 XML_captionEqual, XML_captionNotEqual,
856 XML_captionBeginsWith, XML_captionNotBeginsWith, XML_captionEndsWith, XML_captionNotEndsWith,
857 XML_captionContains, XML_captionNotContains, XML_captionGreaterThan, XML_captionGreaterThanOrEqual,
858 XML_captionLessThan, XML_captionLessThanOrEqual, XML_captionBetween, XML_captionNotBetween,
860 XML_valueEqual, XML_valueNotEqual, XML_valueGreaterThan, XML_valueGreaterThanOrEqual,
861 XML_valueLessThan, XML_valueLessThanOrEqual, XML_valueBetween, XML_valueNotBetween,
863 XML_dateEqual, XML_dateOlderThan, XML_dateNewerThan, XML_dateBetween,
864 XML_tomorrow, XML_today, XML_yesterday, XML_nextWeek, XML_thisWeek, XML_lastWeek,
865 XML_nextMonth, XML_thisMonth, XML_lastMonth, XML_nextQuarter, XML_thisQuarter, XML_lastQuarter,
866 XML_nextYear, XML_thisYear, XML_lastYear, XML_yearToDate, XML_Q1, XML_Q2, XML_Q3, XML_Q4,
867 XML_M1, XML_M2, XML_M3, XML_M4, XML_M5, XML_M6, XML_M7, XML_M8, XML_M9, XML_M10, XML_M11, XML_M12,
868 XML_dateNotEqual, XML_dateOlderThanOrEqual, XML_dateNewerThanOrEqual, XML_dateNotBetween
882 "PivotTableFilter::importTop10 - unexpected value of percent attribute");
895 DataPilotFieldAutoShowInfo aAutoShowInfo;
896 aAutoShowInfo.IsEnabled =
true;
897 aAutoShowInfo.ShowItemsMode =
maModel.
mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
900 aAutoShowInfo.DataField = pCacheField->getName();
901 aPropSet.setProperty( PROP_AutoShowInfo, aAutoShowInfo );
911 mbDataOnRows( false ),
912 mbShowError( false ),
913 mbShowMissing( true ),
915 mbDisableFieldList( false ),
916 mbShowCalcMembers( true ),
917 mbVisualTotals( true ),
919 mbPrintDrill( false ),
920 mbEnableDrill( true ),
921 mbPreserveFormatting( true ),
922 mbUseAutoFormat( false ),
923 mbPageOverThenDown( false ),
924 mbSubtotalHiddenItems( false ),
925 mbRowGrandTotals( true ),
926 mbColGrandTotals( true ),
927 mbFieldPrintTitles( false ),
928 mbItemPrintTitles( false ),
929 mbMergeItem( false ),
930 mbShowEmptyRow( false ),
931 mbShowEmptyCol( false ),
932 mbShowHeaders( true ),
933 mbFieldListSortAsc( false ),
934 mbCustomListSort( true )
939 mnFirstHeaderRow( 0 ),
950 maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
951 mpPivotCache( nullptr )
1033 aModel.
mnItem = rAttribs.
getInteger( XML_item, BIFF12_PTPAGEFIELD_MULTIITEMS );
1055 css::uno::Sequence<css::xml::FastAttribute> aFast = xFastAttributeList->getFastAttributes();
1056 css::uno::Sequence<css::xml::Attribute> aUnk = xFastAttributeList->getUnknownAttributes();
1057 css::uno::Sequence<css::uno::Any> aVal{ css::uno::Any(aFast), css::uno::Any(aUnk) };
1064 sal_uInt32 nFlags1, nFlags2, nFlags3;
1078 if(
getFlag( nFlags2, BIFF12_PTDEF_HASDATACAPTION ) )
1080 if(
getFlag( nFlags2, BIFF12_PTDEF_HASGRANDTOTALCAPTION ) )
1082 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOERRORCAPTION ) )
1084 if( !
getFlag( nFlags3, BIFF12_PTDEF_NOMISSINGCAPTION ) )
1086 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPAGESTYLE ) )
1088 if(
getFlag( nFlags2, BIFF12_PTDEF_HASPIVOTTABLESTYLE ) )
1090 if(
getFlag( nFlags2, BIFF12_PTDEF_HASVACATEDSTYLE ) )
1092 if(
getFlag( nFlags2, BIFF12_PTDEF_HASTAG ) )
1094 if(
getFlag( nFlags3, BIFF12_PTDEF_HASCOLHEADERCAPTION ) )
1096 if(
getFlag( nFlags3, BIFF12_PTDEF_HASROWHEADERCAPTION ) )
1100 (nDataAxis != BIFF12_PTDEF_ROWAXIS) && (nDataAxis != BIFF12_PTDEF_COLAXIS),
1102 "PivotTable::importPTDefinition - unexpected axis position for data field");
1167 if(
getFlag( nFlags, BIFF12_PTPAGEFIELD_HASNAME ) )
1175 sal_Int32 nSubtotal, nShowDataAs;
1193 sal_Int32 nFieldIndex =
static_cast< sal_Int32
>(
maFields.size() );
1196 return *xTableField;
1203 return *xTableFilter;
1219 using namespace ::com::sun::star::sheet::CellFlags;
1230 Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
1231 mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
1233 CellRangeAddress aCellRangeAddress( aRange.
aStart.
Tab(),
1240 auto pImpl = comphelper::getUnoTunnelImplementation<ScDataPilotDescriptorBase>(
mxDPDescriptor);
1252 aDescProp.
setProperty( PROP_ShowFilterButton,
false );
1261 pField->convertRowField();
1266 pField->convertColField();
1271 pField->convertPageField( rPageField );
1274 ::std::set< sal_Int32 > aVisFields;
1275 aVisFields.insert( maRowFields.begin(), maRowFields.end() );
1276 aVisFields.insert( maColFields.begin(), maColFields.end() );
1277 for(
const auto& rPageField : maPageFields )
1278 aVisFields.insert( rPageField.mnField );
1282 if( aVisFields.count( nIndex ) == 0 )
1283 rxField->convertHiddenField();
1292 if ( pCacheField-> getGroupBaseField() != -1 )
1293 rDataField.mnField = pCacheField-> getGroupBaseField();
1296 pField->convertDataField( rDataField );
1306 if( !maPageFields.empty() )
1307 aPos.Row = ::std::max< sal_Int32 >( static_cast< sal_Int32 >( aPos.Row - maPageFields.size() - 1 ), 0 );
1317 TOOLS_WARN_EXCEPTION(
"sc",
"PivotTable::finalizeImport - exception while creating the DataPilot table" );
1333 assert(pDPCollection !=
nullptr);
1362 pParentTableField->finalizeParentGroupingImport( rxBaseDPField, rBaseCacheField, orItemNames );
1367 Reference< XDataPilotField > xDPField;
1371 xDPField.set( xDPFieldsNA->getByName( rFieldName ), UNO_QUERY );
1381 Reference< XDataPilotField > xDPField;
1389 Reference< XDataPilotField > xDPField;
1392 Reference< XDataPilotDataLayoutFieldSupplier > xDPDataFieldSupp(
mxDPDescriptor, UNO_QUERY_THROW );
1393 xDPField = xDPDataFieldSupp->getDataLayoutField();
1431 orFields.push_back( rAttribs.
getInteger( XML_x, -1 ) );
1436 OSL_ENSURE( orFields.empty(),
"PivotTable::importFields - multiple record instances" );
1439 OSL_ENSURE( 4 * nCount == rStrm.
getRemaining(),
"PivotTable::importFields - invalid field count" );
1440 nCount =
static_cast< sal_Int32
>( rStrm.
getRemaining() / 4 );
1441 for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
1442 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.
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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).
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.
static css::uno::Sequence< typename VectorType::value_type > vectorToSequence(const VectorType &rVector)
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.
PivotTable & mrPivotTable
sal_Int32 mnType
Index to shared item in pivot cache.