LibreOffice Module sc (master) 1
xepivot.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 <xepivot.hxx>
21#include <xehelper.hxx>
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#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
28#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
29
30#include <algorithm>
31#include <math.h>
32#include <string_view>
33
34#include <osl/diagnose.h>
35#include <sot/storage.hxx>
36#include <document.hxx>
37#include <dpcache.hxx>
38#include <dpgroup.hxx>
39#include <dpobject.hxx>
40#include <dpsave.hxx>
41#include <dpdimsave.hxx>
42#include <dpshttab.hxx>
43#include <globstr.hrc>
44#include <scresid.hxx>
45#include <xestring.hxx>
46#include <xelink.hxx>
47#include <dputil.hxx>
48#include <generalfunction.hxx>
49#include <svl/numformat.hxx>
50
51using namespace ::oox;
52
53using ::com::sun::star::sheet::DataPilotFieldOrientation;
54using ::com::sun::star::sheet::DataPilotFieldOrientation_ROW;
55using ::com::sun::star::sheet::DataPilotFieldOrientation_COLUMN;
56using ::com::sun::star::sheet::DataPilotFieldOrientation_PAGE;
57using ::com::sun::star::sheet::DataPilotFieldOrientation_DATA;
58using ::com::sun::star::sheet::DataPilotFieldSortInfo;
59using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo;
60using ::com::sun::star::sheet::DataPilotFieldLayoutInfo;
61using ::com::sun::star::sheet::DataPilotFieldReference;
62
63// Pivot cache
64
65namespace {
66
67// constants to track occurrence of specific data types
68const sal_uInt16 EXC_PCITEM_DATA_STRING = 0x0001;
69const sal_uInt16 EXC_PCITEM_DATA_DOUBLE = 0x0002;
70const sal_uInt16 EXC_PCITEM_DATA_INTEGER = 0x0004;
71const sal_uInt16 EXC_PCITEM_DATA_DATE = 0x0008;
72
74const sal_uInt16 spnPCItemFlags[] =
75{ // STR DBL INT DAT
92};
93
94} // namespace
95
96XclExpPCItem::XclExpPCItem( const OUString& rText ) :
97 XclExpRecord( (!rText.isEmpty()) ? EXC_ID_SXSTRING : EXC_ID_SXEMPTY, 0 ),
98 mnTypeFlag( EXC_PCITEM_DATA_STRING )
99{
100 if( !rText.isEmpty() )
101 SetText( rText );
102 else
103 SetEmpty();
104}
105
106XclExpPCItem::XclExpPCItem( double fValue, const OUString& rText ) :
108{
109 SetDouble( fValue, rText );
110 mnTypeFlag = (fValue - floor( fValue ) == 0.0) ?
111 EXC_PCITEM_DATA_INTEGER : EXC_PCITEM_DATA_DOUBLE;
112}
113
114XclExpPCItem::XclExpPCItem( const DateTime& rDateTime, const OUString& rText ) :
116{
117 SetDateTime( rDateTime, rText );
118 mnTypeFlag = EXC_PCITEM_DATA_DATE;
119}
120
121XclExpPCItem::XclExpPCItem( sal_Int16 nValue ) :
123 mnTypeFlag( EXC_PCITEM_DATA_INTEGER )
124{
126}
127
128XclExpPCItem::XclExpPCItem( bool bValue, const OUString& rText ) :
130 mnTypeFlag( EXC_PCITEM_DATA_STRING )
131{
132 SetBool( bValue, rText );
133}
134
135bool XclExpPCItem::EqualsText( std::u16string_view rText ) const
136{
137 return rText.empty() ? IsEmpty() : (GetText() && (*GetText() == rText));
138}
139
140bool XclExpPCItem::EqualsDouble( double fValue ) const
141{
142 return GetDouble() && (*GetDouble() == fValue);
143}
144
145bool XclExpPCItem::EqualsDateTime( const DateTime& rDateTime ) const
146{
147 return GetDateTime() && (*GetDateTime() == rDateTime);
148}
149
150bool XclExpPCItem::EqualsBool( bool bValue ) const
151{
152 return GetBool() && (*GetBool() == bValue);
153}
154
156{
157 if( const OUString* pText = GetText() )
158 {
159 rStrm << XclExpString( *pText );
160 }
161 else if( const double* pfValue = GetDouble() )
162 {
163 rStrm << *pfValue;
164 }
165 else if( const sal_Int16* pnValue = GetInteger() )
166 {
167 rStrm << *pnValue;
168 }
169 else if( const DateTime* pDateTime = GetDateTime() )
170 {
171 sal_uInt16 nYear = static_cast< sal_uInt16 >( pDateTime->GetYear() );
172 sal_uInt16 nMonth = pDateTime->GetMonth();
173 sal_uInt8 nDay = static_cast< sal_uInt8 >( pDateTime->GetDay() );
174 sal_uInt8 nHour = static_cast< sal_uInt8 >( pDateTime->GetHour() );
175 sal_uInt8 nMin = static_cast< sal_uInt8 >( pDateTime->GetMin() );
176 sal_uInt8 nSec = static_cast< sal_uInt8 >( pDateTime->GetSec() );
177 if( nYear < 1900 ) { nYear = 1900; nMonth = 1; nDay = 0; }
178 rStrm << nYear << nMonth << nDay << nHour << nMin << nSec;
179 }
180 else if( const bool* pbValue = GetBool() )
181 {
182 rStrm << static_cast< sal_uInt16 >( *pbValue ? 1 : 0 );
183 }
184 else
185 {
186 // nothing to do for SXEMPTY
187 OSL_ENSURE( IsEmpty(), "XclExpPCItem::WriteBody - no data found" );
188 }
189}
190
192 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
193 const ScDPObject& rDPObj, const ScRange& rRange ) :
195 XclPCField( EXC_PCFIELD_STANDARD, nFieldIdx ),
196 XclExpRoot( rRoot ),
197 mnTypeFlags( 0 )
198{
199 // general settings for the standard field, insert all items from source range
200 InitStandardField( rRange );
201
202 // add special settings for inplace numeric grouping
203 if( const ScDPSaveData* pSaveData = rDPObj.GetSaveData() )
204 {
205 if( const ScDPDimensionSaveData* pSaveDimData = pSaveData->GetExistingDimensionData() )
206 {
207 if( const ScDPSaveNumGroupDimension* pNumGroupDim = pSaveDimData->GetNumGroupDim( GetFieldName() ) )
208 {
209 const ScDPNumGroupInfo& rNumInfo = pNumGroupDim->GetInfo();
210 const ScDPNumGroupInfo& rDateInfo = pNumGroupDim->GetDateInfo();
211 OSL_ENSURE( !rNumInfo.mbEnable || !rDateInfo.mbEnable,
212 "XclExpPCField::XclExpPCField - numeric and date grouping enabled" );
213
214 if( rNumInfo.mbEnable )
215 InitNumGroupField( rDPObj, rNumInfo );
216 else if( rDateInfo.mbEnable )
217 InitDateGroupField( rDPObj, rDateInfo, pNumGroupDim->GetDatePart() );
218 }
219 }
220 }
221
222 // final settings (flags, item numbers)
223 Finalize();
224}
225
227 const XclExpRoot& rRoot, sal_uInt16 nFieldIdx,
228 const ScDPObject& rDPObj, const ScDPSaveGroupDimension& rGroupDim, const XclExpPCField& rBaseField ) :
230 XclPCField( EXC_PCFIELD_STDGROUP, nFieldIdx ),
231 XclExpRoot( rRoot ),
232 mnTypeFlags( 0 )
233{
234 // add base field info (always using first base field, not predecessor of this field) ***
235 OSL_ENSURE( rBaseField.GetFieldName() == rGroupDim.GetSourceDimName(),
236 "XclExpPCField::FillFromGroup - wrong base cache field" );
237 maFieldInfo.maName = rGroupDim.GetGroupDimName();
239
240 // add standard group info or date group info
241 const ScDPNumGroupInfo& rDateInfo = rGroupDim.GetDateInfo();
242 if( rDateInfo.mbEnable && (rGroupDim.GetDatePart() != 0) )
243 InitDateGroupField( rDPObj, rDateInfo, rGroupDim.GetDatePart() );
244 else
245 InitStdGroupField( rBaseField, rGroupDim );
246
247 // final settings (flags, item numbers)
248 Finalize();
249}
250
252{
253}
254
256{
258 "XclExpPCField::SetGroupChildIndex - field already has a grouping child field" );
260 maFieldInfo.mnGroupChild = rChildField.GetFieldIndex();
261}
262
264{
265 return static_cast< sal_uInt16 >( GetVisItemList().GetSize() );
266}
267
268const XclExpPCItem* XclExpPCField::GetItem( sal_uInt16 nItemIdx ) const
269{
270 return GetVisItemList().GetRecord( nItemIdx );
271}
272
273sal_uInt16 XclExpPCField::GetItemIndex( std::u16string_view rItemName ) const
274{
275 const XclExpPCItemList& rItemList = GetVisItemList();
276 for( size_t nPos = 0, nSize = rItemList.GetSize(); nPos < nSize; ++nPos )
277 if( rItemList.GetRecord( nPos )->ConvertToText() == rItemName )
278 return static_cast< sal_uInt16 >( nPos );
279 return EXC_PC_NOITEM;
280}
281
283{
284 return Has16BitIndexes() ? 2 : 1;
285}
286
287void XclExpPCField::WriteIndex( XclExpStream& rStrm, sal_uInt32 nSrcRow ) const
288{
289 // only standard fields write item indexes
290 if( nSrcRow < maIndexVec.size() )
291 {
292 sal_uInt16 nIndex = maIndexVec[ nSrcRow ];
293 if( Has16BitIndexes() )
294 rStrm << nIndex;
295 else
296 rStrm << static_cast< sal_uInt8 >( nIndex );
297 }
298}
299
301{
302 OSL_ENSURE( IsSupportedField(), "XclExpPCField::Save - unknown field type" );
303 // SXFIELD
305 // SXFDBTYPE
307 // list of grouping items
309 // SXGROUPINFO
311 // SXNUMGROUP and additional grouping items (grouping limit settings)
313 // list of original items
315}
316
317// private --------------------------------------------------------------------
318
320{
321 OSL_ENSURE( IsStandardField() == maGroupItemList.IsEmpty(),
322 "XclExpPCField::GetVisItemList - unexpected additional items in standard field" );
324}
325
327{
328 OSL_ENSURE( IsStandardField(), "XclExpPCField::InitStandardField - only for standard fields" );
329 OSL_ENSURE( rRange.aStart.Col() == rRange.aEnd.Col(), "XclExpPCField::InitStandardField - cell range with multiple columns" );
330
331 ScDocument& rDoc = GetDoc();
332 SvNumberFormatter& rFormatter = GetFormatter();
333
334 // field name is in top cell of the range
335 ScAddress aPos( rRange.aStart );
336 maFieldInfo.maName = rDoc.GetString(aPos.Col(), aPos.Row(), aPos.Tab());
337 // #i76047# maximum field name length in pivot cache is 255
338 if (maFieldInfo.maName.getLength() > EXC_PC_MAXSTRLEN)
340
341 // loop over all cells, create pivot cache items
342 for( aPos.IncRow(); (aPos.Row() <= rRange.aEnd.Row()) && (maOrigItemList.GetSize() < EXC_PC_MAXITEMCOUNT); aPos.IncRow() )
343 {
344 OUString aText = rDoc.GetString(aPos.Col(), aPos.Row(), aPos.Tab());
345 if( rDoc.HasValueData( aPos.Col(), aPos.Row(), aPos.Tab() ) )
346 {
347 double fValue = rDoc.GetValue( aPos );
348 SvNumFormatType nFmtType = rFormatter.GetType( rDoc.GetNumberFormat( rDoc.GetNonThreadedContext(), aPos ) );
349 if( nFmtType == SvNumFormatType::LOGICAL )
350 InsertOrigBoolItem( fValue != 0, aText );
351 else if( nFmtType & SvNumFormatType::DATETIME )
352 InsertOrigDateTimeItem( GetDateTimeFromDouble( ::std::max( fValue, 0.0 ) ), aText );
353 else
354 InsertOrigDoubleItem( fValue, aText );
355 }
356 else
357 {
358 InsertOrigTextItem( aText );
359 }
360 }
361}
362
364{
365 OSL_ENSURE( IsGroupField(), "XclExpPCField::InitStdGroupField - only for standard grouping fields" );
366
367 maFieldInfo.mnBaseItems = rBaseField.GetItemCount();
369
370 // loop over all groups of this field
371 for( tools::Long nGroupIdx = 0, nGroupCount = rGroupDim.GetGroupCount(); nGroupIdx < nGroupCount; ++nGroupIdx )
372 {
373 const ScDPSaveGroupItem& rGroupItem = rGroupDim.GetGroupByIndex( nGroupIdx );
374 // the index of the new item containing the grouping name
375 sal_uInt16 nGroupItemIdx = EXC_PC_NOITEM;
376 // loop over all elements of one group
377 for( size_t nElemIdx = 0, nElemCount = rGroupItem.GetElementCount(); nElemIdx < nElemCount; ++nElemIdx )
378 {
379 if (const OUString* pElemName = rGroupItem.GetElementByIndex(nElemIdx))
380 {
381 // try to find the item that is part of the group in the base field
382 sal_uInt16 nBaseItemIdx = rBaseField.GetItemIndex( *pElemName );
383 if( nBaseItemIdx < maFieldInfo.mnBaseItems )
384 {
385 // add group name item only if there are any valid base items
386 if( nGroupItemIdx == EXC_PC_NOITEM )
387 nGroupItemIdx = InsertGroupItem( new XclExpPCItem( rGroupItem.GetGroupName() ) );
388 maGroupOrder[ nBaseItemIdx ] = nGroupItemIdx;
389 }
390 }
391 }
392 }
393
394 // add items and base item indexes of all ungrouped elements
395 for( sal_uInt16 nBaseItemIdx = 0; nBaseItemIdx < maFieldInfo.mnBaseItems; ++nBaseItemIdx )
396 // items that are not part of a group still have the EXC_PC_NOITEM entry
397 if( maGroupOrder[ nBaseItemIdx ] == EXC_PC_NOITEM )
398 // try to find the base item
399 if( const XclExpPCItem* pBaseItem = rBaseField.GetItem( nBaseItemIdx ) )
400 // create a clone of the base item, insert its index into item order list
401 maGroupOrder[ nBaseItemIdx ] = InsertGroupItem( new XclExpPCItem( *pBaseItem ) );
402}
403
405{
406 OSL_ENSURE( IsStandardField(), "XclExpPCField::InitNumGroupField - only for standard fields" );
407 OSL_ENSURE( rNumInfo.mbEnable, "XclExpPCField::InitNumGroupField - numeric grouping not enabled" );
408
409 // new field type, date type, limit settings (min/max/step/auto)
410 if( rNumInfo.mbDateValues )
411 {
412 // special case: group by days with step count
414 maNumGroupInfo.SetScDateType( css::sheet::DataPilotFieldGroupBy::DAYS );
415 SetDateGroupLimit( rNumInfo, true );
416 }
417 else
418 {
421 SetNumGroupLimit( rNumInfo );
422 }
423
424 // generate visible items
425 InsertNumDateGroupItems( rDPObj, rNumInfo );
426}
427
428void XclExpPCField::InitDateGroupField( const ScDPObject& rDPObj, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nDatePart )
429{
430 OSL_ENSURE( IsStandardField() || IsStdGroupField(), "XclExpPCField::InitDateGroupField - only for standard fields" );
431 OSL_ENSURE( rDateInfo.mbEnable, "XclExpPCField::InitDateGroupField - date grouping not enabled" );
432
433 // new field type
435
436 // date type, limit settings (min/max/step/auto)
437 maNumGroupInfo.SetScDateType( nDatePart );
438 SetDateGroupLimit( rDateInfo, false );
439
440 // generate visible items
441 InsertNumDateGroupItems( rDPObj, rDateInfo, nDatePart );
442}
443
445{
446 OSL_ENSURE( IsStandardField(), "XclExpPCField::InsertItemArrayIndex - only for standard fields" );
447 maIndexVec.push_back( static_cast< sal_uInt16 >( nListPos ) );
448}
449
451{
452 size_t nItemIdx = maOrigItemList.GetSize();
454 InsertItemArrayIndex( nItemIdx );
455 mnTypeFlags |= pNewItem->GetTypeFlag();
456}
457
458void XclExpPCField::InsertOrigTextItem( const OUString& aText )
459{
460 size_t nPos = 0;
461 bool bFound = false;
462 // #i76047# maximum item text length in pivot cache is 255
463 OUString aShortText = aText.copy( 0, ::std::min(aText.getLength(), EXC_PC_MAXSTRLEN ) );
464 for( size_t nSize = maOrigItemList.GetSize(); !bFound && (nPos < nSize); ++nPos )
465 if( (bFound = maOrigItemList.GetRecord( nPos )->EqualsText( aShortText )) )
467 if( !bFound )
468 InsertOrigItem( new XclExpPCItem( aShortText ) );
469}
470
471void XclExpPCField::InsertOrigDoubleItem( double fValue, const OUString& rText )
472{
473 size_t nPos = 0;
474 bool bFound = false;
475 for( size_t nSize = maOrigItemList.GetSize(); !bFound && (nPos < nSize); ++nPos )
476 if( (bFound = maOrigItemList.GetRecord( nPos )->EqualsDouble( fValue )) )
478 if( !bFound )
479 InsertOrigItem( new XclExpPCItem( fValue, rText ) );
480}
481
482void XclExpPCField::InsertOrigDateTimeItem( const DateTime& rDateTime, const OUString& rText )
483{
484 size_t nPos = 0;
485 bool bFound = false;
486 for( size_t nSize = maOrigItemList.GetSize(); !bFound && (nPos < nSize); ++nPos )
487 if( (bFound = maOrigItemList.GetRecord( nPos )->EqualsDateTime( rDateTime )) )
489 if( !bFound )
490 InsertOrigItem( new XclExpPCItem( rDateTime, rText ) );
491}
492
493void XclExpPCField::InsertOrigBoolItem( bool bValue, const OUString& rText )
494{
495 size_t nPos = 0;
496 bool bFound = false;
497 for( size_t nSize = maOrigItemList.GetSize(); !bFound && (nPos < nSize); ++nPos )
498 if( (bFound = maOrigItemList.GetRecord( nPos )->EqualsBool( bValue )) )
500 if( !bFound )
501 InsertOrigItem( new XclExpPCItem( bValue, rText ) );
502}
503
505{
507 return static_cast< sal_uInt16 >( maGroupItemList.GetSize() - 1 );
508}
509
510void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nDatePart )
511{
512 OSL_ENSURE( rDPObj.GetSheetDesc(), "XclExpPCField::InsertNumDateGroupItems - cannot generate element list" );
513 const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc();
514 if(!pSrcDesc)
515 return;
516
517 // get the string collection with original source elements
518 const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
519 const ScDPDimensionSaveData* pDimData = nullptr;
520 if (pSaveData)
521 pDimData = pSaveData->GetExistingDimensionData();
522
523 const ScDPCache* pCache = pSrcDesc->CreateCache(pDimData);
524 if (!pCache)
525 return;
526
527 ScSheetDPData aDPData(&GetDoc(), *pSrcDesc, *pCache);
528 tools::Long nDim = GetFieldIndex();
529 // get the string collection with generated grouping elements
530 ScDPNumGroupDimension aTmpDim( rNumInfo );
531 if( nDatePart != 0 )
532 aTmpDim.SetDateDimension();
533 const std::vector<SCROW>& aMemberIds = aTmpDim.GetNumEntries(
534 static_cast<SCCOL>(nDim), pCache);
535 for (SCROW nMemberId : aMemberIds)
536 {
537 const ScDPItemData* pData = aDPData.GetMemberById(nDim, nMemberId);
538 if ( pData )
539 {
540 OUString aStr = pCache->GetFormattedString(nDim, *pData, false);
542 }
543 }
544}
545
547{
553}
554
555void XclExpPCField::SetDateGroupLimit( const ScDPNumGroupInfo& rDateInfo, bool bUseStep )
556{
561 sal_Int16 nStep = bUseStep ? limit_cast< sal_Int16 >( rDateInfo.mfStep, 1, SAL_MAX_INT16 ) : 1;
563}
564
566{
567 // flags
569 // Excel writes long indexes even for 0x0100 items (indexes from 0x00 to 0xFF)
572 /* mnTypeFlags is updated in all Insert***Item() functions. Now the flags
573 for the current combination of item types is added to the flags. */
574 ::set_flag( maFieldInfo.mnFlags, spnPCItemFlags[ mnTypeFlags ] );
575
576 // item count fields
577 maFieldInfo.mnVisItems = static_cast< sal_uInt16 >( GetVisItemList().GetSize() );
578 maFieldInfo.mnGroupItems = static_cast< sal_uInt16 >( maGroupItemList.GetSize() );
579 // maFieldInfo.mnBaseItems set in InitStdGroupField()
580 maFieldInfo.mnOrigItems = static_cast< sal_uInt16 >( maOrigItemList.GetSize() );
581}
582
584{
586 {
587 // SXNUMGROUP record
588 rStrm.StartRecord( EXC_ID_SXNUMGROUP, 2 );
590 rStrm.EndRecord();
591
592 // limits (min/max/step) for numeric grouping
593 OSL_ENSURE( maNumGroupLimits.GetSize() == 3,
594 "XclExpPCField::WriteSxnumgroup - missing numeric grouping limits" );
596 }
597}
598
600{
601 OSL_ENSURE( IsStdGroupField() != maGroupOrder.empty(),
602 "XclExpPCField::WriteSxgroupinfo - missing grouping info" );
603 if( IsStdGroupField() && !maGroupOrder.empty() )
604 {
605 rStrm.StartRecord( EXC_ID_SXGROUPINFO, 2 * maGroupOrder.size() );
606 for( const auto& rItem : maGroupOrder )
607 rStrm << rItem;
608 rStrm.EndRecord();
609 }
610}
611
613{
615}
616
617XclExpPivotCache::XclExpPivotCache( const XclExpRoot& rRoot, const ScDPObject& rDPObj, sal_uInt16 nListIdx ) :
618 XclExpRoot( rRoot ),
619 mnListIdx( nListIdx ),
620 mbValid( false )
621{
622 // source from sheet only
623 const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc();
624 if(!pSrcDesc)
625 return;
626
627 /* maOrigSrcRange: Range received from the DataPilot object.
628 maExpSrcRange: Range written to the DCONREF record.
629 maDocSrcRange: Range used to get source data from Calc document.
630 This range may be shorter than maExpSrcRange to improve export
631 performance (#i22541#). */
633 maSrcRangeName = pSrcDesc->GetRangeName();
634
635 // internal sheet data only
636 SCTAB nScTab = maExpSrcRange.aStart.Tab();
637 if( !((nScTab == maExpSrcRange.aEnd.Tab()) && GetTabInfo().IsExportTab( nScTab )) )
638 return;
639
640 // ValidateRange() restricts source range to valid Excel limits
641 if( !GetAddressConverter().ValidateRange( maExpSrcRange, true ) )
642 return;
643
644 // #i22541# skip empty cell areas (performance)
645 SCCOL nDocCol1, nDocCol2;
646 SCROW nDocRow1, nDocRow2;
647 GetDoc().GetDataStart( nScTab, nDocCol1, nDocRow1 );
648 GetDoc().GetPrintArea( nScTab, nDocCol2, nDocRow2, false );
649 SCCOL nSrcCol1 = maExpSrcRange.aStart.Col();
650 SCROW nSrcRow1 = maExpSrcRange.aStart.Row();
651 SCCOL nSrcCol2 = maExpSrcRange.aEnd.Col();
652 SCROW nSrcRow2 = maExpSrcRange.aEnd.Row();
653
654 // #i22541# do not store index list for too big ranges
655 if( 2 * (nDocRow2 - nDocRow1) < (nSrcRow2 - nSrcRow1) )
657
658 // adjust row indexes, keep one row of empty area to surely have the empty cache item
659 if( nSrcRow1 < nDocRow1 )
660 nSrcRow1 = nDocRow1 - 1;
661 if( nSrcRow2 > nDocRow2 )
662 nSrcRow2 = nDocRow2 + 1;
663
664 maDocSrcRange.aStart.SetCol( ::std::max( nDocCol1, nSrcCol1 ) );
665 maDocSrcRange.aStart.SetRow( nSrcRow1 );
666 maDocSrcRange.aEnd.SetCol( ::std::min( nDocCol2, nSrcCol2 ) );
667 maDocSrcRange.aEnd.SetRow( nSrcRow2 );
668
669 GetDoc().GetName( nScTab, maTabName );
670 maPCInfo.mnSrcRecs = static_cast< sal_uInt32 >( maExpSrcRange.aEnd.Row() - maExpSrcRange.aStart.Row() );
671 maPCInfo.mnStrmId = nListIdx + 1;
673
674 AddFields( rDPObj );
675
676 mbValid = true;
677}
678
680{
682}
683
685{
686 return static_cast< sal_uInt16 >( maFieldList.GetSize() );
687}
688
689const XclExpPCField* XclExpPivotCache::GetField( sal_uInt16 nFieldIdx ) const
690{
691 return maFieldList.GetRecord( nFieldIdx );
692}
693
695{
696 // pivot cache can be shared, if there are no additional cache fields
698}
699
701{
702 /* For now, only sheet sources are supported, therefore it is enough to
703 compare the ScSheetSourceDesc. Later, there should be done more complicated
704 comparisons regarding the source type of rDPObj and this cache. */
705 if( const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc() )
706 return pSrcDesc->GetSourceRange() == maOrigSrcRange;
707 return false;
708}
709
711{
712 OSL_ENSURE( mbValid, "XclExpPivotCache::Save - invalid pivot cache" );
713 // SXIDSTM
715 // SXVS
717
718 if (!maSrcRangeName.isEmpty())
719 // DCONNAME
721 else
722 // DCONREF
724
725 // create the pivot cache storage stream
727}
728
730{
731}
732
734{
735 AddStdFields( rDPObj );
737 AddGroupFields( rDPObj );
739};
740
742{
743 // if item index list is not written, used shortened source range (maDocSrcRange) for performance
745 // create a standard pivot cache field for each source column
746 for( SCCOL nScCol = rRange.aStart.Col(), nEndScCol = rRange.aEnd.Col(); nScCol <= nEndScCol; ++nScCol )
747 {
748 ScRange aColRange( rRange );
749 aColRange.aStart.SetCol( nScCol );
750 aColRange.aEnd.SetCol( nScCol );
752 GetRoot(), GetFieldCount(), rDPObj, aColRange ) );
753 }
754}
755
757{
758 const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
759 if(!pSaveData)
760 return;
761 const ScDPDimensionSaveData* pSaveDimData = pSaveData->GetExistingDimensionData();
762 if( !pSaveDimData )
763 return;
764
765 // loop over all existing standard fields to find their group fields
766 for( sal_uInt16 nFieldIdx = 0; nFieldIdx < maPCInfo.mnStdFields; ++nFieldIdx )
767 {
768 if( XclExpPCField* pCurrStdField = maFieldList.GetRecord( nFieldIdx ) )
769 {
770 const ScDPSaveGroupDimension* pGroupDim = pSaveDimData->GetGroupDimForBase( pCurrStdField->GetFieldName() );
771 XclExpPCField* pLastGroupField = pCurrStdField;
772 while( pGroupDim )
773 {
774 // insert the new grouping field
775 XclExpPCFieldRef xNewGroupField = new XclExpPCField(
776 GetRoot(), GetFieldCount(), rDPObj, *pGroupDim, *pCurrStdField );
777 maFieldList.AppendRecord( xNewGroupField );
778
779 // register new grouping field at current grouping field, building a chain
780 pLastGroupField->SetGroupChildField( *xNewGroupField );
781
782 // next grouping dimension
783 pGroupDim = pSaveDimData->GetGroupDimForBase( pGroupDim->GetGroupDimName() );
784 pLastGroupField = xNewGroupField.get();
785 }
786 }
787 }
788}
789
791{
793 rStrm.StartRecord( EXC_ID_DCONREF, 7 + aRef.GetSize() );
794 rStrm << static_cast< sal_uInt16 >( maExpSrcRange.aStart.Row() )
795 << static_cast< sal_uInt16 >( maExpSrcRange.aEnd.Row() )
796 << static_cast< sal_uInt8 >( maExpSrcRange.aStart.Col() )
797 << static_cast< sal_uInt8 >( maExpSrcRange.aEnd.Col() )
798 << aRef
799 << sal_uInt8( 0 );
800 rStrm.EndRecord();
801}
802
804{
806 rStrm.StartRecord(EXC_ID_DCONNAME, aName.GetSize() + 2);
807 rStrm << aName << sal_uInt16(0);
808 rStrm.EndRecord();
809}
810
812{
815 if( !xSvStrm.is() )
816 return;
817
818 XclExpStream aStrm( *xSvStrm, GetRoot() );
819 // SXDB
820 WriteSxdb( aStrm );
821 // SXDBEX
822 WriteSxdbex( aStrm );
823 // field list (SXFIELD and items)
824 maFieldList.Save( aStrm );
825 // index table (list of SXINDEXLIST)
826 WriteSxindexlistList( aStrm );
827 // EOF
829}
830
832{
833 rStrm.StartRecord( EXC_ID_SXDB, 21 );
834 rStrm << maPCInfo;
835 rStrm.EndRecord();
836}
837
839{
840 rStrm.StartRecord( EXC_ID_SXDBEX, 12 );
842 << sal_uInt32( 0 ); // number of SXFORMULA records
843 rStrm.EndRecord();
844}
845
847{
848 if( !HasItemIndexList() )
849 return;
850
851 std::size_t nRecSize = 0;
852 size_t nPos, nSize = maFieldList.GetSize();
853 for( nPos = 0; nPos < nSize; ++nPos )
854 nRecSize += maFieldList.GetRecord( nPos )->GetIndexSize();
855
856 for( sal_uInt32 nSrcRow = 0; nSrcRow < maPCInfo.mnSrcRecs; ++nSrcRow )
857 {
858 rStrm.StartRecord( EXC_ID_SXINDEXLIST, nRecSize );
859 for( nPos = 0; nPos < nSize; ++nPos )
860 maFieldList.GetRecord( nPos )->WriteIndex( rStrm, nSrcRow );
861 rStrm.EndRecord();
862 }
863}
864
865// Pivot table
866
867namespace {
868
870OUString lclGetDataFieldCaption( std::u16string_view rFieldName, ScGeneralFunction eFunc )
871{
872 OUString aCaption;
873
874 TranslateId pResIdx;
875 switch( eFunc )
876 {
877 case ScGeneralFunction::SUM: pResIdx = STR_FUN_TEXT_SUM; break;
878 case ScGeneralFunction::COUNT: pResIdx = STR_FUN_TEXT_COUNT; break;
879 case ScGeneralFunction::AVERAGE: pResIdx = STR_FUN_TEXT_AVG; break;
880 case ScGeneralFunction::MAX: pResIdx = STR_FUN_TEXT_MAX; break;
881 case ScGeneralFunction::MIN: pResIdx = STR_FUN_TEXT_MIN; break;
882 case ScGeneralFunction::PRODUCT: pResIdx = STR_FUN_TEXT_PRODUCT; break;
883 case ScGeneralFunction::COUNTNUMS: pResIdx = STR_FUN_TEXT_COUNT; break;
884 case ScGeneralFunction::STDEV: pResIdx = STR_FUN_TEXT_STDDEV; break;
885 case ScGeneralFunction::STDEVP: pResIdx = STR_FUN_TEXT_STDDEV; break;
886 case ScGeneralFunction::VAR: pResIdx = STR_FUN_TEXT_VAR; break;
887 case ScGeneralFunction::VARP: pResIdx = STR_FUN_TEXT_VAR; break;
888 default:;
889 }
890 if (pResIdx)
891 aCaption = ScResId(pResIdx) + " - ";
892 aCaption += rFieldName;
893 return aCaption;
894}
895
896} // namespace
897
898XclExpPTItem::XclExpPTItem( const XclExpPCField& rCacheField, sal_uInt16 nCacheIdx ) :
900 mpCacheItem( rCacheField.GetItem( nCacheIdx ) )
901{
903 maItemInfo.mnCacheIdx = nCacheIdx;
905}
906
907XclExpPTItem::XclExpPTItem( sal_uInt16 nItemType, sal_uInt16 nCacheIdx ) :
909 mpCacheItem( nullptr )
910{
911 maItemInfo.mnType = nItemType;
912 maItemInfo.mnCacheIdx = nCacheIdx;
914}
915
917{
918 return mpCacheItem ? mpCacheItem->ConvertToText() : OUString();
919}
920
922{
923 // #i115659# GetIsVisible() is not valid if HasIsVisible() returns false, default is 'visible' then
925 // #i115659# GetShowDetails() is not valid if HasShowDetails() returns false, default is 'show detail' then
927
928 // visible name
929 const std::optional<OUString> & pVisName = rSaveMem.GetLayoutName();
930 if (pVisName && *pVisName != GetItemName())
931 maItemInfo.SetVisName(*pVisName);
932}
933
935{
936 rStrm << maItemInfo;
937}
938
939XclExpPTField::XclExpPTField( const XclExpPivotTable& rPTable, sal_uInt16 nCacheIdx ) :
940 mrPTable( rPTable ),
941 mpCacheField( rPTable.GetCacheField( nCacheIdx ) )
942{
943 maFieldInfo.mnCacheIdx = nCacheIdx;
944
945 // create field items
946 if( mpCacheField )
947 for( sal_uInt16 nItemIdx = 0, nItemCount = mpCacheField->GetItemCount(); nItemIdx < nItemCount; ++nItemIdx )
949 maFieldInfo.mnItemCount = static_cast< sal_uInt16 >( maItemList.GetSize() );
950}
951
952// data access ----------------------------------------------------------------
953
955{
956 return mpCacheField ? mpCacheField->GetFieldName() : OUString();
957}
958
960{
961 OSL_ENSURE( !maDataInfoVec.empty(), "XclExpPTField::GetLastDataInfoIndex - no data info found" );
962 // will return 0xFFFF for empty vector -> ok
963 return static_cast< sal_uInt16 >( maDataInfoVec.size() - 1 );
964}
965
966sal_uInt16 XclExpPTField::GetItemIndex( std::u16string_view rName, sal_uInt16 nDefaultIdx ) const
967{
968 for( size_t nPos = 0, nSize = maItemList.GetSize(); nPos < nSize; ++nPos )
969 if( maItemList.GetRecord( nPos )->GetItemName() == rName )
970 return static_cast< sal_uInt16 >( nPos );
971 return nDefaultIdx;
972}
973
974// fill data --------------------------------------------------------------
975
980static OUString lcl_convertCalcSubtotalName(const OUString& rName)
981{
982 OUStringBuffer aBuf;
983 const sal_Unicode* p = rName.getStr();
984 sal_Int32 n = rName.getLength();
985 bool bEscaped = false;
986 for (sal_Int32 i = 0; i < n; ++i)
987 {
988 const sal_Unicode c = p[i];
989 if (!bEscaped && c == '\\')
990 {
991 bEscaped = true;
992 continue;
993 }
994
995 aBuf.append(c);
996 bEscaped = false;
997 }
998 return aBuf.makeStringAndClear();
999}
1000
1002{
1003 // orientation
1004 DataPilotFieldOrientation eOrient = rSaveDim.GetOrientation();
1005 OSL_ENSURE( eOrient != DataPilotFieldOrientation_DATA, "XclExpPTField::SetPropertiesFromDim - called for data field" );
1006 maFieldInfo.AddApiOrient( eOrient );
1007
1008 // show empty items (#i115659# GetShowEmpty() is not valid if HasShowEmpty() returns false, default is false then)
1010
1011 // visible name
1012 const std::optional<OUString> & pLayoutName = rSaveDim.GetLayoutName();
1013 if (pLayoutName && *pLayoutName != GetFieldName())
1014 maFieldInfo.SetVisName(*pLayoutName);
1015
1016 const std::optional<OUString> & pSubtotalName = rSaveDim.GetSubtotalName();
1017 if (pSubtotalName)
1018 {
1019 OUString aSubName = lcl_convertCalcSubtotalName(*pSubtotalName);
1021 }
1022
1023 // subtotals
1024 XclPTSubtotalVec aSubtotals;
1025 aSubtotals.reserve( static_cast< size_t >( rSaveDim.GetSubTotalsCount() ) );
1026 for( tools::Long nSubtIdx = 0, nSubtCount = rSaveDim.GetSubTotalsCount(); nSubtIdx < nSubtCount; ++nSubtIdx )
1027 aSubtotals.push_back( rSaveDim.GetSubTotalFunc( nSubtIdx ) );
1028 maFieldInfo.SetSubtotals( aSubtotals );
1029
1030 // sorting
1031 if( const DataPilotFieldSortInfo* pSortInfo = rSaveDim.GetSortInfo() )
1032 {
1033 maFieldExtInfo.SetApiSortMode( pSortInfo->Mode );
1034 if( pSortInfo->Mode == css::sheet::DataPilotFieldSortMode::DATA )
1036 ::set_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SORT_ASC, pSortInfo->IsAscending );
1037 }
1038
1039 // auto show
1040 if( const DataPilotFieldAutoShowInfo* pShowInfo = rSaveDim.GetAutoShowInfo() )
1041 {
1042 ::set_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_AUTOSHOW, pShowInfo->IsEnabled );
1043 maFieldExtInfo.SetApiAutoShowMode( pShowInfo->ShowItemsMode );
1044 maFieldExtInfo.SetApiAutoShowCount( pShowInfo->ItemCount );
1046 }
1047
1048 // layout
1049 if( const DataPilotFieldLayoutInfo* pLayoutInfo = rSaveDim.GetLayoutInfo() )
1050 {
1051 maFieldExtInfo.SetApiLayoutMode( pLayoutInfo->LayoutMode );
1052 ::set_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_LAYOUT_BLANK, pLayoutInfo->AddEmptyLines );
1053 }
1054
1055 // special page field properties
1056 if( eOrient == DataPilotFieldOrientation_PAGE )
1057 {
1060 }
1061
1062 // item properties
1063 const ScDPSaveDimension::MemberList &rMembers = rSaveDim.GetMembers();
1064 for (const auto& pMember : rMembers)
1065 if( XclExpPTItem* pItem = GetItemAcc( pMember->GetName() ) )
1066 pItem->SetPropertiesFromMember( *pMember );
1067}
1068
1070{
1071 maDataInfoVec.emplace_back( );
1072 XclPTDataFieldInfo& rDataInfo = maDataInfoVec.back();
1073 rDataInfo.mnField = GetFieldIndex();
1074
1075 // orientation
1076 maFieldInfo.AddApiOrient( DataPilotFieldOrientation_DATA );
1077
1078 // aggregation function
1079 ScGeneralFunction eFunc = rSaveDim.GetFunction();
1080 rDataInfo.SetApiAggFunc( eFunc );
1081
1082 // visible name
1083 const std::optional<OUString> & pVisName = rSaveDim.GetLayoutName();
1084 if (pVisName)
1085 rDataInfo.SetVisName(*pVisName);
1086 else
1087 rDataInfo.SetVisName( lclGetDataFieldCaption( GetFieldName(), eFunc ) );
1088
1089 // result field reference
1090 if( const DataPilotFieldReference* pFieldRef = rSaveDim.GetReferenceValue() )
1091 {
1092 rDataInfo.SetApiRefType( pFieldRef->ReferenceType );
1093 rDataInfo.SetApiRefItemType( pFieldRef->ReferenceItemType );
1094 if( const XclExpPTField* pRefField = mrPTable.GetField( pFieldRef->ReferenceField ) )
1095 {
1096 rDataInfo.mnRefField = pRefField->GetFieldIndex();
1097 if( pFieldRef->ReferenceItemType == css::sheet::DataPilotFieldReferenceItemType::NAMED )
1098 rDataInfo.mnRefItem = pRefField->GetItemIndex( pFieldRef->ReferenceItemName, 0 );
1099 }
1100 }
1101}
1102
1104{
1117}
1118
1119// records --------------------------------------------------------------------
1120
1122{
1123 rStrm << maPageInfo;
1124}
1125
1126void XclExpPTField::WriteSxdi( XclExpStream& rStrm, sal_uInt16 nDataInfoIdx ) const
1127{
1128 OSL_ENSURE( nDataInfoIdx < maDataInfoVec.size(), "XclExpPTField::WriteSxdi - data field not found" );
1129 if( nDataInfoIdx < maDataInfoVec.size() )
1130 {
1131 rStrm.StartRecord( EXC_ID_SXDI, 12 );
1132 rStrm << maDataInfoVec[ nDataInfoIdx ];
1133 rStrm.EndRecord();
1134 }
1135}
1136
1138{
1139 // SXVD
1140 WriteSxvd( rStrm );
1141 // list of SXVI records
1143 // SXVDEX
1144 WriteSxvdex( rStrm );
1145}
1146
1147// private --------------------------------------------------------------------
1148
1149XclExpPTItem* XclExpPTField::GetItemAcc( std::u16string_view rName )
1150{
1151 XclExpPTItem* pItem = nullptr;
1152 for( size_t nPos = 0, nSize = maItemList.GetSize(); !pItem && (nPos < nSize); ++nPos )
1153 if( maItemList.GetRecord( nPos )->GetItemName() == rName )
1154 pItem = maItemList.GetRecord( nPos );
1155 return pItem;
1156}
1157
1158void XclExpPTField::AppendSubtotalItem( sal_uInt16 nItemType )
1159{
1162}
1163
1165{
1166 rStrm.StartRecord( EXC_ID_SXVD, 10 );
1167 rStrm << maFieldInfo;
1168 rStrm.EndRecord();
1169}
1170
1172{
1173 rStrm.StartRecord( EXC_ID_SXVDEX, 20 );
1175 rStrm.EndRecord();
1176}
1177
1178XclExpPivotTable::XclExpPivotTable( const XclExpRoot& rRoot, const ScDPObject& rDPObj, const XclExpPivotCache& rPCache ) :
1179 XclExpRoot( rRoot ),
1180 mrPCache( rPCache ),
1181 maDataOrientField( *this, EXC_SXIVD_DATA ),
1182 mnOutScTab( 0 ),
1183 mbValid( false ),
1184 mbFilterBtn( false )
1185{
1186 const ScRange& rOutScRange = rDPObj.GetOutRange();
1187 if( !GetAddressConverter().ConvertRange( maPTInfo.maOutXclRange, rOutScRange, true ) )
1188 return;
1189
1190 // DataPilot properties -----------------------------------------------
1191
1192 // pivot table properties from DP object
1193 mnOutScTab = rOutScRange.aStart.Tab();
1194 maPTInfo.maTableName = rDPObj.GetName();
1196
1197 maPTViewEx9Info.Init( rDPObj );
1198
1199 const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
1200 if( !pSaveData )
1201 return;
1202
1203 // additional properties from ScDPSaveData
1204 SetPropertiesFromDP( *pSaveData );
1205
1206 // loop over all dimensions ---------------------------------------
1207
1208 /* 1) Default-construct all pivot table fields for all pivot cache fields. */
1209 for( sal_uInt16 nFieldIdx = 0, nFieldCount = mrPCache.GetFieldCount(); nFieldIdx < nFieldCount; ++nFieldIdx )
1210 maFieldList.AppendNewRecord( new XclExpPTField( *this, nFieldIdx ) );
1211
1212 const ScDPSaveData::DimsType& rDimList = pSaveData->GetDimensions();
1213
1214 /* 2) First process all data dimensions, they are needed for extended
1215 settings of row/column/page fields (sorting/auto show). */
1216 for (auto const& iter : rDimList)
1217 {
1218 if (iter->GetOrientation() == DataPilotFieldOrientation_DATA)
1220 }
1221
1222 /* 3) Row/column/page/hidden fields. */
1223 for (auto const& iter : rDimList)
1224 {
1225 if (iter->GetOrientation() != DataPilotFieldOrientation_DATA)
1227 }
1228
1229 // Finalize -------------------------------------------------------
1230
1231 Finalize();
1232 mbValid = true;
1233}
1234
1235const XclExpPCField* XclExpPivotTable::GetCacheField( sal_uInt16 nCacheIdx ) const
1236{
1237 return mrPCache.GetField( nCacheIdx );
1238}
1239
1240const XclExpPTField* XclExpPivotTable::GetField( sal_uInt16 nFieldIdx ) const
1241{
1242 return (nFieldIdx == EXC_SXIVD_DATA) ? &maDataOrientField : maFieldList.GetRecord( nFieldIdx );
1243}
1244
1245const XclExpPTField* XclExpPivotTable::GetField( std::u16string_view rName ) const
1246{
1247 return const_cast< XclExpPivotTable* >( this )->GetFieldAcc( rName );
1248}
1249
1250sal_uInt16 XclExpPivotTable::GetDataFieldIndex( const OUString& rName, sal_uInt16 nDefaultIdx ) const
1251{
1252 auto aIt = std::find_if(maDataFields.begin(), maDataFields.end(),
1253 [this, &rName](const XclPTDataFieldPos& rDataField) {
1254 const XclExpPTField* pField = GetField( rDataField.first );
1255 return pField && pField->GetFieldName() == rName;
1256 });
1257 if (aIt != maDataFields.end())
1258 return static_cast< sal_uInt16 >( std::distance(maDataFields.begin(), aIt) );
1259 return nDefaultIdx;
1260}
1261
1263{
1264 if( !mbValid )
1265 return;
1266
1267 // SXVIEW
1268 WriteSxview( rStrm );
1269 // pivot table fields (SXVD, SXVDEX, and item records)
1271 // SXIVD records for row and column fields
1274 // SXPI
1275 WriteSxpi( rStrm );
1276 // list of SXDI records containing data field info
1278 // SXLI records
1281 // SXEX
1282 WriteSxex( rStrm );
1283 // QSISXTAG
1285 // SXVIEWEX9
1287}
1288
1290{
1291 XclExpPTField* pField = nullptr;
1292 for( size_t nPos = 0, nSize = maFieldList.GetSize(); !pField && (nPos < nSize); ++nPos )
1293 if( maFieldList.GetRecord( nPos )->GetFieldName() == rName )
1294 pField = maFieldList.GetRecord( nPos );
1295 return pField;
1296}
1297
1299{
1300 // data field orientation field?
1301 if( rSaveDim.IsDataLayout() )
1302 return &maDataOrientField;
1303
1304 // a real dimension
1305 OUString aFieldName = ScDPUtil::getSourceDimensionName(rSaveDim.GetName());
1306 return aFieldName.isEmpty() ? nullptr : GetFieldAcc(aFieldName);
1307}
1308
1309// fill data --------------------------------------------------------------
1310
1312{
1316 mbFilterBtn = rSaveData.GetFilterButton();
1317 const ScDPSaveDimension* pDim = rSaveData.GetExistingDataLayoutDimension();
1318
1319 if (pDim && pDim->GetLayoutName())
1321 else
1322 maPTInfo.maDataName = ScResId(STR_PIVOT_DATA);
1323}
1324
1326{
1327 XclExpPTField* pField = GetFieldAcc( rSaveDim );
1328 if(!pField)
1329 return;
1330
1331 // field properties
1332 pField->SetPropertiesFromDim( rSaveDim );
1333
1334 // update the corresponding field position list
1335 DataPilotFieldOrientation eOrient = rSaveDim.GetOrientation();
1336 sal_uInt16 nFieldIdx = pField->GetFieldIndex();
1337 bool bDataLayout = nFieldIdx == EXC_SXIVD_DATA;
1338 bool bMultiData = maDataFields.size() > 1;
1339
1340 if( bDataLayout && !bMultiData )
1341 return;
1342
1343 switch( eOrient )
1344 {
1345 case DataPilotFieldOrientation_ROW:
1346 maRowFields.push_back( nFieldIdx );
1347 if( bDataLayout )
1349 break;
1350 case DataPilotFieldOrientation_COLUMN:
1351 maColFields.push_back( nFieldIdx );
1352 if( bDataLayout )
1354 break;
1355 case DataPilotFieldOrientation_PAGE:
1356 maPageFields.push_back( nFieldIdx );
1357 OSL_ENSURE( !bDataLayout, "XclExpPivotTable::SetFieldPropertiesFromDim - wrong orientation for data fields" );
1358 break;
1359 case DataPilotFieldOrientation_DATA:
1360 OSL_FAIL( "XclExpPivotTable::SetFieldPropertiesFromDim - called for data field" );
1361 break;
1362 default:;
1363 }
1364}
1365
1367{
1368 if( XclExpPTField* pField = GetFieldAcc( rSaveDim ) )
1369 {
1370 // field properties
1371 pField->SetDataPropertiesFromDim( rSaveDim );
1372 // update the data field position list
1373 maDataFields.emplace_back( pField->GetFieldIndex(), pField->GetLastDataInfoIndex() );
1374 }
1375}
1376
1378{
1379 // field numbers
1380 maPTInfo.mnFields = static_cast< sal_uInt16 >( maFieldList.GetSize() );
1381 maPTInfo.mnRowFields = static_cast< sal_uInt16 >( maRowFields.size() );
1382 maPTInfo.mnColFields = static_cast< sal_uInt16 >( maColFields.size() );
1383 maPTInfo.mnPageFields = static_cast< sal_uInt16 >( maPageFields.size() );
1384 maPTInfo.mnDataFields = static_cast< sal_uInt16 >( maDataFields.size() );
1385
1388
1389 // subtotal items
1390 for( size_t nPos = 0, nSize = maFieldList.GetSize(); nPos < nSize; ++nPos )
1392
1393 // find data field orientation field
1395 const ScfUInt16Vec* pFieldVec = nullptr;
1396 switch( maPTInfo.mnDataAxis )
1397 {
1398 case EXC_SXVD_AXIS_ROW: pFieldVec = &maRowFields; break;
1399 case EXC_SXVD_AXIS_COL: pFieldVec = &maColFields; break;
1400 }
1401
1402 if( pFieldVec && !pFieldVec->empty() && (pFieldVec->back() != EXC_SXIVD_DATA) )
1403 {
1404 ScfUInt16Vec::const_iterator aIt = ::std::find( pFieldVec->begin(), pFieldVec->end(), EXC_SXIVD_DATA );
1405 if( aIt != pFieldVec->end() )
1406 maPTInfo.mnDataPos = static_cast< sal_uInt16 >( std::distance(pFieldVec->begin(), aIt) );
1407 }
1408
1409 // single data field is always row oriented
1412
1413 // update output range (initialized in ctor)
1414 sal_uInt16& rnXclCol1 = maPTInfo.maOutXclRange.maFirst.mnCol;
1415 sal_uInt32& rnXclRow1 = maPTInfo.maOutXclRange.maFirst.mnRow;
1416 sal_uInt16& rnXclCol2 = maPTInfo.maOutXclRange.maLast.mnCol;
1417 sal_uInt32& rnXclRow2 = maPTInfo.maOutXclRange.maLast.mnRow;
1418 // exclude page fields from output range
1419 rnXclRow1 = rnXclRow1 + maPTInfo.mnPageFields;
1420 // exclude filter button from output range
1421 if( mbFilterBtn )
1422 ++rnXclRow1;
1423 // exclude empty row between (filter button and/or page fields) and table
1425 ++rnXclRow1;
1426
1427 // data area
1428 sal_uInt16& rnDataXclCol = maPTInfo.maDataXclPos.mnCol;
1429 sal_uInt32& rnDataXclRow = maPTInfo.maDataXclPos.mnRow;
1430 rnDataXclCol = rnXclCol1 + maPTInfo.mnRowFields;
1431 rnDataXclRow = rnXclRow1 + maPTInfo.mnColFields + 1;
1432 if( maDataFields.empty() )
1433 ++rnDataXclRow;
1434
1435 bool bExtraHeaderRow = (0 == maPTViewEx9Info.mnGridLayout && maPTInfo.mnColFields == 0);
1436 if (bExtraHeaderRow)
1437 // Insert an extra row only when there is no column field.
1438 ++rnDataXclRow;
1439
1440 rnXclCol2 = ::std::max( rnXclCol2, rnDataXclCol );
1441 rnXclRow2 = ::std::max( rnXclRow2, rnDataXclRow );
1442 maPTInfo.mnDataCols = rnXclCol2 - rnDataXclCol + 1;
1443 maPTInfo.mnDataRows = rnXclRow2 - rnDataXclRow + 1;
1444
1445 // first heading
1446 maPTInfo.mnFirstHeadRow = rnXclRow1 + 1;
1447 if (bExtraHeaderRow)
1449}
1450
1451// records ----------------------------------------------------------------
1452
1454{
1455 rStrm.StartRecord( EXC_ID_SXVIEW, 46 + maPTInfo.maTableName.getLength() + maPTInfo.maDataName.getLength() );
1456 rStrm << maPTInfo;
1457 rStrm.EndRecord();
1458}
1459
1461{
1462 if( !rFields.empty() )
1463 {
1464 rStrm.StartRecord( EXC_ID_SXIVD, rFields.size() * 2 );
1465 for( const auto& rField : rFields )
1466 rStrm << rField;
1467 rStrm.EndRecord();
1468 }
1469}
1470
1472{
1473 if( !maPageFields.empty() )
1474 {
1475 rStrm.StartRecord( EXC_ID_SXPI, maPageFields.size() * 6 );
1476 rStrm.SetSliceSize( 6 );
1477 for( const auto& rPageField : maPageFields )
1478 {
1479 XclExpPTFieldRef xField = maFieldList.GetRecord( rPageField );
1480 if( xField )
1481 xField->WriteSxpiEntry( rStrm );
1482 }
1483 rStrm.EndRecord();
1484 }
1485}
1486
1488{
1489 for( const auto& [rFieldIdx, rDataInfoIdx] : maDataFields )
1490 {
1491 XclExpPTFieldRef xField = maFieldList.GetRecord( rFieldIdx );
1492 if( xField )
1493 xField->WriteSxdi( rStrm, rDataInfoIdx );
1494 }
1495}
1496
1497void XclExpPivotTable::WriteSxli( XclExpStream& rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount )
1498{
1499 if( nLineCount <= 0 )
1500 return;
1501
1502 std::size_t nLineSize = 8 + 2 * nIndexCount;
1503 rStrm.StartRecord( EXC_ID_SXLI, nLineSize * nLineCount );
1504
1505 /* Excel expects the records to be filled completely, do not
1506 set a segment size... */
1507// rStrm.SetSliceSize( nLineSize );
1508
1509 for( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
1510 {
1511 // Excel XP needs a partly initialized SXLI record
1512 rStrm << sal_uInt16( 0 ) // number of equal index entries
1514 << nIndexCount
1516 rStrm.WriteZeroBytes( 2 * nIndexCount );
1517 }
1518 rStrm.EndRecord();
1519}
1520
1522{
1523 rStrm.StartRecord( EXC_ID_SXEX, 24 );
1524 rStrm << maPTExtInfo;
1525 rStrm.EndRecord();
1526}
1527
1529{
1530 rStrm.StartRecord( 0x0802, 32 );
1531
1532 sal_uInt16 const nRecordType = 0x0802;
1533 sal_uInt16 const nDummyFlags = 0x0000;
1534 sal_uInt16 const nTableType = 1; // 0 = query table : 1 = pivot table
1535
1536 rStrm << nRecordType << nDummyFlags << nTableType;
1537
1538 // General flags
1539 sal_uInt16 const nFlags = 0x0001;
1540#if 0
1541 // for doc purpose
1542 sal_uInt16 nFlags = 0x0000;
1543 bool bEnableRefresh = true;
1544 bool bPCacheInvalid = false;
1545 bool bOlapPTReport = false;
1546
1547 if (bEnableRefresh) nFlags |= 0x0001;
1548 if (bPCacheInvalid) nFlags |= 0x0002;
1549 if (bOlapPTReport) nFlags |= 0x0004;
1550#endif
1551 rStrm << nFlags;
1552
1553 // Feature-specific options. The value differs depending on the table
1554 // type, but we assume the table type is always pivot table.
1555 sal_uInt32 const nOptions = 0x00000000;
1556#if 0
1557 // documentation for which bit is for what
1558 bool bNoStencil = false;
1559 bool bHideTotal = false;
1560 bool bEmptyRows = false;
1561 bool bEmptyCols = false;
1562 if (bNoStencil) nOptions |= 0x00000001;
1563 if (bHideTotal) nOptions |= 0x00000002;
1564 if (bEmptyRows) nOptions |= 0x00000008;
1565 if (bEmptyCols) nOptions |= 0x00000010;
1566#endif
1567 rStrm << nOptions;
1568
1569 sal_uInt8 eXclVer = 0; // Excel2000
1570 sal_uInt8 const nOffsetBytes = 16;
1571 rStrm << eXclVer // version table last refreshed
1572 << eXclVer // minimum version to refresh
1573 << nOffsetBytes
1574 << eXclVer; // first version created
1575
1577 rStrm << static_cast<sal_uInt16>(0x0001); // no idea what this is for.
1578
1579 rStrm.EndRecord();
1580}
1581
1583{
1584 // Until we sync the autoformat ids only export if using grid header layout
1585 // That could only have been set via xls import so far.
1586 if ( 0 == maPTViewEx9Info.mnGridLayout )
1587 {
1588 rStrm.StartRecord( EXC_ID_SXVIEWEX9, 17 );
1590 rStrm.EndRecord();
1591 }
1592}
1593
1594namespace {
1595
1596const SCTAB EXC_PTMGR_PIVOTCACHES = SCTAB_MAX;
1597
1599class XclExpPivotRecWrapper : public XclExpRecordBase
1600{
1601public:
1602 explicit XclExpPivotRecWrapper( XclExpPivotTableManager& rPTMgr, SCTAB nScTab );
1603 virtual void Save( XclExpStream& rStrm ) override;
1604private:
1605 XclExpPivotTableManager& mrPTMgr;
1606 SCTAB mnScTab;
1607};
1608
1609XclExpPivotRecWrapper::XclExpPivotRecWrapper( XclExpPivotTableManager& rPTMgr, SCTAB nScTab ) :
1610 mrPTMgr( rPTMgr ),
1611 mnScTab( nScTab )
1612{
1613}
1614
1615void XclExpPivotRecWrapper::Save( XclExpStream& rStrm )
1616{
1617 if( mnScTab == EXC_PTMGR_PIVOTCACHES )
1618 mrPTMgr.WritePivotCaches( rStrm );
1619 else
1620 mrPTMgr.WritePivotTables( rStrm, mnScTab );
1621}
1622
1623} // namespace
1624
1626 XclExpRoot( rRoot )
1627{
1628}
1629
1631{
1632 if( ScDPCollection* pDPColl = GetDoc().GetDPCollection() )
1633 for( size_t nDPObj = 0, nCount = pDPColl->GetCount(); nDPObj < nCount; ++nDPObj )
1634 {
1635 ScDPObject& rDPObj = (*pDPColl)[ nDPObj ];
1636 if( const XclExpPivotCache* pPCache = CreatePivotCache( rDPObj ) )
1637 maPTableList.AppendNewRecord( new XclExpPivotTable( GetRoot(), rDPObj, *pPCache ) );
1638 }
1639}
1640
1642{
1643 return new XclExpPivotRecWrapper( *this, EXC_PTMGR_PIVOTCACHES );
1644}
1645
1647{
1648 return new XclExpPivotRecWrapper( *this, nScTab );
1649}
1650
1652{
1654}
1655
1657{
1658 for( size_t nPos = 0, nSize = maPTableList.GetSize(); nPos < nSize; ++nPos )
1659 {
1661 if( xPTable->GetScTab() == nScTab )
1662 xPTable->Save( rStrm );
1663 }
1664}
1665
1667{
1668 // try to find a pivot cache with the same data source
1669 /* #i25110# In Excel, the pivot cache contains additional fields
1670 (i.e. grouping info, calculated fields). If the passed DataPilot object
1671 or the found cache contains this data, do not share the cache with
1672 multiple pivot tables. */
1673 if( const ScDPSaveData* pSaveData = rDPObj.GetSaveData() )
1674 {
1675 const ScDPDimensionSaveData* pDimSaveData = pSaveData->GetExistingDimensionData();
1676 // no dimension save data at all or save data does not contain grouping info
1677 if( !pDimSaveData || !pDimSaveData->HasGroupDimensions() )
1678 {
1679 // check all existing pivot caches
1680 for( size_t nPos = 0, nSize = maPCacheList.GetSize(); nPos < nSize; ++nPos )
1681 {
1683 // pivot cache does not have grouping info and source data is equal
1684 if( !pPCache->HasAddFields() && pPCache->HasEqualDataSource( rDPObj ) )
1685 return pPCache;
1686 }
1687 }
1688 }
1689
1690 // create a new pivot cache
1691 sal_uInt16 nNewCacheIdx = static_cast< sal_uInt16 >( maPCacheList.GetSize() );
1692 XclExpPivotCacheRef xNewPCache = new XclExpPivotCache( GetRoot(), rDPObj, nNewCacheIdx );
1693 if( xNewPCache->IsValid() )
1694 {
1695 maPCacheList.AppendRecord( xNewPCache.get() );
1696 return xNewPCache.get();
1697 }
1698
1699 return nullptr;
1700}
1701
1702/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCTAB SCTAB_MAX
Definition: address.hxx:57
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 IncRow(SCROW nDelta=1)
Definition: address.hxx:312
SCCOL Col() const
Definition: address.hxx:279
This class represents the cached data part of the datapilot cache table implementation.
Definition: dpcache.hxx:48
OUString GetFormattedString(tools::Long nDim, const ScDPItemData &rItem, bool bLocaleIndependent) const
Definition: dpcache.cxx:1205
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:164
bool HasGroupDimensions() const
Definition: dpdimsave.cxx:693
const ScDPSaveGroupDimension * GetGroupDimForBase(const OUString &rBaseDimName) const
Definition: dpdimsave.cxx:631
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
const std::vector< SCROW > & GetNumEntries(SCCOL nSourceDim, const ScDPCache *pCache) const
Definition: dpgroup.cxx:455
const ScRange & GetOutRange() const
Definition: dpobject.cxx:410
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
ScDPSaveData * GetSaveData() const
Definition: dpobject.hxx:141
const OUString & GetName() const
Definition: dpobject.hxx:167
bool GetDrillDown() const
Definition: dpsave.hxx:343
bool GetFilterButton() const
Definition: dpsave.hxx:339
bool GetRowGrand() const
Definition: dpsave.hxx:327
bool GetColumnGrand() const
Definition: dpsave.hxx:323
std::vector< std::unique_ptr< ScDPSaveDimension > > DimsType
Definition: dpsave.hxx:238
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDataLayoutDimension() const
Definition: dpsave.cxx:879
const DimsType & GetDimensions() const
Definition: dpsave.hxx:271
const ScDPDimensionSaveData * GetExistingDimensionData() const
Definition: dpsave.hxx:353
const css::sheet::DataPilotFieldSortInfo * GetSortInfo() const
Definition: dpsave.hxx:186
bool HasShowEmpty() const
Definition: dpsave.cxx:330
ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const
Definition: dpsave.hxx:152
css::sheet::DataPilotFieldOrientation GetOrientation() const
Definition: dpsave.hxx:202
const css::sheet::DataPilotFieldLayoutInfo * GetLayoutInfo() const
Definition: dpsave.hxx:194
const css::sheet::DataPilotFieldAutoShowInfo * GetAutoShowInfo() const
Definition: dpsave.hxx:190
const std::optional< OUString > & GetSubtotalName() const
Definition: dpsave.cxx:360
const std::optional< OUString > & GetLayoutName() const
Definition: dpsave.cxx:386
ScGeneralFunction GetFunction() const
Definition: dpsave.hxx:165
tools::Long GetSubTotalsCount() const
Definition: dpsave.hxx:149
const css::sheet::DataPilotFieldReference * GetReferenceValue() const
Definition: dpsave.hxx:181
const MemberList & GetMembers() const
Definition: dpsave.hxx:128
std::vector< ScDPSaveMember * > MemberList
Definition: dpsave.hxx:115
bool IsDataLayout() const
Definition: dpsave.hxx:142
const OUString & GetName() const
Definition: dpsave.hxx:139
bool GetShowEmpty() const
Definition: dpsave.hxx:157
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
Definition: dpdimsave.hxx:91
const OUString & GetSourceDimName() const
Definition: dpdimsave.hxx:108
const OUString & GetGroupDimName() const
Definition: dpdimsave.hxx:107
const ScDPNumGroupInfo & GetDateInfo() const
Definition: dpdimsave.hxx:111
sal_Int32 GetDatePart() const
Definition: dpdimsave.hxx:110
tools::Long GetGroupCount() const
Definition: dpdimsave.cxx:199
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Definition: dpdimsave.cxx:204
Classes to save Data Pilot settings that create new dimensions (fields).
Definition: dpdimsave.hxx:47
size_t GetElementCount() const
Definition: dpdimsave.cxx:72
const OUString & GetGroupName() const
Definition: dpdimsave.hxx:65
const OUString * GetElementByIndex(size_t nIndex) const
Definition: dpdimsave.cxx:77
SC_DLLPUBLIC bool HasShowDetails() const
Definition: dpsave.cxx:102
bool GetShowDetails() const
Definition: dpsave.hxx:76
SC_DLLPUBLIC bool HasIsVisible() const
Definition: dpsave.cxx:92
bool GetIsVisible() const
Definition: dpsave.hxx:71
SC_DLLPUBLIC const std::optional< OUString > & GetLayoutName() const
Definition: dpsave.cxx:125
Represents a group dimension that introduces a new hierarchy for an existing dimension.
Definition: dpdimsave.hxx:136
virtual const ScDPItemData * GetMemberById(sal_Int32 nDim, sal_Int32 nId)
Definition: dptabdat.cxx:258
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
Definition: dputil.cxx:66
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3640
SC_DLLPUBLIC double GetValue(const ScAddress &rPos) const
Definition: document.cxx:3626
ScInterpreterContext & GetNonThreadedContext() const
Definition: document.hxx:617
SC_DLLPUBLIC bool HasValueData(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3750
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:611
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
Definition: document.cxx:3505
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
Definition: documen2.cxx:679
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:204
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
Implementation of ScDPTableData with sheet data.
Definition: dpshttab.hxx:87
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:40
const OUString & GetRangeName() const
Definition: dpshttab.hxx:60
SC_DLLPUBLIC const ScDPCache * CreateCache(const ScDPDimensionSaveData *pDimData) const
Definition: dpshttab.cxx:282
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
static OUString GetHexStr(sal_uInt16 nValue)
Returns a string representing the hexadecimal value of nValue.
Definition: ftools.cxx:121
SvNumFormatType GetType(sal_uInt32 nFIndex) const
A record without body.
Definition: xerecord.hxx:184
const OUString & GetFieldName() const
Returns the name of this cache field.
Definition: xepivot.hxx:77
XclExpPCItemList maOrigItemList
Definition: xepivot.hxx:148
void InsertOrigDateTimeItem(const DateTime &rDateTime, const OUString &rText)
Inserts an original date/time item, if it is not contained already.
Definition: xepivot.cxx:482
void WriteIndex(XclExpStream &rStrm, sal_uInt32 nSrcRow) const
Writes the item index at the passed source row position as part of the SXINDEXLIST record.
Definition: xepivot.cxx:287
sal_uInt16 GetItemCount() const
Returns the number of visible items of this field.
Definition: xepivot.cxx:263
void InitStdGroupField(const XclExpPCField &rBaseField, const ScDPSaveGroupDimension &rGroupDim)
Initializes a standard grouping field.
Definition: xepivot.cxx:363
XclExpPCItemList maGroupItemList
List with original items.
Definition: xepivot.hxx:149
void InsertOrigBoolItem(bool bValue, const OUString &rText)
Inserts an original boolean item, if it is not contained already.
Definition: xepivot.cxx:493
XclExpPCItemList maNumGroupLimits
Indexes into maItemList.
Definition: xepivot.hxx:151
void InitStandardField(const ScRange &rRange)
Initializes a standard field.
Definition: xepivot.cxx:326
void InitDateGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rDateInfo, sal_Int32 nDatePart)
Initializes a date grouping field.
Definition: xepivot.cxx:428
XclExpPCField(const XclExpRoot &rRoot, sal_uInt16 nFieldIdx, const ScDPObject &rDPObj, const ScRange &rRange)
Creates a standard pivot cache field, filled from sheet source data.
Definition: xepivot.cxx:191
void WriteSxgroupinfo(XclExpStream &rStrm)
Writes an SXGROUPINFO record describing the item order in grouping fields.
Definition: xepivot.cxx:599
void InsertOrigItem(XclExpPCItem *pNewItem)
Inserts an original source item.
Definition: xepivot.cxx:450
void InitNumGroupField(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo)
Initializes a numeric grouping field.
Definition: xepivot.cxx:404
virtual ~XclExpPCField() override
Definition: xepivot.cxx:251
void InsertOrigDoubleItem(double fValue, const OUString &rText)
Inserts an original value item, if it is not contained already.
Definition: xepivot.cxx:471
sal_uInt16 mnTypeFlags
List with limit values for numeric grouping.
Definition: xepivot.hxx:152
void WriteSxnumgroup(XclExpStream &rStrm)
Writes an SXNUMGROUP record and the additional items for a numeric grouping field.
Definition: xepivot.cxx:583
std::size_t GetIndexSize() const
Returns the size an item index needs to write out.
Definition: xepivot.cxx:282
virtual void Save(XclExpStream &rStrm) override
Writes the pivot cache field and all items and other related records.
Definition: xepivot.cxx:300
virtual void WriteBody(XclExpStream &rStrm) override
Writes the contents of the SXFIELD record for this field.
Definition: xepivot.cxx:612
void InsertNumDateGroupItems(const ScDPObject &rDPObj, const ScDPNumGroupInfo &rNumInfo, sal_Int32 nDatePart=0)
Generates and inserts all visible items for numeric or date grouping.
Definition: xepivot.cxx:510
void SetDateGroupLimit(const ScDPNumGroupInfo &rDateInfo, bool bUseStep)
Inserts the SXDATETIME/SXINTEGER items that specify the limits for a date grouping.
Definition: xepivot.cxx:555
void SetGroupChildField(const XclExpPCField &rChildField)
Sets the passed field as direct grouping child field of this field.
Definition: xepivot.cxx:255
void InsertItemArrayIndex(size_t nListPos)
Inserts the passed index into the item index array of original items.
Definition: xepivot.cxx:444
sal_uInt16 InsertGroupItem(XclExpPCItem *pNewItem)
Inserts an item into the grouping item list.
Definition: xepivot.cxx:504
void SetNumGroupLimit(const ScDPNumGroupInfo &rNumInfo)
Inserts the SXDOUBLE items that specify the limits for a numeric grouping.
Definition: xepivot.cxx:546
sal_uInt16 GetItemIndex(std::u16string_view rItemName) const
Returns the index of a pivot cache item, or EXC_PC_NOITEM on error.
Definition: xepivot.cxx:273
void Finalize()
Initializes flags and item count fields.
Definition: xepivot.cxx:565
const XclExpPCItem * GetItem(sal_uInt16 nItemIdx) const
Returns the specified pivot cache item (returns visible items in groupings).
Definition: xepivot.cxx:268
const XclExpPCItemList & GetVisItemList() const
Returns the item list that contains the visible items.
Definition: xepivot.cxx:319
void InsertOrigTextItem(const OUString &rText)
Inserts an original text item, if it is not contained already.
Definition: xepivot.cxx:458
ScfUInt16Vec maIndexVec
List with grouping items.
Definition: xepivot.hxx:150
Represents a data item in a pivot cache containing data of any type.
Definition: xepivot.hxx:37
sal_uInt16 GetTypeFlag() const
Definition: xepivot.hxx:45
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: xepivot.cxx:155
XclExpPCItem(const OUString &rText)
Definition: xepivot.cxx:96
bool EqualsDouble(double fValue) const
Definition: xepivot.cxx:140
bool EqualsDateTime(const DateTime &rDateTime) const
Definition: xepivot.cxx:145
bool EqualsText(std::u16string_view rText) const
Definition: xepivot.cxx:135
bool EqualsBool(bool bValue) const
Definition: xepivot.cxx:150
sal_uInt16 mnTypeFlag
Definition: xepivot.hxx:56
XclPTFieldInfo maFieldInfo
The referred pivot cache field.
Definition: xepivot.hxx:308
const XclExpPCField * mpCacheField
Parent pivot table containing this field.
Definition: xepivot.hxx:307
void SetPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with row/column/page properties from the passed save dimension.
Definition: xepivot.cxx:1001
sal_uInt16 GetLastDataInfoIndex() const
Returns the index of the last inserted data info struct.
Definition: xepivot.cxx:959
const XclExpPivotTable & mrPTable
Definition: xepivot.hxx:306
XclExpPTItem * GetItemAcc(std::u16string_view rName)
Returns an item by its name.
Definition: xepivot.cxx:1149
XclExpPTField(const XclExpPivotTable &rPTable, sal_uInt16 nCacheIdx)
Definition: xepivot.cxx:939
void WriteSxdi(XclExpStream &rStrm, sal_uInt16 nDataInfoIdx) const
Writes an SXDI records containing info about a data field.
Definition: xepivot.cxx:1126
void AppendSubtotalItem(sal_uInt16 nItemType)
Appends a special item describing a field subtotal entry.
Definition: xepivot.cxx:1158
XclPTFieldExtInfo maFieldExtInfo
General field info (SXVD record).
Definition: xepivot.hxx:309
XclPTPageFieldInfo maPageInfo
Extended field info (SXVDEX record).
Definition: xepivot.hxx:310
XclExpRecordList< XclExpPTItem > maItemList
List of extended data field info (SXDI records).
Definition: xepivot.hxx:314
void WriteSxvd(XclExpStream &rStrm) const
Writes the SXVD record introducing the field.
Definition: xepivot.cxx:1164
OUString GetFieldName() const
Returns the name of this field.
Definition: xepivot.cxx:954
void SetDataPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills this field with data field properties from the passed save dimension.
Definition: xepivot.cxx:1069
std::vector< XclPTDataFieldInfo > maDataInfoVec
Page field info (entry in SXPI record).
Definition: xepivot.hxx:312
void WriteSxvdex(XclExpStream &rStrm) const
Writes the SXVDEX record containing additional settings.
Definition: xepivot.cxx:1171
void WriteSxpiEntry(XclExpStream &rStrm) const
Writes an entry for an SXPI record containing own page field info.
Definition: xepivot.cxx:1121
void AppendSubtotalItems()
Appends special items describing the field subtotal entries.
Definition: xepivot.cxx:1103
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table field.
Definition: xepivot.cxx:1137
sal_uInt16 GetFieldIndex() const
Returns the pivot table field list index of this field.
Definition: xepivot.hxx:263
sal_uInt16 GetItemIndex(std::u16string_view rName, sal_uInt16 nDefaultIdx) const
Returns the list index of an item by its name.
Definition: xepivot.cxx:966
XclExpPTItem(const XclExpPCField &rCacheField, sal_uInt16 nCacheIdx)
Definition: xepivot.cxx:898
OUString GetItemName() const
Returns the internal name of this item.
Definition: xepivot.cxx:916
const XclExpPCItem * mpCacheItem
Definition: xepivot.hxx:247
XclPTItemInfo maItemInfo
The referred pivot cache item.
Definition: xepivot.hxx:248
void SetPropertiesFromMember(const ScDPSaveMember &rSaveMem)
Fills this item with properties from the passed save member.
Definition: xepivot.cxx:921
virtual void WriteBody(XclExpStream &rStrm) override
Writes the SXVI record body describing the pivot table item.
Definition: xepivot.cxx:934
void AddGroupFields(const ScDPObject &rDPObj)
Adds all grouping pivot cache fields.
Definition: xepivot.cxx:756
void WriteSxdb(XclExpStream &rStrm) const
Writes the SXDB record.
Definition: xepivot.cxx:831
bool mbValid
List index in pivot cache buffer.
Definition: xepivot.hxx:218
XclPCInfo maPCInfo
Definition: xepivot.hxx:210
void WriteDconref(XclExpStream &rStrm) const
Writes the DCONREF record containing the source range.
Definition: xepivot.cxx:790
void WriteCacheStream()
Creates the pivot cache storage stream and writes the cache.
Definition: xepivot.cxx:811
sal_uInt16 GetCacheIndex() const
Returns the list index of the cache used in pivot table records.
Definition: xepivot.hxx:167
bool HasEqualDataSource(const ScDPObject &rDPObj) const
Returns true, if the passed DP object has the same data source as this cache.
Definition: xepivot.cxx:700
static void SaveXml(XclExpXmlStream &rStrm)
Definition: xepivot.cxx:729
void AddStdFields(const ScDPObject &rDPObj)
Adds all standard pivot cache fields based on source data.
Definition: xepivot.cxx:741
bool HasAddFields() const
Returns true, if this pivot cache contains non-standard fields (e.g.
Definition: xepivot.cxx:694
void Save(XclExpStream &rStrm)
Writes related records into Workbook stream and creates the pivot cache storage stream.
Definition: xepivot.cxx:710
void WriteSxindexlistList(XclExpStream &rStrm) const
Writes the SXINDEXLIST record list containing the item index table.
Definition: xepivot.cxx:846
XclExpPivotCache(const XclExpRoot &rRoot, const ScDPObject &rDPObj, sal_uInt16 nListIdx)
Definition: xepivot.cxx:617
ScRange maDocSrcRange
The exported sheet source range.
Definition: xepivot.hxx:216
OUString maTabName
List of all pivot cache fields.
Definition: xepivot.hxx:212
OUString maSrcRangeName
Name of source data sheet.
Definition: xepivot.hxx:213
const XclExpPCField * GetField(sal_uInt16 nFieldIdx) const
Returns the specified pivot cache field.
Definition: xepivot.cxx:689
bool HasItemIndexList() const
Returns true, if the item index list will be written.
Definition: xepivot.cxx:679
sal_uInt16 GetFieldCount() const
Returns the number of pivot cache fields.
Definition: xepivot.cxx:684
void AddFields(const ScDPObject &rDPObj)
Adds all pivot cache fields.
Definition: xepivot.cxx:733
ScRange maExpSrcRange
The original sheet source range.
Definition: xepivot.hxx:215
ScRange maOrigSrcRange
Range name for source data.
Definition: xepivot.hxx:214
void WriteDConName(XclExpStream &rStrm) const
DCONNAME record contains range name source.
Definition: xepivot.cxx:803
static void WriteSxdbex(XclExpStream &rStrm)
Writes the SXDBEX record.
Definition: xepivot.cxx:838
XclExpPCFieldList maFieldList
Pivot cache settings (SXDB record).
Definition: xepivot.hxx:211
The main class for pivot table export.
Definition: xepivot.hxx:406
XclExpRecordRef CreatePivotCachesRecord()
Creates a record wrapper for exporting all pivot caches.
Definition: xepivot.cxx:1641
void CreatePivotTables()
Creates all pivot tables and caches from the Calc DataPilot objects.
Definition: xepivot.cxx:1630
XclExpRecordRef CreatePivotTablesRecord(SCTAB nScTab)
Creates a record wrapper for exporting all pivot tables of the specified sheet.
Definition: xepivot.cxx:1646
void WritePivotCaches(XclExpStream &rStrm)
Writes all pivot caches (all Workbook records and cache streams).
Definition: xepivot.cxx:1651
XclExpPivotTableList maPTableList
List of all pivot caches.
Definition: xepivot.hxx:433
void WritePivotTables(XclExpStream &rStrm, SCTAB nScTab)
Writes all pivot tables of the specified Calc sheet.
Definition: xepivot.cxx:1656
const XclExpPivotCache * CreatePivotCache(const ScDPObject &rDPObj)
Finds an existing (if enabled in mbShareCaches) or creates a new pivot cache.
Definition: xepivot.cxx:1666
XclExpPivotTableManager(const XclExpRoot &rRoot)
Definition: xepivot.cxx:1625
XclExpRecordList< XclExpPivotCache > maPCacheList
Definition: xepivot.hxx:432
void WriteSxdiList(XclExpStream &rStrm) const
Writes all SXDI records containing info about the data fields.
Definition: xepivot.cxx:1487
const XclExpPTField * GetField(sal_uInt16 nFieldIdx) const
Returns a pivot table field by its name.
Definition: xepivot.cxx:1240
const XclExpPCField * GetCacheField(sal_uInt16 nCacheIdx) const
Returns a pivot cache field.
Definition: xepivot.cxx:1235
void SetPropertiesFromDP(const ScDPSaveData &rSaveData)
Fills internal members with all properties from the passed save data.
Definition: xepivot.cxx:1311
std::vector< XclPTDataFieldPos > maDataFields
Page field indexes.
Definition: xepivot.hxx:391
SCTAB mnOutScTab
Special data field orientation field.
Definition: xepivot.hxx:393
virtual void Save(XclExpStream &rStrm) override
Writes the entire pivot table.
Definition: xepivot.cxx:1262
void WriteSxview(XclExpStream &rStrm) const
Writes the SXVIEW record starting the pivot table.
Definition: xepivot.cxx:1453
bool mbValid
Sheet index of the output range.
Definition: xepivot.hxx:394
ScfUInt16Vec maColFields
Row field indexes.
Definition: xepivot.hxx:388
void WriteQsiSxTag(XclExpStream &rStrm) const
Definition: xepivot.cxx:1528
sal_uInt16 GetDataFieldIndex(const OUString &rName, sal_uInt16 nDefaultIdx) const
Returns the data-field-only index of the first data field with the passed name.
Definition: xepivot.cxx:1250
void Finalize()
Initializes any data after processing the entire source DataPilot.
Definition: xepivot.cxx:1377
bool mbFilterBtn
true = The pivot table is valid for export.
Definition: xepivot.hxx:395
void WriteSxViewEx9(XclExpStream &rStrm) const
Writes the SX_AUTOFORMAT records with the autoformat id and header layout.
Definition: xepivot.cxx:1582
static void WriteSxivd(XclExpStream &rStrm, const ScfUInt16Vec &rFields)
Writes an SXIVD record for row field or column field order.
Definition: xepivot.cxx:1460
XclPTInfo maPTInfo
The pivot cache this pivot table bases on.
Definition: xepivot.hxx:383
ScfUInt16Vec maRowFields
All fields in pivot cache order.
Definition: xepivot.hxx:387
const XclExpPivotCache & mrPCache
Definition: xepivot.hxx:382
static void WriteSxli(XclExpStream &rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount)
Writes a dummy SXLI records containing item layout info.
Definition: xepivot.cxx:1497
XclExpPTField * GetFieldAcc(std::u16string_view rName)
Returns a pivot table field by its name.
Definition: xepivot.cxx:1289
XclExpPTFieldList maFieldList
The selected autoformat (SXVIEWEX9)
Definition: xepivot.hxx:386
XclExpPivotTable(const XclExpRoot &rRoot, const ScDPObject &rDPObj, const XclExpPivotCache &rPCache)
Definition: xepivot.cxx:1178
void WriteSxex(XclExpStream &rStrm) const
Writes the SXEX records containing additional pivot table info.
Definition: xepivot.cxx:1521
XclExpPTField maDataOrientField
Data field indexes.
Definition: xepivot.hxx:392
void SetFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table field with all properties from the passed save dimension.
Definition: xepivot.cxx:1325
void SetDataFieldPropertiesFromDim(const ScDPSaveDimension &rSaveDim)
Fills a pivot table data field with all properties from the passed save dimension.
Definition: xepivot.cxx:1366
ScfUInt16Vec maPageFields
Column field indexes.
Definition: xepivot.hxx:389
XclPTExtInfo maPTExtInfo
Info about the pivot table (SXVIEW record).
Definition: xepivot.hxx:384
void WriteSxpi(XclExpStream &rStrm) const
Writes the SXPI record containing page field info.
Definition: xepivot.cxx:1471
XclPTViewEx9Info maPTViewEx9Info
Extended info about the pivot table (SXEX record).
Definition: xepivot.hxx:385
Base class for all Excel records.
Definition: xerecord.hxx:39
virtual void Save(XclExpStream &rStrm)
Overwrite this method to do any operation while saving the record.
Definition: xerecord.cxx:36
void AppendNewRecord(RecType *pRec)
Appends a newly created record to the list.
Definition: xerecord.hxx:361
size_t GetSize() const
Definition: xerecord.hxx:327
bool IsEmpty() const
Definition: xerecord.hxx:326
virtual void Save(XclExpStream &rStrm) override
Writes the complete record list.
Definition: xerecord.hxx:375
void AppendRecord(RecType *pRec)
Appends a record to the list.
Definition: xerecord.hxx:348
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Definition: xerecord.hxx:333
Base class for single records with any content.
Definition: xerecord.hxx:143
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: xerecord.cxx:150
Access to global data from other classes.
Definition: xeroot.hxx:113
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xeroot.cxx:82
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
Definition: xeroot.cxx:76
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:118
This class is used to export Excel record streams.
Definition: xestream.hxx:73
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
static OUString EncodeUrl(const XclExpRoot &rRoot, std::u16string_view rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
Definition: xehelper.cxx:989
Represents a field in a pivot cache.
Definition: xlpivot.hxx:477
sal_uInt16 GetFieldIndex() const
Returns the index of this field in the containing pivot cache.
Definition: xlpivot.hxx:483
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 Has16BitIndexes() const
Returns true, if the item indexes in the SXINDEXLIST record are stored as 16-bit values.
Definition: xlpivot.cxx:348
bool IsSupportedField() const
Returns true, if the type of the field is supported by Calc.
Definition: xlpivot.cxx:293
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 IsGroupField() const
Returns true, if this field is a grouping field of any type.
Definition: xlpivot.cxx:318
bool IsStandardField() const
Returns true, if this is a standard field build directly from source data.
Definition: xlpivot.cxx:298
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
const bool * GetBool() const
Returns pointer to Boolean value, if the item type is 'boolean', otherwise 0.
Definition: xlpivot.cxx:160
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
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
bool IsEmpty() const
Returns true, if the item type is 'empty'.
Definition: xlpivot.cxx:130
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 OUString & ConvertToText() const
Returns the text representation of the item.
Definition: xlpivot.hxx:393
const sal_Int16 * GetInteger() const
Returns pointer to integer, if the item type is 'integer', otherwise 0.
Definition: xlpivot.cxx:150
tools::SvRef< SotStorage > OpenStorage(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrgName) const
Tries to open a storage as child of the specified storage for reading or writing.
Definition: xlroot.cxx:261
SvNumberFormatter & GetFormatter() const
Returns the number formatter of the Calc document.
Definition: xlroot.cxx:322
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
Definition: xlroot.cxx:273
DateTime GetDateTimeFromDouble(double fValue) const
Converts a floating-point value to a date/time value.
Definition: xlroot.cxx:352
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
bool is() const
int nCount
float u
sal_Int16 nValue
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
void set_flag(Type &rnBitField, Type nMask, bool bSet=true)
Sets or clears (according to bSet) all set bits of nMask in rnBitField.
Definition: ftools.hxx:95
::std::vector< sal_uInt16 > ScfUInt16Vec
Definition: ftools.hxx:255
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2,...
@ AVERAGE
average of all numerical values is calculated.
@ PRODUCT
product of all numerical values is calculated.
@ MAX
maximum value of all numerical values is calculated.
@ COUNT
all values, including non-numerical values, are counted.
@ VARP
variance is calculated based on the entire population.
@ SUM
sum of all numerical values is calculated.
@ STDEVP
standard deviation is calculated based on the entire population.
@ COUNTNUMS
numerical values are counted.
@ MIN
minimum value of all numerical values is calculated.
@ VAR
variance is calculated based on a sample.
@ STDEV
standard deviation is calculated based on a sample.
sal_Int32 nIndex
OUString aName
void * p
sal_Int64 n
sal_uInt16 nPos
aStr
aBuf
std::unique_ptr< sal_Int32[]> pData
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
int i
void SvStream & rStrm
long Long
const int nIndexCount
Definition: qproform.cxx:564
bool mbValid
Definition: queryiter.cxx:923
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
sal_uInt16 mnCol
Definition: xladdress.hxx:31
sal_uInt32 mnRow
Definition: xladdress.hxx:32
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 mnGroupChild
Various flags.
Definition: xlpivot.hxx:439
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 mnSrcType
Number of all fields (standard, grouped, calculated).
Definition: xlpivot.hxx:533
sal_uInt16 mnFlags
Stream identifier.
Definition: xlpivot.hxx:529
sal_uInt16 mnTotalFields
Number of standard pivot cache fields.
Definition: xlpivot.hxx:532
sal_uInt16 mnStrmId
Records in source database.
Definition: xlpivot.hxx:528
sal_uInt16 mnStdFields
Records in a source database block.
Definition: xlpivot.hxx:531
sal_uInt32 mnSrcRecs
Definition: xlpivot.hxx:527
void SetScDateType(sal_Int32 nScType)
Definition: xlpivot.cxx:242
sal_uInt16 mnFlags
Definition: xlpivot.hxx:457
bool mbUseCache
The visible name, if used.
Definition: xlpivot.hxx:550
Contains data for a pivot table data field (SXDI record).
Definition: xlpivot.hxx:673
sal_uInt16 mnField
Definition: xlpivot.hxx:674
void SetApiRefItemType(sal_Int32 nRefItemType)
Sets the result reference item type represented by the passed API constant.
Definition: xlpivot.cxx:798
sal_uInt16 mnRefItem
Index to SXVD of referred field used for the results.
Definition: xlpivot.hxx:678
void SetApiRefType(sal_Int32 nRefType)
Sets the result reference type represented by the passed API constant.
Definition: xlpivot.cxx:769
sal_uInt16 mnRefField
Result reference type.
Definition: xlpivot.hxx:677
void SetApiAggFunc(ScGeneralFunction eAggFunc)
Sets the aggregation function represented by the passed API enum.
Definition: xlpivot.cxx:731
sal_uInt32 mnFlags
Number of page fields per column.
Definition: xlpivot.hxx:740
sal_uInt16 mnPagePerRow
Number of SXSELECT records.
Definition: xlpivot.hxx:738
sal_uInt16 mnPagePerCol
Number of page fields per row.
Definition: xlpivot.hxx:739
void SetApiAutoShowMode(sal_Int32 nShowMode)
Sets the AutoShow mode represented by the passed API constant.
Definition: xlpivot.cxx:601
sal_uInt32 mnFlags
Definition: xlpivot.hxx:622
void SetApiAutoShowCount(sal_Int32 nShowCount)
Sets the number of items to be shown in AutoShow mode.
Definition: xlpivot.cxx:611
void SetApiLayoutMode(sal_Int32 nLayoutMode)
Sets the layout mode represented by the passed API constant.
Definition: xlpivot.cxx:625
sal_uInt16 mnSortField
Several flags and number of items for AutoShow.
Definition: xlpivot.hxx:623
std::optional< OUString > mpFieldTotalName
Definition: xlpivot.hxx:626
void SetApiSortMode(sal_Int32 nSortMode)
Sets the sorting mode represented by the passed API constant.
Definition: xlpivot.cxx:587
sal_uInt16 mnShowField
Index to data field sorting bases on.
Definition: xlpivot.hxx:624
sal_uInt16 mnSubtotals
Number of subtotal functions.
Definition: xlpivot.hxx:595
sal_uInt16 mnCacheIdx
Number of items of this field.
Definition: xlpivot.hxx:597
sal_uInt16 mnItemCount
Bitfield for subtotal functions.
Definition: xlpivot.hxx:596
void SetSubtotals(const XclPTSubtotalVec &rSubtotals)
Sets the subtotal functions contained in the passed sequence.
Definition: xlpivot.cxx:518
void AddApiOrient(css::sheet::DataPilotFieldOrientation eOrient)
Adds the axis orientation represented by the passed API enum.
Definition: xlpivot.cxx:485
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 mnDataPos
Orientation of data fields.
Definition: xlpivot.hxx:714
sal_uInt16 mnPageFields
Number of column fields.
Definition: xlpivot.hxx:718
sal_uInt16 mnDataCols
Number of rows containing data.
Definition: xlpivot.hxx:721
sal_uInt16 mnDataRows
Number of data fields.
Definition: xlpivot.hxx:720
sal_uInt16 mnCacheIdx
First heading row.
Definition: xlpivot.hxx:712
OUString maTableName
Definition: xlpivot.hxx:707
XclAddress maDataXclPos
Output range.
Definition: xlpivot.hxx:710
sal_uInt16 mnFields
Position of data fields.
Definition: xlpivot.hxx:715
sal_uInt16 mnColFields
Number of row fields.
Definition: xlpivot.hxx:717
sal_uInt16 mnDataFields
Number of page fields.
Definition: xlpivot.hxx:719
sal_uInt16 mnDataAxis
0-based index of the pivot cache.
Definition: xlpivot.hxx:713
sal_uInt16 mnFirstHeadRow
First cell containing data.
Definition: xlpivot.hxx:711
sal_uInt16 mnRowFields
Number of all fields.
Definition: xlpivot.hxx:716
sal_uInt16 mnType
Definition: xlpivot.hxx:576
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
sal_uInt16 mnSelItem
Base field for this page info.
Definition: xlpivot.hxx:660
sal_uInt16 mnField
Definition: xlpivot.hxx:659
void Init(const ScDPObject &rDPObj)
Definition: xlpivot.cxx:976
sal_uInt8 mnGridLayout
AutoFormat ID.
Definition: xlpivot.hxx:755
XclPTCachedName maVisName
Definition: xlpivot.hxx:561
void SetVisName(const OUString &rName)
Sets the visible name and enables usage of cache if name is empty.
Definition: xlpivot.cxx:425
XclAddress maFirst
Definition: xladdress.hxx:60
XclAddress maLast
Definition: xladdress.hxx:61
unsigned char sal_uInt8
#define SAL_MAX_INT16
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_convertCalcSubtotalName(const OUString &rName)
Calc's subtotal names are escaped with backslashes ('\'), while Excel's are not escaped at all.
Definition: xepivot.cxx:980
::std::pair< sal_uInt16, sal_uInt16 > XclPTDataFieldPos
Data field position specifying the pivot table field index (first) and data info index (second).
Definition: xepivot.hxx:225
XclExpValueRecord< sal_uInt16 > XclExpUInt16Record
A record containing an unsigned 16-bit value.
Definition: xerecord.hxx:247
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_SXVI_TYPE_COUNTNUM
Definition: xlpivot.hxx:147
const sal_uInt16 EXC_ID_SXNUMGROUP
Definition: xlpivot.hxx:275
const sal_uInt16 EXC_SXVD_SUBT_COUNT
Definition: xlpivot.hxx:121
const sal_uInt16 EXC_SXVI_TYPE_COUNT
Definition: xlpivot.hxx:142
const sal_uInt16 EXC_ID_DCONNAME
Definition: xlpivot.hxx:94
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_ID_SXPI
Definition: xlpivot.hxx:171
const sal_uInt16 EXC_SXVD_SUBT_COUNTNUM
Definition: xlpivot.hxx:126
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_SXIVD
Definition: xlpivot.hxx:163
@ 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_DATECHILD
First date grouping field (opt. with child grouping field).
Definition: xlpivot.hxx:86
const sal_uInt16 EXC_SXVI_TYPE_AVERAGE
Definition: xlpivot.hxx:143
const sal_uInt16 EXC_SXVDEX_SHOW_NONE
Definition: xlpivot.hxx:343
const sal_uInt16 EXC_SXFIELD_DATA_STR_DBL
Only strings and integers, opt. with doubles.
Definition: xlpivot.hxx:237
const sal_uInt16 EXC_SXVD_SUBT_MAX
Definition: xlpivot.hxx:123
const sal_uInt16 EXC_SXVI_TYPE_MIN
Definition: xlpivot.hxx:145
const sal_uInt16 EXC_SXVD_SUBT_DEFAULT
Definition: xlpivot.hxx:119
const sal_uInt16 EXC_SXFIELD_DATA_INT
Only strings, nothing else.
Definition: xlpivot.hxx:234
const sal_uInt16 EXC_SXVD_SUBT_STDDEVP
Definition: xlpivot.hxx:128
const double EXC_SXDBEX_CREATION_DATE
Definition: xlpivot.hxx:351
const sal_uInt16 EXC_SXFIELD_DATA_STR_INT
Only doubles, nothing else.
Definition: xlpivot.hxx:236
const sal_uInt16 EXC_SXVD_SUBT_VAR
Definition: xlpivot.hxx:129
const sal_uInt16 EXC_SXVI_DEFAULT_CACHE
Definition: xlpivot.hxx:160
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
const sal_uInt16 EXC_ID_SXVS
Definition: xlpivot.hxx:296
const sal_uInt16 EXC_ID_SXEX
Definition: xlpivot.hxx:309
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_SXLI_DEFAULTFLAGS
Definition: xlpivot.hxx:168
const sal_uInt16 EXC_SXVD_AXIS_NONE
Definition: xlpivot.hxx:110
const sal_uInt16 EXC_PC_NOITEM
Definition: xlpivot.hxx:51
const sal_uInt16 EXC_SXFIELD_16BIT
Definition: xlpivot.hxx:228
const sal_uInt16 EXC_SXNUMGROUP_AUTOMIN
Definition: xlpivot.hxx:277
const sal_uInt16 EXC_SXVIEW_COLGRAND
Definition: xlpivot.hxx:101
const sal_uInt16 EXC_SXVI_TYPE_PROD
Definition: xlpivot.hxx:146
const sal_uInt16 EXC_ID_SXVDEX
Definition: xlpivot.hxx:330
const sal_uInt16 EXC_SXFDBTYPE_DEFAULT
Definition: xlpivot.hxx:355
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_SXIDSTM
Definition: xlpivot.hxx:272
const sal_uInt16 EXC_ID_SXVD
Definition: xlpivot.hxx:108
const sal_uInt16 EXC_ID_SXBOOLEAN
Definition: xlpivot.hxx:254
::std::vector< ScGeneralFunction > XclPTSubtotalVec
Definition: xlpivot.hxx:588
const sal_uInt16 EXC_SXVD_SUBT_AVERAGE
Definition: xlpivot.hxx:122
const sal_uInt16 EXC_SXVD_SUBT_SUM
Definition: xlpivot.hxx:120
const sal_uInt16 EXC_SXVI_HIDDEN
Definition: xlpivot.hxx:155
const sal_uInt16 EXC_ID_SXVI
Definition: xlpivot.hxx:135
const sal_uInt16 EXC_SXVD_SUBT_MIN
Definition: xlpivot.hxx:124
const sal_uInt16 EXC_SXVI_TYPE_VAR
Definition: xlpivot.hxx:150
const sal_uInt16 EXC_SXPI_ALLITEMS
Definition: xlpivot.hxx:172
const sal_uInt16 EXC_SXVD_SUBT_STDDEV
Definition: xlpivot.hxx:127
const size_t EXC_PC_MAXITEMCOUNT
Definition: xlpivot.hxx:50
const sal_uInt32 EXC_SXVDEX_LAYOUT_BLANK
Definition: xlpivot.hxx:338
const sal_uInt16 EXC_SXFIELD_DATA_NONE
Definition: xlpivot.hxx:232
const sal_uInt16 EXC_SXVI_TYPE_SUM
Definition: xlpivot.hxx:141
const sal_uInt16 EXC_SXVI_TYPE_MAX
Definition: xlpivot.hxx:144
const sal_uInt16 EXC_ID_DCONREF
Definition: xlpivot.hxx:93
const sal_uInt16 EXC_SXVD_SUBT_PROD
Definition: xlpivot.hxx:125
const sal_uInt16 EXC_ID_SXVIEWEX9
Definition: xlpivot.hxx:358
const sal_uInt16 EXC_ID_SXLI
Definition: xlpivot.hxx:167
const sal_uInt16 EXC_SXVDEX_SORT_OWN
Definition: xlpivot.hxx:342
const sal_uInt16 EXC_SXDB_SAVEDATA
Definition: xlpivot.hxx:205
const sal_uInt16 EXC_SXDB_SRC_SHEET
Definition: xlpivot.hxx:215
const sal_uInt16 EXC_SXFIELD_DATA_DATE_STR
Dates with integers or doubles without strings.
Definition: xlpivot.hxx:241
const sal_uInt16 EXC_ID_SXDI
Definition: xlpivot.hxx:175
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_SXVIEW_DATALAST
Definition: xlpivot.hxx:104
const sal_uInt16 EXC_SXVI_TYPE_DATA
Definition: xlpivot.hxx:139
const sal_uInt32 EXC_SXEX_DRILLDOWN
Definition: xlpivot.hxx:311
const sal_uInt16 EXC_SXVI_TYPE_STDDEV
Definition: xlpivot.hxx:148
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_Int32 EXC_PC_MAXSTRLEN
Definition: xlpivot.hxx:47
const sal_uInt16 EXC_SXVS_SHEET
Definition: xlpivot.hxx:299
const sal_uInt16 EXC_SXNUMGROUP_AUTOMAX
Definition: xlpivot.hxx:278
const sal_uInt16 EXC_ID_SXDB
Definition: xlpivot.hxx:203
const sal_uInt16 EXC_SXVI_TYPE_DEFAULT
Definition: xlpivot.hxx:140
const sal_uInt16 EXC_SXVI_TYPE_STDDEVP
Definition: xlpivot.hxx:149
const sal_uInt16 EXC_ID_SXFDBTYPE
Definition: xlpivot.hxx:354
const sal_uInt16 EXC_ID_SXDBEX
Definition: xlpivot.hxx:350
const sal_uInt16 EXC_ID_SXVIEW
Definition: xlpivot.hxx:98
const sal_uInt16 EXC_SXVI_TYPE_VARP
Definition: xlpivot.hxx:151
const sal_uInt16 EXC_SXVD_SUBT_VARP
Definition: xlpivot.hxx:130
const sal_uInt16 EXC_SXVIEW_ROWGRAND
Definition: xlpivot.hxx:100
SvNumFormatType