[Libreoffice-commits] core.git: sc/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Thu Apr 3 12:41:20 PDT 2014
sc/source/ui/dbgui/PivotLayoutTreeListData.cxx | 57 ++++++++++++++++++++-----
sc/source/ui/inc/PivotLayoutTreeListData.hxx | 2
2 files changed, 48 insertions(+), 11 deletions(-)
New commits:
commit f9636d50e6543302f236164aeebadab2733e849b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu Apr 3 21:38:48 2014 +0200
pivot: duplicate data field handling
Change-Id: I3d367b8b638217f18143118df00324f21a0470f2
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
index 012781a..e8f4805 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -88,15 +88,15 @@ bool ScPivotLayoutTreeListData::DoubleClickHdl()
if (pDialog->Execute() == RET_OK)
{
- if (rCurrentFunctionData.mnFuncMask != pDialog->GetFuncMask())
- {
- rCurrentFunctionData.mnDupCount = rCurrentFunctionData.mnDupCount + 1;
- }
- rCurrentFunctionData.mnFuncMask = pCurrentLabelData->mnFuncMask = pDialog->GetFuncMask();
+ rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
+ pCurrentLabelData->mnFuncMask = pDialog->GetFuncMask();
+
rCurrentFunctionData.maFieldRef = pDialog->GetFieldRef();
ScDPLabelData* pDFData = mpParent->GetLabelData(rCurrentFunctionData.mnCol);
+ AdjustDuplicateCount(pCurrentItemValue);
+
OUString sDataItemName = lclCreateDataItemName(
rCurrentFunctionData.mnFuncMask,
pDFData->maName,
@@ -132,15 +132,15 @@ void ScPivotLayoutTreeListData::FillDataField(ScPivotFieldVector& rDataFields)
pItemValue->mpOriginalItemValue = pOriginalItemValue;
pItemValue->maFunctionData.mnOriginalDim = rField.mnOriginalDim;
- pItemValue->maFunctionData.mnDupCount = rField.mnDupCount;
pItemValue->maFunctionData.maFieldRef = rField.maFieldRef;
- maDataItemValues.push_back(pItemValue);
-
- OUString sDataItemName = lclCreateDataItemName(rField.nFuncMask, pItemValue->maName, rField.mnDupCount);
+ AdjustDuplicateCount(pItemValue);
+ OUString sDataItemName = lclCreateDataItemName(pItemValue->maFunctionData.mnFuncMask,
+ pItemValue->maName,
+ pItemValue->maFunctionData.mnDupCount);
- SvTreeListEntry* pEntry = InsertEntry(sDataItemName);
- pEntry->SetUserData(pItemValue);
+ maDataItemValues.push_back(pItemValue);
+ InsertEntry(sDataItemName, NULL, false, TREELIST_APPEND, pItemValue);
}
}
@@ -205,6 +205,8 @@ void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_
rFunctionData.mnFuncMask = PIVOT_FUNC_SUM;
}
+ AdjustDuplicateCount(pDataItemValue);
+
OUString sDataName = lclCreateDataItemName(
rFunctionData.mnFuncMask,
pDataItemValue->maName,
@@ -213,6 +215,39 @@ void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_
InsertEntry(sDataName, NULL, false, nPosition, pDataItemValue);
}
+void ScPivotLayoutTreeListData::AdjustDuplicateCount(ScItemValue* pInputItemValue)
+{
+ ScPivotFuncData& rInputFunctionData = pInputItemValue->maFunctionData;
+
+ bool bFoundDuplicate = false;
+
+ rInputFunctionData.mnDupCount = 0;
+ sal_uInt8 nMaxDuplicateCount = 0;
+
+ SvTreeListEntry* pEachEntry;
+ for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
+ {
+ ScItemValue* pItemValue = (ScItemValue*) pEachEntry->GetUserData();
+ if (pItemValue == pInputItemValue)
+ continue;
+
+ ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
+
+ if (rFunctionData.mnCol == rInputFunctionData.mnCol &&
+ rFunctionData.mnFuncMask == rInputFunctionData.mnFuncMask)
+ {
+ bFoundDuplicate = true;
+ if(rFunctionData.mnDupCount > nMaxDuplicateCount)
+ nMaxDuplicateCount = rFunctionData.mnDupCount;
+ }
+ }
+
+ if(bFoundDuplicate)
+ {
+ rInputFunctionData.mnDupCount = nMaxDuplicateCount + 1;
+ }
+}
+
void ScPivotLayoutTreeListData::KeyInput(const KeyEvent& rKeyEvent)
{
KeyCode aCode = rKeyEvent.GetKeyCode();
diff --git a/sc/source/ui/inc/PivotLayoutTreeListData.hxx b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
index d58b077..f7d9f5c 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListData.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
@@ -31,6 +31,8 @@ protected:
virtual void InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget) SAL_OVERRIDE;
virtual void InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition) SAL_OVERRIDE;
+ void AdjustDuplicateCount(ScItemValue* pInputItemValue);
+
virtual void KeyInput(const KeyEvent& rKeyEvent) SAL_OVERRIDE;
};
More information about the Libreoffice-commits
mailing list