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 "PivotLayoutTreeListBase.hxx"
13 : #include "PivotLayoutDialog.hxx"
14 :
15 : #include <reffact.hxx>
16 : #include <svtools/treelistentry.hxx>
17 : #include "scabstdlg.hxx"
18 :
19 : using namespace std;
20 :
21 0 : ScPivotLayoutTreeListBase::ScPivotLayoutTreeListBase(Window* pParent, WinBits nBits, SvPivotTreeListType eType) :
22 : SvTreeListBox(pParent, nBits),
23 0 : meType(eType)
24 : {
25 0 : SetHighlightRange();
26 0 : SetDragDropMode(SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_APP_MOVE | SV_DRAGDROP_APP_DROP);
27 0 : }
28 :
29 0 : ScPivotLayoutTreeListBase::~ScPivotLayoutTreeListBase()
30 0 : {}
31 :
32 0 : void ScPivotLayoutTreeListBase::Setup(ScPivotLayoutDialog* pParent)
33 : {
34 0 : mpParent = pParent;
35 0 : }
36 :
37 0 : DragDropMode ScPivotLayoutTreeListBase::NotifyStartDrag(TransferDataContainer& /*aTransferDataContainer*/,
38 : SvTreeListEntry* /*pEntry*/ )
39 : {
40 0 : return GetDragDropMode();
41 : }
42 :
43 0 : void ScPivotLayoutTreeListBase::DragFinished(sal_Int8 /*nDropAction*/)
44 0 : {}
45 :
46 0 : sal_Int8 ScPivotLayoutTreeListBase::AcceptDrop(const AcceptDropEvent& rEvent)
47 : {
48 0 : return SvTreeListBox::AcceptDrop(rEvent);
49 : }
50 :
51 0 : bool ScPivotLayoutTreeListBase::NotifyAcceptDrop(SvTreeListEntry* /*pEntry*/)
52 : {
53 0 : return true;
54 : }
55 :
56 0 : TriState ScPivotLayoutTreeListBase::NotifyMoving(SvTreeListEntry* pTarget, SvTreeListEntry* pSource,
57 : SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
58 : {
59 0 : InsertEntryForSourceTarget(pSource, pTarget);
60 0 : return TRISTATE_FALSE;
61 : }
62 :
63 0 : TriState ScPivotLayoutTreeListBase::NotifyCopying(SvTreeListEntry* /*pTarget*/, SvTreeListEntry* /*pSource*/,
64 : SvTreeListEntry*& /*rpNewParent*/, sal_uLong& /*rNewChildPos*/)
65 : {
66 0 : return TRISTATE_FALSE;
67 : }
68 :
69 0 : bool ScPivotLayoutTreeListBase::HasEntry(SvTreeListEntry* pEntry)
70 : {
71 : SvTreeListEntry* pEachEntry;
72 0 : for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
73 : {
74 0 : if(pEachEntry == pEntry)
75 0 : return true;
76 : }
77 0 : return false;
78 : }
79 :
80 0 : void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector& rVector)
81 : {
82 : SvTreeListEntry* pEachEntry;
83 0 : for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
84 : {
85 0 : ScItemValue* pItemValue = (ScItemValue*) pEachEntry->GetUserData();
86 0 : ScPivotFuncData& rFunctionData = pItemValue->maFunctionData;
87 :
88 0 : ScPivotField aField;
89 0 : aField.nCol = rFunctionData.mnCol;
90 0 : aField.mnOriginalDim = rFunctionData.mnOriginalDim;
91 0 : aField.nFuncMask = rFunctionData.mnFuncMask;
92 0 : aField.mnDupCount = rFunctionData.mnDupCount;
93 0 : aField.maFieldRef = rFunctionData.maFieldRef;
94 0 : rVector.push_back(aField);
95 0 : }
96 0 : }
97 :
98 0 : void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(SvTreeListEntry* /*pSource*/, SvTreeListEntry* /*pTarget*/)
99 0 : {}
100 :
101 0 : void ScPivotLayoutTreeListBase::InsertEntryForItem(ScItemValue* /*pItemValue*/, sal_uLong /*nPosition*/)
102 0 : {}
103 :
104 0 : void ScPivotLayoutTreeListBase::RemoveEntryForItem(ScItemValue* pItemValue)
105 : {
106 : SvTreeListEntry* pEachEntry;
107 0 : for (pEachEntry = First(); pEachEntry != NULL; pEachEntry = Next(pEachEntry))
108 : {
109 0 : ScItemValue* pEachItemValue = (ScItemValue*) pEachEntry->GetUserData();
110 0 : if (pEachItemValue == pItemValue)
111 : {
112 0 : GetModel()->Remove(pEachEntry);
113 0 : return;
114 : }
115 : }
116 : }
117 :
118 0 : void ScPivotLayoutTreeListBase::GetFocus()
119 : {
120 0 : SvTreeListBox::GetFocus();
121 :
122 0 : if( GetGetFocusFlags() & GETFOCUS_MNEMONIC )
123 : {
124 0 : SvTreeListEntry* pEntry = mpParent->mpPreviouslyFocusedListBox->GetCurEntry();
125 0 : InsertEntryForSourceTarget(pEntry, NULL);
126 :
127 0 : if(mpParent->mpPreviouslyFocusedListBox != NULL)
128 0 : mpParent->mpPreviouslyFocusedListBox->GrabFocus();
129 : }
130 :
131 0 : mpParent->mpCurrentlyFocusedListBox = this;
132 0 : }
133 :
134 0 : void ScPivotLayoutTreeListBase::LoseFocus()
135 : {
136 0 : SvTreeListBox::LoseFocus();
137 0 : mpParent->mpPreviouslyFocusedListBox = this;
138 0 : }
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|