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