25#include <document.hxx>
27#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
30#include <osl/diagnose.h>
31#include <rtl/math.hxx>
101 sal_uInt32 nFormat = 0;
105 aData.SetValue(fValue);
107 aData.SetString(rElement);
121 for (
const auto& rItem :
maItems)
128 aSourceDim(
std::move( aSource )),
135 aSourceDim(
std::move( aSource )),
137 aDateInfo( rDateInfo ),
161 const sal_Int32 nMaxAdd = nAdd +
aGroups.size();
162 while ( nAdd <= nMaxAdd )
164 OUString aGroupName = rPrefix + OUString::number( nAdd );
169 return rGroup.GetGroupName() == aGroupName;
178 OSL_FAIL(
"CreateGroupName: no valid name found");
191 return rGroup.GetGroupName() == rGroupName;
215 for ( ScDPSaveGroupItemVec::iterator aIter(
aGroups.begin()); aIter !=
aGroups.end(); ++aIter )
216 if ( aIter->RemoveElement( rItemName ) )
218 if ( aIter->IsEmpty() )
229 return rGroup.GetGroupName() == rGroupName;
245 [&rVisible](
const ScDPSaveGroupItem& rGroup) { return rVisible.count(rGroup.GetGroupName()) > 0; });
261bool isInteger(
double fValue)
263 return rtl::math::approxEqual(fValue, rtl::math::approxFloor(fValue));
266void fillDateGroupDimension(
272 double fSourceMin = 0.0;
273 double fSourceMax = 0.0;
282 double fVal = rItem.GetValue();
285 fSourceMin = fSourceMax = fVal;
290 if (fVal < fSourceMin)
292 if ( fVal > fSourceMax )
301 rDateInfo.
mfStart = rtl::math::approxFloor(fSourceMin);
303 rDateInfo.
mfEnd = rtl::math::approxFloor(fSourceMax) + 1;
311 case sheet::DataPilotFieldGroupBy::YEARS:
313 fSourceMin,
nullptr, sheet::DataPilotFieldGroupBy::YEARS, pFormatter);
316 case sheet::DataPilotFieldGroupBy::QUARTERS: nStart = 1; nEnd = 4;
break;
317 case sheet::DataPilotFieldGroupBy::MONTHS: nStart = 1; nEnd = 12;
break;
318 case sheet::DataPilotFieldGroupBy::DAYS: nStart = 1; nEnd = 366;
break;
319 case sheet::DataPilotFieldGroupBy::HOURS: nStart = 0; nEnd = 23;
break;
320 case sheet::DataPilotFieldGroupBy::MINUTES: nStart = 0; nEnd = 59;
break;
321 case sheet::DataPilotFieldGroupBy::SECONDS: nStart = 0; nEnd = 59;
break;
323 OSL_FAIL(
"invalid date part");
342 if ( nSourceIndex < 0 )
356 for (
const auto& rGroup :
aGroups)
357 rGroup.AddToData(aDim);
381 rGI.ConvertElementsToItems(pFormatter);
403 aDateInfo( rDateInfo ),
446 double fSourceMin = 0.0;
447 double fSourceMax = 0.0;
456 double fValue = rItem.GetValue();
459 fSourceMin = fSourceMax = fValue;
464 if (fValue < fSourceMin)
466 if (fValue > fSourceMax)
481 fSourceMin = rtl::math::approxFloor(fSourceMin);
482 fSourceMax = rtl::math::approxFloor(fSourceMax) + 1;
503 bool bFirstGroup =
true;
538struct ScDPSaveGroupDimNameFunc
541 explicit ScDPSaveGroupDimNameFunc( OUString aDimName ) : maDimName(
std::move( aDimName )) {}
545struct ScDPSaveGroupSourceNameFunc
547 OUString maSrcDimName;
548 explicit ScDPSaveGroupSourceNameFunc( OUString aSrcDimName ) : maSrcDimName(
std::move( aSrcDimName )) {}
566 "ScDPDimensionSaveData::AddGroupDimension - group dimension exists already" );
573 ScDPSaveGroupDimVec::iterator aIt = ::std::find_if(
583 ScDPSaveGroupDimVec::iterator aIt = ::std::find_if(
592 "ScDPDimensionSaveData::AddNumGroupDimension - numeric group dimension exists already" );
603 aIt->second = rGroupDim;
617 rGroupDim.AddToData( rData );
620 rEntry.second.AddToData( rData );
626 rEntry.AddToCache(rCache);
628 rEntry.second.AddToCache(rCache);
664 ScDPSaveGroupDimVec::iterator aIt = ::std::find_if(
666 return (aIt ==
maGroupDims.end()) ? nullptr : &*aIt;
671 ScDPSaveGroupDimVec::iterator aIt = ::std::find_if(
673 return (aIt ==
maGroupDims.end()) ? nullptr : &*aIt;
679 ScDPSaveGroupDimVec::iterator aIt = ::std::find_if(
683 aIt = ::std::find_if( aIt + 1,
maGroupDims.end(), ScDPSaveGroupSourceNameFunc( aIt->GetSourceDimName() ) );
684 return (aIt ==
maGroupDims.end()) ? nullptr : &*aIt;
689 ScDPSaveNumGroupDimMap::iterator aIt =
maNumGroupDims.find( rGroupDimName );
700 sal_Int32 nParts = 0;
703 nParts |= pNumDim->GetDatePart();
706 nParts |= pGroupDim->GetDatePart();
712 const OUString& rSourceName,
const ScDPObject& rObject,
bool bAllowSource,
713 const std::vector<OUString>* pDeletedNames )
718 bool bUseSource = bAllowSource;
721 const sal_Int32 nMaxAdd = 1000;
722 while ( nAdd <= nMaxAdd )
724 OUString aDimName( rSourceName );
726 aDimName += OUString::number(nAdd);
731 return rDim.GetGroupDimName() == aDimName;
737 if ( pDeletedNames &&
738 std::find( pDeletedNames->begin(), pDeletedNames->end(), aDimName ) != pDeletedNames->end() )
754 OSL_FAIL(
"CreateGroupDimName: no valid name found");
762 STR_DPFIELD_GROUP_BY_SECONDS,
763 STR_DPFIELD_GROUP_BY_MINUTES,
764 STR_DPFIELD_GROUP_BY_HOURS,
765 STR_DPFIELD_GROUP_BY_DAYS,
766 STR_DPFIELD_GROUP_BY_MONTHS,
767 STR_DPFIELD_GROUP_BY_QUARTERS,
768 STR_DPFIELD_GROUP_BY_YEARS
773 sal_Int32 nDatePart,
const ScDPObject& rObject,
bool bAllowSource,
774 const std::vector<OUString>* pDeletedNames )
776 using namespace css::sheet::DataPilotFieldGroupBy;
780 case SECONDS: aPartName =
ScResId(aDatePartIds[0]);
break;
781 case MINUTES: aPartName =
ScResId(aDatePartIds[1]);
break;
782 case HOURS: aPartName =
ScResId(aDatePartIds[2]);
break;
783 case DAYS: aPartName =
ScResId(aDatePartIds[3]);
break;
784 case MONTHS: aPartName =
ScResId(aDatePartIds[4]);
break;
785 case QUARTERS: aPartName =
ScResId(aDatePartIds[5]);
break;
786 case YEARS: aPartName =
ScResId(aDatePartIds[6]);
break;
788 OSL_ENSURE(!aPartName.isEmpty(),
"ScDPDimensionSaveData::CreateDateGroupDimName - invalid date part");
This class represents the cached data part of the datapilot cache table implementation.
void ResetGroupItems(tools::Long nDim, const ScDPNumGroupInfo &rNumInfo, sal_Int32 nGroupType)
ScDocument & GetDoc() const
SCROW SetGroupItem(tools::Long nDim, const ScDPItemData &rData)
tools::Long AppendGroupField()
const ScDPItemDataVec & GetDimMemberValues(SCCOL nDim) const
std::vector< ScDPItemData > ScDPItemDataVec
SCCOL GetDimensionIndex(std::u16string_view sName) const
This class has to do with handling exclusively grouped dimensions? TODO: Find out what this class doe...
void WriteToCache(ScDPCache &rCache) const
const ScDPSaveGroupDimension * GetNamedGroupDim(const OUString &rGroupDimName) const
bool HasGroupDimensions() const
OUString CreateGroupDimName(const OUString &rSourceName, const ScDPObject &rObject, bool bAllowSource, const ::std::vector< OUString > *pDeletedNames)
void ReplaceNumGroupDimension(const ScDPSaveNumGroupDimension &rGroupDim)
void WriteToData(ScDPGroupTableData &rData) const
sal_Int32 CollectDateParts(const OUString &rBaseDimName) const
void ReplaceGroupDimension(const ScDPSaveGroupDimension &rGroupDim)
const ScDPSaveGroupDimension * GetFirstNamedGroupDim(const OUString &rBaseDimName) const
const ScDPSaveGroupDimension * GetGroupDimForBase(const OUString &rBaseDimName) const
void AddNumGroupDimension(const ScDPSaveNumGroupDimension &rGroupDim)
void RemoveNumGroupDimension(const OUString &rGroupDimName)
const ScDPSaveNumGroupDimension * GetNumGroupDim(const OUString &rGroupDimName) const
OUString CreateDateGroupDimName(sal_Int32 nDatePart, const ScDPObject &rObject, bool bAllowSource, const ::std::vector< OUString > *pDeletedNames)
void AddGroupDimension(const ScDPSaveGroupDimension &rGroupDim)
ScDPSaveNumGroupDimension * GetNumGroupDimAcc(const OUString &rGroupDimName)
ScDPSaveGroupDimension * GetFirstNamedGroupDimAcc(const OUString &rBaseDimName)
ScDPSaveGroupDimVec maGroupDims
ScDPSaveGroupDimension * GetGroupDimAccForBase(const OUString &rBaseDimName)
ScDPSaveGroupDimension * GetNamedGroupDimAcc(const OUString &rGroupDimName)
const ScDPSaveGroupDimension * GetNextNamedGroupDim(const OUString &rGroupDimName) const
bool operator==(const ScDPDimensionSaveData &r) const
ScDPSaveNumGroupDimMap maNumGroupDims
void RemoveGroupDimension(const OUString &rGroupDimName)
ScDPSaveGroupDimension * GetNextNamedGroupDimAcc(const OUString &rGroupDimName)
void AddItem(const ScDPGroupItem &rItem)
void AddElement(const ScDPItemData &rName)
sal_Int32 GetDimensionIndex(std::u16string_view rName)
void SetNumGroupDimension(sal_Int32 nIndex, const ScDPNumGroupDimension &rGroup)
void AddGroupDimension(const ScDPGroupDimension &rGroup)
When assigning a string value, you can also assign an interned string whose life-cycle is managed by ...
void SetRangeStart(double fVal)
static const sal_Int32 DateFirst
static const sal_Int32 DateLast
bool IsDimNameInUse(std::u16string_view rName) const
Represents a new group dimension whose dimension ID is higher than the highest source dimension ID.
bool IsInGroup(const ScDPItemData &rItem) const
void AddToCache(ScDPCache &rCache) const
ScDPSaveGroupItem * GetNamedGroupAcc(const OUString &rGroupName)
OUString aSourceDim
always the real source from the original data
void Rename(const OUString &rNewName)
void AddGroupItem(const ScDPSaveGroupItem &rItem)
void RemoveFromGroups(const OUString &rItemName)
const OUString & GetSourceDimName() const
const OUString & GetGroupDimName() const
void RemoveGroup(const OUString &rGroupName)
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
ScDPNumGroupInfo aDateInfo
const ScDPSaveGroupItem * GetNamedGroup(const OUString &rGroupName) const
OUString CreateGroupName(std::u16string_view rPrefix)
ScDPSaveGroupDimension(OUString aSource, OUString aName)
bool HasOnlyHidden(const ScDPUniqueStringSet &rVisible)
void AddToData(ScDPGroupTableData &rData) const
tools::Long GetGroupCount() const
ScDPSaveGroupItemVec aGroups
const ScDPSaveGroupItem & GetGroupByIndex(tools::Long nIndex) const
Classes to save Data Pilot settings that create new dimensions (fields).
void Rename(const OUString &rNewName)
ScDPSaveGroupItem(OUString aName)
void AddElementsFromGroup(const ScDPSaveGroupItem &rGroup)
void AddToData(ScDPGroupDimension &rDataDim) const
size_t GetElementCount() const
void RemoveElementsFromGroups(ScDPSaveGroupDimension &rDimension) const
remove this group's elements from their groups in rDimension (rDimension must be a different dimensio...
OUString aGroupName
name of group
void AddElement(const OUString &rName)
bool HasInGroup(const ScDPItemData &rItem) const
void ConvertElementsToItems(SvNumberFormatter *pFormatter) const
bool RemoveElement(const OUString &rName)
const OUString * GetElementByIndex(size_t nIndex) const
std::vector< ScDPItemData > maItems
items converted from the strings.
std::vector< OUString > aElements
names of items in original dimension
Represents a group dimension that introduces a new hierarchy for an existing dimension.
const OUString & GetDimensionName() const
ScDPNumGroupInfo aGroupInfo
void SetDateInfo(const ScDPNumGroupInfo &rInfo, sal_Int32 nPart)
void AddToCache(ScDPCache &rCache) const
ScDPSaveNumGroupDimension(OUString aName, const ScDPNumGroupInfo &rInfo)
void AddToData(ScDPGroupTableData &rData) const
ScDPNumGroupInfo aDateInfo
void SetGroupInfo(const ScDPNumGroupInfo &rNew)
static sal_Int32 getDatePartValue(double fValue, const ScDPNumGroupInfo *pInfo, sal_Int32 nDatePart, const SvNumberFormatter *pFormatter)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
std::unordered_set< OUString > ScDPUniqueStringSet
constexpr OUStringLiteral aData
OUString ScResId(TranslateId aId)