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