Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / sc / source / ui / dbgui / PivotLayoutTreeListBase.cxx
blob3710e4ca0f03353cec3289a83dcdc07e7c99c438
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
19 using namespace std;
21 ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(Window* pParent, WinBits nBits, SvPivotTreeListType eType)
22 : SvTreeListBox(pParent, nBits)
23 , meType(eType)
24 , mpParent(NULL)
26 SetHighlightRange();
27 SetDragDropMode(SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_APP_MOVE | SV_DRAGDROP_APP_DROP);
30 ScPivotLayoutTreeListBase::~ScPivotLayoutTreeListBase()
33 void ScPivotLayoutTreeListBase::Setup(ScPivotLayoutDialog* pParent)
35 mpParent = pParent;
38 DragDropMode ScPivotLayoutTreeListBase::NotifyStartDrag(TransferDataContainer& /*aTransferDataContainer*/,
39 SvTreeListEntry* /*pEntry*/ )
41 return GetDragDropMode();
44 void ScPivotLayoutTreeListBase::DragFinished(sal_Int8 /*nDropAction*/)
47 sal_Int8 ScPivotLayoutTreeListBase::AcceptDrop(const AcceptDropEvent& rEvent)
49 return SvTreeListBox::AcceptDrop(rEvent);
52 bool ScPivotLayoutTreeListBase::NotifyAcceptDrop(SvTreeListEntry* /*pEntry*/)
54 return true;
57 TriState ScPivotLayoutTreeListBase::NotifyMoving(SvTreeListEntry* pTarget, SvTreeListEntry* pSource,
58 SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
60 InsertEntryForSourceTarget(pSource, pTarget);
61 return TRISTATE_FALSE;
64 TriState ScPivotLayoutTreeListBase::NotifyCopying(SvTreeListEntry* /*pTarget*/, SvTreeListEntry* /*pSource*/,
65 SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
67 return TRISTATE_FALSE;
70 bool ScPivotLayoutTreeListBase::HasEntry(SvTreeListEntry* pEntry)
72 SvTreeListEntry* pEachEntry;
73 for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
75 if(pEachEntry == pEntry)
76 return true;
78 return false;
81 void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector& rVector)
83 SvTreeListEntry* pEachEntry;
84 for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
86 ScItemValue* pItemValue = (ScItemValue*) pEachEntry->GetUserData();
87 ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
89 ScPivotField aField;
90 aField.nCol = rFunctionData.mnCol;
91 aField.mnOriginalDim = rFunctionData.mnOriginalDim;
92 aField.nFuncMask = rFunctionData.mnFuncMask;
93 aField.mnDupCount = rFunctionData.mnDupCount;
94 aField.maFieldRef = rFunctionData.maFieldRef;
95 rVector.push_back(aField);
99 void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(SvTreeListEntry* /*pSource*/, SvTreeListEntry* /*pTarget*/)
102 void ScPivotLayoutTreeListBase::InsertEntryForItem(ScItemValue* /*pItemValue*/, sal_uLong /*nPosition*/)
105 void ScPivotLayoutTreeListBase::RemoveEntryForItem(ScItemValue* pItemValue)
107 SvTreeListEntry* pEachEntry;
108 for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
110 ScItemValue* pEachItemValue = (ScItemValue*) pEachEntry->GetUserData();
111 if (pEachItemValue == pItemValue)
113 GetModel()->Remove(pEachEntry);
114 return;
119 void ScPivotLayoutTreeListBase::GetFocus()
121 SvTreeListBox::GetFocus();
123 if( GetGetFocusFlags() & GETFOCUS_MNEMONIC )
125 SvTreeListEntry* pEntry = mpParent->mpPreviouslyFocusedListBox->GetCurEntry();
126 InsertEntryForSourceTarget(pEntry, NULL);
128 if(mpParent->mpPreviouslyFocusedListBox != NULL)
129 mpParent->mpPreviouslyFocusedListBox->GrabFocus();
132 mpParent->mpCurrentlyFocusedListBox = this;
135 void ScPivotLayoutTreeListBase::LoseFocus()
137 SvTreeListBox::LoseFocus();
138 mpParent->mpPreviouslyFocusedListBox = this;
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */