LibreOffice Module sc (master) 1
dpsave.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 <memory>
21#include <dpsave.hxx>
22#include <dpdimsave.hxx>
23#include <miscuno.hxx>
24#include <unonames.hxx>
25#include <dputil.hxx>
26#include <generalfunction.hxx>
27#include <dptabdat.hxx>
28
29#include <sal/types.h>
30#include <sal/log.hxx>
31#include <osl/diagnose.h>
34
35#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
36#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
37#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
38#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
39#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
40#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
41#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
42#include <com/sun/star/sheet/XLevelsSupplier.hpp>
43#include <com/sun/star/sheet/XMembersSupplier.hpp>
44#include <com/sun/star/container/XNamed.hpp>
45#include <com/sun/star/util/XCloneable.hpp>
47
48#include <unordered_map>
49#include <algorithm>
50#include <utility>
51
52using namespace com::sun::star;
53using namespace com::sun::star::sheet;
54using ::std::unique_ptr;
55
56#define SC_DPSAVEMODE_DONTKNOW 2
57
58static void lcl_SetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp,
59 const OUString& rName, bool bValue )
60{
61 //TODO: move to ScUnoHelpFunctions?
62
63 xProp->setPropertyValue( rName, uno::Any( bValue ) );
64}
65
67 aName(std::move( _aName )),
68 nVisibleMode( SC_DPSAVEMODE_DONTKNOW ),
69 nShowDetailsMode( SC_DPSAVEMODE_DONTKNOW )
70{
71}
72
74 aName( r.aName ),
75 mpLayoutName( r.mpLayoutName ),
76 nVisibleMode( r.nVisibleMode ),
77 nShowDetailsMode( r.nShowDetailsMode )
78{
79}
80
82{
83}
84
86{
87 return aName == r.aName &&
90}
91
93{
95}
96
98{
99 nVisibleMode = sal_uInt16(bSet);
100}
101
103{
105}
106
108{
109 nShowDetailsMode = sal_uInt16(bSet);
110}
111
112void ScDPSaveMember::SetName( const OUString& rNew )
113{
114 // Used only if the source member was renamed (groups).
115 // For UI renaming of members, a layout name must be used.
116
117 aName = rNew;
118}
119
120void ScDPSaveMember::SetLayoutName( const OUString& rName )
121{
122 mpLayoutName = rName;
123}
124
125const std::optional<OUString> & ScDPSaveMember::GetLayoutName() const
126{
127 return mpLayoutName;
128}
129
131{
132 mpLayoutName.reset();
133}
134
135void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMember, sal_Int32 nPosition )
136{
137 uno::Reference<beans::XPropertySet> xMembProp( xMember, uno::UNO_QUERY );
138 OSL_ENSURE( xMembProp.is(), "no properties at member" );
139 if ( !xMembProp.is() )
140 return;
141
142 // exceptions are caught at ScDPSaveData::WriteToSource
143
145 lcl_SetBoolProperty( xMembProp,
146 SC_UNO_DP_ISVISIBLE, static_cast<bool>(nVisibleMode) );
147
149 lcl_SetBoolProperty( xMembProp,
150 SC_UNO_DP_SHOWDETAILS, static_cast<bool>(nShowDetailsMode) );
151
152 if (mpLayoutName)
154
155 if ( nPosition >= 0 )
157}
158
159#if DUMP_PIVOT_TABLE
160
161void ScDPSaveMember::Dump(int nIndent) const
162{
163 std::string aIndent(nIndent*4, ' ');
164 cout << aIndent << "* member name: '" << aName << "'" << endl;
165
166 cout << aIndent << " + layout name: ";
167 if (mpLayoutName)
168 cout << "'" << *mpLayoutName << "'";
169 else
170 cout << "(none)";
171 cout << endl;
172
173 cout << aIndent << " + visibility: ";
175 cout << "(unknown)";
176 else
177 cout << (nVisibleMode ? "visible" : "hidden");
178 cout << endl;
179}
180
181#endif
182
183ScDPSaveDimension::ScDPSaveDimension(OUString _aName, bool bDataLayout) :
184 aName(std::move( _aName )),
185 bIsDataLayout( bDataLayout ),
186 bDupFlag( false ),
187 nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ),
188 nFunction( ScGeneralFunction::AUTO ),
189 nUsedHierarchy( -1 ),
190 nShowEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
191 bRepeatItemLabels( false ),
192 bSubTotalDefault( true )
193{
194}
195
197 aName( r.aName ),
198 mpLayoutName( r.mpLayoutName ),
199 mpSubtotalName( r.mpSubtotalName ),
200 bIsDataLayout( r.bIsDataLayout ),
201 bDupFlag( r.bDupFlag ),
202 nOrientation( r.nOrientation ),
203 nFunction( r.nFunction ),
204 nUsedHierarchy( r.nUsedHierarchy ),
205 nShowEmptyMode( r.nShowEmptyMode ),
206 bRepeatItemLabels( r.bRepeatItemLabels ),
207 bSubTotalDefault( r.bSubTotalDefault ),
208 maSubTotalFuncs( r.maSubTotalFuncs )
209{
210 for (const ScDPSaveMember* pMem : r.maMemberList)
211 {
212 const OUString& rName = pMem->GetName();
213 std::unique_ptr<ScDPSaveMember> pNew(new ScDPSaveMember( *pMem ));
214 maMemberList.push_back( pNew.get() );
215 maMemberHash[rName] = std::move(pNew);
216 }
217 if (r.pReferenceValue)
218 pReferenceValue.reset( new sheet::DataPilotFieldReference( *(r.pReferenceValue) ) );
219 if (r.pSortInfo)
220 pSortInfo.reset( new sheet::DataPilotFieldSortInfo( *(r.pSortInfo) ) );
221 if (r.pAutoShowInfo)
222 pAutoShowInfo.reset( new sheet::DataPilotFieldAutoShowInfo( *(r.pAutoShowInfo) ) );
223 if (r.pLayoutInfo)
224 pLayoutInfo.reset(new sheet::DataPilotFieldLayoutInfo( *(r.pLayoutInfo) ));
225}
226
228{
229 maMemberHash.clear();
230 pReferenceValue.reset();
231 pSortInfo.reset();
232 pAutoShowInfo.reset();
233 pLayoutInfo.reset();
234}
235
237{
238 if ( aName != r.aName ||
240 bDupFlag != r.bDupFlag ||
242 nFunction != r.nFunction ||
248 return false;
249
250 if (maMemberHash.size() != r.maMemberHash.size() )
251 return false;
252
253 if (!std::equal(maMemberList.begin(), maMemberList.end(), r.maMemberList.begin(), r.maMemberList.end(),
254 [](const ScDPSaveMember* a, const ScDPSaveMember* b) { return *a == *b; }))
255 return false;
256
258 {
259 if ( *pReferenceValue != *r.pReferenceValue )
260 {
261 return false;
262 }
263 }
264 else if ( pReferenceValue || r.pReferenceValue )
265 {
266 return false;
267 }
268 if( this->pSortInfo && r.pSortInfo )
269 {
270 if ( *this->pSortInfo != *r.pSortInfo )
271 {
272 return false;
273 }
274 }
275 else if ( this->pSortInfo || r.pSortInfo )
276 {
277 return false;
278 }
279 if( this->pAutoShowInfo && r.pAutoShowInfo )
280 {
281 if ( *this->pAutoShowInfo != *r.pAutoShowInfo )
282 {
283 return false;
284 }
285 }
286 else if ( this->pAutoShowInfo || r.pAutoShowInfo )
287 {
288 return false;
289 }
290
291 return true;
292}
293
294void ScDPSaveDimension::AddMember(std::unique_ptr<ScDPSaveMember> pMember)
295{
296 const OUString & rName = pMember->GetName();
297 auto aExisting = maMemberHash.find( rName );
298 auto tmp = pMember.get();
299 if ( aExisting == maMemberHash.end() )
300 {
301 maMemberHash[rName] = std::move(pMember);
302 }
303 else
304 {
305 maMemberList.erase(std::remove(maMemberList.begin(), maMemberList.end(), aExisting->second.get()), maMemberList.end());
306 aExisting->second = std::move(pMember);
307 }
308 maMemberList.push_back( tmp );
309}
310
311void ScDPSaveDimension::SetName( const OUString& rNew )
312{
313 // Used only if the source dim was renamed (groups).
314 // For UI renaming of dimensions, the layout name must be used.
315
316 aName = rNew;
317}
318
319void ScDPSaveDimension::SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
320{
321 nOrientation = nNew;
322}
323
324void ScDPSaveDimension::SetSubTotals(std::vector<ScGeneralFunction> && rFuncs)
325{
326 maSubTotalFuncs = std::move(rFuncs);
327 bSubTotalDefault = false;
328}
329
331{
333}
334
336{
337 nShowEmptyMode = sal_uInt16(bSet);
338}
339
341{
342 bRepeatItemLabels = bSet;
343}
344
346{
347 nFunction = nNew;
348}
349
351{
352 nUsedHierarchy = nNew;
353}
354
355void ScDPSaveDimension::SetSubtotalName(const OUString& rName)
356{
357 mpSubtotalName = rName;
358}
359
360const std::optional<OUString> & ScDPSaveDimension::GetSubtotalName() const
361{
362 return mpSubtotalName;
363}
364
366{
367 mpSubtotalName.reset();
368}
369
370bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const
371{
372 return std::any_of(maMemberList.begin(), maMemberList.end(), [&rName](const ScDPSaveMember* pMem) {
373 if (rName.equalsIgnoreAsciiCase(pMem->GetName()))
374 return true;
375
376 const std::optional<OUString> & pLayoutName = pMem->GetLayoutName();
377 return pLayoutName && rName.equalsIgnoreAsciiCase(*pLayoutName);
378 });
379}
380
381void ScDPSaveDimension::SetLayoutName(const OUString& rName)
382{
383 mpLayoutName = rName;
384}
385
386const std::optional<OUString> & ScDPSaveDimension::GetLayoutName() const
387{
388 return mpLayoutName;
389}
390
392{
393 mpLayoutName.reset();
394}
395
396void ScDPSaveDimension::SetReferenceValue(const sheet::DataPilotFieldReference* pNew)
397{
398 if (pNew)
399 pReferenceValue.reset( new sheet::DataPilotFieldReference(*pNew) );
400 else
401 pReferenceValue.reset();
402}
403
404void ScDPSaveDimension::SetSortInfo(const sheet::DataPilotFieldSortInfo* pNew)
405{
406 if (pNew)
407 pSortInfo.reset( new sheet::DataPilotFieldSortInfo(*pNew) );
408 else
409 pSortInfo.reset();
410}
411
412void ScDPSaveDimension::SetAutoShowInfo(const sheet::DataPilotFieldAutoShowInfo* pNew)
413{
414 if (pNew)
415 pAutoShowInfo.reset( new sheet::DataPilotFieldAutoShowInfo(*pNew) );
416 else
417 pAutoShowInfo.reset();
418}
419
420void ScDPSaveDimension::SetLayoutInfo(const sheet::DataPilotFieldLayoutInfo* pNew)
421{
422 if (pNew)
423 pLayoutInfo.reset( new sheet::DataPilotFieldLayoutInfo(*pNew) );
424 else
425 pLayoutInfo.reset();
426}
427
428void ScDPSaveDimension::SetCurrentPage( const OUString* pPage )
429{
430 // We use member's visibility attribute to filter by page dimension.
431
432 // pPage == nullptr -> all members visible.
433 for (ScDPSaveMember* pMem : maMemberList)
434 {
435 bool bVisible = !pPage || pMem->GetName() == *pPage;
436 pMem->SetIsVisible(bVisible);
437 }
438}
439
441{
442 MemberList::const_iterator it = std::find_if(maMemberList.begin(), maMemberList.end(),
443 [](const ScDPSaveMember* pMem) { return pMem->GetIsVisible(); });
444 if (it != maMemberList.end())
445 return (*it)->GetName();
446
447 return OUString();
448}
449
451{
452 auto res = maMemberHash.find (rName);
453 if (res != maMemberHash.end())
454 return res->second.get();
455 return nullptr;
456}
457
459{
460 auto res = maMemberHash.find (rName);
461 if (res != maMemberHash.end())
462 return res->second.get();
463
464 ScDPSaveMember* pNew = new ScDPSaveMember( rName );
465 maMemberHash[rName] = std::unique_ptr<ScDPSaveMember>(pNew);
466 maMemberList.push_back( pNew );
467 return pNew;
468}
469
470void ScDPSaveDimension::SetMemberPosition( const OUString& rName, sal_Int32 nNewPos )
471{
472 ScDPSaveMember* pMember = GetMemberByName( rName ); // make sure it exists and is in the hash
473
474 maMemberList.erase(std::remove( maMemberList.begin(), maMemberList.end(), pMember), maMemberList.end() );
475
476 maMemberList.insert( maMemberList.begin() + nNewPos, pMember );
477}
478
479void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xDim )
480{
481 uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
482 OSL_ENSURE( xDimProp.is(), "no properties at dimension" );
483 if ( xDimProp.is() )
484 {
485 // exceptions are caught at ScDPSaveData::WriteToSource
486
487 sheet::DataPilotFieldOrientation eOrient = nOrientation;
488 xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(eOrient) );
489
490 sal_Int16 eFunc = static_cast<sal_Int16>(nFunction);
491 xDimProp->setPropertyValue( SC_UNO_DP_FUNCTION2, uno::Any(eFunc) );
492
493 if ( nUsedHierarchy >= 0 )
494 {
495 xDimProp->setPropertyValue( SC_UNO_DP_USEDHIERARCHY, uno::Any(static_cast<sal_Int32>(nUsedHierarchy)) );
496 }
497
498 if ( pReferenceValue )
499 {
500 ;
501 xDimProp->setPropertyValue( SC_UNO_DP_REFVALUE, uno::Any(*pReferenceValue) );
502 }
503
504 if (mpLayoutName)
506
507 const std::optional<OUString> & pSubTotalName = GetSubtotalName();
508 if (pSubTotalName)
509 // Custom subtotal name, with '?' being replaced by the visible field name later.
511 }
512
513 // Level loop outside of maMemberList loop
514 // because SubTotals have to be set independently of known members
515
517
518 tools::Long nHierCount = 0;
519 uno::Reference<container::XIndexAccess> xHiers;
520 uno::Reference<sheet::XHierarchiesSupplier> xHierSupp( xDim, uno::UNO_QUERY );
521 if ( xHierSupp.is() )
522 {
523 uno::Reference<container::XNameAccess> xHiersName = xHierSupp->getHierarchies();
524 xHiers = new ScNameToIndexAccess( xHiersName );
525 nHierCount = xHiers->getCount();
526 }
527
528 bool bHasHiddenMember = false;
529
530 for (tools::Long nHier=0; nHier<nHierCount; nHier++)
531 {
532 tools::Long nLevCount = 0;
533 uno::Reference<container::XIndexAccess> xLevels;
534 uno::Reference<sheet::XLevelsSupplier> xLevSupp(xHiers->getByIndex(nHier), uno::UNO_QUERY);
535 if ( xLevSupp.is() )
536 {
537 uno::Reference<container::XNameAccess> xLevelsName = xLevSupp->getLevels();
538 xLevels = new ScNameToIndexAccess( xLevelsName );
539 nLevCount = xLevels->getCount();
540 }
541
542 for (tools::Long nLev=0; nLev<nLevCount; nLev++)
543 {
544 uno::Reference<uno::XInterface> xLevel(xLevels->getByIndex(nLev), uno::UNO_QUERY);
545 uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
546 OSL_ENSURE( xLevProp.is(), "no properties at level" );
547 if ( xLevProp.is() )
548 {
549 if ( !bSubTotalDefault )
550 {
551 uno::Sequence<sal_Int16> aSeq(maSubTotalFuncs.size());
552 for(size_t i = 0; i < maSubTotalFuncs.size(); ++i)
553 aSeq.getArray()[i] = static_cast<sal_Int16>(maSubTotalFuncs[i]);
554 xLevProp->setPropertyValue( SC_UNO_DP_SUBTOTAL2, uno::Any(aSeq) );
555 }
557 lcl_SetBoolProperty( xLevProp,
558 SC_UNO_DP_SHOWEMPTY, static_cast<bool>(nShowEmptyMode) );
559
560 lcl_SetBoolProperty( xLevProp,
562
563 if ( pSortInfo )
565
566 if ( pAutoShowInfo )
568
569 if ( pLayoutInfo )
571
572 // exceptions are caught at ScDPSaveData::WriteToSource
573 }
574
575 if ( nCount > 0 )
576 {
577 uno::Reference<sheet::XMembersSupplier> xMembSupp( xLevel, uno::UNO_QUERY );
578 if ( xMembSupp.is() )
579 {
580 uno::Reference<sheet::XMembersAccess> xMembers = xMembSupp->getMembers();
581 if ( xMembers.is() )
582 {
583 sal_Int32 nPosition = -1; // set position only in manual mode
584 if ( !pSortInfo || pSortInfo->Mode == sheet::DataPilotFieldSortMode::MANUAL )
585 nPosition = 0;
586
587 for (ScDPSaveMember* pMember : maMemberList)
588 {
589 if (!pMember->GetIsVisible())
590 bHasHiddenMember = true;
591 OUString aMemberName = pMember->GetName();
592 if ( xMembers->hasByName( aMemberName ) )
593 {
594 uno::Reference<uno::XInterface> xMemberInt(
595 xMembers->getByName(aMemberName), uno::UNO_QUERY);
596 pMember->WriteToSource( xMemberInt, nPosition );
597
598 if ( nPosition >= 0 )
599 ++nPosition; // increase if initialized
600 }
601 // missing member is no error
602 }
603 }
604 }
605 }
606 }
607 }
608
609 if (xDimProp.is())
611}
612
613void ScDPSaveDimension::UpdateMemberVisibility(const std::unordered_map<OUString, bool>& rData)
614{
615 for (ScDPSaveMember* pMem : maMemberList)
616 {
617 const OUString& rMemName = pMem->GetName();
618 auto itr = rData.find(rMemName);
619 if (itr != rData.end())
620 pMem->SetIsVisible(itr->second);
621 }
622}
623
625{
626 return std::any_of(maMemberList.begin(), maMemberList.end(),
627 [](const ScDPSaveMember* pMem) { return !pMem->GetIsVisible(); });
628}
629
631{
632 MemberList aNew;
633 for (ScDPSaveMember* pMem : maMemberList)
634 {
635 if (rMembers.count(pMem->GetName()))
636 {
637 // This member still exists.
638 aNew.push_back(pMem);
639 }
640 else
641 {
642 maMemberHash.erase(pMem->GetName());
643 }
644 }
645
646 maMemberList.swap(aNew);
647}
648
649#if DUMP_PIVOT_TABLE
650
651void ScDPSaveDimension::Dump(int nIndent) const
652{
653 static const char* pOrientNames[] = { "hidden", "column", "row", "page", "data" };
654 std::string aIndent(nIndent*4, ' ');
655
656 cout << aIndent << "* dimension name: '" << aName << "'" << endl;
657
658 cout << aIndent << " + orientation: ";
659 if (nOrientation <= DataPilotFieldOrientation_DATA)
660 cout << pOrientNames[static_cast<int>(nOrientation)];
661 else
662 cout << "(invalid)";
663 cout << endl;
664
665 cout << aIndent << " + layout name: ";
666 if (mpLayoutName)
667 cout << "'" << *mpLayoutName << "'";
668 else
669 cout << "(none)";
670 cout << endl;
671
672 cout << aIndent << " + subtotal name: ";
673 if (mpSubtotalName)
674 cout << "'" << *mpSubtotalName << "'";
675 else
676 cout << "(none)";
677 cout << endl;
678
679 cout << aIndent << " + is data layout: " << (bIsDataLayout ? "yes" : "no") << endl;
680 cout << aIndent << " + is duplicate: " << (bDupFlag ? "yes" : "no") << endl;
681
682 for (ScDPSaveMember* pMem : maMemberList)
683 {
684 pMem->Dump(nIndent+1);
685 }
686
687 cout << endl; // blank line
688}
689
690#endif
691
693 nColumnGrandMode( SC_DPSAVEMODE_DONTKNOW ),
694 nRowGrandMode( SC_DPSAVEMODE_DONTKNOW ),
695 nIgnoreEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
696 nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
697 bFilterButton( true ),
698 bDrillDown( true ),
699 mbDimensionMembersBuilt(false)
700{
701}
702
704 nColumnGrandMode( r.nColumnGrandMode ),
705 nRowGrandMode( r.nRowGrandMode ),
706 nIgnoreEmptyMode( r.nIgnoreEmptyMode ),
707 nRepeatEmptyMode( r.nRepeatEmptyMode ),
708 bFilterButton( r.bFilterButton ),
709 bDrillDown( r.bDrillDown ),
710 mbDimensionMembersBuilt(r.mbDimensionMembersBuilt),
711 mpGrandTotalName(r.mpGrandTotalName)
712{
713 if ( r.pDimensionData )
715
716 for (auto const& it : r.m_DimList)
717 {
718 m_DimList.push_back(std::make_unique<ScDPSaveDimension>(*it));
719 }
720}
721
723{
724 if ( &r != this )
725 {
726 this->~ScDPSaveData();
727 new( this ) ScDPSaveData ( r );
728 }
729 return *this;
730}
731
733{
739 bDrillDown != r.bDrillDown ||
741 return false;
742
745 return false;
746
747 if (!(::comphelper::ContainerUniquePtrEquals(m_DimList, r.m_DimList)))
748 return false;
749
751 {
752 if (!r.mpGrandTotalName)
753 return false;
755 return false;
756 }
757 else if (r.mpGrandTotalName)
758 return false;
759
760 return true;
761}
762
764{
765}
766
767void ScDPSaveData::SetGrandTotalName(const OUString& rName)
768{
769 mpGrandTotalName = rName;
770}
771
772const std::optional<OUString> & ScDPSaveData::GetGrandTotalName() const
773{
774 return mpGrandTotalName;
775}
776
777namespace {
778
779class DimOrderInserter
780{
782public:
783 explicit DimOrderInserter(ScDPSaveData::DimOrderType& rNames) : mrNames(rNames) {}
784
785 void operator() (const ScDPSaveDimension* pDim)
786 {
787 size_t nRank = mrNames.size();
788 mrNames.emplace(ScGlobal::getCharClass().uppercase(pDim->GetName()), nRank);
789 }
790};
791
792}
793
795{
796 if (!mpDimOrder)
797 {
798 mpDimOrder.reset(new DimOrderType);
799 std::vector<const ScDPSaveDimension*> aRowDims, aColDims;
800 GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aRowDims);
801 GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aColDims);
802
803 std::for_each(aRowDims.begin(), aRowDims.end(), DimOrderInserter(*mpDimOrder));
804 std::for_each(aColDims.begin(), aColDims.end(), DimOrderInserter(*mpDimOrder));
805 }
806 return *mpDimOrder;
807}
808
810 sheet::DataPilotFieldOrientation eOrientation, std::vector<const ScDPSaveDimension*>& rDims) const
811{
812 std::vector<const ScDPSaveDimension*> aDims;
813 for (auto const& it : m_DimList)
814 {
815 const ScDPSaveDimension& rDim = *it;
816 if (rDim.GetOrientation() != eOrientation)
817 continue;
818
819 aDims.push_back(&rDim);
820 }
821
822 rDims.swap(aDims);
823}
824
826{
827 if (!pDim)
828 return;
829
830 CheckDuplicateName(*pDim);
831 m_DimList.push_back(std::unique_ptr<ScDPSaveDimension>(pDim));
832
834}
835
837{
838 for (auto const& iter : m_DimList)
839 {
840 if (iter->GetName() == rName && !iter->IsDataLayout() )
841 return &(*iter);
842 }
843
844 return AppendNewDimension(rName, false);
845}
846
848{
849 for (auto const& iter : m_DimList)
850 {
851 if (iter->GetName() == rName && !iter->IsDataLayout() )
852 return &(*iter);
853 }
854 return nullptr; // don't create new
855}
856
858{
859 for (auto const& iter : m_DimList)
860 {
861 if (iter->GetName() == rName && !iter->IsDataLayout() )
862 return DuplicateDimension(rName);
863 }
864
865 return AppendNewDimension(rName, false);
866}
867
869{
871 if (pDim)
872 return pDim;
873
874 return AppendNewDimension(OUString(), true);
875}
876
878{
879 for (auto const& iter : m_DimList)
880 {
881 if ( iter->IsDataLayout() )
882 return &(*iter);
883 }
884 return nullptr;
885}
886
888{
889 // always insert new
890
892 if (!pOld)
893 return nullptr;
894
895 ScDPSaveDimension* pNew = new ScDPSaveDimension( *pOld );
896 AddDimension(pNew);
897 return pNew;
898}
899
900void ScDPSaveData::RemoveDimensionByName(const OUString& rName)
901{
902 auto iter = std::find_if(m_DimList.begin(), m_DimList.end(),
903 [&rName](const std::unique_ptr<ScDPSaveDimension>& rxDim) {
904 return rxDim->GetName() == rName && !rxDim->IsDataLayout(); });
905 if (iter != m_DimList.end())
906 {
907 m_DimList.erase(iter);
910 }
911}
912
914{
915 ScDPSaveDimension* pNew = new ScDPSaveDimension( rDim );
916 AddDimension(pNew);
917 return *pNew;
918}
919
920ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(DataPilotFieldOrientation nOrientation)
921{
922 // return the innermost dimension for the given orientation,
923 // excluding data layout dimension
924
925 auto iter = std::find_if(m_DimList.rbegin(), m_DimList.rend(),
926 [&nOrientation](const std::unique_ptr<ScDPSaveDimension>& rxDim) {
927 return rxDim->GetOrientation() == nOrientation && !rxDim->IsDataLayout(); });
928 if (iter != m_DimList.rend())
929 return iter->get();
930
931 return nullptr;
932}
933
934ScDPSaveDimension* ScDPSaveData::GetFirstDimension(sheet::DataPilotFieldOrientation eOrientation)
935{
936 for (auto const& iter : m_DimList)
937 {
938 if (iter->GetOrientation() == eOrientation && !iter->IsDataLayout())
939 return &(*iter);
940 }
941 return nullptr;
942}
943
945{
946 tools::Long nDataCount = 0;
947
948 for (auto const& iter : m_DimList)
949 {
950 if (iter->GetOrientation() == sheet::DataPilotFieldOrientation_DATA)
951 ++nDataCount;
952 }
953
954 return nDataCount;
955}
956
958{
959 // position (nNew) is counted within dimensions of the same orientation
960
961 DataPilotFieldOrientation nOrient = pDim->GetOrientation();
962
963 auto it = std::find_if(m_DimList.begin(), m_DimList.end(),
964 [&pDim](const std::unique_ptr<ScDPSaveDimension>& rxDim) { return pDim == rxDim.get(); });
965 if (it != m_DimList.end())
966 {
967 // Tell vector<unique_ptr> to give up ownership of this element. Don't
968 // delete this instance as it is re-inserted into the container later.
969 // coverity[leaked_storage] - re-inserted into the container later
970 it->release();
971 m_DimList.erase(it);
972 }
973
974 auto iterInsert = std::find_if(m_DimList.begin(), m_DimList.end(),
975 [&nOrient, &nNew](const std::unique_ptr<ScDPSaveDimension>& rxDim) {
976 if (rxDim->GetOrientation() == nOrient )
977 --nNew;
978 return nNew <= 0;
979 });
980
981 m_DimList.insert(iterInsert, std::unique_ptr<ScDPSaveDimension>(pDim));
983}
984
986{
987 nColumnGrandMode = sal_uInt16(bSet);
988}
989
991{
992 nRowGrandMode = sal_uInt16(bSet);
993}
994
996{
997 nIgnoreEmptyMode = sal_uInt16(bSet);
998}
999
1001{
1002 nRepeatEmptyMode = sal_uInt16(bSet);
1003}
1004
1006{
1007 bFilterButton = bSet;
1008}
1009
1011{
1012 bDrillDown = bSet;
1013}
1014
1015static void lcl_ResetOrient( const uno::Reference<sheet::XDimensionsSupplier>& xSource )
1016{
1017 uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
1018 uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
1019 tools::Long nIntCount = xIntDims->getCount();
1020 for (tools::Long nIntDim=0; nIntDim<nIntCount; nIntDim++)
1021 {
1022 uno::Reference<beans::XPropertySet> xDimProp(xIntDims->getByIndex(nIntDim), uno::UNO_QUERY);
1023 if (xDimProp.is())
1024 {
1025 xDimProp->setPropertyValue( SC_UNO_DP_ORIENTATION, uno::Any(sheet::DataPilotFieldOrientation_HIDDEN) );
1026 }
1027 }
1028}
1029
1030void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplier>& xSource )
1031{
1032 if (!xSource.is())
1033 return;
1034
1035 // source options must be first!
1036
1037 uno::Reference<beans::XPropertySet> xSourceProp( xSource, uno::UNO_QUERY );
1038 SAL_WARN_IF( !xSourceProp.is(), "sc.core", "no properties at source" );
1039 if ( xSourceProp.is() )
1040 {
1041 // source options are not available for external sources
1042 //TODO: use XPropertySetInfo to test for availability?
1043
1044 try
1045 {
1047 lcl_SetBoolProperty( xSourceProp,
1048 SC_UNO_DP_IGNOREEMPTY, static_cast<bool>(nIgnoreEmptyMode) );
1050 lcl_SetBoolProperty( xSourceProp,
1051 SC_UNO_DP_REPEATEMPTY, static_cast<bool>(nRepeatEmptyMode) );
1052 }
1053 catch(uno::Exception&)
1054 {
1055 // no error
1056 }
1057
1058 const std::optional<OUString> & pGrandTotalName = GetGrandTotalName();
1059 if (pGrandTotalName)
1061 }
1062
1063 // exceptions in the other calls are errors
1064 try
1065 {
1066 // reset all orientations
1067 //TODO: "forgetSettings" or similar at source ?????
1068 //TODO: reset all duplicated dimensions, or reuse them below !!!
1069 SAL_INFO("sc.core", "ScDPSaveData::WriteToSource");
1070
1071 lcl_ResetOrient( xSource );
1072
1073 uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
1074 uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
1075 tools::Long nIntCount = xIntDims->getCount();
1076
1077 for (const auto& rxDim : m_DimList)
1078 {
1079 OUString aName = rxDim->GetName();
1080 OUString aCoreName = ScDPUtil::getSourceDimensionName(aName);
1081
1082 SAL_INFO("sc.core", aName);
1083
1084 bool bData = rxDim->IsDataLayout();
1085
1086 //TODO: getByName for ScDPSource, including DataLayoutDimension !!!!!!!!
1087
1088 bool bFound = false;
1089 for (tools::Long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
1090 {
1091 uno::Reference<uno::XInterface> xIntDim(xIntDims->getByIndex(nIntDim),
1092 uno::UNO_QUERY);
1093 if ( bData )
1094 {
1095 uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
1096 if ( xDimProp.is() )
1097 {
1098 bFound = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
1100 //TODO: error checking -- is "IsDataLayoutDimension" property required??
1101 }
1102 }
1103 else
1104 {
1105 uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
1106 if (xDimName.is() && xDimName->getName() == aCoreName)
1107 bFound = true;
1108 }
1109
1110 if (bFound)
1111 {
1112 if (rxDim->GetDupFlag())
1113 {
1114 uno::Reference<util::XCloneable> xCloneable(xIntDim, uno::UNO_QUERY);
1115 SAL_WARN_IF(!xCloneable.is(), "sc.core", "cannot clone dimension");
1116 if (xCloneable.is())
1117 {
1118 uno::Reference<util::XCloneable> xNew = xCloneable->createClone();
1119 uno::Reference<container::XNamed> xNewName(xNew, uno::UNO_QUERY);
1120 if (xNewName.is())
1121 {
1122 xNewName->setName(aName);
1123 rxDim->WriteToSource(xNew);
1124 }
1125 }
1126 }
1127 else
1128 rxDim->WriteToSource( xIntDim );
1129 }
1130 }
1131 SAL_WARN_IF(!bFound, "sc.core", "WriteToSource: Dimension not found: " + aName + ".");
1132 }
1133
1134 if ( xSourceProp.is() )
1135 {
1137 lcl_SetBoolProperty( xSourceProp,
1138 SC_UNO_DP_COLGRAND, static_cast<bool>(nColumnGrandMode) );
1140 lcl_SetBoolProperty( xSourceProp,
1141 SC_UNO_DP_ROWGRAND, static_cast<bool>(nRowGrandMode) );
1142 }
1143 }
1144 catch(uno::Exception const &)
1145 {
1146 TOOLS_WARN_EXCEPTION("sc.core", "WriteToSource");
1147 }
1148}
1149
1151{
1152 for (auto const& iter : m_DimList)
1153 {
1154 if (iter->GetOrientation() != sheet::DataPilotFieldOrientation_HIDDEN && !iter->IsDataLayout())
1155 return false;
1156 }
1157 return true; // no entries that are not hidden
1158}
1159
1160void ScDPSaveData::RemoveAllGroupDimensions( const OUString& rSrcDimName, std::vector<OUString>* pDeletedNames )
1161{
1162 if (!pDimensionData)
1163 // No group dimensions exist. Nothing to do.
1164 return;
1165
1166 // Remove numeric group dimension (exists once at most). No need to delete
1167 // anything in save data (grouping was done inplace in an existing base
1168 // dimension).
1169 pDimensionData->RemoveNumGroupDimension(rSrcDimName);
1170
1171 // Remove named group dimension(s). Dimensions have to be removed from
1172 // dimension save data and from save data too.
1173 const ScDPSaveGroupDimension* pExistingGroup = pDimensionData->GetGroupDimForBase(rSrcDimName);
1174 while ( pExistingGroup )
1175 {
1176 OUString aGroupDimName = pExistingGroup->GetGroupDimName();
1177 pDimensionData->RemoveGroupDimension(aGroupDimName); // pExistingGroup is deleted
1178
1179 // also remove SaveData settings for the dimension that no longer exists
1180 RemoveDimensionByName(aGroupDimName);
1181
1182 if (pDeletedNames)
1183 pDeletedNames->push_back(aGroupDimName);
1184
1185 // see if there are more group dimensions
1186 pExistingGroup = pDimensionData->GetGroupDimForBase(rSrcDimName);
1187
1188 if ( pExistingGroup && pExistingGroup->GetGroupDimName() == aGroupDimName )
1189 {
1190 // still get the same group dimension?
1191 OSL_FAIL("couldn't remove group dimension");
1192 pExistingGroup = nullptr; // avoid endless loop
1193 }
1194 }
1195}
1196
1198{
1199 if (!pDimensionData)
1201 return pDimensionData.get();
1202}
1203
1205{
1206 if ( pNew )
1207 pDimensionData.reset( new ScDPDimensionSaveData( *pNew ) );
1208 else
1209 pDimensionData.reset();
1210}
1211
1213{
1215 return;
1216
1217 // First, build a dimension name-to-index map.
1218 typedef std::unordered_map<OUString, tools::Long> NameIndexMap;
1219 NameIndexMap aMap;
1220 tools::Long nColCount = pData->GetColumnCount();
1221 for (tools::Long i = 0; i < nColCount; ++i)
1222 aMap.emplace(pData->getDimensionName(i), i);
1223
1224 NameIndexMap::const_iterator itrEnd = aMap.end();
1225
1226 for (auto const& iter : m_DimList)
1227 {
1228 const OUString& rDimName = iter->GetName();
1229 if (rDimName.isEmpty())
1230 // empty dimension name. It must be data layout.
1231 continue;
1232
1233 NameIndexMap::const_iterator itr = aMap.find(rDimName);
1234 if (itr == itrEnd)
1235 // dimension name not in the data. This should never happen!
1236 continue;
1237
1238 tools::Long nDimIndex = itr->second;
1239 const std::vector<SCROW>& rMembers = pData->GetColumnEntries(nDimIndex);
1240 size_t nMemberCount = rMembers.size();
1241 for (size_t j = 0; j < nMemberCount; ++j)
1242 {
1243 const ScDPItemData* pMemberData = pData->GetMemberById( nDimIndex, rMembers[j] );
1244 OUString aMemName = pData->GetFormattedString(nDimIndex, *pMemberData, false);
1245 if (iter->GetExistingMemberByName(aMemName))
1246 // this member instance already exists. nothing to do.
1247 continue;
1248
1249 unique_ptr<ScDPSaveMember> pNewMember(new ScDPSaveMember(aMemName));
1250 pNewMember->SetIsVisible(true);
1251 iter->AddMember(std::move(pNewMember));
1252 }
1253 }
1254
1256}
1257
1259{
1260 typedef std::unordered_map<OUString, tools::Long> NameIndexMap;
1261
1262 // First, build a dimension name-to-index map.
1263 NameIndexMap aMap;
1264 tools::Long nColCount = pData->GetColumnCount();
1265 for (tools::Long i = 0; i < nColCount; ++i)
1266 aMap.emplace(pData->getDimensionName(i), i);
1267
1268 NameIndexMap::const_iterator itMapEnd = aMap.end();
1269
1270 for (auto const& it : m_DimList)
1271 {
1272 const OUString& rDimName = it->GetName();
1273 if (rDimName.isEmpty())
1274 // empty dimension name. It must be data layout.
1275 continue;
1276
1277 NameIndexMap::const_iterator itMap = aMap.find(rDimName);
1278 if (itMap == itMapEnd)
1279 // dimension name not in the data. This should never happen!
1280 continue;
1281
1283 tools::Long nDimIndex = itMap->second;
1284 const std::vector<SCROW>& rMembers = pData->GetColumnEntries(nDimIndex);
1285 size_t nMemberCount = rMembers.size();
1286 for (size_t j = 0; j < nMemberCount; ++j)
1287 {
1288 const ScDPItemData* pMemberData = pData->GetMemberById(nDimIndex, rMembers[j]);
1289 // ScDPCache::GetItemDataById() (via
1290 // ScDPTableData::GetMemberById(),
1291 // ScDPGroupTableData::GetMemberById() through
1292 // GetCacheTable().getCache()) may return nullptr.
1293 if (pMemberData)
1294 {
1295 OUString aMemName = pData->GetFormattedString(nDimIndex, *pMemberData, false);
1296 aMemNames.insert(aMemName);
1297 }
1298 else
1299 {
1300 SAL_WARN("sc.core", "No pMemberData for nDimIndex " << nDimIndex << ", rMembers[j] " << rMembers[j]
1301 << ", j " << j);
1302 }
1303 }
1304
1305 it->RemoveObsoleteMembers(aMemNames);
1306 }
1307}
1308
1309bool ScDPSaveData::HasInvisibleMember(std::u16string_view rDimName) const
1310{
1312 if (!pDim)
1313 return false;
1314
1315 return pDim->HasInvisibleMember();
1316}
1317
1318#if DUMP_PIVOT_TABLE
1319
1320void ScDPSaveData::Dump() const
1321{
1322 for (auto const& itDim : m_DimList)
1323 {
1324 const ScDPSaveDimension& rDim = *itDim;
1325 rDim.Dump();
1326 }
1327}
1328
1329#endif
1330
1332{
1333 const OUString aName = ScDPUtil::getSourceDimensionName(rDim.GetName());
1334 DupNameCountType::iterator it = maDupNameCounts.find(aName);
1335 if (it != maDupNameCounts.end())
1336 {
1338 rDim.SetDupFlag(true);
1339 }
1340 else
1341 // New name.
1342 maDupNameCounts.emplace(aName, 0);
1343}
1344
1346{
1347 OUString aCoreName = rName;
1349 aCoreName = ScDPUtil::getSourceDimensionName(rName);
1350
1351 DupNameCountType::iterator it = maDupNameCounts.find(aCoreName);
1352 if (it == maDupNameCounts.end())
1353 return;
1354
1355 if (!it->second)
1356 {
1357 maDupNameCounts.erase(it);
1358 return;
1359 }
1360
1361 --it->second;
1362}
1363
1364ScDPSaveDimension* ScDPSaveData::AppendNewDimension(const OUString& rName, bool bDataLayout)
1365{
1367 // This call is for original dimensions only.
1368 return nullptr;
1369
1370 ScDPSaveDimension* pNew = new ScDPSaveDimension(rName, bDataLayout);
1371 m_DimList.push_back(std::unique_ptr<ScDPSaveDimension>(pNew));
1372 if (!maDupNameCounts.count(rName))
1373 maDupNameCounts.emplace(rName, 0);
1374
1376 return pNew;
1377}
1378
1380{
1381 mpDimOrder.reset();
1382}
1383
1384/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
Definition: dpdimsave.hxx:164
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
Definition: dpitemdata.hxx:29
std::unordered_map< OUString, size_t > DimOrderType
Definition: dpsave.hxx:237
void RemoveAllGroupDimensions(const OUString &rSrcDimName, std::vector< OUString > *pDeletedNames=nullptr)
Definition: dpsave.cxx:1160
void WriteToSource(const css::uno::Reference< css::sheet::XDimensionsSupplier > &xSource)
Definition: dpsave.cxx:1030
SC_DLLPUBLIC void SetIgnoreEmptyRows(bool bSet)
Definition: dpsave.cxx:995
ScDPSaveDimension * GetInnermostDimension(css::sheet::DataPilotFieldOrientation nOrientation)
Definition: dpsave.cxx:920
void RemoveDuplicateNameCount(const OUString &rName)
Definition: dpsave.cxx:1345
bool operator==(const ScDPSaveData &r) const
Definition: dpsave.cxx:732
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDimensionByName(std::u16string_view rName) const
Definition: dpsave.cxx:847
void DimensionsChanged()
Definition: dpsave.cxx:1379
bool IsEmpty() const
Definition: dpsave.cxx:1150
const DimOrderType & GetDimensionSortOrder() const
Get sort order map to sort row and column dimensions in order of appearance.
Definition: dpsave.cxx:794
SC_DLLPUBLIC void GetAllDimensionsByOrientation(css::sheet::DataPilotFieldOrientation eOrientation, std::vector< const ScDPSaveDimension * > &rDims) const
Get all dimensions in a given orientation.
Definition: dpsave.cxx:809
ScDPSaveData & operator=(const ScDPSaveData &r)
Definition: dpsave.cxx:722
SC_DLLPUBLIC ScDPSaveDimension * GetNewDimensionByName(const OUString &rName)
Definition: dpsave.cxx:857
void Dump() const
ScDPSaveDimension * GetFirstDimension(css::sheet::DataPilotFieldOrientation eOrientation)
Definition: dpsave.cxx:934
bool bDrillDown
Definition: dpsave.hxx:249
void SetPosition(ScDPSaveDimension *pDim, tools::Long nNew)
Definition: dpsave.cxx:957
SC_DLLPUBLIC bool HasInvisibleMember(std::u16string_view rDimName) const
Check whether a dimension has one or more invisible members.
Definition: dpsave.cxx:1309
sal_uInt16 nRowGrandMode
Definition: dpsave.hxx:245
ScDPSaveDimension * DuplicateDimension(std::u16string_view rName)
Definition: dpsave.cxx:887
std::unique_ptr< DimOrderType > mpDimOrder
Definition: dpsave.hxx:256
sal_uInt16 nIgnoreEmptyMode
Definition: dpsave.hxx:246
SC_DLLPUBLIC const std::optional< OUString > & GetGrandTotalName() const
Definition: dpsave.cxx:772
bool bFilterButton
Definition: dpsave.hxx:248
void CheckDuplicateName(ScDPSaveDimension &rDim)
Definition: dpsave.cxx:1331
SC_DLLPUBLIC void SetRepeatIfEmpty(bool bSet)
Definition: dpsave.cxx:1000
DupNameCountType maDupNameCounts
Definition: dpsave.hxx:242
SC_DLLPUBLIC void SetFilterButton(bool bSet)
Definition: dpsave.cxx:1005
void RemoveDimensionByName(const OUString &rName)
Definition: dpsave.cxx:900
SC_DLLPUBLIC void SetGrandTotalName(const OUString &rName)
Definition: dpsave.cxx:767
SC_DLLPUBLIC ScDPSaveDimension * GetDataLayoutDimension()
Definition: dpsave.cxx:868
std::optional< OUString > mpGrandTotalName
Definition: dpsave.hxx:255
ScDPSaveDimension * AppendNewDimension(const OUString &rName, bool bDataLayout)
Append a new original dimension.
Definition: dpsave.cxx:1364
void AddDimension(ScDPSaveDimension *pDim)
Definition: dpsave.cxx:825
SC_DLLPUBLIC void SetRowGrand(bool bSet)
Definition: dpsave.cxx:990
SC_DLLPUBLIC void SetColumnGrand(bool bSet)
Definition: dpsave.cxx:985
SC_DLLPUBLIC ScDPSaveDimension * GetExistingDataLayoutDimension() const
Definition: dpsave.cxx:877
void SyncAllDimensionMembers(ScDPTableData *pData)
Definition: dpsave.cxx:1258
DimsType m_DimList
Definition: dpsave.hxx:241
SC_DLLPUBLIC ScDPDimensionSaveData * GetDimensionData()
Definition: dpsave.cxx:1197
SC_DLLPUBLIC void SetDimensionData(const ScDPDimensionSaveData *pNew)
Definition: dpsave.cxx:1204
SC_DLLPUBLIC tools::Long GetDataDimensionCount() const
Definition: dpsave.cxx:944
void BuildAllDimensionMembers(ScDPTableData *pData)
Definition: dpsave.cxx:1212
SC_DLLPUBLIC ScDPSaveDimension * GetDimensionByName(const OUString &rName)
Get a dimension object by its name.
Definition: dpsave.cxx:836
sal_uInt16 nColumnGrandMode
Definition: dpsave.hxx:244
SC_DLLPUBLIC void SetDrillDown(bool bSet)
Definition: dpsave.cxx:1010
bool mbDimensionMembersBuilt
if true, all dimensions already have all of their member instances created.
Definition: dpsave.hxx:253
std::unique_ptr< ScDPDimensionSaveData > pDimensionData
keep track of number of duplicates in each name.
Definition: dpsave.hxx:243
sal_uInt16 nRepeatEmptyMode
Definition: dpsave.hxx:247
SC_DLLPUBLIC ~ScDPSaveData()
Definition: dpsave.cxx:763
SC_DLLPUBLIC ScDPSaveData()
Definition: dpsave.cxx:692
void RemoveObsoleteMembers(const MemberSetType &rMembers)
Definition: dpsave.cxx:630
tools::Long nUsedHierarchy
Definition: dpsave.hxx:103
std::optional< OUString > mpSubtotalName
Definition: dpsave.hxx:98
void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo *pNew)
Definition: dpsave.cxx:412
bool bSubTotalDefault
at level
Definition: dpsave.hxx:106
sal_uInt16 nShowEmptyMode
Definition: dpsave.hxx:104
std::unique_ptr< css::sheet::DataPilotFieldLayoutInfo > pLayoutInfo
Definition: dpsave.hxx:111
void SetRepeatItemLabels(bool bSet)
Definition: dpsave.cxx:340
bool operator==(const ScDPSaveDimension &r) const
Definition: dpsave.cxx:236
void RemoveSubtotalName()
Definition: dpsave.cxx:365
void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo *pNew)
Definition: dpsave.cxx:420
void UpdateMemberVisibility(const std::unordered_map< OUString, bool > &rData)
Definition: dpsave.cxx:613
OUString aName
Definition: dpsave.hxx:96
std::vector< ScGeneralFunction > maSubTotalFuncs
at level
Definition: dpsave.hxx:107
std::unordered_set< OUString > MemberSetType
Definition: dpsave.hxx:114
bool HasShowEmpty() const
Definition: dpsave.cxx:330
bool bIsDataLayout
Definition: dpsave.hxx:99
void SetLayoutName(const OUString &rName)
Definition: dpsave.cxx:381
void SetReferenceValue(const css::sheet::DataPilotFieldReference *pNew)
Definition: dpsave.cxx:396
bool bRepeatItemLabels
at level
Definition: dpsave.hxx:105
OUString GetCurrentPage() const
Definition: dpsave.cxx:440
bool HasInvisibleMember() const
Definition: dpsave.cxx:624
std::unique_ptr< css::sheet::DataPilotFieldAutoShowInfo > pAutoShowInfo
Definition: dpsave.hxx:110
void SetOrientation(css::sheet::DataPilotFieldOrientation nNew)
Definition: dpsave.cxx:319
ScGeneralFunction nFunction
Definition: dpsave.hxx:102
void AddMember(std::unique_ptr< ScDPSaveMember > pMember)
Definition: dpsave.cxx:294
void SetDupFlag(bool bSet)
Definition: dpsave.hxx:133
ScDPSaveMember * GetExistingMemberByName(const OUString &rName)
Definition: dpsave.cxx:450
css::sheet::DataPilotFieldOrientation GetOrientation() const
Definition: dpsave.hxx:202
MemberList maMemberList
Definition: dpsave.hxx:119
std::unique_ptr< css::sheet::DataPilotFieldSortInfo > pSortInfo
Definition: dpsave.hxx:109
std::unordered_map< OUString, std::unique_ptr< ScDPSaveMember > > maMemberHash
Definition: dpsave.hxx:118
void SetSubtotalName(const OUString &rName)
Definition: dpsave.cxx:355
void SetUsedHierarchy(tools::Long nNew)
Definition: dpsave.cxx:350
std::unique_ptr< css::sheet::DataPilotFieldReference > pReferenceValue
Definition: dpsave.hxx:108
css::sheet::DataPilotFieldOrientation nOrientation
Definition: dpsave.hxx:101
std::optional< OUString > mpLayoutName
Definition: dpsave.hxx:97
void RemoveLayoutName()
Definition: dpsave.cxx:391
void SetSortInfo(const css::sheet::DataPilotFieldSortInfo *pNew)
Definition: dpsave.cxx:404
const std::optional< OUString > & GetSubtotalName() const
Definition: dpsave.cxx:360
bool IsMemberNameInUse(const OUString &rName) const
Definition: dpsave.cxx:370
ScDPSaveMember * GetMemberByName(const OUString &rName)
Get a member object by its name.
Definition: dpsave.cxx:458
const std::optional< OUString > & GetLayoutName() const
Definition: dpsave.cxx:386
ScDPSaveDimension(OUString aName, bool bDataLayout)
Definition: dpsave.cxx:183
void SetCurrentPage(const OUString *pPage)
Definition: dpsave.cxx:428
void WriteToSource(const css::uno::Reference< css::uno::XInterface > &xDim)
Definition: dpsave.cxx:479
void Dump(int nIndent=0) const
std::vector< ScDPSaveMember * > MemberList
Definition: dpsave.hxx:115
const OUString & GetName() const
Definition: dpsave.hxx:139
void SetSubTotals(std::vector< ScGeneralFunction > &&rFuncs)
Definition: dpsave.cxx:324
void SetName(const OUString &rNew)
Definition: dpsave.cxx:311
void SetShowEmpty(bool bSet)
Definition: dpsave.cxx:335
void SetMemberPosition(const OUString &rName, sal_Int32 nNewPos)
Definition: dpsave.cxx:470
void SetFunction(ScGeneralFunction nNew)
Definition: dpsave.cxx:345
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
Definition: dpdimsave.hxx:91
const OUString & GetGroupDimName() const
Definition: dpdimsave.hxx:107
void SetName(const OUString &rNew)
Definition: dpsave.cxx:112
OUString aName
Definition: dpsave.hxx:54
SC_DLLPUBLIC void SetIsVisible(bool bSet)
Definition: dpsave.cxx:97
const OUString & GetName() const
Definition: dpsave.hxx:66
sal_uInt16 nVisibleMode
Definition: dpsave.hxx:56
std::optional< OUString > mpLayoutName
Definition: dpsave.hxx:55
void WriteToSource(const css::uno::Reference< css::uno::XInterface > &xMember, sal_Int32 nPosition)
Definition: dpsave.cxx:135
SC_DLLPUBLIC bool HasShowDetails() const
Definition: dpsave.cxx:102
SC_DLLPUBLIC bool HasIsVisible() const
Definition: dpsave.cxx:92
void Dump(int nIndent=0) const
SC_DLLPUBLIC void SetLayoutName(const OUString &rName)
Definition: dpsave.cxx:120
void RemoveLayoutName()
Definition: dpsave.cxx:130
ScDPSaveMember(OUString aName)
Definition: dpsave.cxx:66
bool operator==(const ScDPSaveMember &r) const
Definition: dpsave.cxx:85
sal_uInt16 nShowDetailsMode
Definition: dpsave.hxx:57
SC_DLLPUBLIC const std::optional< OUString > & GetLayoutName() const
Definition: dpsave.cxx:125
SC_DLLPUBLIC void SetShowDetails(bool bSet)
Definition: dpsave.cxx:107
Base class that abstracts different data source types of a datapilot table.
Definition: dptabdat.hxx:57
static SC_DLLPUBLIC OUString getSourceDimensionName(std::u16string_view rName)
Definition: dputil.cxx:66
static bool isDuplicateDimension(std::u16string_view rName)
Definition: dputil.cxx:61
static SC_DLLPUBLIC OUString createDuplicateDimensionName(const OUString &rOriginal, size_t nDupCount)
Definition: dputil.cxx:92
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
static bool GetBoolProperty(const css::uno::Reference< css::beans::XPropertySet > &xProp, const OUString &rName, bool bDefault=false)
Definition: miscuno.cxx:36
static void SetOptionalPropertyValue(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const char *pPropName, const css::uno::Any &rVal)
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
static void lcl_ResetOrient(const uno::Reference< sheet::XDimensionsSupplier > &xSource)
Definition: dpsave.cxx:1015
static void lcl_SetBoolProperty(const uno::Reference< beans::XPropertySet > &xProp, const OUString &rName, bool bValue)
Definition: dpsave.cxx:58
#define SC_DPSAVEMODE_DONTKNOW
Definition: dpsave.cxx:56
ScGeneralFunction
the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2,...
OUString aName
uno_Any a
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
AUTO
int i
long Long
HashMap_OWString_Interface aMap
TOOLS_DLLPUBLIC SvStream & endl(SvStream &rStr)
bool bVisible
constexpr OUStringLiteral SC_UNO_DP_SORTING
Definition: unonames.hxx:625
constexpr OUStringLiteral SC_UNO_DP_HAS_HIDDEN_MEMBER
Definition: unonames.hxx:621
constexpr OUStringLiteral SC_UNO_DP_COLGRAND
Definition: unonames.hxx:594
constexpr OUStringLiteral SC_UNO_DP_POSITION
Definition: unonames.hxx:600
constexpr OUStringLiteral SC_UNO_DP_REPEATEMPTY
Definition: unonames.hxx:612
constexpr OUStringLiteral SC_UNO_DP_ISDATALAYOUT
Definition: unonames.hxx:598
constexpr OUStringLiteral SC_UNO_DP_IGNOREEMPTY
Definition: unonames.hxx:611
constexpr OUStringLiteral SC_UNO_DP_SUBTOTAL2
Definition: unonames.hxx:606
constexpr OUStringLiteral SC_UNO_DP_GRANDTOTAL_NAME
Definition: unonames.hxx:620
constexpr OUStringLiteral SC_UNO_DP_LAYOUTNAME
Definition: unonames.hxx:618
constexpr OUStringLiteral SC_UNO_DP_REPEATITEMLABELS
Definition: unonames.hxx:608
constexpr OUStringLiteral SC_UNO_DP_FUNCTION2
Definition: unonames.hxx:602
constexpr OUStringLiteral SC_UNO_DP_ROWGRAND
Definition: unonames.hxx:595
constexpr OUStringLiteral SC_UNO_DP_USEDHIERARCHY
Definition: unonames.hxx:603
constexpr OUStringLiteral SC_UNO_DP_ORIENTATION
Definition: unonames.hxx:599
constexpr OUStringLiteral SC_UNO_DP_FIELD_SUBTOTALNAME
Definition: unonames.hxx:619
constexpr OUStringLiteral SC_UNO_DP_ISVISIBLE
Definition: unonames.hxx:609
constexpr OUStringLiteral SC_UNO_DP_SHOWDETAILS
Definition: unonames.hxx:610
constexpr OUStringLiteral SC_UNO_DP_SHOWEMPTY
Definition: unonames.hxx:607
constexpr OUStringLiteral SC_UNO_DP_LAYOUT
Definition: unonames.hxx:627
constexpr OUStringLiteral SC_UNO_DP_REFVALUE
Definition: unonames.hxx:624
constexpr OUStringLiteral SC_UNO_DP_AUTOSHOW
Definition: unonames.hxx:626