LibreOffice Module sc (master) 1
PivotLayoutTreeListBase.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
13#include <PivotLayoutDialog.hxx>
14
15ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(std::unique_ptr<weld::TreeView> xControl, SvPivotTreeListType eType)
16 : mxControl(std::move(xControl))
17 , maDropTargetHelper(*this)
18 , meType(eType)
19 , mpParent(nullptr)
20{
21 mxControl->connect_focus_in(LINK(this, ScPivotLayoutTreeListBase, GetFocusHdl));
22 mxControl->connect_mnemonic_activate(LINK(this, ScPivotLayoutTreeListBase, MnemonicActivateHdl));
23 mxControl->connect_focus_out(LINK(this, ScPivotLayoutTreeListBase, LoseFocusHdl));
24}
25
27{
28}
29
31{
32 mpParent = pParent;
33}
34
36 : DropTargetHelper(rTreeView.get_widget().get_drop_target())
37 , m_rTreeView(rTreeView)
38{
39}
40
42{
43 // to enable the autoscroll when we're close to the edges
45 rWidget.get_dest_row_at_pos(rEvt.maPosPixel, nullptr, true);
46 return DND_ACTION_MOVE;
47}
48
50{
52 weld::TreeView* pSource = rWidget.get_drag_source();
53 if (!pSource)
54 return DND_ACTION_NONE;
55
56 std::unique_ptr<weld::TreeIter> xTarget(rWidget.make_iterator());
57 int nTargetPos = -1;
58 if (rWidget.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), true))
59 nTargetPos = rWidget.get_iter_index_in_parent(*xTarget);
60 m_rTreeView.InsertEntryForSourceTarget(*pSource, nTargetPos);
61 rWidget.unset_drag_dest_row();
62 return DND_ACTION_NONE;
63}
64
66{
67 std::unique_ptr<weld::TreeIter> xEachEntry(mxControl->make_iterator());
68 if (!mxControl->get_iter_first(*xEachEntry))
69 return;
70 do
71 {
72 ScItemValue* pItemValue = weld::fromId<ScItemValue*>(mxControl->get_id(*xEachEntry));
73 ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
74
75 ScPivotField aField;
76 aField.nCol = rFunctionData.mnCol;
77 aField.mnOriginalDim = rFunctionData.mnOriginalDim;
78 aField.nFuncMask = rFunctionData.mnFuncMask;
79 aField.mnDupCount = rFunctionData.mnDupCount;
80 aField.maFieldRef = rFunctionData.maFieldRef;
81 rVector.push_back(aField);
82 } while (mxControl->iter_next(*xEachEntry));
83}
84
86{
87}
88
90{
91 OUString sId(weld::toId(pItemValue));
92 int nPos = mxControl->find_id(sId);
93 if (nPos == -1)
94 return;
95 mxControl->remove(nPos);
96}
97
99{
100 if (!mpParent)
101 return;
102 mpParent->mpPreviouslyFocusedListBox = this;
103}
104
106{
107 if (!mpParent || !mpParent->mpPreviouslyFocusedListBox)
108 return false;
109 weld::TreeView& rSource = mpParent->mpPreviouslyFocusedListBox->get_widget();
110 int nEntry = rSource.get_cursor_index();
111 if (nEntry != -1)
112 InsertEntryForSourceTarget(rSource, -1);
113 return true;
114}
115
117{
118 if (!mpParent)
119 return;
120 mpParent->mpPreviouslyFocusedListBox = nullptr;
121}
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK_NOARG(ScPivotLayoutTreeListBase, GetFocusHdl, weld::Widget &, void)
ScPivotFuncData maFunctionData
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
ScPivotLayoutTreeDropTarget(ScPivotLayoutTreeListBase &rTreeView)
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
ScPivotLayoutTreeListBase & m_rTreeView
ScPivotLayoutTreeListBase(std::unique_ptr< weld::TreeView > xControl, SvPivotTreeListType eType=UNDEFINED)
void Setup(ScPivotLayoutDialog *pParent)
void PushEntriesToPivotFieldVector(ScPivotFieldVector &rVector)
std::unique_ptr< weld::TreeView > mxControl
virtual void InsertEntryForSourceTarget(weld::TreeView &rSource, int nTarget)
void RemoveEntryForItem(const ScItemValue *pItemValue)
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual int get_iter_index_in_parent(const TreeIter &rIter) const=0
virtual TreeView * get_drag_source() const=0
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
virtual void unset_drag_dest_row()=0
virtual int get_cursor_index() const=0
RegionData_Impl * mpParent
Reference< XInterface > xTarget
DocumentType eType
sal_uInt16 nPos
OUString toId(const void *pValue)
std::vector< ScPivotField > ScPivotFieldVector
Definition: pivot.hxx:129
sal_uInt8 mnDupCount
Definition: pivot.hxx:122
SCCOL nCol
0-based dimension index (not source column index)
Definition: pivot.hxx:121
css::sheet::DataPilotFieldReference maFieldRef
Definition: pivot.hxx:117
tools::Long mnOriginalDim
>= 0 for duplicated field.
Definition: pivot.hxx:119
PivotFunc nFuncMask
Definition: pivot.hxx:120
css::sheet::DataPilotFieldReference maFieldRef
Definition: pivot.hxx:158
sal_uInt8 mnDupCount
Definition: pivot.hxx:163
tools::Long mnOriginalDim
Definition: pivot.hxx:160
PivotFunc mnFuncMask
Definition: pivot.hxx:161
#define DND_ACTION_MOVE
#define DND_ACTION_NONE
signed char sal_Int8
OUString sId
RedlineType meType