tdf#83720 Pivot Table: Data field should always at last place

In the pivot table dialog we should always put the "Data" field to
the last place or the cell formats won't be shown correct in the
pivot table.

Change-Id: If4befe4fff1e6f04d9b709615a1955e3b5f4b4cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164161
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index 45af29a..672de95 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -67,6 +67,9 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
    std::unique_ptr<weld::TreeIter> xEachEntry(mxControl->make_iterator());
    if (!mxControl->get_iter_first(*xEachEntry))
        return;

    std::optional<ScPivotField> oDataField;

    do
    {
        ScItemValue* pItemValue = weld::fromId<ScItemValue*>(mxControl->get_id(*xEachEntry));
@@ -78,8 +81,15 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
        aField.nFuncMask     = rFunctionData.mnFuncMask;
        aField.mnDupCount    = rFunctionData.mnDupCount;
        aField.maFieldRef    = rFunctionData.maFieldRef;
        rVector.push_back(aField);

        if (aField.nCol == PIVOT_DATA_FIELD)
            oDataField = aField;
        else
            rVector.push_back(aField);
    } while (mxControl->iter_next(*xEachEntry));

    if (oDataField)
        rVector.push_back(*oDataField);
}

void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& /*pSource*/, int /*nTarget*/)