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( '_' ).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(c);
1104 aBuf.append(c);
1105 }
1106 else
1107 aBuf.append(c);
1108 }
1109 return aBuf.makeStringAndClear();
1110}
1111
1113{
1114 const OUString& rFieldName = GetFieldName();
1115 if( rFieldName.isEmpty() )
1116 return;
1117
1118 const XclImpPCField* pCacheField = GetCacheField();
1119 if( !pCacheField || !pCacheField->IsSupportedField() )
1120 return;
1121
1122 ScDPSaveDimension* pTest = rSaveData.GetNewDimensionByName(rFieldName);
1123 if (!pTest)
1124 return;
1125
1126 ScDPSaveDimension& rSaveDim = *pTest;
1127
1128 // orientation
1130
1131 // visible name
1132 if (const OUString* pVisName = maFieldInfo.GetVisName())
1133 if (!pVisName->isEmpty())
1134 rSaveDim.SetLayoutName( *pVisName );
1135
1136 // subtotal function(s)
1137 XclPTSubtotalVec aSubtotalVec;
1138 maFieldInfo.GetSubtotals( aSubtotalVec );
1139 if( !aSubtotalVec.empty() )
1140 rSaveDim.SetSubTotals( std::move(aSubtotalVec) );
1141
1142 // sorting
1143 DataPilotFieldSortInfo aSortInfo;
1145 aSortInfo.IsAscending = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SORT_ASC );
1146 aSortInfo.Mode = maFieldExtInfo.GetApiSortMode();
1147 rSaveDim.SetSortInfo( &aSortInfo );
1148
1149 // auto show
1150 DataPilotFieldAutoShowInfo aShowInfo;
1151 aShowInfo.IsEnabled = ::get_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_AUTOSHOW );
1152 aShowInfo.ShowItemsMode = maFieldExtInfo.GetApiAutoShowMode();
1153 aShowInfo.ItemCount = maFieldExtInfo.GetApiAutoShowCount();
1154 aShowInfo.DataField = mrPTable.GetDataFieldName( maFieldExtInfo.mnShowField );
1155 rSaveDim.SetAutoShowInfo( &aShowInfo );
1156
1157 // layout
1158 DataPilotFieldLayoutInfo aLayoutInfo;
1161 rSaveDim.SetLayoutInfo( &aLayoutInfo );
1162
1163 // grouping info
1164 pCacheField->ConvertGroupField( rSaveData, mrPTable.GetVisFieldNames() );
1165
1166 // custom subtotal name
1168 {
1170 rSaveDim.SetSubtotalName(aSubName);
1171 }
1172}
1173
1174void XclImpPTField::ConvertFieldInfo( const ScDPSaveData& rSaveData, ScDPObject* pObj, const XclImpRoot& rRoot, bool bPageField ) const
1175{
1176 const OUString& rFieldName = GetFieldName();
1177 if( rFieldName.isEmpty() )
1178 return;
1179
1180 const XclImpPCField* pCacheField = GetCacheField();
1181 if( !pCacheField || !pCacheField->IsSupportedField() )
1182 return;
1183
1184 ScDPSaveDimension* pSaveDim = rSaveData.GetExistingDimensionByName(rFieldName);
1185 if (!pSaveDim)
1186 return;
1187
1189 for( const auto& rxItem : maItems )
1190 rxItem->ConvertItem( *pSaveDim, pObj, rRoot );
1191
1192 if(bPageField && maPageInfo.mnSelItem != EXC_SXPI_ALLITEMS)
1193 {
1194 const XclImpPTItem* pItem = GetItem( maPageInfo.mnSelItem );
1195 if(pItem)
1196 {
1197 std::pair<bool, OUString> aReturnedName = pItem->GetItemName(*pSaveDim, pObj, rRoot);
1198 if(aReturnedName.first)
1199 pSaveDim->SetCurrentPage(&aReturnedName.second);
1200 }
1201 }
1202}
1203
1205{
1206 // orientation
1207 rSaveDim.SetOrientation( DataPilotFieldOrientation_DATA );
1208 // extended data field info
1209 ConvertDataFieldInfo( rSaveDim, rDataInfo );
1210}
1211
1213{
1214 // visible name
1215 const OUString* pVisName = rDataInfo.GetVisName();
1216 if (pVisName && !pVisName->isEmpty())
1217 rSaveDim.SetLayoutName(*pVisName);
1218
1219 // aggregation function
1220 rSaveDim.SetFunction( rDataInfo.GetApiAggFunc() );
1221
1222 // result field reference
1223 sal_Int32 nRefType = rDataInfo.GetApiRefType();
1224 DataPilotFieldReference aFieldRef;
1225 aFieldRef.ReferenceType = nRefType;
1226 const XclImpPTField* pRefField = mrPTable.GetField(rDataInfo.mnRefField);
1227 if (pRefField)
1228 {
1229 aFieldRef.ReferenceField = pRefField->GetFieldName();
1230 aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
1231 if (aFieldRef.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
1232 {
1233 const OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem);
1234 if (pRefItemName)
1235 aFieldRef.ReferenceItemName = *pRefItemName;
1236 }
1237 }
1238
1239 rSaveDim.SetReferenceValue(&aFieldRef);
1240}
1241
1243 XclImpRoot( rRoot ),
1244 maDataOrientField( *this, EXC_SXIVD_DATA ),
1245 mpDPObj(nullptr)
1246{
1247}
1248
1250{
1251}
1252
1253// cache/field access, misc. --------------------------------------------------
1254
1256{
1257 return static_cast< sal_uInt16 >( maFields.size() );
1258}
1259
1260const XclImpPTField* XclImpPivotTable::GetField( sal_uInt16 nFieldIdx ) const
1261{
1262 return (nFieldIdx == EXC_SXIVD_DATA) ? &maDataOrientField :
1263 ((nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr);
1264}
1265
1267{
1268 // do not return maDataOrientField
1269 return (nFieldIdx < maFields.size()) ? maFields[ nFieldIdx ].get() : nullptr;
1270}
1271
1272const XclImpPTField* XclImpPivotTable::GetDataField( sal_uInt16 nDataFieldIdx ) const
1273{
1274 if( nDataFieldIdx < maOrigDataFields.size() )
1275 return GetField( maOrigDataFields[ nDataFieldIdx ] );
1276 return nullptr;
1277}
1278
1279OUString XclImpPivotTable::GetDataFieldName( sal_uInt16 nDataFieldIdx ) const
1280{
1281 if( const XclImpPTField* pField = GetDataField( nDataFieldIdx ) )
1282 return pField->GetFieldName();
1283 return OUString();
1284}
1285
1286// records --------------------------------------------------------------------
1287
1289{
1290 rStrm >> maPTInfo;
1291
1294
1296 mxCurrField.reset();
1297}
1298
1300{
1301 sal_uInt16 nFieldCount = GetFieldCount();
1302 if( nFieldCount < EXC_PT_MAXFIELDCOUNT )
1303 {
1304 // cache index for the field is equal to the SXVD record index
1305 mxCurrField = std::make_shared<XclImpPTField>( *this, nFieldCount );
1306 maFields.push_back( mxCurrField );
1307 mxCurrField->ReadSxvd( rStrm );
1308 // add visible name of new field to list of visible names
1309 maVisFieldNames.push_back( mxCurrField->GetVisFieldName() );
1310 OSL_ENSURE( maFields.size() == maVisFieldNames.size(),
1311 "XclImpPivotTable::ReadSxvd - wrong size of visible name array" );
1312 }
1313 else
1314 mxCurrField.reset();
1315}
1316
1318{
1319 if( mxCurrField )
1320 mxCurrField->ReadSxvi( rStrm );
1321}
1322
1324{
1325 if( mxCurrField )
1326 mxCurrField->ReadSxvdex( rStrm );
1327}
1328
1330{
1331 mxCurrField.reset();
1332
1333 // find the index vector to fill (row SXIVD doesn't exist without row fields)
1334 ScfUInt16Vec* pFieldVec = nullptr;
1335 if( maRowFields.empty() && (maPTInfo.mnRowFields > 0) )
1336 pFieldVec = &maRowFields;
1337 else if( maColFields.empty() && (maPTInfo.mnColFields > 0) )
1338 pFieldVec = &maColFields;
1339
1340 // fill the vector from record data
1341 if( !pFieldVec )
1342 return;
1343
1344 sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 2, EXC_PT_MAXROWCOLCOUNT );
1345 pFieldVec->reserve( nSize );
1346 for( sal_uInt16 nIdx = 0; nIdx < nSize; ++nIdx )
1347 {
1348 sal_uInt16 nFieldIdx;
1349 nFieldIdx = rStrm.ReaduInt16();
1350 pFieldVec->push_back( nFieldIdx );
1351
1352 // set orientation at special data orientation field
1353 if( nFieldIdx == EXC_SXIVD_DATA )
1354 {
1355 sal_uInt16 nAxis = (pFieldVec == &maRowFields) ? EXC_SXVD_AXIS_ROW : EXC_SXVD_AXIS_COL;
1356 maDataOrientField.SetAxes( nAxis );
1357 }
1358 }
1359}
1360
1362{
1363 mxCurrField.reset();
1364
1365 sal_uInt16 nSize = ulimit_cast< sal_uInt16 >( rStrm.GetRecSize() / 6 );
1366 for( sal_uInt16 nEntry = 0; nEntry < nSize; ++nEntry )
1367 {
1368 XclPTPageFieldInfo aPageInfo;
1369 rStrm >> aPageInfo;
1370 if( XclImpPTField* pField = GetFieldAcc( aPageInfo.mnField ) )
1371 {
1372 maPageFields.push_back( aPageInfo.mnField );
1373 pField->SetPageFieldInfo( aPageInfo );
1374 }
1375 GetCurrSheetDrawing().SetSkipObj( aPageInfo.mnObjId );
1376 }
1377}
1378
1380{
1381 mxCurrField.reset();
1382
1383 XclPTDataFieldInfo aDataInfo;
1384 rStrm >> aDataInfo;
1385 if( XclImpPTField* pField = GetFieldAcc( aDataInfo.mnField ) )
1386 {
1387 maOrigDataFields.push_back( aDataInfo.mnField );
1388 // DataPilot does not support double data fields -> add first appearance to index list only
1389 if( !pField->HasDataFieldInfo() )
1390 maFiltDataFields.push_back( aDataInfo.mnField );
1391 pField->AddDataFieldInfo( aDataInfo );
1392 }
1393}
1394
1396{
1397 rStrm >> maPTExtInfo;
1398}
1399
1401{
1403}
1404
1406{
1408}
1409
1411{
1412 if( !mxPCache || !mxPCache->IsValid() )
1413 return;
1414
1415 if (utl::ConfigManager::IsFuzzing()) //just too slow
1416 return;
1417
1418 ScDPSaveData aSaveData;
1419
1420 // *** global settings ***
1421
1424 aSaveData.SetFilterButton( false );
1426 aSaveData.SetIgnoreEmptyRows( false );
1427 aSaveData.SetRepeatIfEmpty( false );
1428
1429 // *** fields ***
1430
1431 // row fields
1432 for( const auto& rRowField : maRowFields )
1433 if( const XclImpPTField* pField = GetField( rRowField ) )
1434 pField->ConvertRowColField( aSaveData );
1435
1436 // column fields
1437 for( const auto& rColField : maColFields )
1438 if( const XclImpPTField* pField = GetField( rColField ) )
1439 pField->ConvertRowColField( aSaveData );
1440
1441 // page fields
1442 for( const auto& rPageField : maPageFields )
1443 if( const XclImpPTField* pField = GetField( rPageField ) )
1444 pField->ConvertPageField( aSaveData );
1445
1446 // We need to import hidden fields because hidden fields may contain
1447 // special settings for subtotals (aggregation function, filters, custom
1448 // name etc.) and members (hidden, custom name etc.).
1449
1450 // hidden fields
1451 for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1452 if( const XclImpPTField* pField = GetField( nField ) )
1453 if (!pField->GetAxes())
1454 pField->ConvertHiddenField( aSaveData );
1455
1456 // data fields
1457 for( const auto& rFiltDataField : maFiltDataFields )
1458 if( const XclImpPTField* pField = GetField( rFiltDataField ) )
1459 pField->ConvertDataField( aSaveData );
1460
1461 // *** insert into Calc document ***
1462
1463 // create source descriptor
1464 ScSheetSourceDesc aDesc(&GetDoc());
1465 const OUString& rSrcName = mxPCache->GetSourceRangeName();
1466 if (!rSrcName.isEmpty())
1467 // Range name is the data source.
1468 aDesc.SetRangeName(rSrcName);
1469 else
1470 // Normal cell range.
1471 aDesc.SetSourceRange(mxPCache->GetSourceRange());
1472
1473 // adjust output range to include the page fields
1474 ScRange aOutRange( maOutScRange );
1475 if( !maPageFields.empty() )
1476 {
1477 SCROW nDecRows = ::std::min< SCROW >( aOutRange.aStart.Row(), maPageFields.size() + 1 );
1478 aOutRange.aStart.IncRow( -nDecRows );
1479 }
1480
1481 // create the DataPilot
1482 std::unique_ptr<ScDPObject> pDPObj(new ScDPObject( &GetDoc() ));
1483 pDPObj->SetName( maPTInfo.maTableName );
1484 if (!maPTInfo.maDataName.isEmpty())
1486
1487 if (!maPTViewEx9Info.maGrandTotalName.isEmpty())
1489
1490 pDPObj->SetSaveData( aSaveData );
1491 pDPObj->SetSheetDesc( aDesc );
1492 pDPObj->SetOutRange( aOutRange );
1493 pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
1494
1495 mpDPObj = GetDoc().GetDPCollection()->InsertNewTable(std::move(pDPObj));
1496
1498 ApplyMergeFlags(aOutRange, aSaveData);
1499}
1500
1502{
1503 if (mpDPObj && mxPCache->IsRefreshOnLoad())
1504 {
1505 // 'refresh table on load' flag is set. Refresh the table now. Some
1506 // Excel files contain partial table output when this flag is set.
1507 ScRange aOutRange = mpDPObj->GetOutRange();
1508 mpDPObj->Output(aOutRange.aStart);
1509 }
1510}
1511
1512void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData)
1513{
1514 // Apply merge flags for various datapilot controls.
1515
1516 ScDPOutputGeometry aGeometry(rOutRange, false);
1521
1522 // Make sure we set headerlayout when input file has additional raw header
1523 if(maPTInfo.mnColFields == 0)
1524 {
1525 mpDPObj->SetHeaderLayout( maPTInfo.mnFirstHeadRow - 2 == static_cast<sal_uInt16>(aGeometry.getRowFieldHeaderRow()) );
1526 }
1529
1530 ScDocument& rDoc = GetDoc();
1531
1532 vector<const ScDPSaveDimension*> aFieldDims;
1533 vector<ScAddress> aFieldBtns;
1534
1535 aGeometry.getPageFieldPositions(aFieldBtns);
1536 for (const auto& rFieldBtn : aFieldBtns)
1537 {
1538 rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), ScMF::Button);
1539
1540 ScMF nMFlag = ScMF::ButtonPopup;
1541 OUString aName = rDoc.GetString(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab());
1542 if (rSaveData.HasInvisibleMember(aName))
1543 nMFlag |= ScMF::HiddenMember;
1544
1545 rDoc.ApplyFlagsTab(rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Col()+1, rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1546 }
1547
1548 aGeometry.getColumnFieldPositions(aFieldBtns);
1549 rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aFieldDims);
1550 if (aFieldBtns.size() == aFieldDims.size())
1551 {
1552 vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1553 for (const auto& rFieldBtn : aFieldBtns)
1554 {
1555 ScMF nMFlag = ScMF::Button;
1556 const ScDPSaveDimension* pDim = *itDim;
1557 if (pDim->HasInvisibleMember())
1558 nMFlag |= ScMF::HiddenMember;
1559 if (!pDim->IsDataLayout())
1560 nMFlag |= ScMF::ButtonPopup;
1561 rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1562 ++itDim;
1563 }
1564 }
1565
1566 aGeometry.getRowFieldPositions(aFieldBtns);
1567 rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aFieldDims);
1568 if (!((aFieldBtns.size() == aFieldDims.size()) || (maPTAddlInfo.mbCompactMode && aFieldBtns.size() == 1)))
1569 return;
1570
1571 vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
1572 for (const auto& rFieldBtn : aFieldBtns)
1573 {
1574 ScMF nMFlag = ScMF::Button;
1575 const ScDPSaveDimension* pDim = itDim != aFieldDims.end() ? *itDim++ : nullptr;
1576 if (pDim && pDim->HasInvisibleMember())
1577 nMFlag |= ScMF::HiddenMember;
1578 if (!pDim || !pDim->IsDataLayout())
1579 nMFlag |= ScMF::ButtonPopup;
1580 rDoc.ApplyFlagsTab(rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Col(), rFieldBtn.Row(), rFieldBtn.Tab(), nMFlag);
1581 }
1582}
1583
1584
1586{
1588 ScDPSaveData& rSaveData = *mpDPObj->GetSaveData();
1589
1590 // row fields
1591 for( const auto& rRowField : maRowFields )
1592 if( const XclImpPTField* pField = GetField( rRowField ) )
1593 pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1594
1595 // column fields
1596 for( const auto& rColField : maColFields )
1597 if( const XclImpPTField* pField = GetField( rColField ) )
1598 pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1599
1600 // page fields
1601 for( const auto& rPageField : maPageFields )
1602 if( const XclImpPTField* pField = GetField( rPageField ) )
1603 pField->ConvertFieldInfo( rSaveData, mpDPObj, *this, true );
1604
1605 // hidden fields
1606 for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
1607 if( const XclImpPTField* pField = GetField( nField ) )
1608 if (!pField->GetAxes())
1609 pField->ConvertFieldInfo( rSaveData, mpDPObj, *this );
1610}
1611
1613 XclImpRoot( rRoot )
1614{
1615}
1616
1618{
1619}
1620
1621// pivot cache records --------------------------------------------------------
1622
1624{
1625 XclImpPivotCacheRef xPCache;
1626 if( nCacheIdx < maPCaches.size() )
1627 xPCache = maPCaches[ nCacheIdx ];
1628 return xPCache;
1629}
1630
1632{
1633 XclImpPivotCacheRef xPCache = std::make_shared<XclImpPivotCache>( GetRoot() );
1634 maPCaches.push_back( xPCache );
1635 xPCache->ReadSxidstm( rStrm );
1636}
1637
1639{
1640 if( !maPCaches.empty() )
1641 maPCaches.back()->ReadSxvs( rStrm );
1642}
1643
1645{
1646 if( !maPCaches.empty() )
1647 maPCaches.back()->ReadDconref( rStrm );
1648}
1649
1651{
1652 if( !maPCaches.empty() )
1653 maPCaches.back()->ReadDConName( rStrm );
1654}
1655
1656// pivot table records --------------------------------------------------------
1657
1659{
1660 XclImpPivotTableRef xPTable = std::make_shared<XclImpPivotTable>( GetRoot() );
1661 maPTables.push_back( xPTable );
1662 xPTable->ReadSxview( rStrm );
1663}
1664
1666{
1667 if( !maPTables.empty() )
1668 maPTables.back()->ReadSxvd( rStrm );
1669}
1670
1672{
1673 if( !maPTables.empty() )
1674 maPTables.back()->ReadSxvdex( rStrm );
1675}
1676
1678{
1679 if( !maPTables.empty() )
1680 maPTables.back()->ReadSxivd( rStrm );
1681}
1682
1684{
1685 if( !maPTables.empty() )
1686 maPTables.back()->ReadSxpi( rStrm );
1687}
1688
1690{
1691 if( !maPTables.empty() )
1692 maPTables.back()->ReadSxdi( rStrm );
1693}
1694
1696{
1697 if( !maPTables.empty() )
1698 maPTables.back()->ReadSxvi( rStrm );
1699}
1700
1702{
1703 if( !maPTables.empty() )
1704 maPTables.back()->ReadSxex( rStrm );
1705}
1706
1708{
1709 if( !maPTables.empty() )
1710 maPTables.back()->ReadSxViewEx9( rStrm );
1711}
1712
1714{
1715 if( !maPTables.empty() )
1716 maPTables.back()->ReadSxAddl( rStrm );
1717}
1718
1720{
1721 for( auto& rxPCache : maPCaches )
1722 rxPCache->ReadPivotCacheStream( rStrm );
1723}
1724
1726{
1727 for( auto& rxPTable : maPTables )
1728 rxPTable->Convert();
1729}
1730
1732{
1733 for( auto& rxPTable : maPTables )
1734 rxPTable->MaybeRefresh();
1735}
1736
1737/* 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:3743
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:995
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
Definition: dpsave.cxx:847
SC_DLLPUBLIC void GetAllDimensionsByOrientation(css::sheet::DataPilotFieldOrientation eOrientation, std::vector< const ScDPSaveDimension * > &rDims) const
Get all dimensions in a given orientation.
Definition: dpsave.cxx:809
SC_DLLPUBLIC ScDPSaveDimension * GetNewDimensionByName(const OUString &rName)
Definition: dpsave.cxx:857
SC_DLLPUBLIC bool HasInvisibleMember(std::u16string_view rDimName) const
Check whether a dimension has one or more invisible members.
Definition: dpsave.cxx:1309
ScDPSaveDimension * DuplicateDimension(std::u16string_view rName)
Definition: dpsave.cxx:887
SC_DLLPUBLIC void SetRepeatIfEmpty(bool bSet)
Definition: dpsave.cxx:1000
SC_DLLPUBLIC void SetFilterButton(bool bSet)
Definition: dpsave.cxx:1005
SC_DLLPUBLIC void SetGrandTotalName(const OUString &rName)
Definition: dpsave.cxx:767
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
Definition: dpsave.cxx:868
SC_DLLPUBLIC void SetRowGrand(bool bSet)
Definition: dpsave.cxx:990
SC_DLLPUBLIC void SetColumnGrand(bool bSet)
Definition: dpsave.cxx:985
SC_DLLPUBLIC ScDPDimensionSaveData * GetDimensionData()
Definition: dpsave.cxx:1197
SC_DLLPUBLIC void SetDrillDown(bool bSet)
Definition: dpsave.cxx:1010
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:891
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:865
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5083
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:395
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:172
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4835
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3545
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:195
SC_DLLPUBLIC ScDPCollection * GetDPCollection()
Definition: documen3.cxx:371
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
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:4070
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:1174
void ConvertRowColField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1014
void ConvertRCPField(ScDPSaveData &rSaveData) const
Definition: xipivot.cxx:1112
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:1212
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:1671
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of the current field.
Definition: xipivot.cxx:1695
std::vector< XclImpPivotCacheRef > maPCaches
Definition: xipivot.hxx:423
void ReadSxpi(XclImpStream &rStrm)
Reads an SXPI record containing page field data.
Definition: xipivot.cxx:1683
XclImpPivotTableManager(const XclImpRoot &rRoot)
Definition: xipivot.cxx:1612
void ReadSxViewEx9(XclImpStream &rStrm)
Reads an SXVIEWEX9 record that specifies the pivot tables autoformat.
Definition: xipivot.cxx:1707
void ReadPivotCaches(const XclImpStream &rStrm)
Reads all used pivot caches and creates additional sheets for external data sources.
Definition: xipivot.cxx:1719
void ReadSxview(XclImpStream &rStrm)
Reads an SXVIEW record describing a new pivot table.
Definition: xipivot.cxx:1658
void ReadDconref(XclImpStream &rStrm)
Reads a DCONREF record containing the source range of a pivot cache.
Definition: xipivot.cxx:1644
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:1677
void ReadSxdi(XclImpStream &rStrm)
Reads an SXDI record containing data field data.
Definition: xipivot.cxx:1689
void ReadSxidstm(XclImpStream &rStrm)
Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache.
Definition: xipivot.cxx:1631
virtual ~XclImpPivotTableManager() override
Definition: xipivot.cxx:1617
void ReadSxAddl(XclImpStream &rStrm)
Reads an SXADDL record that specifies additional info for pivot table.
Definition: xipivot.cxx:1713
XclImpPivotCacheRef GetPivotCache(sal_uInt16 nCacheIdx)
Returns the pivot cache with the specified 0-based index.
Definition: xipivot.cxx:1623
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing a new field.
Definition: xipivot.cxx:1665
void ReadDConName(XclImpStream &rStrm)
Definition: xipivot.cxx:1650
void ConvertPivotTables()
Inserts all pivot tables into the Calc document.
Definition: xipivot.cxx:1725
void ReadSxex(XclImpStream &rStrm)
Reads an SXEX record containing additional settings for a pivot table.
Definition: xipivot.cxx:1701
void ReadSxvs(XclImpStream &rStrm)
Reads an SXVS record containing the source type of a pivot cache.
Definition: xipivot.cxx:1638
const XclImpPTField * GetField(sal_uInt16 nFieldIdx) const
Definition: xipivot.cxx:1260
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:1288
XclImpPivotCacheRef mxPCache
Definition: xipivot.hxx:344
void ReadSxex(XclImpStream &rStrm)
Reads an SXEX record containing additional settings for the pivot table.
Definition: xipivot.cxx:1395
const ScfStringVec & GetVisFieldNames() const
Definition: xipivot.hxx:301
const XclImpPivotCacheRef & GetPivotCache() const
Definition: xipivot.hxx:300
void MaybeRefresh()
Definition: xipivot.cxx:1501
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:1249
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:1255
void ReadSxvi(XclImpStream &rStrm)
Reads an SXVI record describing a new item of the current field.
Definition: xipivot.cxx:1317
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:1266
void ReadSxvdex(XclImpStream &rStrm)
Reads an SXVDEX record describing extended options of the current field.
Definition: xipivot.cxx:1323
XclImpPivotTable(const XclImpRoot &rRoot)
Definition: xipivot.cxx:1242
void ReadSxViewEx9(XclImpStream &rStrm)
Reads an SXVIEWEX9 record that specifies the pivot tables autoformat.
Definition: xipivot.cxx:1400
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:1279
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:1329
void ReadSxAddl(XclImpStream &rStrm)
Reads an SXADDL record that specifies additional info for pivot table.
Definition: xipivot.cxx:1405
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:1410
void ReadSxdi(XclImpStream &rStrm)
Reads an SXDI record containing data field data.
Definition: xipivot.cxx:1379
void ApplyFieldInfo()
Definition: xipivot.cxx:1585
XclPTAddl maPTAddlInfo
(SXVIEWEX9 record)
Definition: xipivot.hxx:349
const XclImpPTField * GetDataField(sal_uInt16 nDataFieldIdx) const
Definition: xipivot.cxx:1272
void ReadSxvd(XclImpStream &rStrm)
Reads an SXVD record describing a new field.
Definition: xipivot.cxx:1299
void ReadSxpi(XclImpStream &rStrm)
Reads an SXPI record containing page field data.
Definition: xipivot.cxx:1361
void ApplyMergeFlags(const ScRange &rOutRange, const ScDPSaveData &rSaveData)
Definition: xipivot.cxx:1512
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:603
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:262
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:323
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:274
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:342
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:286
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:89
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