summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-03 11:33:04 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-03 12:19:37 +0200
commit19d71217aba8700dac913c278767d6e387ce65a1 (patch)
tree453a8d52527921cef76d2db6e68c6828d00888aa /sc/source/ui/dbgui
parente748cf70977bbdd2d869bdeab1921ee68238dca4 (diff)
pivot: Apply changes made in "Data Field" and "Data Field Options"
Change-Id: If8560d47c5b4e64367c441237c1e38f964cf6825
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/PivotLayoutDialog.cxx117
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeList.cxx41
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx18
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListData.cxx28
-rw-r--r--sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx2
5 files changed, 143 insertions, 63 deletions
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index 48b4874a79c7..4acc7585c74f 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -16,8 +16,12 @@
#include "rangeutl.hxx"
#include "uiitems.hxx"
+#include "dputil.hxx"
+
+#include <vector>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
using namespace css::uno;
using namespace css::sheet;
@@ -156,6 +160,7 @@ ScPivotLayoutDialog::ScPivotLayoutDialog(
FillValuesToListBoxes();
+ // Initialize Options
const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
if (pSaveData == NULL)
{
@@ -446,65 +451,108 @@ void ScPivotLayoutDialog::UpdateSourceRange()
bool ScPivotLayoutDialog::ApplyChanges()
{
ScDPSaveData aSaveData;
- aSaveData.SetIgnoreEmptyRows(mpCheckIgnoreEmptyRows->IsChecked());
- aSaveData.SetRepeatIfEmpty(mpCheckIdentifyCategories->IsChecked());
- aSaveData.SetColumnGrand(mpCheckTotalColumns->IsChecked());
- aSaveData.SetRowGrand(mpCheckTotalRows->IsChecked());
- aSaveData.SetFilterButton(mpCheckAddFilter->IsChecked());
- aSaveData.SetDrillDown(mpCheckDrillToDetail->IsChecked());
+ ApplySaveData(aSaveData);
+ ApplyLabelData(aSaveData);
+
+ ScRange aDestinationRange;
+ bool bToNewSheet = false;
+
+ if (!GetDestination(aDestinationRange, bToNewSheet))
+ return false;
+
+ SetDispatcherLock(false);
+ SwitchToDocument();
+
+ sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich(SID_PIVOT_TABLE);
+ ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet);
+ mpViewData->GetViewShell()->SetDialogDPObject(&maPivotTableObject);
+
+ SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
+ SfxCallMode nCallMode = SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD;
+ const SfxPoolItem* pResult = pDispatcher->Execute(SID_PIVOT_TABLE, nCallMode, &aPivotItem, NULL, 0);
+
+ if (pResult != NULL)
+ {
+ const SfxBoolItem* pItem = reinterpret_cast<const SfxBoolItem*>(pResult);
+ if (pItem)
+ {
+ return pItem->GetValue();
+ }
+ }
+
+ SetDispatcherLock(true);
+ return true;
+}
+
+void ScPivotLayoutDialog::ApplySaveData(ScDPSaveData& rSaveData)
+{
+ rSaveData.SetIgnoreEmptyRows(mpCheckIgnoreEmptyRows->IsChecked());
+ rSaveData.SetRepeatIfEmpty(mpCheckIdentifyCategories->IsChecked());
+ rSaveData.SetColumnGrand(mpCheckTotalColumns->IsChecked());
+ rSaveData.SetRowGrand(mpCheckTotalRows->IsChecked());
+ rSaveData.SetFilterButton(mpCheckAddFilter->IsChecked());
+ rSaveData.SetDrillDown(mpCheckDrillToDetail->IsChecked());
Reference<XDimensionsSupplier> xSource = maPivotTableObject.GetSource();
ScPivotFieldVector aPageFieldVector;
mpListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
- ScDPObject::ConvertOrientation(aSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
+ ScDPObject::ConvertOrientation(rSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aColFieldVector;
mpListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
- ScDPObject::ConvertOrientation(aSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
+ ScDPObject::ConvertOrientation(rSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aRowFieldVector;
mpListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
- ScDPObject::ConvertOrientation(aSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
+ ScDPObject::ConvertOrientation(rSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
xSource, maPivotParameters.maLabelArray);
ScPivotFieldVector aDataFieldVector;
mpListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
- ScDPObject::ConvertOrientation(aSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
+ ScDPObject::ConvertOrientation(rSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
xSource, maPivotParameters.maLabelArray,
&aColFieldVector, &aRowFieldVector, &aPageFieldVector);
+}
+void ScPivotLayoutDialog::ApplyLabelData(ScDPSaveData& rSaveData)
+{
+ ScDPLabelDataVector::const_iterator it;
+ ScDPLabelDataVector& rLabelDataVector = GetLabelDataVector();
- ScRange aDestinationRange;
- bool bToNewSheet = false;
+ for (it = rLabelDataVector.begin(); it != rLabelDataVector.end(); ++it)
+ {
+ const ScDPLabelData& pLabelData = *it;
- if (!GetDestination(aDestinationRange, bToNewSheet))
- return false;
+ OUString aUnoName = ScDPUtil::createDuplicateDimensionName(pLabelData.maName, pLabelData.mnDupCount);
+ ScDPSaveDimension* pSaveDimensions = rSaveData.GetExistingDimensionByName(aUnoName);
- SetDispatcherLock(false);
- SwitchToDocument();
+ if (pSaveDimensions == NULL)
+ continue;
- sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich(SID_PIVOT_TABLE);
- ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet);
- mpViewData->GetViewShell()->SetDialogDPObject(new ScDPObject(maPivotTableObject));
+ pSaveDimensions->SetUsedHierarchy(pLabelData.mnUsedHier);
+ pSaveDimensions->SetShowEmpty(pLabelData.mbShowAll);
+ pSaveDimensions->SetSortInfo(&pLabelData.maSortInfo);
+ pSaveDimensions->SetLayoutInfo(&pLabelData.maLayoutInfo);
+ pSaveDimensions->SetAutoShowInfo(&pLabelData.maShowInfo);
- SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
- SfxCallMode nCallMode = SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD;
- const SfxPoolItem* pResult = pDispatcher->Execute(SID_PIVOT_TABLE, nCallMode, &aPivotItem, NULL, 0);
+ bool bManualSort = (pLabelData.maSortInfo.Mode == DataPilotFieldSortMode::MANUAL);
- if (pResult != NULL)
- {
- const SfxBoolItem* pItem = reinterpret_cast<const SfxBoolItem*>(pResult);
- if (pItem)
+ std::vector<ScDPLabelData::Member>::const_iterator itMember;
+ for (itMember = pLabelData.maMembers.begin(); itMember != pLabelData.maMembers.end(); ++itMember)
{
- return pItem->GetValue();
+ const ScDPLabelData::Member& rLabelMember = *itMember;
+ ScDPSaveMember* pMember = pSaveDimensions->GetMemberByName(rLabelMember.maName);
+
+ if (bManualSort || !rLabelMember.mbVisible || !rLabelMember.mbShowDetails)
+ {
+ pMember->SetIsVisible(rLabelMember.mbVisible);
+ pMember->SetShowDetails(rLabelMember.mbShowDetails);
+ }
}
}
-
- SetDispatcherLock(true);
- return true;
}
bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNewSheet)
@@ -537,9 +585,9 @@ ScItemValue* ScPivotLayoutDialog::GetItem(SCCOL nColumn)
return mpListBoxField->GetItem(nColumn);
}
-bool ScPivotLayoutDialog::IsDataItem(SCCOL nColumn)
+bool ScPivotLayoutDialog::IsDataElement(SCCOL nColumn)
{
- return mpListBoxField->IsDataItem(nColumn);
+ return mpListBoxField->IsDataElement(nColumn);
}
ScDPLabelData* ScPivotLayoutDialog::GetLabelData(SCCOL nColumn)
@@ -552,6 +600,11 @@ ScDPLabelDataVector& ScPivotLayoutDialog::GetLabelDataVector()
return maPivotParameters.maLabelArray;
}
+void ScPivotLayoutDialog::PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames)
+{
+ return mpListBoxData->PushDataFieldNames(rDataFieldNames);
+}
+
IMPL_LINK( ScPivotLayoutDialog, OkClicked, PushButton*, /*pButton*/ )
{
if (ApplyChanges())
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
index 9eae737eeffd..bdfae545a399 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
@@ -36,11 +36,35 @@ void ScPivotLayoutTreeList::Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListT
meType = eType;
}
+OUString lclFunctName(const sal_uInt16 nFunctionMask)
+{
+ switch (nFunctionMask)
+ {
+ case PIVOT_FUNC_SUM: return OUString("Sum");
+ case PIVOT_FUNC_COUNT: return OUString("Count");
+ case PIVOT_FUNC_AVERAGE: return OUString("Mean");
+ case PIVOT_FUNC_MAX: return OUString("Max");
+ case PIVOT_FUNC_MIN: return OUString("Min");
+ case PIVOT_FUNC_PRODUCT: return OUString("Product");
+ case PIVOT_FUNC_COUNT_NUM: return OUString("Count");
+ case PIVOT_FUNC_STD_DEV: return OUString("StDev");
+ case PIVOT_FUNC_STD_DEVP: return OUString("StDevP");
+ case PIVOT_FUNC_STD_VAR: return OUString("Var");
+ case PIVOT_FUNC_STD_VARP: return OUString("VarP");
+ default:
+ break;
+ }
+ return OUString();
+}
+
bool ScPivotLayoutTreeList::DoubleClickHdl()
{
ScItemValue* pCurrentItemValue = (ScItemValue*) GetCurEntry()->GetUserData();
ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData;
+ if (mpParent->IsDataElement(rCurrentFunctionData.mnCol))
+ return false;
+
SCCOL nCurrentColumn = rCurrentFunctionData.mnCol;
ScDPLabelData* pCurrentLabelData = mpParent->GetLabelData(nCurrentColumn);
if (!pCurrentLabelData)
@@ -49,18 +73,7 @@ bool ScPivotLayoutTreeList::DoubleClickHdl()
ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
vector<ScDPName> aDataFieldNames;
- SvTreeListEntry* pLoopEntry;
- for (pLoopEntry = First(); pLoopEntry != NULL; pLoopEntry = Next(pLoopEntry))
- {
- ScItemValue* pEachItemValue = (ScItemValue*) pLoopEntry->GetUserData();
- SCCOL nColumn = pEachItemValue->maFunctionData.mnCol;
-
- ScDPLabelData* pDFData = mpParent->GetLabelData(nColumn);
- if (pDFData == NULL && pDFData->maName.isEmpty())
- continue;
-
- aDataFieldNames.push_back(ScDPName(pDFData->maName, pDFData->maLayoutName, pDFData->mnDupCount));
- }
+ mpParent->PushDataFieldNames(aDataFieldNames);
boost::scoped_ptr<AbstractScDPSubtotalDlg> pDialog(
pFactory->CreateScDPSubtotalDlg(this, mpParent->maPivotTableObject, *pCurrentLabelData, rCurrentFunctionData, aDataFieldNames, true));
@@ -68,7 +81,7 @@ bool ScPivotLayoutTreeList::DoubleClickHdl()
if (pDialog->Execute() == RET_OK)
{
pDialog->FillLabelData(*pCurrentLabelData);
- rCurrentFunctionData.mnFuncMask = pCurrentLabelData->mnFuncMask;
+ rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
}
return true;
@@ -93,7 +106,7 @@ void ScPivotLayoutTreeList::InsertEntryForSourceTarget(SvTreeListEntry* pSource,
ScItemValue* pOriginalItemValue = pItemValue->mpOriginalItemValue;
// Don't allow to add "Data" element to page fields
- if(meType == PAGE_LIST && mpParent->IsDataItem(pItemValue->maFunctionData.mnCol))
+ if(meType == PAGE_LIST && mpParent->IsDataElement(pItemValue->maFunctionData.mnCol))
return;
mpParent->ItemInserted(pOriginalItemValue, meType);
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index ee5b44a5dd7c..5e1f320296e9 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -86,23 +86,11 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
ScPivotField aField;
-
aField.nCol = rFunctionData.mnCol;
aField.mnOriginalDim = rFunctionData.mnOriginalDim;
-
- if (rFunctionData.mnFuncMask == PIVOT_FUNC_NONE ||
- rFunctionData.mnFuncMask == PIVOT_FUNC_AUTO)
- {
- aField.nFuncMask = PIVOT_FUNC_SUM;
- }
- else
- {
- aField.nFuncMask = rFunctionData.mnFuncMask;
- }
-
- aField.mnDupCount = rFunctionData.mnDupCount;
- aField.maFieldRef = rFunctionData.maFieldRef;
-
+ aField.nFuncMask = rFunctionData.mnFuncMask;
+ aField.mnDupCount = rFunctionData.mnDupCount;
+ aField.maFieldRef = rFunctionData.maFieldRef;
rVector.push_back(aField);
}
}
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
index 8ef80b0c0199..012781ad78d2 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -144,11 +144,37 @@ void ScPivotLayoutTreeListData::FillDataField(ScPivotFieldVector& rDataFields)
}
}
+void ScPivotLayoutTreeListData::PushDataFieldNames(vector<ScDPName>& rDataFieldNames)
+{
+ SvTreeListEntry* pLoopEntry;
+ for (pLoopEntry = First(); pLoopEntry != NULL; pLoopEntry = Next(pLoopEntry))
+ {
+ ScItemValue* pEachItemValue = (ScItemValue*) pLoopEntry->GetUserData();
+ SCCOL nColumn = pEachItemValue->maFunctionData.mnCol;
+
+ ScDPLabelData* pLabelData = mpParent->GetLabelData(nColumn);
+
+ if (pLabelData == NULL && pLabelData->maName.isEmpty())
+ continue;
+
+ OUString sLayoutName = pLabelData->maLayoutName;
+ if (sLayoutName.isEmpty())
+ {
+ sLayoutName = lclCreateDataItemName(
+ pEachItemValue->maFunctionData.mnFuncMask,
+ pEachItemValue->maName,
+ pEachItemValue->maFunctionData.mnDupCount);
+ }
+
+ rDataFieldNames.push_back(ScDPName(pLabelData->maName, sLayoutName, pLabelData->mnDupCount));
+ }
+}
+
void ScPivotLayoutTreeListData::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget)
{
ScItemValue* pItemValue = (ScItemValue*) pSource->GetUserData();
- if(mpParent->IsDataItem(pItemValue->maFunctionData.mnCol))
+ if(mpParent->IsDataElement(pItemValue->maFunctionData.mnCol))
return;
if (HasEntry(pSource))
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
index 023f3ce56fb4..6617b0b03c4a 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx
@@ -61,7 +61,7 @@ void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(SvTreeListEntry* /*p
mpParent->mpPreviouslyFocusedListBox->RemoveSelection();
}
-bool ScPivotLayoutTreeListLabel::IsDataItem(SCCOL nColumn)
+bool ScPivotLayoutTreeListLabel::IsDataElement(SCCOL nColumn)
{
return (nColumn == PIVOT_DATA_FIELD || nColumn == maDataItem);
}