1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
13 #include <PivotLayoutTreeListLabel.hxx>
14 #include <PivotLayoutDialog.hxx>
16 #include <vcl/event.hxx>
19 ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(std::unique_ptr
<weld::TreeView
> xControl
)
20 : ScPivotLayoutTreeListBase(std::move(xControl
), LABEL_LIST
)
23 mxControl
->connect_key_press(LINK(this, ScPivotLayoutTreeListLabel
, KeyInputHdl
));
26 ScPivotLayoutTreeListLabel::~ScPivotLayoutTreeListLabel()
29 void ScPivotLayoutTreeListLabel::FillLabelFields(ScDPLabelDataVector
& rLabelVector
)
34 for (std::unique_ptr
<ScDPLabelData
> const & pLabelData
: rLabelVector
)
36 ScItemValue
* pValue
= new ScItemValue(pLabelData
->maName
, pLabelData
->mnCol
, pLabelData
->mnFuncMask
);
37 maItemValues
.push_back(std::unique_ptr
<ScItemValue
>(pValue
));
38 if (pLabelData
->mbDataLayout
)
40 maDataItem
= maItemValues
.size() - 1;
43 if (pLabelData
->mnOriginalDim
< 0 && !pLabelData
->mbDataLayout
)
45 mxControl
->append(weld::toId(pValue
), pLabelData
->maName
);
50 void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(weld::TreeView
& rSource
, int /*nTarget*/)
52 if (&rSource
== mxControl
.get())
54 rSource
.remove(rSource
.get_selected_index());
57 bool ScPivotLayoutTreeListLabel::IsDataElement(SCCOL nColumn
)
59 return (nColumn
== PIVOT_DATA_FIELD
|| nColumn
== maDataItem
);
62 ScItemValue
* ScPivotLayoutTreeListLabel::GetItem(SCCOL nColumn
)
64 if (nColumn
== PIVOT_DATA_FIELD
)
65 return maItemValues
[maDataItem
].get();
66 return maItemValues
[nColumn
].get();
69 IMPL_LINK(ScPivotLayoutTreeListLabel
, KeyInputHdl
, const KeyEvent
&, rKeyEvent
, bool)
71 vcl::KeyCode aCode
= rKeyEvent
.GetKeyCode();
72 sal_uInt16 nCode
= aCode
.GetCode();
74 if (nCode
== KEY_DELETE
)
76 int nEntry
= mxControl
->get_cursor_index();
78 mxControl
->remove(nEntry
);
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */