[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - 5 commits - extras/source sc/Library_sc.mk sc/source sc/uiconfig sc/UIConfig_scalc.mk

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Thu Apr 3 14:24:58 PDT 2014


 extras/source/glade/libreoffice-catalog.xml.in  |    9 
 sc/Library_sc.mk                                |    5 
 sc/UIConfig_scalc.mk                            |    1 
 sc/source/ui/dbgui/PivotLayoutDialog.cxx        |  702 ++++++++++++++++++++
 sc/source/ui/dbgui/PivotLayoutTreeList.cxx      |  138 ++++
 sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx  |  139 ++++
 sc/source/ui/dbgui/PivotLayoutTreeListData.cxx  |  265 +++++++
 sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx |   90 ++
 sc/source/ui/inc/PivotLayoutDialog.hxx          |  141 ++++
 sc/source/ui/inc/PivotLayoutTreeList.hxx        |   36 +
 sc/source/ui/inc/PivotLayoutTreeListBase.hxx    |   76 ++
 sc/source/ui/inc/PivotLayoutTreeListData.hxx    |   41 +
 sc/source/ui/inc/PivotLayoutTreeListLabel.hxx   |   37 +
 sc/source/ui/view/tabvwshc.cxx                  |   12 
 sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui  |  816 ++++++++++++++++++++++++
 15 files changed, 2501 insertions(+), 7 deletions(-)

New commits:
commit ce5203c4d6bc6afc4e53b45ced7a3fab0479bb41
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 a3fd4a1..2d53653 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -88,15 +88,15 @@ sal_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, sal_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 35fdd8c..00ddee0 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;
 };
 
commit ca3eedb240feae6fe48b9b10e80ccb0bc369a9c2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Thu Apr 3 11:33:04 2014 +0200

    pivot: Apply changes made in "Data Field" and "Data Field Options"
    
    Conflicts:
    	sc/source/ui/dbgui/PivotLayoutDialog.cxx
    	sc/source/ui/dbgui/PivotLayoutTreeList.cxx
    
    Change-Id: If8560d47c5b4e64367c441237c1e38f964cf6825

diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index 7ba35e3..759a936 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -19,8 +19,12 @@
 #include "uiitems.hxx"
 #include "tabvwsh.hxx"
 #include <sfx2/dispatch.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;
@@ -174,6 +178,7 @@ ScPivotLayoutDialog::ScPivotLayoutDialog(
 
     FillValuesToListBoxes();
 
+    // Initialize Options
     const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
     if (pSaveData == NULL)
     {
@@ -467,65 +472,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)
@@ -558,9 +606,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)
@@ -573,6 +621,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 3551365..059d217 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();
+}
+
 sal_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 @@ sal_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, RID_SCDLG_PIVOTSUBT, mpParent->maPivotTableObject, *pCurrentLabelData, rCurrentFunctionData, aDataFieldNames, true));
@@ -68,7 +81,7 @@ sal_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 2c79cbc..f4201dc 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 281a14f..a3fd4a1 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 023f3ce..6617b0b 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);
 }
diff --git a/sc/source/ui/inc/PivotLayoutDialog.hxx b/sc/source/ui/inc/PivotLayoutDialog.hxx
index 8bf4757..f27c47a 100644
--- a/sc/source/ui/inc/PivotLayoutDialog.hxx
+++ b/sc/source/ui/inc/PivotLayoutDialog.hxx
@@ -124,12 +124,15 @@ public:
     void UpdateSourceRange();
 
     bool ApplyChanges();
+    void ApplySaveData(ScDPSaveData& rSaveData);
+    void ApplyLabelData(ScDPSaveData& rSaveData);
 
     ScItemValue* GetItem(SCCOL nColumn);
-    bool IsDataItem(SCCOL nColumn);
+    bool IsDataElement(SCCOL nColumn);
 
     ScDPLabelData* GetLabelData(SCCOL nColumn);
     ScDPLabelDataVector& GetLabelDataVector();
+    void PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames);
 };
 
 
diff --git a/sc/source/ui/inc/PivotLayoutTreeListData.hxx b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
index d5b1f6e..35fdd8c 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListData.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
@@ -25,6 +25,8 @@ public:
     virtual sal_Bool DoubleClickHdl() SAL_OVERRIDE;
 
     void FillDataField(ScPivotFieldVector& rDataFields);
+    void PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames);
+
 protected:
     virtual void InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget) SAL_OVERRIDE;
     virtual void InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition) SAL_OVERRIDE;
diff --git a/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
index 7eb8f52..656fb49 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
@@ -25,7 +25,7 @@ public:
     virtual ~ScPivotLayoutTreeListLabel();
     void FillLabelFields(ScDPLabelDataVector& rLabelVector);
     ScItemValue* GetItem(SCCOL nColumn);
