sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 78065e3798439dd790d1be5ac5c219477285c888
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Feb 29 23:51:26 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Mar 1 02:14:39 2024 +0100

    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 <qui...@gmail.com>

diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx 
b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index 45af29a4f1a4..672de9559c4e 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*/)

Reply via email to