Line data Source code
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 "PivotLayoutTreeListLabel.hxx"
13 : #include "PivotLayoutDialog.hxx"
14 :
15 : #include <vcl/builderfactory.hxx>
16 : #include <svtools/treelistentry.hxx>
17 : #include "pivot.hxx"
18 : #include "scabstdlg.hxx"
19 :
20 : using namespace std;
21 :
22 0 : VCL_BUILDER_FACTORY_ARGS(ScPivotLayoutTreeListLabel,
23 : WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN |
24 : WB_FORCE_MAKEVISIBLE);
25 :
26 0 : ScPivotLayoutTreeListLabel::ScPivotLayoutTreeListLabel(vcl::Window* pParent, WinBits nBits)
27 : : ScPivotLayoutTreeListBase(pParent, nBits, LABEL_LIST)
28 0 : , maDataItem(0)
29 : {
30 0 : }
31 :
32 0 : ScPivotLayoutTreeListLabel::~ScPivotLayoutTreeListLabel()
33 0 : {}
34 :
35 0 : void ScPivotLayoutTreeListLabel::FillLabelFields(ScDPLabelDataVector& rLabelVector)
36 : {
37 0 : Clear();
38 0 : maItemValues.clear();
39 :
40 0 : ScDPLabelDataVector::iterator it;
41 0 : for (it = rLabelVector.begin(); it != rLabelVector.end(); ++it)
42 : {
43 0 : const ScDPLabelData& rLabelData = *it;
44 :
45 0 : ScItemValue* pValue = new ScItemValue(rLabelData.maName, rLabelData.mnCol, rLabelData.mnFuncMask);
46 0 : maItemValues.push_back(pValue);
47 0 : if (rLabelData.mbDataLayout)
48 : {
49 0 : maDataItem = maItemValues.size() - 1;
50 : }
51 :
52 0 : if (rLabelData.mnOriginalDim < 0 && !rLabelData.mbDataLayout)
53 : {
54 0 : SvTreeListEntry* pEntry = InsertEntry(rLabelData.maName);
55 0 : pEntry->SetUserData(pValue);
56 : }
57 : }
58 0 : }
59 :
60 0 : void ScPivotLayoutTreeListLabel::InsertEntryForSourceTarget(SvTreeListEntry* /*pSource*/, SvTreeListEntry* /*pTarget*/)
61 : {
62 0 : if(mpParent->mpPreviouslyFocusedListBox.get() != this)
63 0 : mpParent->mpPreviouslyFocusedListBox->RemoveSelection();
64 0 : }
65 :
66 0 : bool ScPivotLayoutTreeListLabel::IsDataElement(SCCOL nColumn)
67 : {
68 0 : return (nColumn == PIVOT_DATA_FIELD || nColumn == maDataItem);
69 : }
70 :
71 0 : ScItemValue* ScPivotLayoutTreeListLabel::GetItem(SCCOL nColumn)
72 : {
73 0 : if (nColumn == PIVOT_DATA_FIELD)
74 0 : return &maItemValues[maDataItem];
75 0 : return &maItemValues[nColumn];
76 : }
77 :
78 0 : void ScPivotLayoutTreeListLabel::KeyInput(const KeyEvent& rKeyEvent)
79 : {
80 0 : vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
81 0 : sal_uInt16 nCode = aCode.GetCode();
82 :
83 0 : if (nCode == KEY_DELETE)
84 : {
85 0 : const SvTreeListEntry* pEntry = GetCurEntry();
86 0 : if (pEntry)
87 0 : GetModel()->Remove(pEntry);
88 0 : return;
89 : }
90 :
91 0 : SvTreeListBox::KeyInput(rKeyEvent);
92 156 : }
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|