pivot: duplicate data field handling
Change-Id: I3d367b8b638217f18143118df00324f21a0470f2
This commit is contained in:
@@ -88,15 +88,15 @@ bool ScPivotLayoutTreeListData::DoubleClickHdl()
|
|||||||
|
|
||||||
if (pDialog->Execute() == RET_OK)
|
if (pDialog->Execute() == RET_OK)
|
||||||
{
|
{
|
||||||
if (rCurrentFunctionData.mnFuncMask != pDialog->GetFuncMask())
|
rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
|
||||||
{
|
pCurrentLabelData->mnFuncMask = pDialog->GetFuncMask();
|
||||||
rCurrentFunctionData.mnDupCount = rCurrentFunctionData.mnDupCount + 1;
|
|
||||||
}
|
|
||||||
rCurrentFunctionData.mnFuncMask = pCurrentLabelData->mnFuncMask = pDialog->GetFuncMask();
|
|
||||||
rCurrentFunctionData.maFieldRef = pDialog->GetFieldRef();
|
rCurrentFunctionData.maFieldRef = pDialog->GetFieldRef();
|
||||||
|
|
||||||
ScDPLabelData* pDFData = mpParent->GetLabelData(rCurrentFunctionData.mnCol);
|
ScDPLabelData* pDFData = mpParent->GetLabelData(rCurrentFunctionData.mnCol);
|
||||||
|
|
||||||
|
AdjustDuplicateCount(pCurrentItemValue);
|
||||||
|
|
||||||
OUString sDataItemName = lclCreateDataItemName(
|
OUString sDataItemName = lclCreateDataItemName(
|
||||||
rCurrentFunctionData.mnFuncMask,
|
rCurrentFunctionData.mnFuncMask,
|
||||||
pDFData->maName,
|
pDFData->maName,
|
||||||
@@ -132,15 +132,15 @@ void ScPivotLayoutTreeListData::FillDataField(ScPivotFieldVector& rDataFields)
|
|||||||
|
|
||||||
pItemValue->mpOriginalItemValue = pOriginalItemValue;
|
pItemValue->mpOriginalItemValue = pOriginalItemValue;
|
||||||
pItemValue->maFunctionData.mnOriginalDim = rField.mnOriginalDim;
|
pItemValue->maFunctionData.mnOriginalDim = rField.mnOriginalDim;
|
||||||
pItemValue->maFunctionData.mnDupCount = rField.mnDupCount;
|
|
||||||
pItemValue->maFunctionData.maFieldRef = rField.maFieldRef;
|
pItemValue->maFunctionData.maFieldRef = rField.maFieldRef;
|
||||||
|
|
||||||
|
AdjustDuplicateCount(pItemValue);
|
||||||
|
OUString sDataItemName = lclCreateDataItemName(pItemValue->maFunctionData.mnFuncMask,
|
||||||
|
pItemValue->maName,
|
||||||
|
pItemValue->maFunctionData.mnDupCount);
|
||||||
|
|
||||||
maDataItemValues.push_back(pItemValue);
|
maDataItemValues.push_back(pItemValue);
|
||||||
|
InsertEntry(sDataItemName, NULL, false, TREELIST_APPEND, pItemValue);
|
||||||
OUString sDataItemName = lclCreateDataItemName(rField.nFuncMask, pItemValue->maName, rField.mnDupCount);
|
|
||||||
|
|
||||||
SvTreeListEntry* pEntry = InsertEntry(sDataItemName);
|
|
||||||
pEntry->SetUserData(pItemValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +205,8 @@ void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_
|
|||||||
rFunctionData.mnFuncMask = PIVOT_FUNC_SUM;
|
rFunctionData.mnFuncMask = PIVOT_FUNC_SUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdjustDuplicateCount(pDataItemValue);
|
||||||
|
|
||||||
OUString sDataName = lclCreateDataItemName(
|
OUString sDataName = lclCreateDataItemName(
|
||||||
rFunctionData.mnFuncMask,
|
rFunctionData.mnFuncMask,
|
||||||
pDataItemValue->maName,
|
pDataItemValue->maName,
|
||||||
@@ -213,6 +215,39 @@ void ScPivotLayoutTreeListData::InsertEntryForItem(ScItemValue* pItemValue, sal_
|
|||||||
InsertEntry(sDataName, NULL, false, nPosition, pDataItemValue);
|
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)
|
void ScPivotLayoutTreeListData::KeyInput(const KeyEvent& rKeyEvent)
|
||||||
{
|
{
|
||||||
KeyCode aCode = rKeyEvent.GetKeyCode();
|
KeyCode aCode = rKeyEvent.GetKeyCode();
|
||||||
|
@@ -31,6 +31,8 @@ protected:
|
|||||||
virtual void InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget) SAL_OVERRIDE;
|
virtual void InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget) SAL_OVERRIDE;
|
||||||
virtual void InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition) SAL_OVERRIDE;
|
virtual void InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition) SAL_OVERRIDE;
|
||||||
|
|
||||||
|
void AdjustDuplicateCount(ScItemValue* pInputItemValue);
|
||||||
|
|
||||||
virtual void KeyInput(const KeyEvent& rKeyEvent) SAL_OVERRIDE;
|
virtual void KeyInput(const KeyEvent& rKeyEvent) SAL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user