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:
12 #include "PivotLayoutTreeListBase.hxx"
13 #include "PivotLayoutDialog.hxx"
15 #include <reffact.hxx>
16 #include <svtools/treelistentry.hxx>
17 #include "scabstdlg.hxx"
21 ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(vcl::Window
* pParent
, WinBits nBits
, SvPivotTreeListType eType
)
22 : SvTreeListBox(pParent
, nBits
)
27 SetDragDropMode(DragDropMode::CTRL_MOVE
| DragDropMode::APP_MOVE
| DragDropMode::APP_DROP
);
30 ScPivotLayoutTreeListBase::~ScPivotLayoutTreeListBase()
35 void ScPivotLayoutTreeListBase::dispose()
38 SvTreeListBox::dispose();
41 void ScPivotLayoutTreeListBase::Setup(ScPivotLayoutDialog
* pParent
)
46 DragDropMode
ScPivotLayoutTreeListBase::NotifyStartDrag(TransferDataContainer
& /*aTransferDataContainer*/,
47 SvTreeListEntry
* /*pEntry*/ )
49 return GetDragDropMode();
52 void ScPivotLayoutTreeListBase::DragFinished(sal_Int8
/*nDropAction*/)
55 sal_Int8
ScPivotLayoutTreeListBase::AcceptDrop(const AcceptDropEvent
& rEvent
)
57 return SvTreeListBox::AcceptDrop(rEvent
);
60 bool ScPivotLayoutTreeListBase::NotifyAcceptDrop(SvTreeListEntry
* /*pEntry*/)
65 TriState
ScPivotLayoutTreeListBase::NotifyMoving(SvTreeListEntry
* pTarget
, SvTreeListEntry
* pSource
,
66 SvTreeListEntry
*& /*rpNewParent*/, sal_uLong
& /*rNewChildPos*/)
68 InsertEntryForSourceTarget(pSource
, pTarget
);
69 return TRISTATE_FALSE
;
72 TriState
ScPivotLayoutTreeListBase::NotifyCopying(SvTreeListEntry
* /*pTarget*/, SvTreeListEntry
* /*pSource*/,
73 SvTreeListEntry
*& /*rpNewParent*/, sal_uLong
& /*rNewChildPos*/)
75 return TRISTATE_FALSE
;
78 bool ScPivotLayoutTreeListBase::HasEntry(SvTreeListEntry
* pEntry
)
80 SvTreeListEntry
* pEachEntry
;
81 for (pEachEntry
= First(); pEachEntry
!= NULL
; pEachEntry
= Next(pEachEntry
))
83 if(pEachEntry
== pEntry
)
89 void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
& rVector
)
91 SvTreeListEntry
* pEachEntry
;
92 for (pEachEntry
= First(); pEachEntry
!= NULL
; pEachEntry
= Next(pEachEntry
))
94 ScItemValue
* pItemValue
= static_cast<ScItemValue
*>(pEachEntry
->GetUserData());
95 ScPivotFuncData
& rFunctionData
= pItemValue
->maFunctionData
;
98 aField
.nCol
= rFunctionData
.mnCol
;
99 aField
.mnOriginalDim
= rFunctionData
.mnOriginalDim
;
100 aField
.nFuncMask
= rFunctionData
.mnFuncMask
;
101 aField
.mnDupCount
= rFunctionData
.mnDupCount
;
102 aField
.maFieldRef
= rFunctionData
.maFieldRef
;
103 rVector
.push_back(aField
);
107 void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(SvTreeListEntry
* /*pSource*/, SvTreeListEntry
* /*pTarget*/)
110 void ScPivotLayoutTreeListBase::InsertEntryForItem(ScItemValue
* /*pItemValue*/, sal_uLong
/*nPosition*/)
113 void ScPivotLayoutTreeListBase::RemoveEntryForItem(ScItemValue
* pItemValue
)
115 SvTreeListEntry
* pEachEntry
;
116 for (pEachEntry
= First(); pEachEntry
!= NULL
; pEachEntry
= Next(pEachEntry
))
118 ScItemValue
* pEachItemValue
= static_cast<ScItemValue
*>(pEachEntry
->GetUserData());
119 if (pEachItemValue
== pItemValue
)
121 GetModel()->Remove(pEachEntry
);
127 void ScPivotLayoutTreeListBase::GetFocus()
129 SvTreeListBox::GetFocus();
131 if( GetGetFocusFlags() & GETFOCUS_MNEMONIC
)
133 SvTreeListEntry
* pEntry
= mpParent
->mpPreviouslyFocusedListBox
->GetCurEntry();
135 InsertEntryForSourceTarget(pEntry
, NULL
);
137 if (mpParent
->mpPreviouslyFocusedListBox
!= nullptr)
138 mpParent
->mpPreviouslyFocusedListBox
->GrabFocus();
141 mpParent
->mpCurrentlyFocusedListBox
= this;
144 void ScPivotLayoutTreeListBase::LoseFocus()
146 SvTreeListBox::LoseFocus();
148 mpParent
->mpPreviouslyFocusedListBox
= this;
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */