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  {
283  if( bItems && !bPostp )
284  {
285  if( !bCalced )
286  {
287  // 1) standard fields and standard grouping fields
288  if( !bNum )
289  {
290  // 1a) standard field without grouping
291  if( bType && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == nVisC) )
293 
294  // 1b) standard grouping field
295  else if( bTypeNone && (nGroupC == nVisC) && (nBaseC > 0) && (nOrigC == 0) )
297  }
298  // 2) numerical grouping fields
299  else if( (nGroupC == nVisC) && (nBaseC == 0) )
300  {
301  // 2a) single num/date grouping field without child grouping field
302  if( !bChild && bType && (nOrigC > 0) )
303  {
304  switch( nType )
305  {
309  default: OSL_FAIL( "XclImpPCField::ReadSxfield - numeric group with wrong data type" );
310  }
311  }
312 
313  // 2b) first date grouping field with child grouping field
314  else if( bChild && (nType == EXC_SXFIELD_DATA_DATE) && (nOrigC > 0) )
316 
317  // 2c) additional date grouping field
318  else if( bTypeNone && (nOrigC == 0) )
320  }
321  OSL_ENSURE( meFieldType != EXC_PCFIELD_UNKNOWN, "XclImpPCField::ReadSxfield - invalid standard or grouped field" );
322  }
323 
324  // 3) calculated field
325  else
326  {
327  if( !bChild && !bNum && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == 0) )
329  OSL_ENSURE( meFieldType == EXC_PCFIELD_CALCED, "XclImpPCField::ReadSxfield - invalid calculated field" );
330  }
331  }
332 
333  else if( !bItems && bPostp )
334  {
335  // 4) standard field with postponed items
336  if( !bCalced && !bChild && !bNum && bType && (nGroupC == 0) && (nBaseC == 0) && (nOrigC == 0) )
338  OSL_ENSURE( meFieldType == EXC_PCFIELD_STANDARD, "XclImpPCField::ReadSxfield - invalid postponed field" );
339  }
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  if( const XclImpPCField* pBaseField = GetGroupBaseField() )
410  {
411  const OUString& rBaseFieldName = pBaseField->GetFieldName( rVisNames );
412  if( !rBaseFieldName.isEmpty() )
413  {
414  // *** create a ScDPSaveGroupItem for each own item, they collect base item names ***
415  ScDPSaveGroupItemVec aGroupItems;
416  aGroupItems.reserve( maItems.size() );
417  // initialize with own item names
418  for( const auto& rxItem : maItems )
419  aGroupItems.emplace_back( rxItem->ConvertToText() );
420 
421  // *** iterate over all base items, set their names at corresponding own items ***
422  for( sal_uInt16 nItemIdx = 0, nItemCount = static_cast< sal_uInt16 >( maGroupOrder.size() ); nItemIdx < nItemCount; ++nItemIdx )
423  if( maGroupOrder[ nItemIdx ] < aGroupItems.size() )
424  if( const XclImpPCItem* pBaseItem = pBaseField->GetItem( nItemIdx ) )
425  if( const XclImpPCItem* pGroupItem = GetItem( maGroupOrder[ nItemIdx ] ) )
426  if( *pBaseItem != *pGroupItem )
427  aGroupItems[ maGroupOrder[ nItemIdx ] ].AddElement( pBaseItem->ConvertToText() );
428 
429  // *** create the ScDPSaveGroupDimension object, fill with grouping info ***
430  ScDPSaveGroupDimension aGroupDim( rBaseFieldName, GetFieldName( rVisNames ) );
431  for( const auto& rGroupItem : aGroupItems )
432  if( !rGroupItem.IsEmpty() )
433  aGroupDim.AddGroupItem( rGroupItem );
434  rSaveData.GetDimensionData()->AddGroupDimension( aGroupDim );
435  }
436  }
437 }
438 
439 void XclImpPCField::ConvertNumGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
440 {
441  ScDPNumGroupInfo aNumInfo( GetScNumGroupInfo() );
442  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), aNumInfo );
443  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
444 }
445 
446 void XclImpPCField::ConvertDateGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
447 {
448  ScDPNumGroupInfo aDateInfo( GetScDateGroupInfo() );
449  sal_Int32 nScDateType = maNumGroupInfo.GetScDateType();
450 
451  switch( meFieldType )
452  {
454  {
455  if( aDateInfo.mbDateValues )
456  {
457  // special case for days only with step value - create numeric grouping
458  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), aDateInfo );
459  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
460  }
461  else
462  {
463  ScDPSaveNumGroupDimension aNumGroupDim( GetFieldName( rVisNames ), ScDPNumGroupInfo() );
464  aNumGroupDim.SetDateInfo( aDateInfo, nScDateType );
465  rSaveData.GetDimensionData()->AddNumGroupDimension( aNumGroupDim );
466  }
467  }
468  break;
469 
471  {
472  if( const XclImpPCField* pBaseField = GetGroupBaseField() )
473  {
474  const OUString& rBaseFieldName = pBaseField->GetFieldName( rVisNames );
475  if( !rBaseFieldName.isEmpty() )
476  {
477  ScDPSaveGroupDimension aGroupDim( rBaseFieldName, GetFieldName( rVisNames ) );
478  aGroupDim.SetDateInfo( aDateInfo, nScDateType );
479  rSaveData.GetDimensionData()->AddGroupDimension( aGroupDim );
480  }
481  }
482  }
483  break;
484 
485  default:
486  OSL_FAIL( "XclImpPCField::ConvertDateGroupField - unknown date field type" );
487  }
488 }
489 
491 {
492  ScDPNumGroupInfo aNumInfo;
493  aNumInfo.mbEnable = true;
494  aNumInfo.mbDateValues = false;
495  aNumInfo.mbAutoStart = true;
496  aNumInfo.mbAutoEnd = true;
497 
498  if( const double* pfMinValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
499  {
500  aNumInfo.mfStart = *pfMinValue;
502  }
503  if( const double* pfMaxValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
504  {
505  aNumInfo.mfEnd = *pfMaxValue;
507  }
508  if( const double* pfStepValue = GetNumGroupLimit( EXC_SXFIELD_INDEX_STEP ) )
509  aNumInfo.mfStep = *pfStepValue;
510 
511  return aNumInfo;
512 }
513 
515 {
516  ScDPNumGroupInfo aDateInfo;
517  aDateInfo.mbEnable = true;
518  aDateInfo.mbDateValues = false;
519  aDateInfo.mbAutoStart = true;
520  aDateInfo.mbAutoEnd = true;
521 
522  if( const DateTime* pMinDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MIN ) )
523  {
524  aDateInfo.mfStart = GetDoubleFromDateTime( *pMinDate );
526  }
527  if( const DateTime* pMaxDate = GetDateGroupLimit( EXC_SXFIELD_INDEX_MAX ) )
528  {
529  aDateInfo.mfEnd = GetDoubleFromDateTime( *pMaxDate );
531  }
532  // GetDateGroupStep() returns a value for date type "day" in single date groups only
533  if( const sal_Int16* pnStepValue = GetDateGroupStep() )
534  {
535  aDateInfo.mfStep = *pnStepValue;
536  aDateInfo.mbDateValues = true;
537  }
538 
539  return aDateInfo;
540 }
541 
542 const double* XclImpPCField::GetNumGroupLimit( sal_uInt16 nLimitIdx ) const
543 {
544  OSL_ENSURE( IsNumGroupField(), "XclImpPCField::GetNumGroupLimit - only for numeric grouping fields" );
545  if( const XclImpPCItem* pItem = GetLimitItem( nLimitIdx ) )
546  {
547  OSL_ENSURE( pItem->GetDouble(), "XclImpPCField::GetNumGroupLimit - SXDOUBLE item expected" );
548  return pItem->GetDouble();
549  }
550  return nullptr;
551 }
552 
553 const DateTime* XclImpPCField::GetDateGroupLimit( sal_uInt16 nLimitIdx ) const
554 {
555  OSL_ENSURE( IsDateGroupField(), "XclImpPCField::GetDateGroupLimit - only for date grouping fields" );
556  if( const XclImpPCItem* pItem = GetLimitItem( nLimitIdx ) )
557  {
558  OSL_ENSURE( pItem->GetDateTime(), "XclImpPCField::GetDateGroupLimit - SXDATETIME item expected" );
559  return pItem->GetDateTime();
560  }
561  return nullptr;
562 }
563 
564 const sal_Int16* XclImpPCField::GetDateGroupStep() const
565 {
566  // only for single date grouping fields, not for grouping chains
567  if( !IsGroupBaseField() && !IsGroupChildField() )
568  {
569  // only days may have a step value, return 0 for all other date types
571  {
572  if( const XclImpPCItem* pItem = GetLimitItem( EXC_SXFIELD_INDEX_STEP ) )
573  {
574  OSL_ENSURE( pItem->GetInteger(), "XclImpPCField::GetDateGroupStep - SXINTEGER item expected" );
575  if( const sal_Int16* pnStep = pItem->GetInteger() )
576  {
577  OSL_ENSURE( *pnStep > 0, "XclImpPCField::GetDateGroupStep - invalid step count" );
578  // return nothing for step count 1 - this is also a standard date group in Excel
579  return (*pnStep > 1) ? pnStep : nullptr;
580  }
581  }
582  }
583  }
584  return nullptr;
585 }
586 
588  XclImpRoot( rRoot ),
589  maSrcRange( ScAddress::INITIALIZE_INVALID ),
590  mnStrmId( 0 ),
591  mnSrcType( EXC_SXVS_UNKNOWN ),
592  mbSelfRef( false )
593 {
594 }
595 
597 {
598 }
599 
600 // data access ----------------------------------------------------------------
601 
602 const XclImpPCField* XclImpPivotCache::GetField( sal_uInt16 nFieldIdx ) const
603 {
604  return (nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr;
605 }
606 
607 // records --------------------------------------------------------------------
608 
610 {
611  mnStrmId = rStrm.ReaduInt16();
612 }
613 
615 {
616  mnSrcType = rStrm.ReaduInt16();
618 }
619 
621 {
622  /* Read DCONREF only once (by checking maTabName), there may be other
623  DCONREF records in another context. Read reference only if a leading
624  SXVS record is present (by checking mnSrcType). */
625  if( !maTabName.isEmpty() || (mnSrcType != EXC_SXVS_SHEET) )
626  return;
627 
628  XclRange aXclRange( ScAddress::UNINITIALIZED );
629  aXclRange.Read( rStrm, false );
630  OUString aEncUrl = rStrm.ReadUniString();
631 
633 
634  /* Do not convert maTabName to Calc sheet name -> original name is used to
635  find the sheet in the document. Sheet index of source range will be
636  found later in XclImpPivotCache::ReadPivotCacheStream(), because sheet
637  may not exist yet. */
638  if( mbSelfRef )
639  GetAddressConverter().ConvertRange( maSrcRange, aXclRange, 0, 0, true );
640 }
641 
643 {
644  maSrcRangeName = rStrm.ReadUniString();
645 
646  // This 2-byte value equals the length of string that follows, or if 0 it
647  // indicates that the name has a workbook scope. For now, we only support
648  // internal defined name with a workbook scope.
649  sal_uInt16 nFlag;
650  nFlag = rStrm.ReaduInt16();
651  mbSelfRef = (nFlag == 0);
652 
653  if (!mbSelfRef)
654  // External name is not supported yet.
655  maSrcRangeName.clear();
656 }
657 
659 {
661  return;
662 
663  ScDocument& rDoc = GetDoc();
664  SCCOL nFieldScCol = 0; // column index of source data for next field
665  SCROW nItemScRow = 0; // row index of source data for current items
666  SCTAB nScTab = 0; // sheet index of source data
667  bool bGenerateSource = false; // true = write source data from cache to dummy table
668 
669  if( mbSelfRef )
670  {
671  if (maSrcRangeName.isEmpty())
672  {
673  // try to find internal sheet containing the source data
675  if( rDoc.HasTable( nScTab ) )
676  {
677  // set sheet index to source range
678  maSrcRange.aStart.SetTab( nScTab );
679  maSrcRange.aEnd.SetTab( nScTab );
680  }
681  else
682  {
683  // create dummy sheet for deleted internal sheet
684  bGenerateSource = true;
685  }
686  }
687  }
688  else
689  {
690  // create dummy sheet for external sheet
691  bGenerateSource = true;
692  }
693 
694  // create dummy sheet for source data from external or deleted sheet
695  if( bGenerateSource )
696  {
697  if( rDoc.GetTableCount() >= MAXTABCOUNT )
698  // cannot create more sheets -> exit
699  return;
700 
701  nScTab = rDoc.GetTableCount();
702  rDoc.MakeTable( nScTab );
703  OUStringBuffer aDummyName("DPCache");
704  if( maTabName.getLength() > 0 )
705  aDummyName.append( '_' ).append( maTabName );
706  OUString aName = aDummyName.makeStringAndClear();
707  rDoc.CreateValidTabName( aName );
708  rDoc.RenameTab( nScTab, aName );
709  // set sheet index to source range
710  maSrcRange.aStart.SetTab( nScTab );
711  maSrcRange.aEnd.SetTab( nScTab );
712  }
713 
714  // open pivot cache storage stream
717  if( !xSvStrm.is() )
718  return;
719 
720  // create Excel record stream object
721  XclImpStream aPCStrm( *xSvStrm, GetRoot() );
722  aPCStrm.CopyDecrypterFrom( rStrm ); // pivot cache streams are encrypted
723 
724  XclImpPCFieldRef xCurrField; // current field for new items
725  XclImpPCFieldVec aOrigFields; // all standard fields with inline original items
726  XclImpPCFieldVec aPostpFields; // all standard fields with postponed original items
727  size_t nPostpIdx = 0; // index to current field with postponed items
728  bool bLoop = true; // true = continue loop
729 
730  while( bLoop && aPCStrm.StartNextRecord() )
731  {
732  switch( aPCStrm.GetRecId() )
733  {
734  case EXC_ID_EOF:
735  bLoop = false;
736  break;
737 
738  case EXC_ID_SXDB:
739  aPCStrm >> maPCInfo;
740  break;
741 
742  case EXC_ID_SXFIELD:
743  {
744  xCurrField.reset();
745  sal_uInt16 nNewFieldIdx = static_cast< sal_uInt16 >( maFields.size() );
746  if( nNewFieldIdx < EXC_PC_MAXFIELDCOUNT )
747  {
748  xCurrField = std::make_shared<XclImpPCField>( GetRoot(), *this, nNewFieldIdx );
749  maFields.push_back( xCurrField );
750  xCurrField->ReadSxfield( aPCStrm );
751  if( xCurrField->HasOrigItems() )
752  {
753  if( xCurrField->HasPostponedItems() )
754  aPostpFields.push_back( xCurrField );
755  else
756  aOrigFields.push_back( xCurrField );
757  // insert field name into generated source data, field remembers its column index
758  if( bGenerateSource && (nFieldScCol <= rDoc.MaxCol()) )
759  xCurrField->WriteFieldNameToSource( nFieldScCol++, nScTab );
760  }
761  // do not read items into invalid/postponed fields
762  if( !xCurrField->HasInlineItems() )
763  xCurrField.reset();
764  }
765  }
766  break;
767 
768  case EXC_ID_SXINDEXLIST:
769  // read index list and insert all items into generated source data
770  if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) && (++nItemScRow <= rDoc.MaxRow()) )
771  {
772  for( const auto& rxOrigField : aOrigFields )
773  {
774  sal_uInt16 nItemIdx = rxOrigField->Has16BitIndexes() ? aPCStrm.ReaduInt16() : aPCStrm.ReaduInt8();
775  rxOrigField->WriteOrigItemToSource( nItemScRow, nScTab, nItemIdx );
776  }
777  }
778  xCurrField.reset();
779  break;
780 
781  case EXC_ID_SXDOUBLE:
782  case EXC_ID_SXBOOLEAN:
783  case EXC_ID_SXERROR:
784  case EXC_ID_SXINTEGER:
785  case EXC_ID_SXSTRING:
786  case EXC_ID_SXDATETIME:
787  case EXC_ID_SXEMPTY:
788  if( xCurrField ) // inline items
789  {
790  xCurrField->ReadItem( aPCStrm );
791  }
792  else if( !aPostpFields.empty() ) // postponed items
793  {
794  // read postponed item
795  aPostpFields[ nPostpIdx ]->ReadItem( aPCStrm );
796  // write item to source
797  if( bGenerateSource && (nItemScRow <= rDoc.MaxRow()) )
798  {
799  // start new row, if there are only postponed fields
800  if( aOrigFields.empty() && (nPostpIdx == 0) )
801  ++nItemScRow;
802  if( nItemScRow <= rDoc.MaxRow() )
803  aPostpFields[ nPostpIdx ]->WriteLastOrigItemToSource( nItemScRow, nScTab );
804  }
805  // get index of next postponed field
806  ++nPostpIdx;
807  if( nPostpIdx >= aPostpFields.size() )
808  nPostpIdx = 0;
809  }
810  break;
811 
812  case EXC_ID_SXNUMGROUP:
813  if( xCurrField )
814  xCurrField->ReadSxnumgroup( aPCStrm );
815  break;
816 
817  case EXC_ID_SXGROUPINFO:
818  if( xCurrField )
819  xCurrField->ReadSxgroupinfo( aPCStrm );
820  break;
821 
822  // known but ignored records
823  case EXC_ID_SXRULE:
824  case EXC_ID_SXFILT:
825  case EXC_ID_00F5:
826  case EXC_ID_SXNAME:
827  case EXC_ID_SXPAIR:
828  case EXC_ID_SXFMLA:
829  case EXC_ID_SXFORMULA:
830  case EXC_ID_SXDBEX:
831  case EXC_ID_SXFDBTYPE:
832  break;
833 
834  default:
835  SAL_WARN("sc.filter", "XclImpPivotCache::ReadPivotCacheStream - unknown record 0x" << std::hex << aPCStrm.GetRecId() );
836  }
837  }
838 
839  OSL_ENSURE( maPCInfo.mnTotalFields == maFields.size(),
840  "XclImpPivotCache::ReadPivotCacheStream - field count mismatch" );
841 
842  if (static_cast<bool>(maPCInfo.mnFlags & EXC_SXDB_SAVEDATA))
843  {
845  maSrcRange.aEnd.SetRow(nNewEnd);
846  }
847 
848  // set source range for external source data
849  if( bGenerateSource && (nFieldScCol > 0) )
850  {
851  maSrcRange.aStart.SetCol( 0 );
852  maSrcRange.aStart.SetRow( 0 );
853  // nFieldScCol points to first unused column
854  maSrcRange.aEnd.SetCol( nFieldScCol - 1 );
855  // nItemScRow points to last used row
856  maSrcRange.aEnd.SetRow( nItemScRow );
857  }
858 }
859 
861 {
862  return static_cast<bool>(maPCInfo.mnFlags & EXC_SXDB_REFRESH_LOAD);
863 }
864 
866 {
867  if (!maSrcRangeName.isEmpty())
868  return true;
869 
870  return maSrcRange.IsValid();
871 }
872 
873 // Pivot table
874 
876  mpCacheField( pCacheField )
877 {
878 }
879 
880 const OUString* XclImpPTItem::GetItemName() const
881 {
882  if( mpCacheField )
883  if( const XclImpPCItem* pCacheItem = mpCacheField->GetItem( maItemInfo.mnCacheIdx ) )
884  //TODO: use XclImpPCItem::ConvertToText(), if all conversions are available
885  return pCacheItem->IsEmpty() ? nullptr : pCacheItem->GetText();
886  return nullptr;
887 }
888 
889 std::pair<bool, OUString> XclImpPTItem::GetItemName(const ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const XclImpRoot& rRoot) const
890 {
891  if(!mpCacheField)
892  return std::pair<bool, OUString>(false, OUString());
893 
894  const XclImpPCItem* pCacheItem = mpCacheField->GetItem( maItemInfo.mnCacheIdx );
895  if(!pCacheItem)
896  return std::pair<bool, OUString>(false, OUString());
897 
898  OUString sItemName;
899  if(pCacheItem->GetType() == EXC_PCITEM_TEXT || pCacheItem->GetType() == EXC_PCITEM_ERROR)
900  {
901  const OUString* pItemName = pCacheItem->GetText();
902  if(!pItemName)
903  return std::pair<bool, OUString>(false, OUString());
904  sItemName = *pItemName;
905  }
906  else if (pCacheItem->GetType() == EXC_PCITEM_DOUBLE)
907  {
908  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), *pCacheItem->GetDouble());
909  }
910  else if (pCacheItem->GetType() == EXC_PCITEM_INTEGER)
911  {
912  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(*pCacheItem->GetInteger()));
913  }
914  else if (pCacheItem->GetType() == EXC_PCITEM_BOOL)
915  {
916  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(*pCacheItem->GetBool()));
917  }
918  else if (pCacheItem->GetType() == EXC_PCITEM_DATETIME)
919  {
920  sItemName = pObj->GetFormattedString(rSaveDim.GetName(), rRoot.GetDoubleFromDateTime(*pCacheItem->GetDateTime()));
921  }
922  else if (pCacheItem->GetType() == EXC_PCITEM_EMPTY)
923  {
924  // sItemName is an empty string
925  }
926  else // EXC_PCITEM_INVALID
927  return std::pair<bool, OUString>(false, OUString());
928 
929  return std::pair<bool, OUString>(true, sItemName);
930 }
931 
933 {
934  rStrm >> maItemInfo;
935 }
936 
937 void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim, ScDPObject* pObj, const XclImpRoot& rRoot ) const
938 {
939  // Find member and set properties
940  std::pair<bool, OUString> aReturnedName = GetItemName(rSaveDim, pObj, rRoot);
941  if(aReturnedName.first)
942  {
943  ScDPSaveMember* pMember = rSaveDim.GetExistingMemberByName(aReturnedName.second);
944  if(pMember)
945  {
948  if (maItemInfo.HasVisName())
949  pMember->SetLayoutName(*maItemInfo.GetVisName());
950  }
951  }
952 }
953 
954 XclImpPTField::XclImpPTField( const XclImpPivotTable& rPTable, sal_uInt16 nCacheIdx ) :
955  mrPTable( rPTable )
956 {
957  maFieldInfo.mnCacheIdx = nCacheIdx;
958 }
959 
960 // general field/item access --------------------------------------------------
961 
963 {
965  return xPCache ? xPCache->GetField( maFieldInfo.mnCacheIdx ) : nullptr;
966 }
967 
969 {
970  const XclImpPCField* pField = GetCacheField();
971  return pField ? pField->GetFieldName( mrPTable.GetVisFieldNames() ) : OUString();
972 }
973 
975 {
976  const OUString* pVisName = maFieldInfo.GetVisName();
977  return pVisName ? *pVisName : OUString();
978 }
979 
980 const XclImpPTItem* XclImpPTField::GetItem( sal_uInt16 nItemIdx ) const
981 {
982  return (nItemIdx < maItems.size()) ? maItems[ nItemIdx ].get() : nullptr;
983 }
984 
985 const OUString* XclImpPTField::GetItemName( sal_uInt16 nItemIdx ) const
986 {
987  const XclImpPTItem* pItem = GetItem( nItemIdx );
988  return pItem ? pItem->GetItemName() : nullptr;
989 }
990 
991 // records --------------------------------------------------------------------
992 
994 {
995  rStrm >> maFieldInfo;
996 }
997 
999 {
1000  rStrm >> maFieldExtInfo;
1001 }
1002 
1004 {
1005  XclImpPTItemRef xItem = std::make_shared<XclImpPTItem>( GetCacheField() );
1006  maItems.push_back( xItem );
1007  xItem->ReadSxvi( rStrm );
1008 }
1009 
1010 // row/column fields ----------------------------------------------------------
1011 
1013 {
1014  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_ROWCOL, "XclImpPTField::ConvertRowColField - no row/column field" );
1015  // special data orientation field?
1018  else
1019  ConvertRCPField( rSaveData );
1020 }
1021 
1022 // page fields ----------------------------------------------------------------
1023 
1025 {
1026  maPageInfo = rPageInfo;
1027 }
1028 
1030 {
1031  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_PAGE, "XclImpPTField::ConvertPageField - no page field" );
1032  ConvertRCPField( rSaveData );
1033 }
1034 
1035 // hidden fields --------------------------------------------------------------
1036 
1038 {
1039  OSL_ENSURE( (maFieldInfo.mnAxes & EXC_SXVD_AXIS_ROWCOLPAGE) == 0, "XclImpPTField::ConvertHiddenField - field not hidden" );
1040  ConvertRCPField( rSaveData );
1041 }
1042 
1043 // data fields ----------------------------------------------------------------
1044 
1046 {
1047  return !maDataInfoVector.empty();
1048 }
1049 
1051 {
1052  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_DATA, "XclImpPTField::AddDataFieldInfo - no data field" );
1053  maDataInfoVector.push_back( rDataInfo );
1054 }
1055 
1057 {
1058  OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_DATA, "XclImpPTField::ConvertDataField - no data field" );
1059  OSL_ENSURE( !maDataInfoVector.empty(), "XclImpPTField::ConvertDataField - no data field info" );
1060  if (maDataInfoVector.empty())
1061  return;
1062 
1063  OUString aFieldName = GetFieldName();
1064  if (aFieldName.isEmpty())
1065  return;
1066 
1067  ScDPSaveDimension* pSaveDim = rSaveData.GetNewDimensionByName(aFieldName);
1068  if (!pSaveDim)
1069  {
1070  SAL_WARN("sc.filter","XclImpPTField::ConvertDataField - field name not found: " << aFieldName);
1071  return;
1072  }
1073 
1074  auto aIt = maDataInfoVector.begin(), aEnd = maDataInfoVector.end();
1075 
1076  ConvertDataField( *pSaveDim, *aIt );
1077 
1078  // multiple data fields -> clone dimension
1079  for( ++aIt; aIt != aEnd; ++aIt )
1080  {
1081  ScDPSaveDimension& rDupDim = rSaveData.DuplicateDimension( *pSaveDim );
1082  ConvertDataFieldInfo( rDupDim, *aIt );
1083  }
1084 }
1085 
1086 // private --------------------------------------------------------------------
1087 
1091 static OUString lcl_convertExcelSubtotalName(const OUString& rName)
1092 {
1093  OUStringBuffer aBuf;
1094  const sal_Unicode* p = rName.getStr();
1095  sal_Int32 n = rName.getLength();
1096  for (sal_Int32 i = 0; i < n; ++i)
1097  {
1098  const sal_Unicode c = p[i];
1099  if (c == '\\')
1100  {
1101  aBuf.append(c);
1102  aBuf.append(c);
1103  }
1104  else
1105  aBuf.append(c);
1106  }
1107  return aBuf.makeStringAndClear();
1108 }
1109 
1111 {
1112  const OUString& rFieldName = GetFieldName();
1113  if( rFieldName.isEmpty() )
1114  return;
1115 
1116  const XclImpPCField* pCacheField = GetCacheField();
1117  if( !pCacheField || !pCacheField->IsSupportedField() )
1118  return;
1119 
1120  ScDPSaveDimension* pTest = rSaveData.GetNewDimensionByName(rFieldName);
1121  if (!pTest)
1122  return;
1123 
1124  ScDPSaveDimension& rSaveDim = *pTest;
1125 
1126  // orientation
1128 
1129  // visible name
1130  if (const OUString* pVisName = maFieldInfo.GetVisName())
1131  if (!pVisName->isEmpty())
1132  rSaveDim.SetLayoutName( *pVisName );
1133 
1134  // subtotal function(s)
1135  XclPTSubtotalVec aSubtotalVec;
1136  maFieldInfo.GetSubtotals( aSubtotalVec );
1137  if( !aSubtotalVec.empty() )
1138  rSaveDim.SetSubTotals( aSubtotalVec );
1139 
1140  // sorting
1141  DataPilotFieldSortInfo aSortInfo;
1142  aSortInfo.Field = mrPTable.GetDataFieldName( maFieldExtInfo.mnSortField );
1143  aSortInfo.IsAscending = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SORT_ASC );
1144  aSortInfo.Mode = maFieldExtInfo.GetApiSortMode();
1145  rSaveDim.SetSortInfo( &aSortInfo );
1146 
1147  // auto show
1148  DataPilotFieldAutoShowInfo aShowInfo;
1149  aShowInfo.IsEnabled = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_AUTOSHOW );
1150  aShowInfo.ShowItemsMode = maFieldExtInfo.GetApiAutoShowMode();
1151  aShowInfo.ItemCount = maFieldExtInfo.GetApiAutoShowCount();
1152  aShowInfo.DataField = mrPTable.GetDataFieldName( maFieldExtInfo.mnShowField );
1153  rSaveDim.SetAutoShowInfo( &aShowInfo );
1154 
1155  // layout
1156  DataPilotFieldLayoutInfo aLayoutInfo;
1157  aLayoutInfo.LayoutMode = maFieldExtInfo.GetApiLayoutMode();
1158  aLayoutInfo.AddEmptyLines = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_LAYOUT_BLANK );
1159  rSaveDim.SetLayoutInfo( &aLayoutInfo );
1160 
1161  // grouping info
1162  pCacheField->ConvertGroupField( rSaveData, mrPTable.GetVisFieldNames() );
1163 
1164  // custom subtotal name
1166  {
1168  rSaveDim.SetSubtotalName(aSubName);
1169  }
1170 }
1171 
1172 void XclImpPTField::ConvertFieldInfo( const ScDPSaveData& rSaveData, ScDPObject* pObj, const XclImpRoot& rRoot, bool bPageField ) const
1173 {
1174  const OUString& rFieldName = GetFieldName();
1175  if( rFieldName.isEmpty() )
1176  return;
1177 
1178  const XclImpPCField* pCacheField = GetCacheField();
1179  if( !pCacheField || !pCacheField->IsSupportedField() )
1180  return;
1181 
1182  ScDPSaveDimension* pSaveDim = rSaveData.GetExistingDimensionByName(rFieldName);
1183  if (!pSaveDim)
1184  return;
1185 
1187  for( const auto& rxItem : maItems )
1188  rxItem->ConvertItem( *pSaveDim, pObj, rRoot );
1189 
1190  if(bPageField && maPageInfo.mnSelItem != EXC_SXPI_ALLITEMS)
1191  {
1192  const XclImpPTItem* pItem = GetItem( maPageInfo.mnSelItem );
1193  if(pItem)
1194  {
1195  std::pair<bool, OUString> aReturnedName = pItem->GetItemName(*pSaveDim, pObj, rRoot);
1196  if(aReturnedName.first)
1197  pSaveDim->SetCurrentPage(&aReturnedName.second);
1198  }
1199  }
1200 }
1201 
1203 {
1204  // orientation
1205  rSaveDim.SetOrientation( DataPilotFieldOrientation_DATA );
1206  // extended data field info
1207  ConvertDataFieldInfo( rSaveDim, rDataInfo );
1208 }
1209 
1211 {
1212  // visible name
1213  const OUString* pVisName = rDataInfo.GetVisName();
1214  if (pVisName && !pVisName->isEmpty())
1215  rSaveDim.SetLayoutName(*pVisName);
1216 
1217  // aggregation function
1218  rSaveDim.SetFunction( rDataInfo.GetApiAggFunc() );
1219 
1220  // result field reference
1221  sal_Int32 nRefType = rDataInfo.GetApiRefType();
1222  DataPilotFieldReference aFieldRef;
1223  aFieldRef.ReferenceType = nRefType;
1224  const XclImpPTField* pRefField = mrPTable.GetField(rDataInfo.mnRefField);
1225  if (pRefField)
1226  {
1227  aFieldRef.ReferenceField = pRefField->GetFieldName();
1228  aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
1229  if (aFieldRef.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
1230  {
1231  const OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem);
1232  if (pRefItemName)
1233  aFieldRef.ReferenceItemName = *pRefItemName;
1234  }
1235  }
1236 
1237  rSaveDim.SetReferenceValue(&aFieldRef);
1238 }
1239 
1241  XclImpRoot( rRoot ),
1242  maDataOrientField( *this, EXC_SXIVD_DATA ),
1243  mpDPObj(nullptr)
1244 {
1245 }
1246 
1248 {
1249 }
1250 
1251 // cache/field access, misc. --------------------------------------------------
1252 
1254 {
1255  return static_cast< sal_uInt16 >( maFields.size() );
1256 }
1257 
1258 const XclImpPTField* XclImpPivotTable::GetField( sal_uInt16 nFieldIdx ) const
1259 {
1260  return (nFieldIdx == EXC_SXIVD_DATA) ? &maDataOrientField :
1261  ((nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr);
1262 }
1263 
1265 {
1266  // do not return maDataOrientField
1267  return (nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr;
1268 }
1269 
1270 const XclImpPTField* XclImpPivotTable::GetDataField( sal_uInt16 nDataFieldIdx ) const
1271 {
1272  if( nDataFieldIdx < maOrigDataFields.size() )
1273  return GetField( maOrigDataFields[ nDataFieldIdx ] );
1274  return nullptr;
1275 }
1276 
1277 OUString XclImpPivotTable::GetDataFieldName( sal_uInt16 nDataFieldIdx ) const
1278 {
1279  if( const XclImpPTField* pField = GetDataField( nDataFieldIdx ) )
1280  return pField->GetFieldName();
1281  return OUString();
1282 }
1283 
1284 // records --------------------------------------------------------------------
1285 
1287 {
1288  rStrm >> maPTInfo;
1289 
1291  maOutScRange, maPTInfo.maOutXclRange, GetCurrScTab(), GetCurrScTab(), true );
1292 
1293  mxPCache = GetPivotTableManager().GetPivotCache( maPTInfo.mnCacheIdx );
1294  mxCurrField.reset();
1295 }
1296 
1298 {
1299  sal_uInt16 nFieldCount = GetFieldCount();
1300  if( nFieldCount < EXC_PT_MAXFIELDCOUNT )
1301  {
1302  // cache index for the field is equal to the SXVD record index
1303  mxCurrField = std::make_shared<XclImpPTField>( *this, nFieldCount );
1304  maFields.push_back( mxCurrField );
1305  mxCurrField->ReadSxvd( rStrm );
1306  // add visible name of new field to list of visible names
1307  maVisFieldNames.push_back( mxCurrField->GetVisFieldName() );
1308  OSL_ENSURE( maFields.size() == maVisFieldNames.size(),
1309  "XclImpPivotTable::ReadSxvd - wrong size of visible name array" );
1310  }
1311  else
1312  mxCurrField.reset();
1313 }
1314 
1316 {
1317  if( mxCurrField )
1318  mxCurrField->ReadSxvi( rStrm );
1319 }
1320 
1322 {
1323  if( mxCurrField )
1324  mxCurrField->ReadSxvdex( rStrm );
1325 }
1326 
1328 {
1329  mxCurrField.reset();
1330 
1331  // find the index vector to fill (row SXIVD doesn't exist without row fields)
1332  ScfUInt16Vec* pFieldVec = nullptr;
1333  if( maRowFields.empty() && (maPTInfo.mnRowFields > 0) )
1334  pFieldVec = &maRowFields;
1335  else if( maColFields.empty() && (maPTInfo.mnColFields > 0) )
1336  pFieldVec = &maColFields;
1337 
1338  // fill the vector from record data
1339  if( pFieldVec )
1340  {
1341  sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 2, EXC_PT_MAXROWCOLCOUNT );
1342  pFieldVec->reserve( nSize );
1343  for( sal_uInt16 nIdx = 0; nIdx < nSize; ++nIdx )
1344  {
1345  sal_uInt16 nFieldIdx;
1346  nFieldIdx = rStrm.ReaduInt16();
1347  pFieldVec->push_back( nFieldIdx );
1348 
1349  // set orientation at special data orientation field
1350  if( nFieldIdx == EXC_SXIVD_DATA )
1351  {
1352  sal_uInt16 nAxis = (pFieldVec == &maRowFields) ? EXC_SXVD_AXIS_ROW : EXC_SXVD_AXIS_COL;
1353  maDataOrientField.SetAxes( nAxis );
1354  }
1355  }
1356  }
1357 }
1358 
1360 {
1361  mxCurrField.reset();
1362 
1363  sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 6 );
1364  for( sal_uInt16 nEntry = 0; nEntry < nSize; ++nEntry )
1365  {
1366  XclPTPageFieldInfo aPageInfo;
1367  rStrm >> aPageInfo;
1368  if( XclImpPTField* pField = GetFieldAcc( aPageInfo.mnField ) )
1369  {
1370  maPageFields.push_back( aPageInfo.mnField );
1371  pField->SetPageFieldInfo( aPageInfo );
1372  }
1373  GetCurrSheetDrawing().SetSkipObj( aPageInfo.mnObjId );
1374  }
1375 }
1376 
1378 {
1379  mxCurrField.reset();
1380 
1381  XclPTDataFieldInfo aDataInfo;
1382  rStrm >> aDataInfo;
1383  if( XclImpPTField* pField = GetFieldAcc( aDataInfo.mnField ) )
1384  {
1385  maOrigDataFields.push_back( aDataInfo.mnField );
1386  // DataPilot does not support double data fields -> add first appearance to index list only
1387  if( !pField->HasDataFieldInfo() )
1388  maFiltDataFields.push_back( aDataInfo.mnField );
1389  pField->AddDataFieldInfo( aDataInfo );
1390  }
1391 }
1392 
1394 {
1395  rStrm >> maPTExtInfo;
1396 }
1397 
1399 {
1400  rStrm >> maPTViewEx9Info;
1401 }
1402 
1404 {
1405  rStrm >> maPTAddlInfo;
1406 }
1407 
1409 {
1410  if( !mxPCache || !mxPCache->IsValid() )
1411  return;
1412 
1413  if (utl::ConfigManager::IsFuzzing()) //just too slow
1414  return;
1415 
1416  ScDPSaveData aSaveData;
1417 
1418  // *** global settings ***
1419 
1422  aSaveData.SetFilterButton( false );
1424  aSaveData.SetIgnoreEmptyRows( false );
1425  aSaveData.SetRepeatIfEmpty( false );
1426 
1427  // *** fields ***
1428 
1429  // row fields
1430  for( const auto& rRowField : maRowFields )
1431  if( const XclImpPTField* pField = GetField( rRowField ) )
1432  pField->ConvertRowColField( aSaveData );
1433 
1434  // column fields
1435  for( const auto& rColField : maColFields )
1436  if( const XclImpPTField* pField = GetField( rColField ) )
1437  pField->ConvertRowColField( aSaveData );
1438 
1439  // page fields
1440  for( const auto& rPageField : maPageFields )
1441  if( const XclImpPTField* pField = GetField( rPageField ) )
1442  pField->ConvertPageField( aSaveData );
1443 
1444  // We need to import hidden fields because hidden fields may contain
1445  // special settings for subtotals (aggregation function, filters, custom
1446  // name etc.) and members (hidden, custom name etc.).
1447 
1448  // hidden fields
1449  for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1450  if( const XclImpPTField* pField = GetField( nField ) )
1451  if (!pField->GetAxes())
1452  pField->ConvertHiddenField( aSaveData );
1453 
1454  // data fields
1455  for( const auto& rFiltDataField : maFiltDataFields )
1456  if( const XclImpPTField* pField = GetField( rFiltDataField ) )
1457  pField->ConvertDataField( aSaveData );
1458 
1459  // *** insert into Calc document ***
1460 
1461  // create source descriptor
1462  ScSheetSourceDesc aDesc(&GetDoc());
1463  const OUString& rSrcName = mxPCache->GetSourceRangeName();
1464  if (!rSrcName.isEmpty())
1465  // Range name is the data source.
1466  aDesc.SetRangeName(rSrcName);
1467  else
1468  // Normal cell range.
1469  aDesc.SetSourceRange(mxPCache->GetSourceRange());
1470 
1471  // adjust output range to include the page fields
1472  ScRange aOutRange( maOutScRange );
1473  if( !maPageFields.empty() )
1474  {
1475  SCROW nDecRows = ::std::min< SCROW >( aOutRange.aStart.Row(), maPageFields.size() + 1 );
1476  aOutRange.aStart.IncRow( -nDecRows );
1477  }
1478 
1479  // create the DataPilot
1480  std::unique_ptr<ScDPObject> pDPObj(new ScDPObject( &GetDoc() ));
1481  pDPObj->SetName( maPTInfo.maTableName );
1482  if (!maPTInfo.maDataName.isEmpty())
1484 
1485  if (!maPTViewEx9Info.maGrandTotalName.isEmpty())
1487 
1488  pDPObj->SetSaveData( aSaveData );
1489  pDPObj->SetSheetDesc( aDesc );
1490  pDPObj->SetOutRange( aOutRange );
1491  pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
1492 
1493  mpDPObj = GetDoc().GetDPCollection()->InsertNewTable(std::move(pDPObj));
1494 
1495  ApplyFieldInfo();
1496  ApplyMergeFlags(aOutRange, aSaveData);
1497 }
1498 
1500 {
1501  if (mpDPObj && mxPCache->IsRefreshOnLoad())
1502  {
1503  // 'refresh table on load' flag is set. Refresh the table now. Some
1504  // Excel files contain partial table output when this flag is set.
1505  ScRange aOutRange = mpDPObj->GetOutRange();
1506  mpDPObj->Output(aOutRange.aStart);
1507  }
1508 }
1509 
1510 void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData)
1511 {
1512  // Apply merge flags for various datapilot controls.
1513 
1514  ScDPOutputGeometry aGeometry(rOutRange, false);
1519 
1520  // Make sure we set headerlayout when input file has additional raw header
1521  if(maPTInfo.mnColFields == 0)
1522  {
1523  mpDPObj->SetHeaderLayout( maPTInfo.mnFirstHeadRow - 2 == static_cast<sal_uInt16>(aGeometry.getRowFieldHeaderRow()) );
1524  }
1525  aGeometry.setHeaderLayout(mpDPObj->GetHeaderLayout());
1527 
1528  ScDocument& rDoc = GetDoc();
1529 
1530  vector<const ScDPSaveDimension*> aFieldDims;
1531  vector<ScAddress> aFieldBtns;
1532 
1533  aGeometry.getPageFieldPositions(aFieldBtns);
1534  for (const auto& rFieldBtn : aFieldBtns)
1535  {
1536  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), ScMF::Button);
1537 
1538  ScMF nMFlag = ScMF::ButtonPopup;
1539  OUString aName = rDoc.GetString(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab());
1540  if (rSaveData.HasInvisibleMember(aName))
1541  nMFlag |= ScMF::HiddenMember;
1542 
1543  rDoc.ApplyFlagsTab(rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1544  }
1545 
1546  aGeometry.getColumnFieldPositions(aFieldBtns);
1547  rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aFieldDims);
1548  if (aFieldBtns.size() == aFieldDims.size())
1549  {
1550  vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1551  for (const auto& rFieldBtn : aFieldBtns)
1552  {
1553  ScMF nMFlag = ScMF::Button;
1554  const ScDPSaveDimension* pDim = *itDim;
1555  if (pDim->HasInvisibleMember())
1556  nMFlag |= ScMF::HiddenMember;
1557  if (!pDim->IsDataLayout())
1558  nMFlag |= ScMF::ButtonPopup;
1559  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1560  ++itDim;
1561  }
1562  }
1563 
1564  aGeometry.getRowFieldPositions(aFieldBtns);
1565  rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aFieldDims);
1566  if ((aFieldBtns.size() == aFieldDims.size()) || (maPTAddlInfo.mbCompactMode && aFieldBtns.size() == 1))
1567  {
1568  vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1569  for (const auto& rFieldBtn : aFieldBtns)
1570  {
1571  ScMF nMFlag = ScMF::Button;
1572  const ScDPSaveDimension* pDim = itDim != aFieldDims.end() ? *itDim++ : nullptr;
1573  if (pDim && pDim->HasInvisibleMember())
1574  nMFlag |= ScMF::HiddenMember;
1575  if (!pDim || !pDim->IsDataLayout())
1576  nMFlag |= ScMF::ButtonPopup;
1577  rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1578  }
1579  }
1580 }
1581 
1582 
1584 {
1586  ScDPSaveData& rSaveData = *mpDPObj->GetSaveData();
1587 
1588  // row fields
1589  for( const auto& rRowField : maRowFields )
1590  if( const XclImpPTField* pField = GetField( rRowField ) )
1591  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1592 
1593  // column fields
1594  for( const auto& rColField : maColFields )
1595  if( const XclImpPTField* pField = GetField( rColField ) )
1596  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1597 
1598  // page fields
1599  for( const auto& rPageField : maPageFields )
1600  if( const XclImpPTField* pField = GetField( rPageField ) )
1601  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this, true );
1602 
1603  // hidden fields
1604  for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1605  if( const XclImpPTField* pField = GetField( nField ) )
1606  if (!pField->GetAxes())
1607  pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1608 }
1609 
1611  XclImpRoot( rRoot )
1612 {
1613 }
1614 
1616 {
1617 }
1618 
1619 // pivot cache records --------------------------------------------------------
1620 
1622 {
1623  XclImpPivotCacheRef xPCache;
1624  if( nCacheIdx < maPCaches.size() )
1625  xPCache = maPCaches[ nCacheIdx ];
1626  return xPCache;
1627 }
1628 
1630 {
1631  XclImpPivotCacheRef xPCache = std::make_shared<XclImpPivotCache>( GetRoot() );
1632  maPCaches.push_back( xPCache );
1633  xPCache->ReadSxidstm( rStrm );
1634 }
1635 
1637 {
1638  if( !maPCaches.empty() )
1639  maPCaches.back()->ReadSxvs( rStrm );
1640 }
1641 
1643 {
1644  if( !maPCaches.empty() )
1645  maPCaches.back()->ReadDconref( rStrm );
1646 }
1647 
1649 {
1650  if( !maPCaches.empty() )
1651  maPCaches.back()->ReadDConName( rStrm );
1652 }
1653 
1654 // pivot table records --------------------------------------------------------
1655 
1657 {
1658  XclImpPivotTableRef xPTable = std::make_shared<XclImpPivotTable>( GetRoot() );
1659  maPTables.push_back( xPTable );
1660  xPTable->ReadSxview( rStrm );
1661 }
1662 
1664 {
1665  if( !maPTables.empty() )
1666  maPTables.back()->ReadSxvd( rStrm );
1667 }
1668 
1670 {
1671  if( !maPTables.empty() )
1672  maPTables.back()->ReadSxvdex( rStrm );
1673 }
1674 
1676 {
1677  if( !maPTables.empty() )
1678  maPTables.back()->ReadSxivd( rStrm );
1679 }
1680 
1682 {
1683  if( !maPTables.empty() )
1684  maPTables.back()->ReadSxpi( rStrm );
1685 }
1686 
1688 {
1689  if( !maPTables.empty() )
1690  maPTables.back()->ReadSxdi( rStrm );
1691 }
1692 
1694 {
1695  if( !maPTables.empty() )
1696  maPTables.back()->ReadSxvi( rStrm );
1697 }
1698 
1700 {
1701  if( !maPTables.empty() )
1702  maPTables.back()->ReadSxex( rStrm );
1703 }
1704 
1706 {
1707  if( !maPTables.empty() )
1708  maPTables.back()->ReadSxViewEx9( rStrm );
1709 }
1710 
1712 {
1713  if( !maPTables.empty() )
1714  maPTables.back()->ReadSxAddl( rStrm );
1715 }
1716 
1718 {
1719  for( auto& rxPCache : maPCaches )
1720  rxPCache->ReadPivotCacheStream( rStrm );
1721 }
1722 
1724 {
1725  for( auto& rxPTable : maPTables )
1726  rxPTable->Convert();
1727 }
1728 
1730 {
1731  for( auto& rxPTable : maPTables )
1732  rxPTable->MaybeRefresh();
1733 }
1734 
1735 /* 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:999
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:1277
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:1297
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:1296
void ReadSxidstm(XclImpStream &rStrm)
Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache.
Definition: xipivot.cxx:609
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:658
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:244
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of the current field.
Definition: xipivot.cxx:1693
void ReadSxAddl(XclImpStream &rStrm)
Reads an SXADDL record that specifies additional info for pivot table.
Definition: xipivot.cxx:1403
void ConvertDateGroupField(ScDPSaveData &rSaveData, const ScfStringVec &rVisNames) const
Inserts date grouping information of this field into the passed ScDPSaveData.
Definition: xipivot.cxx:446
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:1681
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:968
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:1029
void ReadSxpi(XclImpStream &rStrm)
Reads an SXPI record containing page field data.
Definition: xipivot.cxx:1359
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:1408
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of the current field.
Definition: xipivot.cxx:1321
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:1629
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:1196
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5014
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:346
XclImpPTField(const XclImpPivotTable &rPTable, sal_uInt16 nCacheIdx)
Definition: xipivot.cxx:954
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:564
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:1711
ScDPSaveMember * GetExistingMemberByName(const OUString &rName)
Definition: dpsave.cxx:448
ScDPNumGroupInfo GetScDateGroupInfo() const
Returns a Calc struct with date grouping data.
Definition: xipivot.cxx:514
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:1240
bool IsDataLayout() const
Definition: dpsave.hxx:142
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:278
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:315
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4759
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:254
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:1056
const XclImpPTItem * GetItem(sal_uInt16 nItemIdx) const
Returns the specified item.
Definition: xipivot.cxx:980
bool HasInvisibleMember() const
Definition: dpsave.cxx:623
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:1636
sal_Int32 GetApiSortMode() const
Returns the API constant representing the sorting mode.
Definition: xlpivot.cxx:579
void SetPageFieldInfo(const XclPTPageFieldInfo &rPageInfo)
Definition: xipivot.cxx:1024
virtual ~XclImpPivotCache() override
Definition: xipivot.cxx:596
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:808
void ConvertDataFieldInfo(ScDPSaveDimension &rSaveDim, const XclPTDataFieldInfo &rDataInfo) const
Definition: xipivot.cxx:1210
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:852
bool IsValid() const
Definition: xipivot.cxx:865
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:1642
const sal_uInt16 EXC_SXVS_SHEET
Definition: xlpivot.hxx:300
XclImpPTField * GetFieldAcc(sal_uInt16 nFieldIdx)
Definition: xipivot.cxx:1264
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:876
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
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:3488
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:190
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:860
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:642
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:1699
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:1327
sal_Int16 ReadInt16()
Definition: xistream.cxx:630
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing the field.
Definition: xipivot.cxx:993
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:875
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:490
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:875
void ReadDConName(XclImpStream &rStrm)
Definition: xipivot.cxx:1648
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:1705
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:856
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:1091
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:1610
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:1723
double GetDoubleFromDateTime(const DateTime &rDateTime) const
Converts a date/time value to a floating-point value.
Definition: xlroot.cxx:334
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:391
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:846
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:4038
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:932
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:1286
void ConvertRCPField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1110
const sal_uInt16 EXC_ID_SXDBEX
Definition: xlpivot.hxx:351
SvNumFormatType
void ConvertRowColField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1012
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:1315
SC_DLLPUBLIC ScDPObject * InsertNewTable(std::unique_ptr< ScDPObject > pDPObj)
Definition: dpobject.cxx:3731
SC_DLLPUBLIC void SetIgnoreEmptyRows(bool bSet)
Definition: dpsave.cxx:994
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:602
void ConvertFieldInfo(const ScDPSaveData &rSaveData, ScDPObject *pObj, const XclImpRoot &rRoot, bool bPageField=false) const
Definition: xipivot.cxx:1172
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:1669
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:614
OUString GetVisFieldName() const
Returns the internally set visible name of this field.
Definition: xipivot.cxx:974
SC_DLLPUBLIC void SetFilterButton(bool bSet)
Definition: dpsave.cxx:1004
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:1510
void ReadSxex(XclImpStream &rStrm)
Reads an SXEX record containing additional settings for the pivot table.
Definition: xipivot.cxx:1393
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:1615
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:426
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:1583
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:1398
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:1621
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:1003
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:766
const XclImpPCField * GetCacheField() const
Returns the corresponding pivot cache field of this field.
Definition: xipivot.cxx:962
const DateTime * GetDateGroupLimit(sal_uInt16 nLimitIdx) const
Returns a limit value for date grouping fields (minimum/maximum only).
Definition: xipivot.cxx:553
SC_DLLPUBLIC void SetDrillDown(bool bSet)
Definition: dpsave.cxx:1009
std::vector< XclImpPivotCacheRef > maPCaches
Definition: xipivot.hxx:424
bool HasDataFieldInfo() const
Definition: xipivot.cxx:1045
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:1656
const double * GetNumGroupLimit(sal_uInt16 nLimitIdx) const
Returns a limit value for numeric grouping fields.
Definition: xipivot.cxx:542
::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:886
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:1037
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:1050
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:1499
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:937
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:1270
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:1675
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:984
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:439
const sal_uInt16 EXC_ID_SXFDBTYPE
Definition: xlpivot.hxx:355
SC_DLLPUBLIC void SetRowGrand(bool bSet)
Definition: dpsave.cxx:989
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:1258
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:1377
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:167
OUString maTableName
Definition: xlpivot.hxx:708
sal_uInt16 GetFieldCount() const
Definition: xipivot.cxx:1253
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:620
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing a new field.
Definition: xipivot.cxx:1663
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:1717
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:1247
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:266
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:1687
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:880
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:587
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of the field.
Definition: xipivot.cxx:998
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
Definition: dpsave.cxx:867
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:985
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