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:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "svtools/treelistbox.hxx"
23 #include "svtools/svlbitm.hxx"
31 class SwNavigationConfig
;
34 class SwGlblDocContents
;
35 class SwGlblDocContent
;
39 #define EDIT_MODE_EDIT 0
40 #define EDIT_MODE_UPD_IDX 1
41 #define EDIT_MODE_RMV_IDX 2
42 #define EDIT_UNPROTECT_TABLE 3
43 #define EDIT_MODE_DELETE 4
44 #define EDIT_MODE_RENAME 5
46 //----------------------------------------------------------------------------
47 //----------------------------------------------------------------------------
49 class SwContentTree
: public SvTreeListBox
51 ImageList aEntryImages
;
55 SwContentType
* aActiveContentArr
[CONTENT_TYPE_MAX
];
56 SwContentType
* aHiddenContentArr
[CONTENT_TYPE_MAX
];
57 String aContextStrings
[CONTEXT_COUNT
+ 1];
68 SwWrtShell
* pHiddenShell
; // dropped Doc
69 SwWrtShell
* pActiveShell
; // the active or a const. open view
70 SwNavigationConfig
* pConfig
;
72 std::map
< void*, bool > mOutLineNodeMap
;
74 sal_Int32 nActiveBlock
;
75 sal_uInt16 nHiddenBlock
;
77 sal_uInt16 nLastSelType
;
78 sal_uInt8 nOutlineLevel
;
83 bool bDocChgdInDragging
:1;
84 bool bIsInternalDrag
:1;
87 sal_Bool bIsLastReadOnly
:1;
88 bool bIsOutlineMoveable
:1;
89 bool bViewHasChanged
:1;
90 bool bIsImageListInitialized
: 1;
92 static bool bIsInDrag
;
94 void FindActiveTypeAndRemoveUserData();
96 using SvTreeListBox::ExecuteDrop
;
97 using SvTreeListBox::EditEntry
;
98 using SvListView::Expand
;
99 using SvListView::Collapse
;
100 using SvListView::Select
;
103 virtual void RequestHelp( const HelpEvent
& rHEvt
);
104 virtual void InitEntry(SvTreeListEntry
*, const OUString
&, const Image
&, const Image
&, SvLBoxButtonKind
);
105 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
107 SwNavigationPI
* GetParentWindow(){return
108 (SwNavigationPI
*)Window::GetParent();}
110 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
111 virtual void DragFinished( sal_Int8
);
112 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
114 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
116 bool FillTransferData( TransferDataContainer
& rTransfer
,
117 sal_Int8
& rDragMode
);
118 bool HasContentChanged();
120 virtual DragDropMode
NotifyStartDrag( TransferDataContainer
& rData
,
122 virtual sal_Bool
NotifyAcceptDrop( SvTreeListEntry
* );
124 virtual sal_Bool
NotifyMoving( SvTreeListEntry
* pTarget
,
125 SvTreeListEntry
* pEntry
,
126 SvTreeListEntry
*& rpNewParent
,
127 sal_uLong
& rNewChildPos
129 virtual sal_Bool
NotifyCopying( SvTreeListEntry
* pTarget
,
130 SvTreeListEntry
* pEntry
,
131 SvTreeListEntry
*& rpNewParent
,
132 sal_uLong
& rNewChildPos
134 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
136 void EditEntry( SvTreeListEntry
* pEntry
, sal_uInt8 nMode
);
138 void GotoContent(SwContent
* pCnt
);
139 static void SetInDrag(bool bSet
) {bIsInDrag
= bSet
;}
141 virtual PopupMenu
* CreateContextMenu( void );
142 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
);
145 SwContentTree(Window
* pParent
, const ResId
& rResId
);
149 bool IsRoot() const {return bIsRoot
;}
150 sal_uInt16
GetRootType() const {return nRootType
;}
151 void SetRootType(sal_uInt16 nType
);
152 void Display( bool bActiveView
);
154 void SetHiddenShell(SwWrtShell
* pSh
);
155 void ShowHiddenShell();
156 void ShowActualView();
157 void SetActiveShell(SwWrtShell
* pSh
);
158 void SetConstantShell(SwWrtShell
* pSh
);
160 SwWrtShell
* GetWrtShell()
161 {return bIsActive
||bIsConstant
?
165 static bool IsInDrag() {return bIsInDrag
;}
166 bool IsInternalDrag() const {return bIsInternalDrag
;}
168 sal_Int32
GetActiveBlock() const {return nActiveBlock
;}
170 sal_uInt8
GetOutlineLevel()const {return nOutlineLevel
;}
171 void SetOutlineLevel(sal_uInt8 nSet
);
173 sal_Bool
Expand( SvTreeListEntry
* pParent
);
175 sal_Bool
Collapse( SvTreeListEntry
* pParent
);
177 void ExecCommand(sal_uInt16 nCmd
, sal_Bool bModifier
);
182 bool IsConstantView() {return bIsConstant
;}
183 bool IsActiveView() {return bIsActive
;}
184 bool IsHiddenView() {return bIsHidden
;}
186 const SwWrtShell
* GetActiveWrtShell() {return pActiveShell
;}
187 SwWrtShell
* GetHiddenWrtShell() {return pHiddenShell
;}
189 DECL_LINK( ContentDoubleClickHdl
, void * );
190 DECL_LINK( TimerUpdate
, void * );
192 virtual long GetTabPos( SvTreeListEntry
*, SvLBoxTab
* );
193 virtual void RequestingChildren( SvTreeListEntry
* pParent
);
194 virtual void GetFocus();
195 virtual void KeyInput(const KeyEvent
& rKEvt
);
197 virtual sal_Bool
Select( SvTreeListEntry
* pEntry
, sal_Bool bSelect
=sal_True
);
201 //----------------------------------------------------------------------------
202 // TreeListBox for global documents
203 //----------------------------------------------------------------------------
205 class SwLBoxString
: public SvLBoxString
209 SwLBoxString( SvTreeListEntry
* pEntry
, sal_uInt16 nFlags
,
210 const String
& rStr
) : SvLBoxString(pEntry
,nFlags
,rStr
)
215 const Point
& rPos
, SvTreeListBox
& rDev
, const SvViewDataEntry
* pView
,
216 const SvTreeListEntry
* pEntry
);
219 namespace sfx2
{ class DocumentInserter
; }
220 namespace sfx2
{ class FileDialogHelper
; }
222 class SwGlobalTree
: public SvTreeListBox
225 AutoTimer aUpdateTimer
;
226 String aContextStrings
[GLOBAL_CONTEXT_COUNT
];
228 ImageList aEntryImages
;
230 SwWrtShell
* pActiveShell
; //
231 SvTreeListEntry
* pEmphasisEntry
; // Drag'n Drop emphasis
232 SvTreeListEntry
* pDDSource
; // source for Drag'n Drop
233 SwGlblDocContents
* pSwGlblDocContents
; // array with sorted content
235 Window
* pDefParentWin
;
236 SwGlblDocContent
* pDocContent
;
237 sfx2::DocumentInserter
* pDocInserter
;
239 bool bIsInternalDrag
:1;
240 bool bLastEntryEmphasis
:1; // Drag'n Drop
241 bool bIsImageListInitialized
: 1;
243 static const SfxObjectShell
* pShowShell
;
245 void InsertRegion( const SwGlblDocContent
* _pContent
,
246 const com::sun::star::uno::Sequence
< OUString
>& _rFiles
);
248 DECL_LINK( DialogClosedHdl
, sfx2::FileDialogHelper
* );
250 using SvTreeListBox::DoubleClickHdl
;
251 using SvTreeListBox::ExecuteDrop
;
252 using Window::Update
;
256 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
258 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
260 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
262 virtual void RequestHelp( const HelpEvent
& rHEvt
);
264 virtual long GetTabPos( SvTreeListEntry
*, SvLBoxTab
* );
265 virtual sal_Bool
NotifyMoving( SvTreeListEntry
* pTarget
,
266 SvTreeListEntry
* pEntry
,
267 SvTreeListEntry
*& rpNewParent
,
268 sal_uLong
& rNewChildPos
270 virtual sal_Bool
NotifyCopying( SvTreeListEntry
* pTarget
,
271 SvTreeListEntry
* pEntry
,
272 SvTreeListEntry
*& rpNewParent
,
273 sal_uLong
& rNewChildPos
276 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
277 virtual void DragFinished( sal_Int8
);
278 virtual DragDropMode
NotifyStartDrag( TransferDataContainer
& rData
,
280 virtual sal_Bool
NotifyAcceptDrop( SvTreeListEntry
* );
282 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
283 virtual void KeyInput(const KeyEvent
& rKEvt
);
284 virtual void GetFocus();
285 virtual void SelectHdl();
286 virtual void DeselectHdl();
287 virtual void InitEntry(SvTreeListEntry
*, const OUString
&, const Image
&, const Image
&, SvLBoxButtonKind
);
291 DECL_LINK( PopupHdl
, Menu
* );
292 DECL_LINK( Timeout
, void* );
293 DECL_LINK( DoubleClickHdl
, void* );
295 bool IsInternalDrag() const {return bIsInternalDrag
;}
296 SwNavigationPI
* GetParentWindow()
297 { return (SwNavigationPI
*)Window::GetParent(); }
299 void OpenDoc(const SwGlblDocContent
*);
300 void GotoContent(const SwGlblDocContent
*);
301 sal_uInt16
GetEnableFlags() const;
303 static const SfxObjectShell
* GetShowShell() {return pShowShell
;}
304 static void SetShowShell(const SfxObjectShell
*pSet
) {pShowShell
= pSet
;}
305 DECL_STATIC_LINK(SwGlobalTree
, ShowFrameHdl
, SwGlobalTree
*);
307 virtual PopupMenu
* CreateContextMenu( void );
308 virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
);
311 SwGlobalTree(Window
* pParent
, const ResId
& rResId
);
312 virtual ~SwGlobalTree();
314 void TbxMenuHdl(sal_uInt16 nTbxId
, ToolBox
* pBox
);
315 void InsertRegion( const SwGlblDocContent
* pCont
,
316 const String
* pFileName
= 0 );
317 void EditContent(const SwGlblDocContent
* pCont
);
322 void ExecCommand(sal_uInt16 nCmd
);
324 void Display(bool bOnlyUpdateUserData
= false);
326 sal_Bool
Update(sal_Bool bHard
);
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */