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 
19 ScPivotLayoutTreeListLabel::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(OUString::number(reinterpret_cast<sal_Int64>(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 
69 IMPL_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: */
sal_uInt16 GetCode() const
void FillLabelFields(ScDPLabelDataVector &rLabelVector)
#define PIVOT_DATA_FIELD
Definition: pivot.hxx:55
std::vector< std::unique_ptr< ScItemValue > > maItemValues
sal_uInt16 nCode
std::vector< std::unique_ptr< ScDPLabelData > > ScDPLabelDataVector
Definition: pivot.hxx:114
virtual int get_selected_index() const =0
sal_Int16 SCCOL
Definition: types.hxx:22
virtual void InsertEntryForSourceTarget(weld::TreeView &rSource, int nTarget) override
virtual void remove(int pos)=0
ScItemValue * GetItem(SCCOL nColumn)
virtual ~ScPivotLayoutTreeListLabel() override
std::unique_ptr< weld::TreeView > mxControl
IMPL_LINK(ScPivotLayoutTreeListLabel, KeyInputHdl, const KeyEvent &, rKeyEvent, bool)
constexpr sal_uInt16 KEY_DELETE
ScPivotLayoutTreeListLabel(std::unique_ptr< weld::TreeView > xControl)