-    bool IsDataItem(SCCOL nColumn);
+    bool IsDataElement(SCCOL nColumn);
 
 protected:
     virtual void InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget) SAL_OVERRIDE;
commit 3211d557c8a5f2aee2739a3f728693300d999dee
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Apr 2 19:37:46 2014 +0200

    Pivot dialog: Make it resemble the old dialog a bit.
    
    No idea what is best here :-) - MSO is more like what it was before this
    change, OTOH this layout looks more as the final pivot table, which (in my
    eyes) makes it easier to use.
    
    Conflicts:
    	sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui
    
    Change-Id: I5acb8c151139688c71b06d07006499513a17bdb9

diff --git a/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui b/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui
index e1a7b9e..90b62d6 100644
--- a/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui
+++ b/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
 <interface>
-  <requires lib="gtk+" version="3.0"/>
+  <!-- interface-requires gtk+ 3.0 -->
   <!-- interface-requires LibreOffice 1.0 -->
   <object class="GtkDialog" id="PivotTableLayout">
     <property name="can_focus">False</property>
@@ -68,281 +67,452 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid1">
+          <object class="GtkBox" id="box1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
-            <property name="row_spacing">6</property>
-            <property name="column_spacing">12</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
             <child>
-              <object class="GtkLabel" id="label1">
+              <object class="GtkBox" id="box2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="xpad">4</property>
-                <property name="label" translatable="yes">Available Fields:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">listbox-fields</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="shadow_type">in</property>
+                <property name="border_width">6</property>
+                <property name="spacing">6</property>
                 <child>
-                  <object class="scuilo-ScPivotLayoutTreeList" id="listbox-column">
-                    <property name="width_request">200</property>
-                    <property name="height_request">100</property>
+                  <object class="GtkGrid" id="grid7">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
+                    <property name="can_focus">False</property>
                     <property name="hexpand">True</property>
                     <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Pivot Table List-selection6"/>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkBox" id="box4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
+                            <property name="xpad">4</property>
+                            <property name="label" translatable="yes">Column Fields:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">listbox-column</property>
+                            <attributes>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="scuilo-ScPivotLayoutTreeList" id="listbox-column">
+                            <property name="width_request">200</property>
+                            <property name="height_request">100</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="Pivot Table List-selection"/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
                     </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow3">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="scuilo-ScPivotLayoutTreeListData" id="listbox-data">
-                    <property name="width_request">200</property>
-                    <property name="height_request">100</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Tree List-selection4"/>
+                    <child>
+                      <object class="GtkBox" id="box5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label5">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
+                            <property name="xpad">4</property>
+                            <property name="label" translatable="yes">Data Fields:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">listbox-data</property>
+                            <attributes>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="scuilo-ScPivotLayoutTreeListData" id="listbox-data">
+                            <property name="width_request">240</property>
+                            <property name="height_request">120</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="Pivot Table Data List-selection"/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
                     </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow4">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="scuilo-ScPivotLayoutTreeList" id="listbox-row">
-                    <property name="width_request">200</property>
-                    <property name="height_request">100</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Tree List-selection3"/>
+                    <child>
+                      <object class="GtkBox" id="box6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label4">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
+                            <property name="xpad">4</property>
+                            <property name="label" translatable="yes">Row Fields:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">listbox-row</property>
+                            <attributes>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="scuilo-ScPivotLayoutTreeList" id="listbox-row">
+                            <property name="width_request">180</property>
+                            <property name="height_request">100</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="vexpand">True</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="Pivot Table List-selection4"/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="box7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
+                            <property name="xpad">4</property>
+                            <property name="label" translatable="yes">Page Fields:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">listbox-page</property>
+                            <attributes>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="scuilo-ScPivotLayoutTreeList" id="listbox-page">
+                            <property name="width_request">200</property>
+                            <property name="height_request">100</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="Pivot Table List-selection5"/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">2</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
                     </child>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
                 </child>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="shadow_type">in</property>
                 <child>
-                  <object class="scuilo-ScPivotLayoutTreeList" id="listbox-page">
-                    <property name="width_request">200</property>
-                    <property name="height_request">100</property>
+                  <object class="GtkBox" id="box3">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hexpand">True</property>
+                    <property name="can_focus">False</property>
                     <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Tree List-selection1"/>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">4</property>
+                        <property name="label" translatable="yes">Available Fields:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">listbox-fields</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="scuilo-ScPivotLayoutTreeListLabel" id="listbox-fields">
+                        <property name="width_request">180</property>
+                        <property name="height_request">150</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="Pivot Table Label List-selection"/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">False</property>
-                <property name="vexpand">False</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="xpad">4</property>
-                <property name="label" translatable="yes">Page Fields:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">listbox-page</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">False</property>
-                <property name="vexpand">False</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="xpad">4</property>
-                <property name="label" translatable="yes">Column Fields:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">listbox-column</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label4">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">False</property>
-                <property name="vexpand">False</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="xpad">4</property>
-                <property name="label" translatable="yes">Row Fields:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">listbox-row</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label5">
+              <object class="GtkLabel" id="label6">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="hexpand">False</property>
-                <property name="vexpand">False</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="xpad">4</property>
-                <property name="label" translatable="yes">Data Fields:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">listbox-data</property>
+                <property name="hexpand">True</property>
+                <property name="label" translatable="yes">Drag the items into the desired position</property>
                 <attributes>
-                  <attribute name="weight" value="bold"/>
+                  <attribute name="underline" value="True"/>
                 </attributes>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow5">
+              <object class="GtkExpander" id="expander2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="shadow_type">in</property>
                 <child>
-                  <object class="scuilo-ScPivotLayoutTreeListLabel" id="listbox-fields">
-                    <property name="width_request">200</property>
-                    <property name="height_request">150</property>
+                  <object class="GtkGrid" id="grid5">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Pivot Table List-selection"/>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">12</property>
+                    <property name="border_width">12</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">12</property>
+                    <child>
+                      <object class="GtkCheckButton" id="check-ignore-empty-rows">
+                        <property name="label" translatable="yes">Ignore empty rows</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="check-identify-categories">
+                        <property name="label" translatable="yes">Identify categories</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="check-total-rows">
+                        <property name="label" translatable="yes">Total rows</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="check-total-columns">
+                        <property name="label" translatable="yes">Total columns</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="check-add-filter">
+                        <property name="label" translatable="yes">Add filter</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="check-drill-to-details">
+                        <property name="label" translatable="yes">Enable drill to details</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
                     </child>
                   </object>
                 </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label11">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Options</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label6">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">False</property>
-                <property name="vexpand">False</property>
-                <property name="label" translatable="yes">Drag the items into the desired position</property>
-                <attributes>
-                  <attribute name="underline" value="True"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child>
@@ -353,6 +523,7 @@
                   <object class="GtkGrid" id="grid2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="margin_left">12</property>
                     <property name="hexpand">True</property>
                     <property name="vexpand">True</property>
                     <property name="row_spacing">6</property>
@@ -385,7 +556,6 @@
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
                                     <property name="xalign">0</property>
-                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
                                     <property name="group">destination-radio-named-range</property>
                                   </object>
@@ -403,7 +573,6 @@
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
                                     <property name="xalign">0</property>
-                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
                                     <property name="group">destination-radio-new-sheet</property>
                                   </object>
@@ -419,6 +588,8 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="hexpand">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="invisible_char_set">True</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -431,7 +602,7 @@
                                   <object class="foruilo-RefButton" id="destination-button">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="receives_default">False</property>
+                                    <property name="receives_default">True</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">2</property>
@@ -459,7 +630,6 @@
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
                                     <property name="xalign">0</property>
-                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
                                     <property name="group">destination-radio-selection</property>
                                   </object>
@@ -535,6 +705,8 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="hexpand">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="invisible_char_set">True</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -547,7 +719,7 @@
                                   <object class="foruilo-RefButton" id="source-button">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="receives_default">False</property>
+                                    <property name="receives_default">True</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">2</property>
@@ -621,159 +793,9 @@
                 </child>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">6</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkFrame" id="frame3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkGrid" id="grid5">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="row_spacing">6</property>
-                        <property name="column_spacing">12</property>
-                        <child>
-                          <object class="GtkCheckButton" id="check-ignore-empty-rows">
-                            <property name="label" translatable="yes">Ignore empty rows</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="check-identify-categories">
-                            <property name="label" translatable="yes">Identify categories</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="check-total-rows">
-                            <property name="label" translatable="yes">Total rows</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">1</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="check-total-columns">
-                            <property name="label" translatable="yes">Total columns</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">1</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="check-add-filter">
-                            <property name="label" translatable="yes">Add filter</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">2</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkCheckButton" id="check-drill-to-details">
-                            <property name="label" translatable="yes">Enable drill to details</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">False</property>
-                            <property name="xalign">0</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">2</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label10">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Options</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">5</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
               </packing>
             </child>
           </object>
@@ -785,5 +807,10 @@
         </child>
       </object>
     </child>
+    <action-widgets>
+      <action-widget response="0">ok</action-widget>
+      <action-widget response="0">apply</action-widget>
+      <action-widget response="0">close</action-widget>
+    </action-widgets>
   </object>
 </interface>
commit 2606bf98493d455ba7e221dc2bdb5c9e8db33479
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Mar 31 10:10:25 2014 +0200

    pivot layout dialog: remove SAL_OVERRIDE from destructors
    
    Conflicts:
    	sc/source/ui/inc/PivotLayoutTreeList.hxx
    	sc/source/ui/inc/PivotLayoutTreeListData.hxx
    
    Change-Id: Icdb048a2ad9c49308213c3bb57f540e4ff567593

