LibreOffice Module sc (master)  1
xipivot.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <xipivot.hxx>
21 
22 #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
23 #include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
24 #include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
25 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
26 #include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
27 
28 #include <tools/datetime.hxx>
29 #include <svl/intitem.hxx>
30 #include <sal/log.hxx>
31 #include <sot/storage.hxx>
32 #include <unotools/configmgr.hxx>
33 
34 #include <document.hxx>
35 #include <formulacell.hxx>
36 #include <dpsave.hxx>
37 #include <dpdimsave.hxx>
38 #include <dpobject.hxx>
39 #include <dpshttab.hxx>
40 #include <dpoutputgeometry.hxx>
41 #include <scitems.hxx>
42 #include <attrib.hxx>
43 
44 #include <xltracer.hxx>
45 #include <xistream.hxx>
46 #include <xihelper.hxx>
47 #include <xilink.hxx>
48 #include <xiescher.hxx>
49 
50 //TODO ExcelToSc usage
51 #include <excform.hxx>
52 #include <documentimport.hxx>
53 
54 #include <vector>
55 
56 using namespace com::sun::star;
57 
58 using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
59 using ::com::sun::star::sheet::DataPilotFieldSortInfo;
60 using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
61 using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
62 using ::com::sun::star::sheet::DataPilotFieldReference;
63 using ::std::vector;
64 
65 // Pivot cache
66 
68 {
69  switch( rStrm.GetRecId() )
70  {
71  case EXC_ID_SXDOUBLE: ReadSxdouble( rStrm ); break;
72  case EXC_ID_SXBOOLEAN: ReadSxboolean( rStrm ); break;
73  case EXC_ID_SXERROR: ReadSxerror( rStrm ); break;
74  case EXC_ID_SXINTEGER: ReadSxinteger( rStrm ); break;
75  case EXC_ID_SXSTRING: ReadSxstring( rStrm ); break;
76  case EXC_ID_SXDATETIME: ReadSxdatetime( rStrm ); break;
77  case EXC_ID_SXEMPTY: ReadSxempty( rStrm ); break;
78  default: OSL_FAIL( "XclImpPCItem::XclImpPCItem - unknown record id" );
79  }
80 }
81 
82 namespace {
83 
84 void lclSetValue( XclImpRoot& rRoot, const ScAddress& rScPos, double fValue, SvNumFormatType nFormatType )
85 {
86  ScDocumentImport& rDoc = rRoot.GetDocImport();
87  rDoc.setNumericCell(rScPos, fValue);
88  sal_uInt32 nScNumFmt = rRoot.GetFormatter().GetStandardFormat( nFormatType, rRoot.GetDocLanguage() );
89  rDoc.getDoc().ApplyAttr(
90  rScPos.Col(), rScPos.Row(), rScPos.Tab(), SfxUInt32Item(ATTR_VALUE_FORMAT, nScNumFmt));
91 }
92 
93 } // namespace
94 
95 void XclImpPCItem::WriteToSource( XclImpRoot& rRoot, const ScAddress& rScPos ) const
96 {
97  ScDocumentImport& rDoc = rRoot.GetDocImport();
98  if( const OUString* pText = GetText() )
99  rDoc.setStringCell(rScPos, *pText);
100  else if( const double* pfValue = GetDouble() )
101  rDoc.setNumericCell(rScPos, *pfValue);
102  else if( const sal_Int16* pnValue = GetInteger() )
103  rDoc.setNumericCell(rScPos, *pnValue);
104  else if( const bool* pbValue = GetBool() )
105  lclSetValue( rRoot, rScPos, *pbValue ? 1.0 : 0.0, SvNumFormatType::LOGICAL );
106  else if( const DateTime* pDateTime = GetDateTime() )
107  {
108  // set number format date, time, or date/time, depending on the value
109  double fValue = rRoot.GetDoubleFromDateTime( *pDateTime );
110  double fInt = 0.0;
111  double fFrac = modf( fValue, &fInt );
112  SvNumFormatType nFormatType = ((fFrac == 0.0) && (fInt != 0.0)) ? SvNumFormatType::DATE :
113  ((fInt == 0.0) ? SvNumFormatType::TIME : SvNumFormatType::DATETIME);
114  lclSetValue( rRoot, rScPos, fValue, nFormatType );
115  }
116  else if( const sal_uInt16* pnError = GetError() )
117  {
118  double fValue;
119  sal_uInt8 nErrCode = static_cast< sal_uInt8 >( *pnError );
120  std::unique_ptr<ScTokenArray> pScTokArr = rRoot.GetOldFmlaConverter().GetBoolErr(
121  XclTools::ErrorToEnum( fValue, true, nErrCode ) );
122  ScFormulaCell* pCell = pScTokArr
123  ? new ScFormulaCell(rDoc.getDoc(), rScPos, std::move(pScTokArr))
124  : new ScFormulaCell(rDoc.getDoc(), rScPos);
125  pCell->SetHybridDouble( fValue );
126  rDoc.setFormulaCell(rScPos, pCell);
127  }
128 }
129 
131 {
132  OSL_ENSURE( rStrm.GetRecSize() == 8, "XclImpPCItem::ReadSxdouble - wrong record size" );
133  SetDouble( rStrm.ReadDouble() );
134 }
135 
137 {
138  OSL_ENSURE( rStrm.GetRecSize() == 2, "XclImpPCItem::ReadSxboolean - wrong record size" );
139  SetBool( rStrm.ReaduInt16() != 0 );
140 }
141 
143 {
144  OSL_ENSURE( rStrm.GetRecSize() == 2, "XclImpPCItem::ReadSxerror - wrong record size" );
145  SetError( rStrm.ReaduInt16() );
146 }
147 
149 {
150  OSL_ENSURE( rStrm.GetRecSize() == 2, "XclImpPCItem::ReadSxinteger - wrong record size" );
151  SetInteger( rStrm.ReadInt16() );
152 }
153 
155 {
156  OSL_ENSURE( rStrm.GetRecSize() >= 3, "XclImpPCItem::ReadSxstring - wrong record size" );
157  SetText( rStrm.ReadUniString() );
158 }
159 
161 {
162  OSL_ENSURE( rStrm.GetRecSize() == 8, "XclImpPCItem::ReadSxdatetime - wrong record size" );
163  sal_uInt16 nYear, nMonth;
164  sal_uInt8 nDay, nHour, nMin, nSec;
165  nYear = rStrm.ReaduInt16();
166  nMonth = rStrm.ReaduInt16();
167  nDay = rStrm.ReaduInt8();
168  nHour = rStrm.ReaduInt8();
169  nMin = rStrm.ReaduInt8();
170  nSec = rStrm.ReaduInt8();
171  SetDateTime( DateTime( Date( nDay, nMonth, nYear ), tools::Time( nHour, nMin, nSec ) ) );
172 }
173 
175 {
176  OSL_ENSURE( rStrm.GetRecSize() == 0, "XclImpPCItem::ReadSxempty - wrong record size" );
177  SetEmpty();
178 }
179 
180 XclImpPCField::XclImpPCField( const XclImpRoot& rRoot, XclImpPivotCache& rPCache, sal_uInt16 nFieldIdx ) :
181  XclPCField( EXC_PCFIELD_UNKNOWN, nFieldIdx ),
182  XclImpRoot( rRoot ),
183  mrPCache( rPCache ),
184  mnSourceScCol( -1 ),
185  mbNumGroupInfoRead( false )
186 {
187 }
188 
190 {
191 }
192 
193 // general field/item access --------------------------------------------------
194 
195 const OUString& XclImpPCField::GetFieldName( const ScfStringVec& rVisNames ) const
196 {
197  if( IsGroupChildField() && (mnFieldIdx < rVisNames.size()) )
198  {
199  const OUString& rVisName = rVisNames[ mnFieldIdx ];
200  if (!rVisName.isEmpty())
201  return rVisName;
202  }
203  return maFieldInfo.maName;
204 }
205 
207 {
208  OSL_ENSURE( IsGroupChildField(), "XclImpPCField::GetGroupBaseField - this field type does not have a base field" );
210 }
211 
212 const XclImpPCItem* XclImpPCField::GetItem( sal_uInt16 nItemIdx ) const
213 {
214  return (nItemIdx < maItems.size()) ? maItems[ nItemIdx ].get() : nullptr;
215 }
216 
217 const XclImpPCItem* XclImpPCField::GetLimitItem( sal_uInt16 nItemIdx ) const
218 {
219  OSL_ENSURE( nItemIdx < 3, "XclImpPCField::GetLimitItem - invalid item index" );
220  OSL_ENSURE( nItemIdx < maNumGroupItems.size(), "XclImpPCField::GetLimitItem - no item found" );
221  return (nItemIdx < maNumGroupItems.size()) ? maNumGroupItems[ nItemIdx ].get() : nullptr;
222 }
223 
225 {
226  OSL_ENSURE( HasOrigItems(), "XclImpPCField::WriteFieldNameToSource - only for standard fields" );
227  GetDocImport().setStringCell(ScAddress(nScCol, 0, nScTab), maFieldInfo.maName);
228  mnSourceScCol = nScCol;
229 }
230 
231 void XclImpPCField::WriteOrigItemToSource( SCROW nScRow, SCTAB nScTab, sal_uInt16 nItemIdx )
232 {
233  if( nItemIdx < maOrigItems.size() )
234  maOrigItems[ nItemIdx ]->WriteToSource( GetRoot(), ScAddress( mnSourceScCol, nScRow, nScTab ) );
235 }
236 
238 {
239  if( !maOrigItems.empty() )
240  maOrigItems.back()->WriteToSource( GetRoot(), ScAddress( mnSourceScCol, nScRow, nScTab ) );
241 }
242 
243 // records --------------------------------------------------------------------
244 
246 {
247  rStrm >> maFieldInfo;
248 
249  /* Detect the type of this field. This is done very restrictive to detect
250  any unexpected state. */
252 
253  bool bItems = ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_HASITEMS );
254  bool bPostp = ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_POSTPONE );
255  bool bCalced = ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_CALCED );
256  bool bChild = ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_HASCHILD );
257  bool bNum = ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_NUMGROUP );
258 
259  sal_uInt16 nVisC = maFieldInfo.mnVisItems;
260  sal_uInt16 nGroupC = maFieldInfo.mnGroupItems;
261  sal_uInt16 nBaseC = maFieldInfo.mnBaseItems;
262  sal_uInt16 nOrigC = maFieldInfo.mnOrigItems;
263  OSL_ENSURE( nVisC > 0, "XclImpPCField::ReadSxfield - field without visible items" );
264 
265  sal_uInt16 nType = maFieldInfo.mnFlags & EXC_SXFIELD_DATA_MASK;
266  bool bType =
267  (nType == EXC_SXFIELD_DATA_STR) ||
268  (nType == EXC_SXFIELD_DATA_INT) ||
269  (nType == EXC_SXFIELD_DATA_DBL) ||
270  (nType == EXC_SXFIELD_DATA_STR_INT) ||
271  (nType == EXC_SXFIELD_DATA_STR_DBL) ||
272  (nType == EXC_SXFIELD_DATA_DATE) ||
273  (nType == EXC_SXFIELD_DATA_DATE_EMP) ||
274  (nType == EXC_SXFIELD_DATA_DATE_NUM) ||
275  (nType == EXC_SXFIELD_DATA_DATE_STR);
276  bool bTypeNone =
277  (nType == EXC_SXFIELD_DATA_NONE);
278  // for now, ignore data type of calculated fields
279  OSL_ENSURE( bCalced || bType || bTypeNone, "XclImpPCField::ReadSxfield - unknown item data type" );
280 
281  if( !(nVisC > 0 || bPostp) )
282  return;
283 
284  if( bItems && !bPostp )
285  {
286  if( !bCalced )
287  {
288  // 1) standard fields and standard grouping fields
289  if( !bNum )
290  {
291  // 1a) standard field without grouping
292  if( bType && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == nVisC) )
294 
295  // 1b) standard grouping field
296  else if( bTypeNone && (nGroupC == nVisC) && (nBaseC > 0) && (nOrigC == 0) )
298  }
299  // 2) numerical grouping fields
300  else if( (nGroupC == nVisC) && (nBaseC == 0) )
301  {
302  // 2a) single num/date grouping field without child grouping field
303  if( !bChild && bType && (nOrigC > 0) )
304  {
305  switch( nType )
306  {
310  default: OSL_FAIL( "XclImpPCField::ReadSxfield - numeric group with wrong data type" );
311  }
312  }
313 
314  // 2b) first date grouping field with child grouping field
315  else if( bChild && (nType == EXC_SXFIELD_DATA_DATE) && (nOrigC > 0) )
317 
318  // 2c) additional date grouping field
319  else if( bTypeNone && (nOrigC == 0) )
321  }
322  OSL_ENSURE( meFieldType != EXC_PCFIELD_UNKNOWN, "XclImpPCField::ReadSxfield - invalid standard or grouped field" );
323  }
324 
325  // 3) calculated field
326  else
327  {
328  if( !bChild && !bNum && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == 0) )
330  OSL_ENSURE( meFieldType == EXC_PCFIELD_CALCED, "XclImpPCField::ReadSxfield - invalid calculated field" );
331  }
332  }
333 
334  else if( !bItems && bPostp )
335  {
336  // 4) standard field with postponed items
337  if( !bCalced && !bChild && !bNum && bType && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == 0) )
339  OSL_ENSURE( meFieldType == EXC_PCFIELD_STANDARD, "XclImpPCField::ReadSxfield - invalid postponed field" );
340  }
341 }
342 
344 {
345  OSL_ENSURE( HasInlineItems() || HasPostponedItems(), "XclImpPCField::ReadItem - field does not expect items" );
346 
347  // read the item
348  XclImpPCItemRef xItem = std::make_shared<XclImpPCItem>( rStrm );
349 
350  // try to insert into an item list
351  if( mbNumGroupInfoRead )
352  {
353  // there are 3 items after SXNUMGROUP that contain grouping limits and step count
354  if( maNumGroupItems.size() < 3 )
355  maNumGroupItems.push_back( xItem );
356  else
357  maOrigItems.push_back( xItem );
358  }
359  else if( HasInlineItems() || HasPostponedItems() )
360  {
361  maItems.push_back( xItem );
362  // visible item is original item in standard fields
363  if( IsStandardField() )
364  maOrigItems.push_back( xItem );
365  }
366 }
367 
369 {
370  OSL_ENSURE( IsNumGroupField() || IsDateGroupField(), "XclImpPCField::ReadSxnumgroup - SXNUMGROUP outside numeric grouping field" );
371  OSL_ENSURE( !mbNumGroupInfoRead, "XclImpPCField::ReadSxnumgroup - multiple SXNUMGROUP records" );
372  OSL_ENSURE( maItems.size() == maFieldInfo.mnGroupItems, "XclImpPCField::ReadSxnumgroup - SXNUMGROUP out of record order" );
373  rStrm >> maNumGroupInfo;
375 }
376 
378 {
379  OSL_ENSURE( IsStdGroupField(), "XclImpPCField::ReadSxgroupinfo - SXGROUPINFO outside grouping field" );
380  OSL_ENSURE( maGroupOrder.empty(), "XclImpPCField::ReadSxgroupinfo - multiple SXGROUPINFO records" );
381  OSL_ENSURE( maItems.size() == maFieldInfo.mnGroupItems, "XclImpPCField::ReadSxgroupinfo - SXGROUPINFO out of record order" );
382  OSL_ENSURE( (rStrm.GetRecLeft() / 2) == maFieldInfo.mnBaseItems, "XclImpPCField::ReadSxgroupinfo - wrong SXGROUPINFO size" );
383  maGroupOrder.clear();
384  size_t nSize = rStrm.GetRecLeft() / 2;
385  maGroupOrder.resize( nSize, 0 );
386  for( size_t nIdx = 0; nIdx < nSize; ++nIdx )
387  maGroupOrder[ nIdx ] = rStrm.ReaduInt16();
388 }
389 
390 // grouping -------------------------------------------------------------------
391 
392 void XclImpPCField::ConvertGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
393 {
394  if (!GetFieldName(rVisNames).isEmpty())
395  {
396  if( IsStdGroupField() )
397  ConvertStdGroupField( rSaveData, rVisNames );
398  else if( IsNumGroupField() )
399  ConvertNumGroupField( rSaveData, rVisNames );
400  else if( IsDateGroupField() )
401  ConvertDateGroupField( rSaveData, rVisNames );
402  }
403 }
404 
405 // private --------------------------------------------------------------------
406 
407 void XclImpPCField::ConvertStdGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
408 {
409  const XclImpPCField* pBaseField = GetGroupBaseField();
410  if(!pBaseField)
411  return;
412 
413  const OUString& rBaseFieldName = pBaseField->GetFieldName( rVisNames );
414  if( rBaseFieldName.isEmpty() )
415  return;
416 
417  // *** create a ScDPSaveGroupItem for each own item, they collect base item names ***
418  ScDPSaveGroupItemVec aGroupItems;
419  aGroupItems.reserve( maItems.size() );
420  // initialize with own item names
421  for( const auto& rxItem : maItems )
422  aGroupItems.emplace_back( rxItem->ConvertToText() );
423 
424  // *** iterate over all base items, set their names at corresponding own items ***
425  for( sal_uInt16 nItemIdx = 0, nItemCount = static_cast< sal_uInt16 >( maGroupOrder.size() ); nItemIdx < nItemCount; ++nItemIdx )
426  if( maGroupOrder[ nItemIdx ] < aGroupItems.size() )
427  if( const XclImpPCItem* pBaseItem = pBaseField->GetItem( nItemIdx ) )
428  if( const XclImpPCItem* pGroupItem = GetItem( maGroupOrder[ nItemIdx ] ) )
429  if( *pBaseItem != *pGroupItem )
430  aGroupItems[ maGroupOrder[ nItemIdx ] ].AddElement( pBaseItem->ConvertToText() );
431 
432  // *** create the ScDPSaveGroupDimension object, fill with grouping info ***
433  ScDPSaveGroupDimension aGroupDim( rBaseFieldName, GetFieldName( rVisNames ) );
434  for( const auto& rGroupItem : aGroupItems )
435  if( !rGroupItem.IsEmpty() )
436  aGroupDim.AddGroupItem( rGroupItem );
437  rSaveData.GetDimensionData()->AddGroupDimension( aGroupDim );
438 }
439 
440 void XclImpPCField::ConvertNumGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
441 {
442  ScDPNumGroupInfo aNumInfo( GetScNumGroupInfo() );
443  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), aNumInfo );
444  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
445 }
446 
447 void XclImpPCField::ConvertDateGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
448 {
449  ScDPNumGroupInfo aDateInfo( GetScDateGroupInfo() );
450  sal_Int32 nScDateType = maNumGroupInfo.GetScDateType();
451 
452  switch( meFieldType )
453  {
455  {
456  if( aDateInfo.mbDateValues )
457  {
458  // special case for days only with step value - create numeric grouping
459  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), aDateInfo );
460  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
461  }
462  else
463  {
464  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), ScDPNumGroupInfo() );
465  aNumGroupDim.SetDateInfo( aDateInfo, nScDateType );
466  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
467  }
468  }
469  break;
470 
472  {
473  if( const XclImpPCField* pBaseField = GetGroupBaseField() )
474  {
475  const OUString& rBaseFieldName = pBaseField->GetFieldName( rVisNames );
476  if( !rBaseFieldName.isEmpty() )
477  {
478  ScDPSaveGroupDimension aGroupDim( rBaseFieldName, GetFieldName( rVisNames ) );
479  aGroupDim.SetDateInfo( aDateInfo, nScDateType );
480  rSaveData.GetDimensionData()->AddGroupDimension( aGroupDim );
481  }
482  }
483  }
484  break;
485 
486  default:
487  OSL_FAIL( "XclImpPCField::ConvertDateGroupField - unknown date field type" );
488  }
489 }
490 
492 {
493  ScDPNumGroupInfo aNumInfo;
494  aNumInfo.mbEnable = true;
495  aNumInfo.mbDateValues = false;
496  aNumInfo.mbAutoStart = true;
497  aNumInfo.mbAutoEnd = true;
498 
499  if( const double* pfMinValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
500  {
501  aNumInfo.mfStart = *pfMinValue;
503  }
504  if( const double* pfMaxValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
505  {
506  aNumInfo.mfEnd = *pfMaxValue;
508  }
509  if( const double* pfStepValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_STEP ) )
510  aNumInfo.mfStep = *pfStepValue;
511 
512  return aNumInfo;
513 }
514 
516 {
517  ScDPNumGroupInfo aDateInfo;
518  aDateInfo.mbEnable = true;
519  aDateInfo.mbDateValues = false;
520  aDateInfo.mbAutoStart = true;
521  aDateInfo.mbAutoEnd = true;
522 
523  if( const DateTime* pMinDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
524  {
525  aDateInfo.mfStart = GetDoubleFromDateTime( *pMinDate );
527  }
528  if( const DateTime* pMaxDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
529  {
530  aDateInfo.mfEnd = GetDoubleFromDateTime( *pMaxDate );
532  }
533  // GetDateGroupStep() returns a value for date type "day" in single date groups only
534  if( const sal_Int16* pnStepValue = GetDateGroupStep() )
535  {
536  aDateInfo.mfStep = *pnStepValue;
537  aDateInfo.mbDateValues = true;
538  }
539 
540  return aDateInfo;
541 }
542 
543 const double* XclImpPCField::GetNumGroupLimit( sal_uInt16 nLimitIdx ) const
544 {
545  OSL_ENSURE( IsNumGroupField(), "XclImpPCField::GetNumGroupLimit - only for numeric grouping fields" );
546  if( const XclImpPCItem* pItem = GetLimitItem( nLimitIdx ) )
547  {
548  OSL_ENSURE( pItem->GetDouble(), "XclImpPCField::GetNumGroupLimit - SXDOUBLE item expected" );
549  return pItem->GetDouble();
550  }
551  return nullptr;
552 }
553 
554 const DateTime* XclImpPCField::GetDateGroupLimit( sal_uInt16 nLimitIdx ) const
555 {
556  OSL_ENSURE( IsDateGroupField(), "XclImpPCField::GetDateGroupLimit - only for date grouping fields" );
557  if( const XclImpPCItem* pItem = GetLimitItem( nLimitIdx ) )
558  {
559  OSL_ENSURE( pItem->GetDateTime(), "XclImpPCField::GetDateGroupLimit - SXDATETIME item expected" );
560  return pItem->GetDateTime();
561  }
562  return nullptr;
563 }
564 
565 const sal_Int16* XclImpPCField::GetDateGroupStep() const
566 {
567  // only for single date grouping fields, not for grouping chains
568  if( !IsGroupBaseField() && !IsGroupChildField() )
569  {
570  // only days may have a step value, return 0 for all other date types
572  {
573  if( const XclImpPCItem* pItem = GetLimitItem( EXC_SXFIELD_INDEX_STEP ) )
574  {
575  OSL_ENSURE( pItem->GetInteger(), "XclImpPCField::GetDateGroupStep - SXINTEGER item expected" );
576  if( const sal_Int16* pnStep = pItem->GetInteger() )
577  {
578  OSL_ENSURE( *pnStep > 0, "XclImpPCField::GetDateGroupStep - invalid step count" );
579  // return nothing for step count 1 - this is also a standard date group in Excel
580  return (*pnStep > 1) ? pnStep : nullptr;
581  }
582  }
583  }
584  }
585  return nullptr;
586 }
587 
589  XclImpRoot( rRoot ),
590  maSrcRange( ScAddress::INITIALIZE_INVALID ),
591  mnStrmId( 0 ),
592  mnSrcType( EXC_SXVS_UNKNOWN ),
593  mbSelfRef( false )
594 {
595 }
596 
598 {
599 }
600 
601 // data access ----------------------------------------------------------------
602 
603 const XclImpPCField* XclImpPivotCache::GetField( sal_uInt16 nFieldIdx ) const
604 {
605  return (nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr;
606 }
607 
608 // records --------------------------------------------------------------------
609 
611 {
612  mnStrmId = rStrm.ReaduInt16();
613 }
614 
616 {
617  mnSrcType = rStrm.ReaduInt16();
619 }
620 
622 {
623  /* Read DCONREF only once (by checking maTabName), there may be other
624  DCONREF records in another context. Read reference only if a leading
625  SXVS record is present (by checking mnSrcType). */
626  if( !maTabName.isEmpty() || (mnSrcType != EXC_SXVS_SHEET) )
627  return;
628 
629  XclRange aXclRange( ScAddress::UNINITIALIZED );
630  aXclRange.Read( rStrm, false );
631  OUString aEncUrl = rStrm.ReadUniString();
632 
634 
635  /* Do not convert maTabName to Calc sheet name -> original name is used to
636  find the sheet in the document. Sheet index of source range will be
637  found later in XclImpPivotCache::ReadPivotCacheStream(), because sheet
638  may not exist yet. */
639  if( mbSelfRef )
640  GetAddressConverter().ConvertRange( maSrcRange, aXclRange, 0, 0, true );
641 }
642 
644 {
645  maSrcRangeName = rStrm.ReadUniString();
646 
647  // This 2-byte value equals the length of string that follows, or if 0 it
648  // indicates that the name has a workbook scope. For now, we only support
649  // internal defined name with a workbook scope.
650  sal_uInt16 nFlag;
651  nFlag = rStrm.ReaduInt16();
652  mbSelfRef = (nFlag == 0);
653 
654  if (!mbSelfRef)
655  // External name is not supported yet.
656  maSrcRangeName.clear();
657 }
658 
660 {
662  return;
663 
664  ScDocument& rDoc = GetDoc();
665  SCCOL nFieldScCol = 0; // column index of source data for next field
666  SCROW nItemScRow = 0; // row index of source data for current items
667  SCTAB nScTab = 0; // sheet index of source data
668  bool bGenerateSource = false; // true = write source data from cache to dummy table
669 
670  if( mbSelfRef )
671  {
672  if (maSrcRangeName.isEmpty())
673  {
674  // try to find internal sheet containing the source data
676  if( rDoc.HasTable( nScTab ) )
677  {
678  // set sheet index to source range
679  maSrcRange.aStart.SetTab( nScTab );
680  maSrcRange.aEnd.SetTab( nScTab );
681  }
682  else
683  {
684  // create dummy sheet for deleted internal sheet
685  bGenerateSource = true;
686  }
687  }
688  }
689  else
690  {
691  // create dummy sheet for external sheet
692  bGenerateSource = true;
693  }
694 
695  // create dummy sheet for source data from external or deleted sheet
696  if( bGenerateSource )
697  {
698  if( rDoc.GetTableCount() >= MAXTABCOUNT )
699  // cannot create more sheets -> exit
700  return;
701 
702  nScTab = rDoc.GetTableCount();
703  rDoc.MakeTable( nScTab );
704  OUStringBuffer aDummyName("DPCache");
705  if( maTabName.getLength() > 0 )
706  aDummyName.append( '_' ).append( maTabName );
707  OUString aName = aDummyName.makeStringAndClear();
708  rDoc.CreateValidTabName( aName );
709  rDoc.RenameTab( nScTab, aName );
710  // set sheet index to source range
711  maSrcRange.aStart.SetTab( nScTab );
712  maSrcRange.aEnd.SetTab( nScTab );
713  }
714 
715  // open pivot cache storage stream
718  if( !xSvStrm.is() )
719  return;
720 
721  // create Excel record stream object
722  XclImpStream aPCStrm( *xSvStrm, GetRoot() );
723  aPCStrm.CopyDecrypterFrom( rStrm ); // pivot cache streams are encrypted
724 
725  XclImpPCFieldRef xCurrField; // current field for new items
726  XclImpPCFieldVec aOrigFields; // all standard fields with inline original items
727  XclImpPCFieldVec aPostpFields; // all standard fields with postponed original items
728  size_t nPostpIdx = 0; // index to current field with postponed items
729  bool bLoop = true; // true = continue loop
730 
731  while( bLoop && aPCStrm.StartNextRecord() )
732  {
733  switch( aPCStrm.GetRecId() )
734  {
735  case EXC_ID_EOF:
736  bLoop = false;
737  break;
738 
739  case EXC_ID_SXDB:
740  aPCStrm >> maPCInfo;
741  break;
742 
743  case EXC_ID_SXFIELD:
744  {
745  xCurrField.reset();
746  sal_uInt16 nNewFieldIdx = static_cast< sal_uInt16 >( maFields.size() );
747  if( nNewFieldIdx < EXC_PC_MAXFIELDCOUNT )
748  {
749  xCurrField = std::make_shared<XclImpPCField>( GetRoot(), *this, nNewFieldIdx );
750  maFields.push_back( xCurrField );
751  xCurrField->ReadSxfield( aPCStrm );
752  if( xCurrField->HasOrigItems() )
753  {
754  if( xCurrField->HasPostponedItems() )
755  aPostpFields.push_back( xCurrField );
756  else
757  aOrigFields.push_back( xCurrField );
758  // insert field name into generated source data, field remembers its column index
759  if( bGenerateSource && (nFieldScCol <= rDoc.MaxCol()) )
760  xCurrField->WriteFieldNameToSource( nFieldScCol++, nScTab );
761  }
762  // do not read items into invalid/postponed fields
763  if( !xCurrField->HasInlineItems() )
764  xCurrField.reset();
765  }
766  }
767  break;
768 
769  case EXC_ID_SXINDEXLIST:
770  // read index list and insert all items into generated source data
771  if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) && (++nItemScRow <= rDoc.MaxRow()) )
772  {
773  for( const auto& rxOrigField : aOrigFields )
774  {
775  sal_uInt16 nItemIdx = rxOrigField->Has16BitIndexes() ? aPCStrm.ReaduInt16() : aPCStrm.ReaduInt8();
776  rxOrigField->WriteOrigItemToSource( nItemScRow, nScTab, nItemIdx );
777  }
778  }
779  xCurrField.reset();
780  break;
781 
782  case EXC_ID_SXDOUBLE:
783  case EXC_ID_SXBOOLEAN:
784  case EXC_ID_SXERROR:
785  case EXC_ID_SXINTEGER:
786  case EXC_ID_SXSTRING:
787  case EXC_ID_SXDATETIME:
788  case EXC_ID_SXEMPTY:
789  if( xCurrField ) // inline items
790  {
791  xCurrField->ReadItem( aPCStrm );
792  }
793  else if( !aPostpFields.empty() ) // postponed items
794  {
795  // read postponed item
796  aPostpFields[ nPostpIdx ]->ReadItem( aPCStrm );
797  // write item to source
798  if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) )
799  {
800  // start new row, if there are only postponed fields
801  if( aOrigFields.empty() && (nPostpIdx == 0) )
802  ++nItemScRow;
803  if( nItemScRow <= rDoc.MaxRow() )
804  aPostpFields[ nPostpIdx ]->WriteLastOrigItemToSource( nItemScRow, nScTab );
805  }
806  // get index of next postponed field
807  ++nPostpIdx;
808  if( nPostpIdx >= aPostpFields.size() )
809  nPostpIdx = 0;
810  }
811  break;
812 
813  case EXC_ID_SXNUMGROUP:
814  if( xCurrField )
815  xCurrField->ReadSxnumgroup( aPCStrm );
816  break;
817 
818  case EXC_ID_SXGROUPINFO:
819  if( xCurrField )
820  xCurrField->ReadSxgroupinfo( aPCStrm );
821  break;
822 
823  // known but ignored records
824  case EXC_ID_SXRULE:
825  case EXC_ID_SXFILT:
826  case EXC_ID_00F5:
827  case EXC_ID_SXNAME:
828  case EXC_ID_SXPAIR:
829  case EXC_ID_SXFMLA:
830  case EXC_ID_SXFORMULA:
831  case EXC_ID_SXDBEX:
832  case EXC_ID_SXFDBTYPE:
833  break;
834 
835  default:
836  SAL_WARN("sc.filter", "XclImpPivotCache::ReadPivotCacheStream - unknown record 0x" << std::hex << aPCStrm.GetRecId() );
837  }
838  }
839 
840  OSL_ENSURE( maPCInfo.mnTotalFields == maFields.size(),
841  "XclImpPivotCache::ReadPivotCacheStream - field count mismatch" );
842 
843  if (static_cast<bool>(maPCInfo.mnFlags & EXC_SXDB_SAVEDATA))
844  {
846  maSrcRange.aEnd.SetRow(nNewEnd);
847  }
848 
849  // set source range for external source data
850  if( bGenerateSource && (nFieldScCol > 0) )
851  {
852  maSrcRange.aStart.SetCol( 0 );
853  maSrcRange.aStart.SetRow( 0 );
854  // nFieldScCol points to first unused column
855  maSrcRange.aEnd.SetCol( nFieldScCol - 1 );
856  // nItemScRow points to last used row
857  maSrcRange.aEnd.SetRow( nItemScRow );
858  }
859 }
860 
862 {
863  return static_cast<bool>(maPCInfo.mnFlags & EXC_SXDB_REFRESH_LOAD);
864 }
865 
867 {
868  if (!maSrcRangeName.isEmpty())
869  return true;
870 
871  return maSrcRange.IsValid();
872 }
873 
874 // Pivot table
875 
877  mpCacheField( pCacheField )
878 {
879 }
880 
881 const OUString* XclImpPTItem::GetItemName() const
882 {
883  if( mpCacheField )
884  if( const XclImpPCItem* pCacheItem = mpCacheField->GetItem( maItemInfo.mnCacheIdx ) )
885  //TODO: use XclImpPCItem::ConvertToText(), if all conversions are available
886  return pCacheItem->IsEmpty() ? nullptr : pCacheItem->GetText();
887  return nullptr;
888 }
889 
890 std::pair<bool, OUString> XclImpPTItem::GetItemName(const ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const XclImpRoot& rRoot) const
891 {
892  if(!mpCacheField)
893  return std::pair<bool, OUString>(false, OUString());
894 
895  const XclImpPCItem* pCacheItem = mpCacheField->GetItem( maItemInfo.mnCacheIdx );
896  if(!pCacheItem)
897  return std::pair<bool, OUString>(false, OUString());
898 
899  OUString sItemName;
900  if(pCacheItem->GetType() == EXC_PCITEM_TEXT || pCacheItem->GetType() == EXC_PCITEM_ERROR)
901  {
902  const OUString* pItemName = pCacheItem->GetText();
903  if(!pItemName)
904  return std::pair<bool, OUString>(false, OUString());
905  sItemName = *pItemName;
906  }
907  else if (pCacheItem->GetType() == EXC_PCITEM_DOUBLE)
908  {
909  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), *pCacheItem->GetDouble());
910  }
911  else if (pCacheItem->GetType() == EXC_PCITEM_INTEGER)
912  {
913  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(*pCacheItem->GetInteger()));
914  }
915  else if (pCacheItem->GetType() == EXC_PCITEM_BOOL)
916  {
917  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(*pCacheItem->GetBool()));
918  }
919  else if (pCacheItem->GetType() == EXC_PCITEM_DATETIME)
920  {
921  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), rRoot.GetDoubleFromDateTime(*pCacheItem->GetDateTime()));
922  }
923  else if (pCacheItem->GetType() == EXC_PCITEM_EMPTY)
924  {
925  // sItemName is an empty string
926  }
927  else // EXC_PCITEM_INVALID
928  return std::pair<bool, OUString>(false, OUString());
929 
930  return std::pair<bool, OUString>(true, sItemName);
931 }
932 
934 {
935  rStrm >> maItemInfo;
936 }
937 
938 void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const XclImpRoot& rRoot ) const
939 {
940  // Find member and set properties
941  std::pair<bool, OUString> aReturnedName = GetItemName(rSaveDim, pObj, rRoot);
942  if(aReturnedName.first)
943  {
944  ScDPSaveMember* pMember = rSaveDim.GetExistingMemberByName(aReturnedName.second);
945  if(pMember)
946  {
949  if (maItemInfo.HasVisName())
950  pMember->SetLayoutName(*maItemInfo.GetVisName());
951  }
952  }
953 }
954 
955 XclImpPTField::XclImpPTField( const XclImpPivotTable& rPTable, sal_uInt16 nCacheIdx ) :
956  mrPTable( rPTable )
957 {
958  maFieldInfo.mnCacheIdx = nCacheIdx;
959 }
960 
961 // general field/item access --------------------------------------------------
962 
964 {
966  return xPCache ? xPCache->GetField( maFieldInfo.mnCacheIdx ) : nullptr;
967 }
968 
970 {
971  const XclImpPCField* pField = GetCacheField();
972  return pField ? pField->GetFieldName( mrPTable.GetVisFieldNames() ) : OUString();
973 }
974 
976 {
977  const OUString* pVisName = maFieldInfo.GetVisName();
978  return pVisName ? *pVisName : OUString();
979 }
980 
981 const XclImpPTItem* XclImpPTField::GetItem( sal_uInt16 nItemIdx ) const
982 {
983  return (nItemIdx < maItems.size()) ? maItems[ nItemIdx ].get() : nullptr;
984 }
985 
986 const OUString* XclImpPTField::GetItemName( sal_uInt16 nItemIdx ) const
987 {
988  const XclImpPTItem* pItem = GetItem( nItemIdx );
989  return pItem ? pItem->GetItemName() : nullptr;
990 }
991 
992 // records --------------------------------------------------------------------
993 
995 {
996  rStrm >> maFieldInfo;
997 }
998 
1000 {
1001  rStrm >> maFieldExtInfo;
1002 }
1003 
1005 {
1006  XclImpPTItemRef xItem = std::make_shared<XclImpPTItem>( GetCacheField() );
1007  maItems.push_back( xItem );
1008  xItem->ReadSxvi( rStrm );
1009 }
1010 
1011 // row/column fields ----------------------------------------------------------
1012 
1014 {
1015  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_ROWCOL, "XclImpPTField::ConvertRowColField - no row/column field" );
1016  // special data orientation field?
1019  else
1020  ConvertRCPField( rSaveData );
1021 }
1022 
1023 // page fields ----------------------------------------------------------------
1024 
1026 {
1027  maPageInfo = rPageInfo;
1028 }
1029 
1031 {
1032  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_PAGE, "XclImpPTField::ConvertPageField - no page field" );
1033  ConvertRCPField( rSaveData );
1034 }
1035 
1036 // hidden fields --------------------------------------------------------------
1037 
1039 {
1040  OSL_ENSURE( (maFieldInfo.mnAxes & EXC_SXVD_AXIS_ROWCOLPAGE) == 0, "XclImpPTField::ConvertHiddenField - field not hidden" );
1041  ConvertRCPField( rSaveData );
1042 }
1043 
1044 // data fields ----------------------------------------------------------------
1045 
1047 {
1048  return !maDataInfoVector.empty();
1049 }
1050 
1052 {
1053  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_DATA, "XclImpPTField::AddDataFieldInfo - no data field" );
1054  maDataInfoVector.push_back( rDataInfo );
1055 }
1056 
1058 {
1059  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_DATA, "XclImpPTField::ConvertDataField - no data field" );
1060  OSL_ENSURE( !maDataInfoVector.empty(), "XclImpPTField::ConvertDataField - no data field info" );
1061  if (maDataInfoVector.empty())
1062  return;
1063 
1064  OUString aFieldName = GetFieldName();
1065  if (aFieldName.isEmpty())
1066  return;
1067 
1068  ScDPSaveDimension* pSaveDim = rSaveData.GetNewDimensionByName(aFieldName);
1069  if (!pSaveDim)
1070  {
1071  SAL_WARN("sc.filter","XclImpPTField::ConvertDataField - field name not found: " << aFieldName);
1072  return;
1073  }
1074 
1075  auto aIt = maDataInfoVector.begin(), aEnd = maDataInfoVector.end();
1076 
1077  ConvertDataField( *pSaveDim, *aIt );
1078 
1079  // multiple data fields -> clone dimension
1080  for( ++aIt; aIt != aEnd; ++aIt )
1081  {
1082  ScDPSaveDimension& rDupDim = rSaveData.DuplicateDimension( *pSaveDim );
1083  ConvertDataFieldInfo( rDupDim, *aIt );
1084  }
1085 }
1086 
1087 // private --------------------------------------------------------------------
1088 
1092 static OUString lcl_convertExcelSubtotalName(const OUString& rName)
1093 {
1094  OUStringBuffer aBuf;
1095  const sal_Unicode* p = rName.getStr();
1096  sal_Int32 n = rName.getLength();
1097  for (sal_Int32 i = 0; i < n; ++i)
1098  {
1099  const sal_Unicode c = p[i];
1100  if (c == '\\')
1101  {
1102  aBuf.append(c);
1103  aBuf.append(c);
1104  }
1105  else
1106  aBuf.append(c);
1107  }
1108  return aBuf.makeStringAndClear();
1109 }
1110 
1112 {
1113  const OUString& rFieldName = GetFieldName();
1114  if( rFieldName.isEmpty() )
1115  return;
1116 
1117  const XclImpPCField* pCacheField = GetCacheField();
1118  if( !pCacheField || !pCacheField->IsSupportedField() )
1119  return;
1120 
1121  ScDPSaveDimension* pTest = rSaveData.GetNewDimensionByName(rFieldName);
1122  if (!pTest)
1123  return;
1124 
1125  ScDPSaveDimension& rSaveDim = *pTest;
1126 
1127  // orientation
1129 
1130  // visible name
1131  if (const OUString* pVisName = maFieldInfo.GetVisName())
1132  if (!pVisName->isEmpty())
1133  rSaveDim.SetLayoutName( *pVisName );
1134 
1135  // subtotal function(s)
1136  XclPTSubtotalVec aSubtotalVec;
1137  maFieldInfo.GetSubtotals( aSubtotalVec );
1138  if( !aSubtotalVec.empty() )
1139  rSaveDim.SetSubTotals( aSubtotalVec );
1140 
1141  // sorting
1142  DataPilotFieldSortInfo aSortInfo;
1143  aSortInfo.Field = mrPTable.GetDataFieldName( maFieldExtInfo.mnSortField );
1144  aSortInfo.IsAscending = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SORT_ASC );
1145  aSortInfo.Mode = maFieldExtInfo.GetApiSortMode();
1146  rSaveDim.SetSortInfo( &aSortInfo );
1147 
1148  // auto show
1149  DataPilotFieldAutoShowInfo aShowInfo;
1150  aShowInfo.IsEnabled = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_AUTOSHOW );
1151  aShowInfo.ShowItemsMode = maFieldExtInfo.GetApiAutoShowMode();
1152  aShowInfo.ItemCount = maFieldExtInfo.GetApiAutoShowCount();
1153  aShowInfo.DataField = mrPTable.GetDataFieldName( maFieldExtInfo.mnShowField );
1154  rSaveDim.SetAutoShowInfo( &aShowInfo );
1155 
1156  // layout
1157  DataPilotFieldLayoutInfo aLayoutInfo;
1158  aLayoutInfo.LayoutMode = maFieldExtInfo.GetApiLayoutMode();
1159  aLayoutInfo.AddEmptyLines = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_LAYOUT_BLANK );
1160  rSaveDim.SetLayoutInfo( &aLayoutInfo );
1161 
1162  // grouping info
1163  pCacheField->ConvertGroupField( rSaveData, mrPTable.GetVisFieldNames() );
1164 
1165  // custom subtotal name
1167  {
1169  rSaveDim.SetSubtotalName(aSubName);
1170  }
1171 }
1172 
1173 void XclImpPTField::ConvertFieldInfo( const ScDPSaveData& rSaveData, ScDPObject* pObj, const XclImpRoot& rRoot, bool bPageField ) const
1174 {
1175  const OUString& rFieldName = GetFieldName();
1176  if( rFieldName.isEmpty() )
1177  return;
1178 
1179  const XclImpPCField* pCacheField = GetCacheField();
1180  if( !pCacheField || !pCacheField->IsSupportedField() )
1181  return;
1182 
1183  ScDPSaveDimension* pSaveDim = rSaveData.GetExistingDimensionByName(rFieldName);
1184  if (!pSaveDim)
1185  return;
1186 
1188  for( const auto& rxItem : maItems )
1189  rxItem->ConvertItem( *pSaveDim, pObj, rRoot );
1190 
1191  if(bPageField && maPageInfo.mnSelItem != EXC_SXPI_ALLITEMS)
1192  {
1193  const XclImpPTItem* pItem = GetItem( maPageInfo.mnSelItem );
1194  if(pItem)
1195  {
1196  std::pair<bool, OUString> aReturnedName = pItem->GetItemName(*pSaveDim, pObj, rRoot);
1197  if(aReturnedName.first)
1198  pSaveDim->SetCurrentPage(&aReturnedName.second);
1199  }
1200  }
1201 }
1202 
1204 {
1205  // orientation
1206  rSaveDim.SetOrientation( DataPilotFieldOrientation_DATA );
1207  // extended data field info
1208  ConvertDataFieldInfo( rSaveDim, rDataInfo );
1209 }
1210 
1212 {
1213  // visible name
1214  const OUString* pVisName = rDataInfo.GetVisName();
1215  if (pVisName && !pVisName->isEmpty())
1216  rSaveDim.SetLayoutName(*pVisName);
1217 
1218  // aggregation function
1219  rSaveDim.SetFunction( rDataInfo.GetApiAggFunc() );
1220 
1221  // result field reference
1222  sal_Int32 nRefType = rDataInfo.GetApiRefType();
1223  DataPilotFieldReference aFieldRef;
1224  aFieldRef.ReferenceType = nRefType;
1225  const XclImpPTField* pRefField = mrPTable.GetField(rDataInfo.mnRefField);
1226  if (pRefField)
1227  {
1228  aFieldRef.ReferenceField = pRefField->GetFieldName();
1229  aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
1230  if (aFieldRef.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
1231  {
1232  const OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem);
1233  if (pRefItemName)
1234  aFieldRef.ReferenceItemName = *pRefItemName;
1235  }
1236  }
1237 
1238  rSaveDim.SetReferenceValue(&aFieldRef);
1239 }
1240 
1242  XclImpRoot( rRoot ),
1243  maDataOrientField( *this, EXC_SXIVD_DATA ),
1244  mpDPObj(nullptr)
1245 {
1246 }
1247 
1249 {
1250 }
1251 
1252 // cache/field access, misc. --------------------------------------------------
1253 
1255 {
1256  return static_cast< sal_uInt16 >( maFields.size() );
1257 }
1258 
1259 const XclImpPTField* XclImpPivotTable::GetField( sal_uInt16 nFieldIdx ) const
1260 {
1261  return (nFieldIdx == EXC_SXIVD_DATA) ? &maDataOrientField :
1262  ((nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr);
1263 }
1264 
1266 {
1267  // do not return maDataOrientField
1268  return (nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr;
1269 }
1270 
1271 const XclImpPTField* XclImpPivotTable::GetDataField( sal_uInt16 nDataFieldIdx ) const
1272 {
1273  if( nDataFieldIdx < maOrigDataFields.size() )
1274  return GetField( maOrigDataFields[ nDataFieldIdx ] );
1275  return nullptr;
1276 }
1277 
1278 OUString XclImpPivotTable::GetDataFieldName( sal_uInt16 nDataFieldIdx ) const
1279 {
1280  if( const XclImpPTField* pField = GetDataField( nDataFieldIdx ) )
1281  return pField->GetFieldName();
1282  return OUString();
1283 }
1284 
1285 // records --------------------------------------------------------------------
1286 
1288 {
1289  rStrm >> maPTInfo;
1290 
1292  maOutScRange, maPTInfo.maOutXclRange, GetCurrScTab(), GetCurrScTab(), true );
1293 
1294  mxPCache = GetPivotTableManager().GetPivotCache( maPTInfo.mnCacheIdx );
1295  mxCurrField.reset();
1296 }
1297 
1299 {
1300  sal_uInt16 nFieldCount = GetFieldCount();
1301  if( nFieldCount < EXC_PT_MAXFIELDCOUNT )
1302  {
1303  // cache index for the field is equal to the SXVD record index
1304  mxCurrField = std::make_shared<XclImpPTField>( *this, nFieldCount );
1305  maFields.push_back( mxCurrField );
1306  mxCurrField->ReadSxvd( rStrm );
1307  // add visible name of new field to list of visible names
1308  maVisFieldNames.push_back( mxCurrField->GetVisFieldName() );
1309  OSL_ENSURE( maFields.size() == maVisFieldNames.size(),
1310  "XclImpPivotTable::ReadSxvd - wrong size of visible name array" );
1311  }
1312  else
1313  mxCurrField.reset();
1314 }
1315 
1317 {
1318  if( mxCurrField )
1319  mxCurrField->ReadSxvi( rStrm );
1320 }
1321 
1323 {
1324  if( mxCurrField )
1325  mxCurrField->ReadSxvdex( rStrm );
1326 }
1327 
1329 {
1330  mxCurrField.reset();
1331 
1332  // find the index vector to fill (row SXIVD doesn't exist without row fields)
1333  ScfUInt16Vec* pFieldVec = nullptr;
1334  if( maRowFields.empty() && (maPTInfo.mnRowFields > 0) )
1335  pFieldVec = &maRowFields;
1336  else if( maColFields.empty() && (maPTInfo.mnColFields > 0) )
1337  pFieldVec = &maColFields;
1338 
1339  // fill the vector from record data
1340  if( !pFieldVec )
1341  return;
1342 
1343  sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 2, EXC_PT_MAXROWCOLCOUNT );
1344  pFieldVec->reserve( nSize );
1345  for( sal_uInt16 nIdx = 0; nIdx < nSize; ++nIdx )
1346  {
1347  sal_uInt16 nFieldIdx;
1348  nFieldIdx = rStrm.ReaduInt16();
1349  pFieldVec->push_back( nFieldIdx );
1350 
1351  // set orientation at special data orientation field
1352  if( nFieldIdx == EXC_SXIVD_DATA )
1353  {
1354  sal_uInt16 nAxis = (pFieldVec == &maRowFields) ? EXC_SXVD_AXIS_ROW : EXC_SXVD_AXIS_COL;
1355  maDataOrientField.SetAxes( nAxis );
1356  }
1357  }
1358 }
1359 
1361 {
1362  mxCurrField.reset();
1363 
1364  sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 6 );
1365  for( sal_uInt16 nEntry = 0; nEntry < nSize; ++nEntry )
1366  {
1367  XclPTPageFieldInfo aPageInfo;
1368  rStrm >> aPageInfo;
1369  if( XclImpPTField* pField = GetFieldAcc( aPageInfo.mnField ) )
1370  {
1371  maPageFields.push_back( aPageInfo.mnField );
1372  pField->SetPageFieldInfo( aPageInfo );
1373  }
1374  GetCurrSheetDrawing().SetSkipObj( aPageInfo.mnObjId );
1375  }
1376 }
1377 
1379 {
1380  mxCurrField.reset();
1381 
1382  XclPTDataFieldInfo aDataInfo;
1383  rStrm >> aDataInfo;
1384  if( XclImpPTField* pField = GetFieldAcc( aDataInfo.mnField ) )
1385  {
1386  maOrigDataFields.push_back( aDataInfo.mnField );
1387  // DataPilot does not support double data fields -> add first appearance to index list only
1388  if( !pField->HasDataFieldInfo() )
1389  maFiltDataFields.push_back( aDataInfo.mnField );
1390  pField->AddDataFieldInfo( aDataInfo );
1391  }
1392 }
1393 
1395 {
1396  rStrm >> maPTExtInfo;
1397 }
1398 
1400 {
1401  rStrm >> maPTViewEx9Info;
1402 }
1403 
1405 {
1406  rStrm >> maPTAddlInfo;
1407 }
1408 
1410 {
1411  if( !mxPCache || !mxPCache->IsValid() )
1412  return;
1413 
1414  if (utl::ConfigManager::IsFuzzing()) //just too slow
1415  return;
1416 
1417  ScDPSaveData aSaveData;
1418 
1419  // *** global settings ***
1420 
1423  aSaveData.SetFilterButton( false );
1425  aSaveData.SetIgnoreEmptyRows( false );
1426  aSaveData.SetRepeatIfEmpty( false );
1427 
1428  // *** fields ***
1429 
1430  // row fields
1431  for( const auto& rRowField : maRowFields )
1432  if( const XclImpPTField* pField = GetField( rRowField ) )
1433  pField->ConvertRowColField( aSaveData );
1434 
1435  // column fields
1436  for( const auto& rColField : maColFields )
1437  if( const XclImpPTField* pField = GetField( rColField ) )
1438  pField->ConvertRowColField( aSaveData );
1439 
1440  // page fields
1441  for( const auto& rPageField : maPageFields )
1442  if( const XclImpPTField* pField = GetField( rPageField ) )
1443  pField->ConvertPageField( aSaveData );
1444 
1445  // We need to import hidden fields because hidden fields may contain
1446  // special settings for subtotals (aggregation function, filters, custom
1447  // name etc.) and members (hidden, custom name etc.).
1448 
1449  // hidden fields
1450  for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1451  if( const XclImpPTField* pField = GetField( nField ) )
1452  if (!pField->GetAxes())
1453  pField->ConvertHiddenField( aSaveData );
1454 
1455  // data fields
1456  for( const auto& rFiltDataField : maFiltDataFields )
1457  if( const XclImpPTField* pField = GetField( rFiltDataField ) )
1458  pField->ConvertDataField( aSaveData );
1459 
1460  // *** insert into Calc document ***
1461 
1462  // create source descriptor
1463  ScSheetSourceDesc aDesc(&GetDoc());
1464  const OUString& rSrcName = mxPCache->GetSourceRangeName();
1465  if (!rSrcName.isEmpty())
1466  // Range name is the data source.
1467  aDesc.SetRangeName(rSrcName);
1468  else
1469  // Normal cell range.
1470  aDesc.SetSourceRange(mxPCache->GetSourceRange());
1471 
1472  // adjust output range to include the page fields
1473  ScRange aOutRange( maOutScRange );
1474  if( !maPageFields.empty() )
1475  {
1476  SCROW nDecRows = ::std::min< SCROW >( aOutRange.aStart.Row(), maPageFields.size() + 1 );
1477  aOutRange.aStart.IncRow( -nDecRows );
1478  }
1479 
1480  // create the DataPilot
1481  std::unique_ptr<ScDPObject> pDPObj(new ScDPObject( &GetDoc() ));
1482  pDPObj->SetName( maPTInfo.maTableName );
1483  if (!maPTInfo.maDataName.isEmpty())
1485 
1486  if (!maPTViewEx9Info.maGrandTotalName.isEmpty())
1488 
1489  pDPObj->SetSaveData( aSaveData );
1490  pDPObj->SetSheetDesc( aDesc );
1491  pDPObj->SetOutRange( aOutRange );
1492  pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
1493 
1494  mpDPObj = GetDoc().GetDPCollection()->InsertNewTable(std::move(pDPObj));
1495 
1496  ApplyFieldInfo();
1497  ApplyMergeFlags(aOutRange, aSaveData);
1498 }
1499 
1501 {
1502  if (mpDPObj && mxPCache->IsRefreshOnLoad())
1503  {
1504  // 'refresh table on load' flag is set. Refresh the table now. Some
1505  // Excel files contain partial table output when this flag is set.
1506  ScRange aOutRange = mpDPObj->GetOutRange();
1507  mpDPObj->Output(aOutRange.aStart);
1508  }
1509 }
1510 
1511 void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData)
1512 {
1513  // Apply merge flags for various datapilot controls.
1514 
1515  ScDPOutputGeometry aGeometry(rOutRange, false);
1520 
1521  // Make sure we set headerlayout when input file has additional raw header
1522  if(maPTInfo.mnColFields == 0)
1523  {
1524  mpDPObj->SetHeaderLayout( maPTInfo.mnFirstHeadRow - 2 == static_cast<sal_uInt16>(aGeometry.getRowFieldHeaderRow()) );
1525  }
1526  aGeometry.setHeaderLayout(mpDPObj->GetHeaderLayout());
1528 
1529  ScDocument& rDoc = GetDoc();
1530 
1531  vector<const ScDPSaveDimension*> aFieldDims;
1532  vector<ScAddress> aFieldBtns;
1533 
1534  aGeometry.getPageFieldPositions(aFieldBtns);
1535  for (const auto& rFieldBtn : aFieldBtns)
1536  {
1537  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), ScMF::Button);
1538 
1539  ScMF nMFlag = ScMF::ButtonPopup;
1540  OUString aName = rDoc.GetString(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab());
1541  if (rSaveData.HasInvisibleMember(aName))
1542  nMFlag |= ScMF::HiddenMember;
1543 
1544  rDoc.ApplyFlagsTab(rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1545  }
1546 
1547  aGeometry.getColumnFieldPositions(aFieldBtns);
1548  rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aFieldDims);
1549  if (aFieldBtns.size() == aFieldDims.size())
1550  {
1551  vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1552  for (const auto& rFieldBtn : aFieldBtns)
1553  {
1554  ScMF nMFlag = ScMF::Button;
1555  const ScDPSaveDimension* pDim = *itDim;
1556  if (pDim->HasInvisibleMember())
1557  nMFlag |= ScMF::HiddenMember;
1558  if (!pDim->IsDataLayout())
1559  nMFlag |= ScMF::ButtonPopup;
1560  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1561  ++itDim;
1562  }
1563  }
1564 
1565  aGeometry.getRowFieldPositions(aFieldBtns);
1566  rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aFieldDims);
1567  if (!((aFieldBtns.size() == aFieldDims.size()) || (maPTAddlInfo.mbCompactMode && aFieldBtns.size() == 1)))
1568  return;
1569 
1570  vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1571  for (const auto& rFieldBtn : aFieldBtns)
1572  {
1573  ScMF nMFlag = ScMF::Button;
1574  const ScDPSaveDimension* pDim = itDim != aFieldDims.end() ? *itDim++ : nullptr;
1575  if (pDim && pDim->HasInvisibleMember())
1576  nMFlag |= ScMF::HiddenMember;
1577  if (!pDim || !pDim->IsDataLayout())
1578  nMFlag |= ScMF::ButtonPopup;
1579  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1580  }
1581 }
1582 
1583 
1585 {
1587  ScDPSaveData& rSaveData = *mpDPObj->GetSaveData();
1588 
1589  // row fields
1590  for( const auto& rRowField : maRowFields )
1591  if( const XclImpPTField* pField = GetField( rRowField ) )
1592  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1593 
1594  // column fields
1595  for( const auto& rColField : maColFields )
1596  if( const XclImpPTField* pField = GetField( rColField ) )
1597  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1598 
1599  // page fields
1600  for( const auto& rPageField : maPageFields )
1601  if( const XclImpPTField* pField = GetField( rPageField ) )
1602  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this, true );
1603 
1604  // hidden fields
1605  for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1606  if( const XclImpPTField* pField = GetField( nField ) )
1607  if (!pField->GetAxes())
1608  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1609 }
1610 
1612  XclImpRoot( rRoot )
1613 {
1614 }
1615 
1617 {
1618 }
1619 
1620 // pivot cache records --------------------------------------------------------
1621 
1623 {
1624  XclImpPivotCacheRef xPCache;
1625  if( nCacheIdx < maPCaches.size() )
1626  xPCache = maPCaches[ nCacheIdx ];
1627  return xPCache;
1628 }
1629 
1631 {
1632  XclImpPivotCacheRef xPCache = std::make_shared<XclImpPivotCache>( GetRoot() );
1633  maPCaches.push_back( xPCache );
1634  xPCache->ReadSxidstm( rStrm );
1635 }
1636 
1638 {
1639  if( !maPCaches.empty() )
1640  maPCaches.back()->ReadSxvs( rStrm );
1641 }
1642 
1644 {
1645  if( !maPCaches.empty() )
1646  maPCaches.back()->ReadDconref( rStrm );
1647 }
1648 
1650 {
1651  if( !maPCaches.empty() )
1652  maPCaches.back()->ReadDConName( rStrm );
1653 }
1654 
1655 // pivot table records --------------------------------------------------------
1656 
1658 {
1659  XclImpPivotTableRef xPTable = std::make_shared<XclImpPivotTable>( GetRoot() );
1660  maPTables.push_back( xPTable );
1661  xPTable->ReadSxview( rStrm );
1662 }
1663 
1665 {
1666  if( !maPTables.empty() )
1667  maPTables.back()->ReadSxvd( rStrm );
1668 }
1669 
1671 {
1672  if( !maPTables.empty() )
1673  maPTables.back()->ReadSxvdex( rStrm );
1674 }
1675 
1677 {
1678  if( !maPTables.empty() )
1679  maPTables.back()->ReadSxivd( rStrm );
1680 }
1681 
1683 {
1684  if( !maPTables.empty() )
1685  maPTables.back()->ReadSxpi( rStrm );
1686 }
1687 
1689 {
1690  if( !maPTables.empty() )
1691  maPTables.back()->ReadSxdi( rStrm );
1692 }
1693 
1695 {
1696  if( !maPTables.empty() )
1697  maPTables.back()->ReadSxvi( rStrm );
1698 }
1699 
1701 {
1702  if( !maPTables.empty() )
1703  maPTables.back()->ReadSxex( rStrm );
1704 }
1705 
1707 {
1708  if( !maPTables.empty() )
1709  maPTables.back()->ReadSxViewEx9( rStrm );
1710 }
1711 
1713 {
1714  if( !maPTables.empty() )
1715  maPTables.back()->ReadSxAddl( rStrm );
1716 }
1717 
1719 {
1720  for( auto& rxPCache : maPCaches )
1721  rxPCache->ReadPivotCacheStream( rStrm );
1722 }
1723 
1725 {
1726  for( auto& rxPTable : maPTables )
1727  rxPTable->Convert();
1728 }
1729 
1731 {
1732  for( auto& rxPTable : maPTables )
1733  rxPTable->MaybeRefresh();
1734 }
1735 
1736 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 mnFlags
Definition: xlpivot.hxx:623
sal_uInt16 mnRefItem
Index to SXVD of referred field used for the results.
Definition: xlpivot.hxx:679
bool is() const
SC_DLLPUBLIC void SetRepeatIfEmpty(bool bSet)
Definition: dpsave.cxx:998
XclPTPageFieldInfo maPageInfo
Extended field info (SXVDEX record).
Definition: xipivot.hxx:286
bool IsStdGroupField() const
Returns true, if this field is a grouping field.
Definition: xlpivot.cxx:303
OUString GetDataFieldName(sal_uInt16 nDataFieldIdx) const
Definition: xipivot.cxx:1278
sal_uInt16 mnFlags
Type of the item (e.g. data, function, grand total).
Definition: xlpivot.hxx:578
const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK
Definition: xlpivot.hxx:339
std::vector< XclImpPTFieldRef > maFields
Definition: xipivot.hxx:352
const size_t EXC_PC_MAXFIELDCOUNT
Definition: xlpivot.hxx:46
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing a new field.
Definition: xipivot.cxx:1298
const sal_uInt16 EXC_SXFIELD_DATA_DBL
Only integers, opt. with doubles.
Definition: xlpivot.hxx:236
const sal_uInt16 EXC_ID_00F5
Definition: xlpivot.hxx:319
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:292
SCCOL mnSourceScCol
List of items containing numeric grouping limits.
Definition: xipivot.hxx:137
OUString maTabName
URL of the source data.
Definition: xipivot.hxx:185
ScAddress aStart
Definition: address.hxx:500
SC_DLLPUBLIC bool HasInvisibleMember(const OUString &rDimName) const
Check whether a dimension has one or more invisible members.
Definition: dpsave.cxx:1295
void ReadSxidstm(XclImpStream &rStrm)
Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache.
Definition: xipivot.cxx:610
const sal_uInt16 EXC_SXFIELD_DATA_NONE
Definition: xlpivot.hxx:233
const OUString * GetVisName() const
Returns the name, if set explicitly (maVisName.mbUseCache is false).
Definition: xlpivot.cxx:420
LanguageType GetDocLanguage() const
Returns the document language.
Definition: xlroot.hxx:150
void ReadPivotCacheStream(const XclImpStream &rStrm)
Reads the entire pivot cache stream.
Definition: xipivot.cxx:659
static XclBoolError ErrorToEnum(double &rfDblValue, bool bErrOrBool, sal_uInt8 nValue)
Gets a translated error code or Boolean value from Excel error codes.
Definition: xltools.cxx:246
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of the current field.
Definition: xipivot.cxx:1694
void ReadSxAddl(XclImpStream &rStrm)
Reads an SXADDL record that specifies additional info for pivot table.
Definition: xipivot.cxx:1404
void ConvertDateGroupField(ScDPSaveData &rSaveData, const ScfStringVec &rVisNames) const
Inserts date grouping information of this field into the passed ScDPSaveData.
Definition: xipivot.cxx:447
XclImpPivotTableManager & GetPivotTableManager() const
Returns the pivot table manager.
Definition: xiroot.cxx:230
void ReadSxpi(XclImpStream &rStrm)
Reads an SXPI record containing page field data.
Definition: xipivot.cxx:1682
const sal_uInt16 EXC_SXVS_EXTERN
Definition: xlpivot.hxx:301
void SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
Definition: dpsave.cxx:317
XclPTViewEx9Info maPTViewEx9Info
Extended info about the pivot table (SXEX record).
Definition: xipivot.hxx:349
OUString GetFieldName() const
Returns the name of this field that is used to create the Calc dimensions.
Definition: xipivot.cxx:969
std::optional< OUString > mpFieldTotalName
Definition: xlpivot.hxx:627
sal_uInt16 GetRecId() const
Returns the current record ID.
Definition: xistream.hxx:354
SCROW Row() const
Definition: address.hxx:262
std::shared_ptr< XclImpPCItem > XclImpPCItemRef
Definition: xipivot.hxx:59
const sal_uInt32 EXC_SXVDEX_AUTOSHOW
Definition: xlpivot.hxx:336
void ConvertPageField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1030
void ReadSxpi(XclImpStream &rStrm)
Reads an SXPI record containing page field data.
Definition: xipivot.cxx:1360
std::vector< XclImpPivotTableRef > maPTables
List of all pivot caches.
Definition: xipivot.hxx:425
void ReadSxfield(XclImpStream &rStrm)
Reads the SXFIELD record describing the field.
Definition: xipivot.cxx:245
void Convert()
Inserts the pivot table into the Calc document.
Definition: xipivot.cxx:1409
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of the current field.
Definition: xipivot.cxx:1322
int SetError()
void AddNumGroupDimension(const ScDPSaveNumGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:590
sal_uInt16 mnCacheIdx
Number of items of this field.
Definition: xlpivot.hxx:598
void ReadSxidstm(XclImpStream &rStrm)
Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache.
Definition: xipivot.cxx:1630
sal_uInt16 mnRefField
Result reference type.
Definition: xlpivot.hxx:678
const sal_uInt16 EXC_SXPI_ALLITEMS
Definition: xlpivot.hxx:173
void WriteLastOrigItemToSource(SCROW nScRow, SCTAB nScTab)
Inserts the data of the last inserted item into the document.
Definition: xipivot.cxx:237
const sal_uInt16 EXC_SXVI_HIDDEN
Definition: xlpivot.hxx:156
ScfStringVec maVisFieldNames
Current field for importing additional info.
Definition: xipivot.hxx:354
sal_Int32 GetApiLayoutMode() const
Returns the API constant representing the layout mode.
Definition: xlpivot.cxx:616
void AddGroupDimension(const ScDPSaveGroupDimension &rGroupDim)
Definition: dpdimsave.cxx:564
SC_DLLPUBLIC ScDPDimensionSaveData * GetDimensionData()
Definition: dpsave.cxx:1195
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5012
XclPTFieldInfo maFieldInfo
Parent pivot table containing this field.
Definition: xipivot.hxx:284
const ScfStringVec & GetVisFieldNames() const
Definition: xipivot.hxx:302
sal_uInt16 mnColFields
Number of row fields.
Definition: xlpivot.hxx:718
sal_Int64 n
void TracePivotDataSource(bool bExternal)
Definition: xltracer.cxx:97
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:360
XclImpPTField(const XclImpPivotTable &rPTable, sal_uInt16 nCacheIdx)
Definition: xipivot.cxx:955
OUString maSrcRangeName
Sheet name of the source data.
Definition: xipivot.hxx:186
XclPTFieldExtInfo maFieldExtInfo
General field info (SXVD record).
Definition: xipivot.hxx:285
const sal_uInt16 EXC_SXVD_AXIS_ROWCOLPAGE
Definition: xlpivot.hxx:117
const sal_uInt16 EXC_SXFIELD_DATA_DATE
Only strings and doubles, nothing else.
Definition: xlpivot.hxx:239
const sal_uInt16 EXC_ID_SXRULE
Definition: xlpivot.hxx:307
sal_uInt16 mnFieldIdx
Type of this pivot cache field.
Definition: xlpivot.hxx:518
aBuf
XclImpPCItemVec maItems
Parent pivot cache containing this field.
Definition: xipivot.hxx:134
sal_uInt16 mnCacheIdx
Several flags.
Definition: xlpivot.hxx:579
std::shared_ptr< XclImpPCField > XclImpPCFieldRef
Definition: xipivot.hxx:141
const sal_uInt16 EXC_SXFIELD_DATA_DATE_EMP
Only dates, nothing else.
Definition: xlpivot.hxx:240
void setColumnFieldCount(sal_uInt32 nCount)
const sal_Int16 * GetDateGroupStep() const
Returns the step value for date grouping fields.
Definition: xipivot.cxx:565
sal_uInt16 mnGroupItems
Number of visible items for this field.
Definition: xlpivot.hxx:443
Numeric grouping field.
Definition: xlpivot.hxx:86
ScAddress aEnd
Definition: address.hxx:501
void GetSubtotals(XclPTSubtotalVec &rSubtotals) const
Returns a vector of all set subtotal functions.
Definition: xlpivot.cxx:499
const sal_uInt16 EXC_SXVD_AXIS_COL
Definition: xlpivot.hxx:113
static OUString GetHexStr(sal_uInt16 nValue)
Returns a string representing the hexadecimal value of nValue.
Definition: ftools.cxx:117
Standard field without grouping.
Definition: xlpivot.hxx:84
void ReadSxAddl(XclImpStream &rStrm)
Reads an SXADDL record that specifies additional info for pivot table.
Definition: xipivot.cxx:1712
ScDPSaveMember * GetExistingMemberByName(const OUString &rName)
Definition: dpsave.cxx:448
ScDPNumGroupInfo GetScDateGroupInfo() const
Returns a Calc struct with date grouping data.
Definition: xipivot.cxx:515
DateTime GetDateTime(const css::util::DateTime &_rDT)
const sal_uInt16 EXC_ID_SXINDEXLIST
List index for step item in groupings.
Definition: xlpivot.hxx:249
void ReadSxempty(XclImpStream &rStrm)
Reads an SXEMPTY record describing an empty item.
Definition: xipivot.cxx:174
XclImpPivotTable(const XclImpRoot &rRoot)
Definition: xipivot.cxx:1241
bool IsDataLayout() const
Definition: dpsave.hxx:142
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:276
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:313
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4757
Accessor class to ScDocument.
sal_uInt16 mnSrcType
Pivot cache stream identifier.
Definition: xipivot.hxx:188
Represents a field in a pivot cache.
Definition: xlpivot.hxx:477
tools::SvRef< SotStorage > OpenStorage(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrgName) const
Tries to open a storage as child of the specified storage for reading or writing. ...
Definition: xlroot.cxx:252
void WriteFieldNameToSource(SCCOL nScCol, SCTAB nScTab)
Inserts the field name into the document.
Definition: xipivot.cxx:224
void ConvertDataField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1057
const XclImpPTItem * GetItem(sal_uInt16 nItemIdx) const
Returns the specified item.
Definition: xipivot.cxx:981
bool HasInvisibleMember() const
Definition: dpsave.cxx:622
SC_DLLPUBLIC void SetIsVisible(bool bSet)
Definition: dpsave.cxx:95
sal_uInt16 mnFlags
Number of columns containing data.
Definition: xlpivot.hxx:723
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:132
void ReadItem(XclImpStream &rStrm)
Reads an item data record describing a new item.
Definition: xipivot.cxx:343
XclImpPivotCacheRef mxPCache
Definition: xipivot.hxx:345
void ReadSxvs(XclImpStream &rStrm)
Reads an SXVS record containing the source type of a pivot cache.
Definition: xipivot.cxx:1637
sal_Int32 GetApiSortMode() const
Returns the API constant representing the sorting mode.
Definition: xlpivot.cxx:579
void SetPageFieldInfo(const XclPTPageFieldInfo &rPageInfo)
Definition: xipivot.cxx:1025
virtual ~XclImpPivotCache() override
Definition: xipivot.cxx:597
const sal_uInt16 EXC_SXVI_HIDEDETAIL
Definition: xlpivot.hxx:157
SC_DLLPUBLIC void GetAllDimensionsByOrientation(css::sheet::DataPilotFieldOrientation eOrientation, std::vector< const ScDPSaveDimension * > &rDims) const
Get all dimensions in a given orientation.
Definition: dpsave.cxx:807
void ConvertDataFieldInfo(ScDPSaveDimension &rSaveDim, const XclPTDataFieldInfo &rDataInfo) const
Definition: xipivot.cxx:1211
XclImpPCItem(XclImpStream &rStrm)
Definition: xipivot.cxx:67
ScGeneralFunction GetApiAggFunc() const
Returns the API enum representing the aggregation function.
Definition: xlpivot.cxx:710
sal_uInt16 sal_Unicode
const sal_uInt16 EXC_ID_SXGROUPINFO
Definition: xlpivot.hxx:291
SC_DLLPUBLIC void SetSourceRange(const ScRange &rRange)
Definition: dpshttab.cxx:223
Special state, not used in Excel files.
Definition: xlpivot.hxx:71
ScfUInt16Vec maGroupOrder
Own field index in pivot cache.
Definition: xlpivot.hxx:519
const sal_uInt16 EXC_SXFIELD_INDEX_STEP
List index for maximum item in groupings.
Definition: xlpivot.hxx:246
const XclImpPivotCacheRef & GetPivotCache() const
Definition: xipivot.hxx:301
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:853
bool IsValid() const
Definition: xipivot.cxx:866
const ScRange & GetOutRange() const
Definition: dpobject.cxx:409
void ReadDconref(XclImpStream &rStrm)
Reads a DCONREF record containing the source range of a pivot cache.
Definition: xipivot.cxx:1643
const sal_uInt16 EXC_SXVS_SHEET
Definition: xlpivot.hxx:300
XclImpPTField * GetFieldAcc(sal_uInt16 nFieldIdx)
Definition: xipivot.cxx:1265
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:873
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
ReturnType ulimit_cast(Type nValue, ReturnType nMax)
Returns the value, if it is not greater than nMax, otherwise nMax.
Definition: ftools.hxx:51
void getRowFieldPositions(::std::vector< ScAddress > &rAddrs) const
static bool IsFuzzing()
XclPTItemInfo maItemInfo
Definition: xipivot.hxx:215
int nCount
const sal_uInt16 EXC_SXVD_AXIS_DATA
Definition: xlpivot.hxx:115
const sal_uInt16 EXC_SXFIELD_INDEX_MAX
List index for minimum item in groupings.
Definition: xlpivot.hxx:245
sal_uInt16 mnDataFields
Number of page fields.
Definition: xlpivot.hxx:720
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3486
void ReadSxdatetime(XclImpStream &rStrm)
Reads an SXDATETIME record describing a date/time item.
Definition: xipivot.cxx:160
const sal_uInt16 EXC_SXNUMGROUP_TYPE_DAY
Definition: xlpivot.hxx:284
ExcelToSc & GetOldFmlaConverter() const
Returns the old formula converter.
Definition: xiroot.cxx:129
std::shared_ptr< XclImpPivotTable > XclImpPivotTableRef
Definition: xipivot.hxx:365
String data.
Definition: xlpivot.hxx:73
const sal_uInt16 EXC_ID_SXNAME
Unknown record.
Definition: xlpivot.hxx:322
16-bit integer value.
Definition: xlpivot.hxx:76
const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX
Definition: xlpivot.hxx:279
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:191
SCTAB Tab() const
Definition: address.hxx:271
bool StartNextRecord()
Sets stream pointer to the start of the next record content.
Definition: xistream.cxx:455
void SetRow(SCROW nRowP)
Definition: address.hxx:275
sal_uInt16 mnShowField
Index to data field sorting bases on.
Definition: xlpivot.hxx:625
bool IsRefreshOnLoad() const
Definition: xipivot.cxx:861
sal_Int32 GetScDateType() const
Definition: xlpivot.cxx:225
sal_uInt16 mnGroupBase
Field containing grouping info for this field.
Definition: xlpivot.hxx:441
const sal_uInt32 EXC_SXEX_DRILLDOWN
Definition: xlpivot.hxx:312
OUString maGrandTotalName
0 == gridlayout, 0x10 == modern
Definition: xlpivot.hxx:757
Contains data for a pivot table page field (part of SXPI record).
Definition: xlpivot.hxx:658
Standard grouping field.
Definition: xlpivot.hxx:85
First date grouping field (opt. with child grouping field).
Definition: xlpivot.hxx:87
::std::vector< ScGeneralFunction > XclPTSubtotalVec
Definition: xlpivot.hxx:589
void setPageFieldCount(sal_uInt32 nCount)
void ReadDConName(XclImpStream &rStrm)
Read DECONNAME record which contains the defined name of the source range.
Definition: xipivot.cxx:643
void Output(const ScAddress &rPos)
Definition: dpobject.cxx:888
void SetCol(SCCOL nColP)
Definition: address.hxx:279
void ReadSxex(XclImpStream &rStrm)
Reads an SXEX record containing additional settings for a pivot table.
Definition: xipivot.cxx:1700
void SetFunction(ScGeneralFunction nNew)
Definition: dpsave.cxx:343
const OUString * GetText() const
Returns pointer to text, if the item type is 'text', otherwise 0.
Definition: xlpivot.cxx:135
void ReadSxivd(XclImpStream &rStrm)
Reads an SXIVD record containing the row field or column field order.
Definition: xipivot.cxx:1328
sal_Int16 ReadInt16()
Definition: xistream.cxx:630
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing the field.
Definition: xipivot.cxx:994
std::size_t GetRecSize()
Returns the data size of the whole record without record headers.
Definition: xistream.cxx:568
const sal_uInt16 EXC_ID_SXSTRING
Definition: xlpivot.hxx:264
bool GetHeaderLayout() const
Definition: dpobject.hxx:147
const sal_uInt16 EXC_ID_SXDATETIME
Definition: xlpivot.hxx:267
Floating-point value.
Definition: xlpivot.hxx:74
sal_uInt16 mnFlags
Definition: xlpivot.hxx:458
void SetLayoutName(const OUString &rName)
Definition: dpsave.cxx:379
XclImpPTItem(const XclImpPCField *pCacheField)
Definition: xipivot.cxx:876
void ReadSxgroupinfo(XclImpStream &rStrm)
Reads the SXGROUPINFO record describing the item order in grouping fields.
Definition: xipivot.cxx:377
const sal_uInt16 EXC_SXFIELD_NUMGROUP
Definition: xlpivot.hxx:228
ScDPNumGroupInfo GetScNumGroupInfo() const
Returns a Calc struct with numeric grouping data.
Definition: xipivot.cxx:491
void ReadSxboolean(XclImpStream &rStrm)
Reads an SXBOOLEAN record describing a boolean item.
Definition: xipivot.cxx:136
XclImpPivotCache & mrPCache
Definition: xipivot.hxx:133
const sal_uInt16 EXC_SXDB_REFRESH_LOAD
Definition: xlpivot.hxx:208
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
ScfUInt16Vec maRowFields
Vector containing all visible field names.
Definition: xipivot.hxx:355
const sal_uInt16 EXC_SXFIELD_HASCHILD
Definition: xlpivot.hxx:227
void SetHeaderLayout(bool bUseGrid)
Definition: dpobject.cxx:396
sal_uInt16 mnFlags
Stream identifier.
Definition: xlpivot.hxx:530
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:872
void ReadDConName(XclImpStream &rStrm)
Definition: xipivot.cxx:1649
ScRange maSrcRange
List of pivot cache fields.
Definition: xipivot.hxx:183
void ReadSxViewEx9(XclImpStream &rStrm)
Reads an SXVIEWEX9 record that specifies the pivot tables autoformat.
Definition: xipivot.cxx:1706
dp button with popup arrow
const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE]
void Read(XclImpStream &rStrm, bool bCol16Bit=true)
Definition: xladdress.cxx:46
bool HasVisName() const
The displayed name of the item.
Definition: xlpivot.hxx:565
void ConvertStdGroupField(ScDPSaveData &rSaveData, const ScfStringVec &rVisNames) const
Inserts standard grouping information of this field into the passed ScDPSaveData. ...
Definition: xipivot.cxx:407
const sal_uInt16 EXC_SXFIELD_HASITEMS
Definition: xlpivot.hxx:224
SC_DLLPUBLIC ScDPSaveDimension * GetNewDimensionByName(const OUString &rName)
Definition: dpsave.cxx:855
sal_uInt32 mnSrcRecs
Definition: xlpivot.hxx:528
Additional date grouping field.
Definition: xlpivot.hxx:88
const sal_uInt16 EXC_ID_SXFMLA
Definition: xlpivot.hxx:328
void SetCurrentPage(const OUString *pPage)
Definition: dpsave.cxx:426
XclImpTabInfo & GetTabInfo() const
Returns the buffer that contains the sheet creation order.
Definition: xiroot.cxx:178
int i
const sal_uInt16 EXC_SXFIELD_CALCED
Definition: xlpivot.hxx:226
Represents a group dimension that introduces a new hierarchy for an existing dimension.
Definition: dpdimsave.hxx:132
const sal_uInt16 EXC_SXDB_SAVEDATA
Definition: xlpivot.hxx:206
ScfUInt16Vec maPageFields
Column field indexes.
Definition: xipivot.hxx:357
void setCompactMode(bool bCompactMode)
SC_DLLPUBLIC void SetLayoutName(const OUString &rName)
Definition: dpsave.cxx:118
OUString GetFormattedString(const OUString &rDimName, const double fValue)
Definition: dpobject.cxx:1429
static OUString lcl_convertExcelSubtotalName(const OUString &rName)
Convert Excel-encoded subtotal name to a Calc-encoded one.
Definition: xipivot.cxx:1092
sal_Int16 SCCOL
Definition: types.hxx:22
XclImpPTField maDataOrientField
Filtered data field indexes.
Definition: xipivot.hxx:360
const XclImpPivotTable & mrPTable
Definition: xipivot.hxx:283
const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN
Definition: xlpivot.hxx:278
Represents a data item in a pivot cache.
Definition: xipivot.hxx:34
XclImpPivotTableManager(const XclImpRoot &rRoot)
Definition: xipivot.cxx:1611
void WriteOrigItemToSource(SCROW nScRow, SCTAB nScTab, sal_uInt16 nItemIdx)
Inserts the specified item data into the document.
Definition: xipivot.cxx:231
sal_uInt16 GetXclDataType() const
Definition: xlpivot.cxx:260
void ConvertPivotTables()
Inserts all pivot tables into the Calc document.
Definition: xipivot.cxx:1724
double GetDoubleFromDateTime(const DateTime &rDateTime) const
Converts a date/time value to a floating-point value.
Definition: xlroot.cxx:332
const sal_uInt16 EXC_SXVIEW_COLGRAND
Definition: xlpivot.hxx:102
const sal_uInt16 EXC_ID_SXDOUBLE
Definition: xlpivot.hxx:252
double ReadDouble()
Definition: xistream.cxx:702
const sal_uInt16 EXC_ID_SXINTEGER
Definition: xlpivot.hxx:261
autofilter arrow
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:392
sal_uInt16 mnSelItem
Base field for this page info.
Definition: xlpivot.hxx:661
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xiroot.cxx:119
const sal_uInt16 EXC_ID_SXEMPTY
Definition: xlpivot.hxx:270
ScfUInt16Vec maColFields
Row field indexes.
Definition: xipivot.hxx:356
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(const OUString &rName) const
Definition: dpsave.cxx:845
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
sal_uInt16 mnRowFields
Number of all fields.
Definition: xlpivot.hxx:717
sal_uInt16 mnPageFields
Number of column fields.
Definition: xlpivot.hxx:719
const XclImpPCItem * GetItem(sal_uInt16 nItemIdx) const
Returns the item at the specified position or 0 on error.
Definition: xipivot.cxx:212
Calculated field.
Definition: xlpivot.hxx:89
void SetSkipObj(sal_uInt16 nObjId)
Sets the object with the passed identification to be skipped on import.
Definition: xiescher.cxx:4047
sal_uInt16 mnSortField
Several flags and number of items for AutoShow.
Definition: xlpivot.hxx:624
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record containing data of this item.
Definition: xipivot.cxx:933
bool get_flag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: ftools.hxx:73
const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR
Dates with integers or doubles without strings.
Definition: xlpivot.hxx:242
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
const sal_uInt16 EXC_ID_SXDB
Definition: xlpivot.hxx:204
void ReadSxview(XclImpStream &rStrm)
Reads an SXVIEW record starting a new pivot table.
Definition: xipivot.cxx:1287
void ConvertRCPField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1111
const sal_uInt16 EXC_ID_SXDBEX
Definition: xlpivot.hxx:351
SvNumFormatType
void ConvertRowColField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1013
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
void setRowFieldCount(sal_uInt32 nCount)
void ReadSxstring(XclImpStream &rStrm)
Reads an SXSTRING record describing a text item.
Definition: xipivot.cxx:154
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of the current field.
Definition: xipivot.cxx:1316
SC_DLLPUBLIC ScDPObject * InsertNewTable(std::unique_ptr< ScDPObject > pDPObj)
Definition: dpobject.cxx:3731
SC_DLLPUBLIC void SetIgnoreEmptyRows(bool bSet)
Definition: dpsave.cxx:993
XclPTInfo maPTInfo
Pivot cache containing field/item names.
Definition: xipivot.hxx:347
const XclImpPCField * GetGroupBaseField() const
Returns the base field if this is a grouping field.
Definition: xipivot.cxx:206
#define EXC_STORAGE_PTCACHE
Definition: xlpivot.hxx:39
sal_Int32 GetApiRefItemType() const
Returns the API constant representing the result reference item type.
Definition: xlpivot.cxx:786
const sal_uInt16 EXC_SXVD_AXIS_ROWCOL
Definition: xlpivot.hxx:116
Contains data for a pivot table data field (SXDI record).
Definition: xlpivot.hxx:673
bool mbCompactMode
Definition: xlpivot.hxx:769
bool mbSelfRef
Source data type.
Definition: xipivot.hxx:189
const sal_uInt16 EXC_SXFIELD_DATA_INT
Only strings, nothing else.
Definition: xlpivot.hxx:235
const sal_uInt16 EXC_ID_SXFORMULA
Definition: xlpivot.hxx:348
const XclImpPCField * GetField(sal_uInt16 nFieldIdx) const
Returns read-only access to a pivot cache field.
Definition: xipivot.cxx:603
void ConvertFieldInfo(const ScDPSaveData &rSaveData, ScDPObject *pObj, const XclImpRoot &rRoot, bool bPageField=false) const
Definition: xipivot.cxx:1173
bool IsGroupChildField() const
Returns true, if this field is a child field in a grouping (it has a base field). ...
Definition: xlpivot.cxx:328
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of a field.
Definition: xipivot.cxx:1670
Empty cell.
Definition: xlpivot.hxx:72
void ReadSxvs(XclImpStream &rStrm)
Reads an SXVS record containing the source type of the pivot cache.
Definition: xipivot.cxx:615
OUString GetVisFieldName() const
Returns the internally set visible name of this field.
Definition: xipivot.cxx:975
SC_DLLPUBLIC void SetFilterButton(bool bSet)
Definition: dpsave.cxx:1003
void setHeaderLayout(bool bHeaderLayout)
bool IsValid() const
Definition: address.hxx:547
const sal_uInt32 EXC_SXVDEX_SORT_ASC
Definition: xlpivot.hxx:335
const XclImpPCField * mpCacheField
General data for this item.
Definition: xipivot.hxx:216
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:648
void ApplyMergeFlags(const ScRange &rOutRange, const ScDPSaveData &rSaveData)
Definition: xipivot.cxx:1511
void ReadSxex(XclImpStream &rStrm)
Reads an SXEX record containing additional settings for the pivot table.
Definition: xipivot.cxx:1394
const sal_uInt16 EXC_SXVD_AXIS_PAGE
Definition: xlpivot.hxx:114
void SetReferenceValue(const css::sheet::DataPilotFieldReference *pNew)
Definition: dpsave.cxx:394
XclPCInfo maPCInfo
Definition: xipivot.hxx:181
virtual ~XclImpPivotTableManager() override
Definition: xipivot.cxx:1616
void CopyDecrypterFrom(const XclImpStream &rStrm)
Sets decrypter from another stream.
Definition: xistream.cxx:513
SCCOL Col() const
Definition: address.hxx:267
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:424
bool IsStandardField() const
Returns true, if this is a standard field build directly from source data.
Definition: xlpivot.cxx:298
void getColumnFieldPositions(::std::vector< ScAddress > &rAddrs) const
void ApplyFieldInfo()
Definition: xipivot.cxx:1584
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
void ReadSxViewEx9(XclImpStream &rStrm)
Reads an SXVIEWEX9 record that specifies the pivot tables autoformat.
Definition: xipivot.cxx:1399
XclImpPTFieldRef mxCurrField
Vector containing all fields.
Definition: xipivot.hxx:353
SC_DLLPUBLIC void SetShowDetails(bool bSet)
Definition: dpsave.cxx:105
Boolean value.
Definition: xlpivot.hxx:77
XclImpPivotCacheRef GetPivotCache(sal_uInt16 nCacheIdx)
Returns the pivot cache with the specified 0-based index.
Definition: xipivot.cxx:1622
std::shared_ptr< XclImpPivotCache > XclImpPivotCacheRef
Definition: xipivot.hxx:192
void ReadSxnumgroup(XclImpStream &rStrm)
Reads the SXNUMGROUP record describing numeric grouping fields.
Definition: xipivot.cxx:368
sal_uInt16 mnTotalFields
Number of standard pivot cache fields.
Definition: xlpivot.hxx:533
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of this field.
Definition: xipivot.cxx:1004
bool IsGroupBaseField() const
Returns true, if this field has a child field in a grouping.
Definition: xlpivot.cxx:323
XclImpSheetDrawing & GetCurrSheetDrawing() const
Returns the drawing container of the current sheet.
Definition: xiroot.cxx:199
std::unique_ptr< ScTokenArray > GetBoolErr(XclBoolError)
Definition: excform.cxx:1663
XclPCFieldInfo maFieldInfo
Definition: xlpivot.hxx:516
ScfUInt16Vec maOrigDataFields
Page field indexes.
Definition: xipivot.hxx:358
void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo *pNew)
Definition: dpsave.cxx:410
SC_DLLPUBLIC void SetGrandTotalName(const OUString &rName)
Definition: dpsave.cxx:765
const XclImpPCField * GetCacheField() const
Returns the corresponding pivot cache field of this field.
Definition: xipivot.cxx:963
const DateTime * GetDateGroupLimit(sal_uInt16 nLimitIdx) const
Returns a limit value for date grouping fields (minimum/maximum only).
Definition: xipivot.cxx:554
SC_DLLPUBLIC void SetDrillDown(bool bSet)
Definition: dpsave.cxx:1008
std::vector< XclImpPivotCacheRef > maPCaches
Definition: xipivot.hxx:424
bool HasDataFieldInfo() const
Definition: xipivot.cxx:1046
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
Definition: xistream.cxx:581
const sal_uInt16 EXC_SXFIELD_DATA_STR_INT
Only doubles, nothing else.
Definition: xlpivot.hxx:237
SCROW getRowFieldHeaderRow() const
XclPTAddl maPTAddlInfo
(SXVIEWEX9 record)
Definition: xipivot.hxx:350
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
XclImpPCFieldVec maFields
Pivot cache settings (SXDB record).
Definition: xipivot.hxx:182
sal_Int32 SCROW
Definition: types.hxx:18
void ReadSxdouble(XclImpStream &rStrm)
Reads an SXDOUBLE record describing a floating-point item.
Definition: xipivot.cxx:130
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
Definition: xistream.cxx:886
std::vector< XclPTDataFieldInfo > maDataInfoVector
Page field info (entry from SXPI record).
Definition: xipivot.hxx:287
OUString maDataName
The name of the pivot table.
Definition: xlpivot.hxx:709
XclPTExtInfo maPTExtInfo
General info about the pivot table (SXVIEW record).
Definition: xipivot.hxx:348
ScMF
Definition: attrib.hxx:35
void ReadSxview(XclImpStream &rStrm)
Reads an SXVIEW record describing a new pivot table.
Definition: xipivot.cxx:1657
const double * GetNumGroupLimit(sal_uInt16 nLimitIdx) const
Returns a limit value for numeric grouping fields.
Definition: xipivot.cxx:543
::std::vector< sal_uInt16 > ScfUInt16Vec
Definition: ftools.hxx:253
const sal_uInt16 EXC_ID_SXBOOLEAN
Definition: xlpivot.hxx:255
const XclImpPCItem * GetLimitItem(sal_uInt16 nItemIdx) const
Returns the item representing a limit value in numeric/date/time grouping fields. ...
Definition: xipivot.cxx:217
ScDPSaveDimension * DuplicateDimension(const OUString &rName)
Definition: dpsave.cxx:885
ScRange maOutScRange
Special data field orientation field.
Definition: xipivot.hxx:361
const sal_uInt16 EXC_PT_MAXFIELDCOUNT
Definition: xlpivot.hxx:55
unsigned char sal_uInt8
const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL
Only strings and integers, opt. with doubles.
Definition: xlpivot.hxx:238
void SetSubtotalName(const OUString &rName)
Definition: dpsave.cxx:353
sal_uInt8 ReaduInt8()
Definition: xistream.cxx:616
bool mbNumGroupInfoRead
Column index of source data for this field.
Definition: xipivot.hxx:138
void setDataFieldCount(sal_uInt32 nCount)
void ConvertHiddenField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1038
const sal_uInt16 EXC_SXIVD_DATA
Definition: xlpivot.hxx:165
void setStringCell(const ScAddress &rPos, const OUString &rStr)
OUString aName
const OUString & GetName() const
Definition: dpsave.hxx:139
void AddDataFieldInfo(const XclPTDataFieldInfo &rDataInfo)
Definition: xipivot.cxx:1051
void ReadSxinteger(XclImpStream &rStrm)
Reads an SXINTEGER record describing an integer item.
Definition: xipivot.cxx:148
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
void MaybeRefresh()
Definition: xipivot.cxx:1500
int GetError()
const sal_uInt16 EXC_SXFIELD_POSTPONE
Definition: xlpivot.hxx:225
sal_Int32 GetApiRefType() const
Returns the API constant representing the result reference type.
Definition: xlpivot.cxx:750
std::shared_ptr< XclImpPTItem > XclImpPTItemRef
Definition: xipivot.hxx:219
const sal_uInt16 EXC_ID_SXFILT
Definition: xlpivot.hxx:316
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID...
Definition: dpdimsave.hxx:87
XclImpPCItemVec maOrigItems
List of all displayed data items.
Definition: xipivot.hxx:135
const sal_uInt16 EXC_ID_SXPAIR
Definition: xlpivot.hxx:325
const sal_uInt16 EXC_PT_MAXROWCOLCOUNT
Definition: xlpivot.hxx:56
void ConvertItem(ScDPSaveDimension &rSaveDim, ScDPObject *pObj, const XclImpRoot &rRoot) const
Inserts this item into the passed ScDPSaveDimension.
Definition: xipivot.cxx:938
void * p
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
Definition: dpdimsave.cxx:531
const sal_uInt16 EXC_SXVS_UNKNOWN
Definition: xlpivot.hxx:299
const XclImpPTField * GetDataField(sal_uInt16 nDataFieldIdx) const
Definition: xipivot.cxx:1271
void SetShowEmpty(bool bSet)
Definition: dpsave.cxx:333
const sal_uInt16 EXC_ID_SXNUMGROUP
Definition: xlpivot.hxx:276
void ReadSxivd(XclImpStream &rStrm)
Reads an SXIVD record containing the row field or column field order.
Definition: xipivot.cxx:1676
sal_uInt16 mnStrmId
Name of the source data range.
Definition: xipivot.hxx:187
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
Definition: xihelper.cxx:101
SC_DLLPUBLIC void SetColumnGrand(bool bSet)
Definition: dpsave.cxx:983
Date/time.
Definition: xlpivot.hxx:75
css::sheet::DataPilotFieldOrientation GetApiOrient(sal_uInt16 nMask) const
Returns the API enum representing the orientation (first of row/col/page/data).
Definition: xlpivot.cxx:469
void SetHybridDouble(double n)
For import only: set a double result.
const sal_uInt32 EXC_SXVDEX_SHOWALL
Definition: xlpivot.hxx:333
virtual ~XclImpPCField() override
Definition: xipivot.cxx:189
void ConvertGroupField(ScDPSaveData &rSaveData, const ScfStringVec &rVisNames) const
Inserts grouping information of this field into the passed ScDPSaveData.
Definition: xipivot.cxx:392
void ConvertNumGroupField(ScDPSaveData &rSaveData, const ScfStringVec &rVisNames) const
Inserts numeric grouping information of this field into the passed ScDPSaveData.
Definition: xipivot.cxx:440
const sal_uInt16 EXC_ID_SXFDBTYPE
Definition: xlpivot.hxx:355
SC_DLLPUBLIC void SetRowGrand(bool bSet)
Definition: dpsave.cxx:988
bool HasPostponedItems() const
Returns true, if the items are stored separately after the last field.
Definition: xlpivot.cxx:343
void WriteToSource(XclImpRoot &rRoot, const ScAddress &rScPos) const
Inserts the item data into the passed document.
Definition: xipivot.cxx:95
bool IsDateGroupField() const
Returns true, if this field is a date/time grouping field.
Definition: xlpivot.cxx:313
const sal_uInt16 EXC_SXFIELD_INDEX_MIN
Dates and strings, opt. with integers or doubles.
Definition: xlpivot.hxx:244
void SetAxes(sal_uInt16 nAxes)
Sets the flags of the axes this field is part of.
Definition: xipivot.hxx:243
bool HasOrigItems() const
Returns true, if the field is based on a column in the source data area.
Definition: xlpivot.cxx:333
const sal_uInt16 EXC_ID_SXFIELD
Definition: xlpivot.hxx:222
#define SAL_WARN(area, stream)
sal_Int32 GetApiAutoShowCount() const
Returns the number of items to be shown in AutoShow mode.
Definition: xlpivot.cxx:606
bool HasInlineItems() const
Returns true, if any items are stored after the SXFIELD record.
Definition: xlpivot.cxx:338
::std::vector< ScDPSaveGroupItem > ScDPSaveGroupItemVec
Definition: dpdimsave.hxx:81
const XclImpPTField * GetField(sal_uInt16 nFieldIdx) const
Definition: xipivot.cxx:1259
ScfUInt16Vec maFiltDataFields
Original data field indexes.
Definition: xipivot.hxx:359
XclPCNumGroupInfo maNumGroupInfo
Order of items in a grouping field (SXGROUPINFO record).
Definition: xlpivot.hxx:520
void ReadSxdi(XclImpStream &rStrm)
Reads an SXDI record containing data field data.
Definition: xipivot.cxx:1378
const sal_uInt16 EXC_SXVD_AXIS_ROW
Definition: xlpivot.hxx:112
ScDPObject * mpDPObj
Output range in the Calc document.
Definition: xipivot.hxx:362
bool IsNumGroupField() const
Returns true, if this field is a numeric grouping field.
Definition: xlpivot.cxx:308
SCTAB GetScTabFromXclName(const OUString &rXclTabName) const
Returns the Calc sheet index from the passed original Excel sheet name.
Definition: xilink.cxx:238
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:168
OUString maTableName
Definition: xlpivot.hxx:708
sal_uInt16 GetFieldCount() const
Definition: xipivot.cxx:1254
void setNumericCell(const ScAddress &rPos, double fVal)
SC_DLLPUBLIC void SetRangeName(const OUString &rName)
Definition: dpshttab.cxx:259
void getPageFieldPositions(::std::vector< ScAddress > &rAddrs) const
This class is used to import record oriented streams.
Definition: xistream.hxx:278
void ReadDconref(XclImpStream &rStrm)
Reads a DCONREF record containing the source range of the pivot cache.
Definition: xipivot.cxx:621
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing a new field.
Definition: xipivot.cxx:1664
const sal_uInt16 EXC_SXVIEW_ROWGRAND
Definition: xlpivot.hxx:101
XclImpPCField(const XclImpRoot &rRoot, XclImpPivotCache &rPCache, sal_uInt16 nFieldIdx)
Creates a pivot cache field by reading an SXFIELD record.
Definition: xipivot.cxx:180
void ReadPivotCaches(const XclImpStream &rStrm)
Reads all used pivot caches and creates additional sheets for external data sources.
Definition: xipivot.cxx:1718
void BuildAllDimensionMembers()
Definition: dpobject.cxx:960
sal_uInt16 mnBaseItems
Number of special items in a grouping field.
Definition: xlpivot.hxx:444
virtual ~XclImpPivotTable() override
Definition: xipivot.cxx:1248
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
Definition: xlroot.cxx:264
const sal_uInt16 EXC_ID_SXERROR
Definition: xlpivot.hxx:258
const sal_uInt16 EXC_SXFIELD_DATA_STR
Special state for groupings.
Definition: xlpivot.hxx:234
XclPCFieldType meFieldType
Pivot cache field info (SXFIELD record).
Definition: xlpivot.hxx:517
bool IsSupportedField() const
Returns true, if the type of the field is supported by Calc.
Definition: xlpivot.cxx:293
const SCTAB MAXTABCOUNT
limiting to 10000 for now, problem with 32 bit builds for now
Definition: address.hxx:67
const sal_uInt16 EXC_SXFIELD_DATA_DATE_NUM
Dates and empty strings, nothing else (?).
Definition: xlpivot.hxx:241
Access to global data from other classes.
Definition: xiroot.hxx:126
const OUString & GetFieldName(const ScfStringVec &rVisNames) const
Returns the name of the field, uses the passed visible name if supported.
Definition: xipivot.cxx:195
OUString maName
Definition: xlpivot.hxx:438
::std::vector< OUString > ScfStringVec
Definition: ftools.hxx:256
void ReadSxdi(XclImpStream &rStrm)
Reads an SXDI record containing data field data.
Definition: xipivot.cxx:1688
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:39
void SetSubTotals(std::vector< ScGeneralFunction > const &rFuncs)
Definition: dpsave.cxx:322
sal_uInt32 mnFlags
Number of page fields per column.
Definition: xlpivot.hxx:741
std::vector< XclImpPTItemRef > maItems
Vector of extended data field info (SXDI records).
Definition: xipivot.hxx:288
XclImpPCItemVec maNumGroupItems
List of all source data items.
Definition: xipivot.hxx:136
void AddGroupItem(const ScDPSaveGroupItem &rItem)
Definition: dpdimsave.cxx:149
const OUString * GetItemName() const
Returns the internal name of the item or 0, if no name could be found.
Definition: xipivot.cxx:881
void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo *pNew)
Definition: dpsave.cxx:418
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:58
XclImpPivotCache(const XclImpRoot &rRoot)
Definition: xipivot.cxx:588
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of the field.
Definition: xipivot.cxx:999
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
Definition: dpsave.cxx:866
sal_Int16 SCTAB
Definition: types.hxx:23
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
Definition: dpdimsave.cxx:143
const OUString * GetItemName(sal_uInt16 nItemIdx) const
Returns the internal name of the specified item.
Definition: xipivot.cxx:986
sal_uInt16 mnAxes
Definition: xlpivot.hxx:594
sal_uInt16 mnFirstHeadRow
First cell containing data.
Definition: xlpivot.hxx:712
const sal_uInt16 EXC_SXFIELD_DATA_MASK
Definition: xlpivot.hxx:231
void SetSortInfo(const css::sheet::DataPilotFieldSortInfo *pNew)
Definition: dpsave.cxx:402
::std::vector< XclImpPCFieldRef > XclImpPCFieldVec
Definition: xipivot.hxx:179
sal_Int32 GetApiAutoShowMode() const
Returns the API constant representing the AutoShow mode.
Definition: xlpivot.cxx:595
void ReadSxerror(XclImpStream &rStrm)
Reads an SXERROR record describing an error code item.
Definition: xipivot.cxx:142
OUString maUrl
Source range in the spreadsheet.
Definition: xipivot.hxx:184
ScDocument & getDoc()
static void DecodeUrl(OUString &rUrl, OUString &rTabName, bool &rbSameWb, const XclImpRoot &rRoot, const OUString &rEncodedUrl)
Decodes an encoded external document URL with optional sheet name.
Definition: xihelper.cxx:603
sal_uInt8 mnGridLayout
AutoFormat ID.
Definition: xlpivot.hxx:756
Represents a field in a pivot cache (a column of data items in the source area).
Definition: xipivot.hxx:65
const sal_uInt16 EXC_ID_EOF
Internal use only.
Definition: xlconst.hxx:173