LibreOffice Module sc (master) 1
PivotLayoutTreeListLabel.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 */
11
12#include <memory>
14#include <PivotLayoutDialog.hxx>
15
16#include <vcl/event.hxx>
17#include <pivot.hxx>
18
19ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(std::unique_ptr<weld::TreeView> xControl)
20 : ScPivotLayoutTreeListBase(std::move(xControl), LABEL_LIST)
21 , maDataItem(0)
22{
23 mxControl->connect_key_press(LINK(this, ScPivotLayoutTreeListLabel, KeyInputHdl));
24}
25
27{}
28
30{
31 mxControl->clear();
32 maItemValues.clear();
33
34 for (std::unique_ptr<ScDPLabelData> const & pLabelData : rLabelVector)
35 {
36 ScItemValue* pValue = new ScItemValue(pLabelData->maName, pLabelData->mnCol, pLabelData->mnFuncMask);
37 maItemValues.push_back(std::unique_ptr<ScItemValue>(pValue));
38 if (pLabelData->mbDataLayout)
39 {
40 maDataItem = maItemValues.size() - 1;
41 }
42
43 if (pLabelData->mnOriginalDim < 0 && !pLabelData->mbDataLayout)
44 {
45 mxControl->append(weld::toId(pValue), pLabelData->maName);
46 }
47 }
48}
49
51{
52 if (&rSource == mxControl.get())
53 return;
54 rSource.remove(rSource.get_selected_index());
55}
56
58{
59 return (nColumn == PIVOT_DATA_FIELD || nColumn == maDataItem);
60}
61
63{
64 if (nColumn == PIVOT_DATA_FIELD)
65 return maItemValues[maDataItem].get();
66 return maItemValues[nColumn].get();
67}
68
69IMPL_LINK(ScPivotLayoutTreeListLabel, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
70{
71 vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
72 sal_uInt16 nCode = aCode.GetCode();
73
74 if (nCode == KEY_DELETE)
75 {
76 int nEntry = mxControl->get_cursor_index();
77 if (nEntry != -1)
78 mxControl->remove(nEntry);
79 return true;
80 }
81
82 return false;
83}
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK(ScPivotLayoutTreeListLabel, KeyInputHdl, const KeyEvent &, rKeyEvent, bool)
std::unique_ptr< weld::TreeView > mxControl
void FillLabelFields(ScDPLabelDataVector &rLabelVector)
virtual void InsertEntryForSourceTarget(weld::TreeView &rSource, int nTarget) override
ScItemValue * GetItem(SCCOL nColumn)
std::vector< std::unique_ptr< ScItemValue > > maItemValues
virtual ~ScPivotLayoutTreeListLabel() override
ScPivotLayoutTreeListLabel(std::unique_ptr< weld::TreeView > xControl)
sal_uInt16 GetCode() const
virtual void remove(int pos)=0
virtual int get_selected_index() const=0
constexpr sal_uInt16 KEY_DELETE
OUString toId(const void *pValue)
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
Definition: pivot.hxx:113
#define PIVOT_DATA_FIELD
Definition: pivot.hxx:54
sal_Int16 SCCOL
Definition: types.hxx:21