diff --git a/sc/source/ui/inc/PivotLayoutDialog.hxx b/sc/source/ui/inc/PivotLayoutDialog.hxx
index bd43c56..8bf4757 100644
--- a/sc/source/ui/inc/PivotLayoutDialog.hxx
+++ b/sc/source/ui/inc/PivotLayoutDialog.hxx
@@ -113,7 +113,7 @@ private:
 public:
     ScPivotLayoutDialog(SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, Window* pParent,
                              ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bCreateNewPivotTable);
-    virtual ~ScPivotLayoutDialog() SAL_OVERRIDE;
+    virtual ~ScPivotLayoutDialog();
 
     virtual void SetReference(const ScRange& rReferenceRange, ScDocument* pDocument) SAL_OVERRIDE;
     virtual void SetActive() SAL_OVERRIDE;
diff --git a/sc/source/ui/inc/PivotLayoutTreeList.hxx b/sc/source/ui/inc/PivotLayoutTreeList.hxx
index 55da8ff..12ce1cc 100644
--- a/sc/source/ui/inc/PivotLayoutTreeList.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeList.hxx
@@ -18,7 +18,7 @@ class ScPivotLayoutTreeList : public ScPivotLayoutTreeListBase
 {
 public:
     ScPivotLayoutTreeList(Window* pParent, WinBits nBits);
-    virtual ~ScPivotLayoutTreeList() SAL_OVERRIDE;
+    virtual ~ScPivotLayoutTreeList();
     virtual sal_Bool DoubleClickHdl() SAL_OVERRIDE;
 
     void Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListType eType);
diff --git a/sc/source/ui/inc/PivotLayoutTreeListBase.hxx b/sc/source/ui/inc/PivotLayoutTreeListBase.hxx
index c350736..4de9e42 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListBase.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListBase.hxx
@@ -44,7 +44,7 @@ public:
     void Setup(ScPivotLayoutDialog* pParent);
 
     ScPivotLayoutTreeListBase(Window* pParent, WinBits nBits, SvPivotTreeListType eType = UNDEFINED);
-    virtual ~ScPivotLayoutTreeListBase() SAL_OVERRIDE;
+    virtual ~ScPivotLayoutTreeListBase();
 
     virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvent) SAL_OVERRIDE;
     virtual sal_Bool NotifyAcceptDrop(SvTreeListEntry* pEntry) SAL_OVERRIDE;
diff --git a/sc/source/ui/inc/PivotLayoutTreeListData.hxx b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
index 1ddda60..d5b1f6e 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListData.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListData.hxx
@@ -21,7 +21,7 @@ private:
 
 public:
     ScPivotLayoutTreeListData(Window* pParent, WinBits nBits);
-    virtual ~ScPivotLayoutTreeListData() SAL_OVERRIDE;
+    virtual ~ScPivotLayoutTreeListData();
     virtual sal_Bool DoubleClickHdl() SAL_OVERRIDE;
 
     void FillDataField(ScPivotFieldVector& rDataFields);
diff --git a/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
index 6a13906..7eb8f52 100644
--- a/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
+++ b/sc/source/ui/inc/PivotLayoutTreeListLabel.hxx
@@ -22,7 +22,7 @@ private:
 
 public:
     ScPivotLayoutTreeListLabel(Window* pParent, WinBits nBits);
-    virtual ~ScPivotLayoutTreeListLabel() SAL_OVERRIDE;
+    virtual ~ScPivotLayoutTreeListLabel();
     void FillLabelFields(ScDPLabelDataVector& rLabelVector);
     ScItemValue* GetItem(SCCOL nColumn);
     bool IsDataItem(SCCOL nColumn);
commit 2af78e4feb4b3c9c8e7886ab888369c7ea26d4a4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Mar 30 21:12:27 2014 +0200

    pivot: new pivot table layout dialog
    
    This commit adds a new pivot table layout dialog which was implemented
    from scratch. Instead of custom controls this one uses list boxes
    for field entries which greatly reduces the code. It also fixes
    some visual and behaviour bugs and adds the possibility to edit the
    "Data" field.
    
    Conflicts:
    	sc/Library_sc.mk
    	sc/UIConfig_scalc.mk
    	sc/source/ui/view/tabvwshc.cxx
    
    Change-Id: I6c01252acee5a2e8910e40e65904504d00e03057

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index ecad897..2759d27 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -171,6 +171,15 @@
     <glade-widget-class title="Glossary Tree List" name="swuilo-SwGlTreeListBox"
                         generic-name="Glossary Tree List" parent="GtkTreeView"
                         icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table List" name="scuilo-ScPivotLayoutTreeList"
+                        generic-name="Pivot Table List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table Label List" name="scuilo-ScPivotLayoutTreeListLabel"
+                        generic-name="Pivot Table Label List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table Data List" name="scuilo-ScPivotLayoutTreeListData"
+                        generic-name="Pivot Table Data List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
     <glade-widget-class title="Dial Control" name="svxlo-DialControl"
                         generic-name="Dial Control" parent="GtkSpinner"
                         icon-name="widget-gtk-spinner"/>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index b14708e..c0ac2b3 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -366,6 +366,11 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/ui/dbgui/imoptdlg \
 	$(if $(filter TRUE,$(MPL_SUBSET)),, \
 	    sc/source/ui/dbgui/pvlaydlg) \
+	sc/source/ui/dbgui/PivotLayoutDialog \
+	sc/source/ui/dbgui/PivotLayoutTreeListBase \
+	sc/source/ui/dbgui/PivotLayoutTreeListData \
+	sc/source/ui/dbgui/PivotLayoutTreeListLabel \
+	sc/source/ui/dbgui/PivotLayoutTreeList \
 	sc/source/ui/dbgui/sfiltdlg \
 	sc/source/ui/docshell/arealink \
 	sc/source/ui/docshell/autostyl \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 1f77cdd..3d424d4 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -79,6 +79,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
 	sc/uiconfig/scalc/ui/leftheaderdialog \
 	sc/uiconfig/scalc/ui/managenamesdialog \
 	sc/uiconfig/scalc/ui/optcalculatepage \
+	sc/uiconfig/scalc/ui/pivottablelayoutdialog \
 	sc/uiconfig/scalc/ui/printeroptions \
 	sc/uiconfig/scalc/ui/protectsheetdlg \
 	sc/uiconfig/scalc/ui/sheetprintpage \
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
new file mode 100644
index 0000000..7ba35e3
--- /dev/null
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -0,0 +1,649 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ */
+
+#include "PivotLayoutTreeList.hxx"
+#include "PivotLayoutDialog.hxx"
+#include <reffact.hxx>
+#include <svtools/treelistentry.hxx>
+
+#include "sc.hrc"
+#include "rangeutl.hxx"
+#include "uiitems.hxx"
+#include "tabvwsh.hxx"
+#include <sfx2/dispatch.hxx>
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+
+using namespace css::uno;
+using namespace css::sheet;
+
+ScItemValue::ScItemValue(OUString aName, SCCOL nColumn, sal_uInt16 nFunctionMask) :
+    maName(aName),
+    maFunctionData(nColumn, nFunctionMask),
+    mpOriginalItemValue(this)
+{}
+
+ScItemValue::ScItemValue(ScItemValue* pInputItemValue) :
+    maName(pInputItemValue->maName),
+    maFunctionData(pInputItemValue->maFunctionData),
+    mpOriginalItemValue(this)
+{}
+
+ScItemValue::~ScItemValue()
+{}
+
+namespace
+{
+
+OUString lclGetNameForNamedRange(ScRange aRange, ScDocument* pDocument)
+{
+    OUString aName;
+
+    ScRangeName* pRangeName = pDocument->GetRangeName();
+    if (pRangeName == NULL)
+        return aName;
+
+    const ScRangeData* pData = pRangeName->findByRange(aRange);
+    if (pData == NULL)
+        return aName;
+
+    return pData->GetName();
+}
+
+ScRange lclGetRangeForNamedRange(OUString aName, ScDocument* pDocument)
+{
+    ScRange aInvalidRange(ScAddress::INITIALIZE_INVALID);
+    ScRangeName* pRangeName = pDocument->GetRangeName();
+    if (pRangeName == NULL)
+        return aInvalidRange;
+
+    const ScRangeData* pData = pRangeName->findByUpperName(aName.toAsciiUpperCase());
+    if (pData == NULL)
+        return aInvalidRange;
+
+    ScRange aRange;
+    if (pData->IsReference(aRange))
+        return aRange;
+
+    return aInvalidRange;
+}
+
+}
+
+ScPivotLayoutDialog::ScPivotLayoutDialog(
+                            SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, Window* pParent,
+                            ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bNewPivotTable) :
+    ScAnyRefDlg           (pSfxBindings, pChildWindow, pParent, "PivotTableLayout", "modules/scalc/ui/pivottablelayoutdialog.ui"),
+    maPivotTableObject    (*pPivotTableObject),
+    mpViewData            (pViewData),
+    mpDocument            (pViewData->GetDocument()),
+    mbNewPivotTable       (bNewPivotTable),
+    maAddressDetails      (mpDocument->GetAddressConvention(), 0, 0),
+    mbDialogLostFocus     (false)
+{
+    Link aLink;
+
+    get(mpListBoxField,    "listbox-fields");
+    get(mpListBoxPage,     "listbox-page");
+    get(mpListBoxColumn,   "listbox-column");
+    get(mpListBoxRow,      "listbox-row");
+    get(mpListBoxData,     "listbox-data");
+
+    get(mpCheckIgnoreEmptyRows,     "check-ignore-empty-rows");
+    get(mpCheckTotalColumns,        "check-total-columns");
+    get(mpCheckAddFilter,           "check-add-filter");
+    get(mpCheckIdentifyCategories,  "check-identify-categories");
+    get(mpCheckTotalRows,           "check-total-rows");
+    get(mpCheckDrillToDetail,       "check-drill-to-details");
+
+    get(mpButtonOk,     "ok");
+    get(mpButtonApply,  "apply");
+    get(mpButtonClose,  "close");
+
+    get(mpSourceRadioNamedRange, "source-radio-named-range");
+    get(mpSourceRadioSelection,  "source-radio-selection");
+    get(mpSourceListBox,         "source-list");
+    get(mpSourceEdit,            "source-edit");
+    get(mpSourceButton,          "source-button");
+
+    get(mpDestinationRadioNewSheet,   "destination-radio-new-sheet");
+    get(mpDestinationRadioNamedRange, "destination-radio-named-range");
+    get(mpDestinationRadioSelection,  "destination-radio-selection");
+    get(mpDestinationListBox,         "destination-list");
+    get(mpDestinationEdit,            "destination-edit");
+    get(mpDestinationButton,          "destination-button");
+
+    // Source UI
+    aLink = LINK(this, ScPivotLayoutDialog, ToggleSource);
+    mpSourceRadioNamedRange->SetToggleHdl(aLink);
+    mpSourceRadioSelection->SetToggleHdl(aLink);
+
+    mpSourceEdit->SetReferences(this, mpSourceRadioSelection);
+    mpSourceButton->SetReferences(this, mpSourceEdit);
+
+    aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
+    mpSourceEdit->SetGetFocusHdl(aLink);
+    mpSourceButton->SetGetFocusHdl(aLink);
+
+    aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
+    mpSourceEdit->SetLoseFocusHdl(aLink);
+    mpSourceButton->SetLoseFocusHdl(aLink);
+
+    mpSourceEdit->SetModifyHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
+    mpSourceListBox->SetSelectHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
+
+    // Destination UI
+    aLink = LINK(this, ScPivotLayoutDialog, ToggleDestination);
+    mpDestinationRadioNewSheet->SetToggleHdl(aLink);
+    mpDestinationRadioNamedRange->SetToggleHdl(aLink);
+    mpDestinationRadioSelection->SetToggleHdl(aLink);
+
+    mpDestinationEdit->SetReferences(this, mpDestinationRadioNewSheet);
+    mpDestinationButton->SetReferences(this, mpDestinationEdit);
+
+    aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
+    mpDestinationEdit->SetGetFocusHdl(aLink);
+    mpDestinationButton->SetGetFocusHdl(aLink);
+
+    aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
+    mpDestinationEdit->SetLoseFocusHdl(aLink);
+    mpDestinationButton->SetLoseFocusHdl(aLink);
+
+    // Buttons
+    mpButtonOk->SetClickHdl(   LINK(this, ScPivotLayoutDialog, OkClicked));
+    mpButtonClose->SetClickHdl(LINK(this, ScPivotLayoutDialog, CloseClicked));
+    mpButtonApply->SetClickHdl(LINK(this, ScPivotLayoutDialog, ApplyClicked));
+
+    // Initialize Data
+    maPivotTableObject.FillOldParam(maPivotParameters);
+    maPivotTableObject.FillLabelData(maPivotParameters);
+
+    mpListBoxField->Setup (this);
+    mpListBoxPage->Setup  (this, ScPivotLayoutTreeList::PAGE_LIST);
+    mpListBoxColumn->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST);
+    mpListBoxRow->Setup   (this, ScPivotLayoutTreeList::ROW_LIST);
+    mpListBoxData->Setup  (this);
+
+    FillValuesToListBoxes();
+
+    const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
+    if (pSaveData == NULL)
+    {
+        mpCheckAddFilter->Check(false);
+        mpCheckDrillToDetail->Check(false);
+    }
+    else
+    {
+        mpCheckAddFilter->Check(pSaveData->GetFilterButton());
+        mpCheckDrillToDetail->Check(pSaveData->GetDrillDown());
+    }
+
+    mpCheckIgnoreEmptyRows->Check(maPivotParameters.bIgnoreEmptyRows);
+    mpCheckIdentifyCategories->Check(maPivotParameters.bDetectCategories);
+    mpCheckTotalColumns->Check(maPivotParameters.bMakeTotalCol);
+    mpCheckTotalRows->Check(maPivotParameters.bMakeTotalRow);
+
+    SetupSource();
+    SetupDestination();
+}
+
+ScPivotLayoutDialog::~ScPivotLayoutDialog()
+{}
+
+void ScPivotLayoutDialog::SetupSource()
+{
+    mpSourceListBox->Clear();
+
+    ScRange aSourceRange;
+    OUString sSourceNamedRangeName;
+
+    if (maPivotTableObject.GetSheetDesc())
+    {
+        const ScSheetSourceDesc* pSheetSourceDesc = maPivotTableObject.GetSheetDesc();
+        aSourceRange = pSheetSourceDesc->GetSourceRange();
+
+        if(!aSourceRange.IsValid())
+        {
+            // Source is probably a DB Range
+            mpSourceRadioNamedRange->Disable();
+            mpSourceRadioSelection->Disable();
+            ToggleSource(NULL);
+            return;
+        }
+        else
+        {
+            OUString aSourceRangeName;
+            aSourceRange.Format(aSourceRangeName, SCR_ABS_3D, mpDocument, maAddressDetails);
+            mpSourceEdit->SetText(aSourceRangeName);
+        }
+    }
+    else
+    {
+        mpSourceRadioNamedRange->Disable();
+        mpSourceRadioSelection->Disable();
+        ToggleSource(NULL);
+        return;
+    }
+
+    // Setup Named Ranges
+    bool bIsNamedRange = false;
+
+    ScAreaNameIterator aIterator(mpDocument);
+    OUString aEachName;
+    ScRange aEachRange;
+
+    while (aIterator.Next(aEachName, aEachRange))
+    {
+        if (!aIterator.WasDBName())
+        {
+            mpSourceListBox->InsertEntry(aEachName);
+            if (aEachRange == aSourceRange)
+            {
+                sSourceNamedRangeName = aEachName;
+                bIsNamedRange = true;
+            }
+        }
+    }
+
+    if (bIsNamedRange)
+    {
+        mpSourceListBox->SelectEntry(sSourceNamedRangeName, true);
+        mpSourceRadioNamedRange->Check(true);
+    }
+    else
+    {
+        mpSourceListBox->SelectEntryPos(0, true);
+        mpSourceRadioSelection->Check(true);
+    }
+
+    // If entries - select first entry, otherwise disable the radio button.
+    if (mpSourceListBox->GetEntryCount() <= 0)
+        mpSourceRadioNamedRange->Disable();
+
+    ToggleSource(NULL);
+}
+
+void ScPivotLayoutDialog::SetupDestination()
+{
+    mpDestinationListBox->Clear();
+
+    // Fill up named ranges
+    ScAreaNameIterator aIterator(mpDocument);
+    OUString aName;
+    ScRange aRange;
+
+    while (aIterator.Next(aName, aRange))
+    {
+        if (!aIterator.WasDBName())
+        {
+            mpDestinationListBox->InsertEntry(aName);
+        }
+    }
+
+    // If entries - select first entry, otherwise disable the radio button.
+    if (mpDestinationListBox->GetEntryCount() > 0)
+        mpDestinationListBox->SelectEntryPos(0, true);
+    else
+        mpDestinationRadioNamedRange->Disable();
+
+    //
+    if (mbNewPivotTable)
+    {
+        mpDestinationRadioNewSheet->Check(true);
+    }
+    else
+    {
+        if (maPivotParameters.nTab != MAXTAB + 1)
+        {
+            ScAddress aAddress(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+            OUString aAddressString;
+            aAddress.Format(aAddressString, SCA_VALID | SCA_TAB_3D | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE, mpDocument, maAddressDetails);
+            mpDestinationEdit->SetText(aAddressString);
+            mpDestinationRadioSelection->Check(true);
+        }
+    }
+
+    ToggleDestination(NULL);
+}
+
+void ScPivotLayoutDialog::FillValuesToListBoxes()
+{
+    mpListBoxField->FillLabelFields(maPivotParameters.maLabelArray);
+    mpListBoxData->FillDataField(maPivotParameters.maDataFields);
+    mpListBoxColumn->FillFields(maPivotParameters.maColFields);
+    mpListBoxRow->FillFields(maPivotParameters.maRowFields);
+    mpListBoxPage->FillFields(maPivotParameters.maPageFields);
+}
+
+void ScPivotLayoutDialog::SetActive()
+{
+    if (mbDialogLostFocus)
+    {
+        mbDialogLostFocus = false;
+        if(mpActiveEdit != NULL)
+        {
+            mpActiveEdit->GrabFocus();
+            if (mpActiveEdit == mpSourceEdit)
+                UpdateSourceRange();
+        }
+    }
+    else
+    {
+        GrabFocus();
+    }
+
+    RefInputDone();
+}
+
+void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocument* pDocument)
+{
+    if (!mbDialogLostFocus)
+        return;
+
+    if (mpActiveEdit == NULL)
+        return;
+
+    if (rReferenceRange.aStart != rReferenceRange.aEnd)
+        RefInputStart(mpActiveEdit);
+
+    OUString aReferenceString;
+    rReferenceRange.Format(aReferenceString, SCR_ABS_3D, pDocument, maAddressDetails);
+
+    if (mpActiveEdit == mpSourceEdit)
+    {
+        mpSourceEdit->SetRefString(aReferenceString);
+    }
+    else if (mpActiveEdit == mpDestinationEdit)
+    {
+        mpDestinationEdit->SetRefString(aReferenceString);
+    }
+}
+
+sal_Bool ScPivotLayoutDialog::IsRefInputMode() const
+{
+    return mbDialogLostFocus;
+}
+
+void ScPivotLayoutDialog::ItemInserted(ScItemValue* pItemValue, ScPivotLayoutTreeList::SvPivotTreeListType eType)
+{
+    if (pItemValue == NULL)
+        return;
+
+    switch (eType)
+    {
+        case ScPivotLayoutTreeList::ROW_LIST:
+        case ScPivotLayoutTreeList::COLUMN_LIST:
+        case ScPivotLayoutTreeList::PAGE_LIST:
+        {
+            mpListBoxRow->RemoveEntryForItem(pItemValue);
+            mpListBoxColumn->RemoveEntryForItem(pItemValue);
+            mpListBoxPage->RemoveEntryForItem(pItemValue);
+        }
+        case ScPivotLayoutTreeList::LABEL_LIST:
+        {
+            mpListBoxRow->RemoveEntryForItem(pItemValue);
+            mpListBoxColumn->RemoveEntryForItem(pItemValue);
+            mpListBoxPage->RemoveEntryForItem(pItemValue);
+            mpListBoxData->RemoveEntryForItem(pItemValue);
+        }
+        break;
+        default:
+            break;
+    }
+}
+
+void ScPivotLayoutDialog::UpdateSourceRange()
+{
+    ScSheetSourceDesc aSourceSheet = *maPivotTableObject.GetSheetDesc();
+
+    if (mpSourceRadioNamedRange->IsChecked())
+    {
+        OUString aEntryString = mpSourceListBox->GetSelectEntry();
+        ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, mpDocument);
+        if (!aSourceRange.IsValid() || aSourceSheet.GetSourceRange() == aSourceRange)
+            return;
+        aSourceSheet.SetRangeName(aEntryString);
+    }
+    else if (mpSourceRadioSelection->IsChecked())
+    {
+        OUString aSourceString = mpSourceEdit->GetText();
+        ScRange aSourceRange;
+        sal_uInt16 nResult = aSourceRange.Parse(aSourceString, mpDocument, maAddressDetails);
+
+        bool bIsValid = (nResult & SCA_VALID) == SCA_VALID; // aSourceString is valid
+
+        mpSourceEdit->SetRefValid(true);
+
+        if (bIsValid)
+        {
+            ScRefAddress aStart;
+            ScRefAddress aEnd;
+
+            ConvertDoubleRef(mpDocument, aSourceString, 1, aStart, aEnd, maAddressDetails);
+            aSourceRange.aStart = aStart.GetAddress();
+            aSourceRange.aEnd = aEnd.GetAddress();
+        }
+        else
+        {
+            aSourceRange = lclGetRangeForNamedRange(aSourceString, mpDocument);
+        }
+
+        if (!aSourceRange.IsValid())
+        {
+            mpSourceEdit->SetRefValid(false);
+            return;
+        }
+
+        if (aSourceSheet.GetSourceRange() == aSourceRange)
+                return;
+
+        aSourceSheet.SetSourceRange(aSourceRange);
+        if (aSourceSheet.CheckSourceRange() != 0)
+        {
+            mpSourceEdit->SetRefValid(false);
+            return;
+        }
+    }
+    else
+    {
+        return;
+    }
+
+    maPivotTableObject.SetSheetDesc(aSourceSheet);
+    maPivotTableObject.FillOldParam(maPivotParameters);
+    maPivotTableObject.FillLabelData(maPivotParameters);
+
+    FillValuesToListBoxes();
+}
+
+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());
+
+    Reference<XDimensionsSupplier> xSource = maPivotTableObject.GetSource();
+
+    ScPivotFieldVector aPageFieldVector;
+    mpListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aColFieldVector;
+    mpListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aRowFieldVector;
+    mpListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aDataFieldVector;
+    mpListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
+                                   xSource, maPivotParameters.maLabelArray,
+                                   &aColFieldVector, &aRowFieldVector, &aPageFieldVector);
+
+
+    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(new ScDPObject(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;
+}
+
+bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNewSheet)
+{
+    bToNewSheet = false;
+
+    if (mpDestinationRadioNamedRange->IsChecked())
+    {
+        OUString aName = mpDestinationListBox->GetSelectEntry();
+        aDestinationRange = lclGetRangeForNamedRange(aName, mpDocument);
+        if (!aDestinationRange.IsValid())
+            return false;
+    }
+    else if (mpDestinationRadioSelection->IsChecked())
+    {
+        ScAddress aAddress;
+        aAddress.Parse(mpDestinationEdit->GetText(), mpDocument, maAddressDetails);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list