update dev300-m58
[ooovba.git] / sw / source / ui / inc / conttree.hxx
blobb79757556019ebded4cce69b7fe11596b82c9a7d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conttree.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CONTTREE_HXX
31 #define _CONTTREE_HXX
33 #include <svtools/svtreebx.hxx>
34 #include "swcont.hxx"
36 #include<map>
37 //using namespace std;
39 class SwWrtShell;
40 class SwContentType;
41 class SwNavigationPI;
42 class SwNavigationConfig;
43 class Menu;
44 class ToolBox;
45 class SwGlblDocContents;
46 class SwGlblDocContent;
47 class SfxObjectShell;
50 #define EDIT_MODE_EDIT 0
51 #define EDIT_MODE_UPD_IDX 1
52 #define EDIT_MODE_RMV_IDX 2
53 #define EDIT_UNPROTECT_TABLE 3
54 #define EDIT_MODE_DELETE 4
55 #define EDIT_MODE_RENAME 5
57 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
60 class SwContentTree : public SvTreeListBox
62 ImageList aEntryImages;
63 String sSpace;
64 AutoTimer aUpdTimer;
66 SwContentType* aActiveContentArr[CONTENT_TYPE_MAX];
67 SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX];
68 String aContextStrings[CONTEXT_COUNT + 1];
69 String sRemoveIdx;
70 String sUpdateIdx;
71 String sUnprotTbl;
72 String sRename;
73 String sReadonlyIdx;
74 String sInvisible;
75 String sPostItShow;
76 String sPostItHide;
77 String sPostItDelete;
79 SwWrtShell* pHiddenShell; // gedropptes Doc
80 SwWrtShell* pActiveShell; // die aktive oder eine konst. offene View
81 SwNavigationConfig* pConfig;
83 std::map< void*, sal_Bool > mOutLineNodeMap;
85 sal_Int32 nActiveBlock;
86 USHORT nHiddenBlock;
87 USHORT nRootType;
88 USHORT nLastSelType;
89 BYTE nOutlineLevel;
91 BOOL bIsActive :1;
92 BOOL bIsConstant :1;
93 BOOL bIsHidden :1;
94 BOOL bDocChgdInDragging :1;
95 BOOL bIsInternalDrag :1;
96 BOOL bIsRoot :1;
97 BOOL bIsIdleClear :1;
98 BOOL bIsLastReadOnly :1;
99 BOOL bIsOutlineMoveable :1;
100 BOOL bViewHasChanged :1;
101 BOOL bIsImageListInitialized : 1;
103 static BOOL bIsInDrag;
105 void FindActiveTypeAndRemoveUserData();
107 using SvLBox::ExecuteDrop;
108 using SvTreeListBox::EditEntry;
109 using SvListView::Expand;
110 using SvListView::Collapse;
111 using SvListView::Select;
113 protected:
114 // virtual void Command( const CommandEvent& rCEvt );
115 virtual void RequestHelp( const HelpEvent& rHEvt );
116 virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
117 virtual void DataChanged( const DataChangedEvent& rDCEvt );
119 SwNavigationPI* GetParentWindow(){return
120 (SwNavigationPI*)Window::GetParent();}
122 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
123 virtual void DragFinished( sal_Int8 );
124 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
126 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
128 sal_Bool FillTransferData( TransferDataContainer& rTransfer,
129 sal_Int8& rDragMode );
130 BOOL HasContentChanged();
132 virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
133 SvLBoxEntry* );
134 virtual BOOL NotifyAcceptDrop( SvLBoxEntry* );
136 virtual BOOL NotifyMoving( SvLBoxEntry* pTarget,
137 SvLBoxEntry* pEntry,
138 SvLBoxEntry*& rpNewParent,
139 ULONG& rNewChildPos
141 virtual BOOL NotifyCopying( SvLBoxEntry* pTarget,
142 SvLBoxEntry* pEntry,
143 SvLBoxEntry*& rpNewParent,
144 ULONG& rNewChildPos
146 virtual void MouseButtonDown( const MouseEvent& rMEvt );
148 void EditEntry( SvLBoxEntry* pEntry, BYTE nMode );
150 void GotoContent(SwContent* pCnt);
151 static void SetInDrag(BOOL bSet) {bIsInDrag = bSet;}
153 virtual PopupMenu* CreateContextMenu( void );
154 virtual void ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );
156 public:
157 SwContentTree(Window* pParent, const ResId& rResId);
158 ~SwContentTree();
160 BOOL ToggleToRoot();
161 BOOL IsRoot() const {return bIsRoot;}
162 USHORT GetRootType() const {return nRootType;}
163 void SetRootType(USHORT nType);
164 void Display( BOOL bActiveView );
165 void Clear();
166 void SetHiddenShell(SwWrtShell* pSh);
167 void ShowHiddenShell();
168 void ShowActualView();
169 void SetActiveShell(SwWrtShell* pSh);
170 void SetConstantShell(SwWrtShell* pSh);
172 SwWrtShell* GetWrtShell()
173 {return bIsActive||bIsConstant ?
174 pActiveShell :
175 pHiddenShell;}
177 static BOOL IsInDrag() {return bIsInDrag;}
178 BOOL IsInternalDrag() const {return bIsInternalDrag != 0;}
180 sal_Int32 GetActiveBlock() const {return nActiveBlock;}
182 BYTE GetOutlineLevel()const {return nOutlineLevel;}
183 void SetOutlineLevel(BYTE nSet);
185 BOOL Expand( SvLBoxEntry* pParent );
187 BOOL Collapse( SvLBoxEntry* pParent );
189 void ExecCommand(USHORT nCmd, BOOL bModifier);
191 void ShowTree();
192 void HideTree();
194 BOOL IsConstantView() {return bIsConstant;}
195 BOOL IsActiveView() {return bIsActive;}
196 BOOL IsHiddenView() {return bIsHidden;}
198 const SwWrtShell* GetActiveWrtShell() {return pActiveShell;}
199 SwWrtShell* GetHiddenWrtShell() {return pHiddenShell;}
201 DECL_LINK( ContentDoubleClickHdl, SwContentTree * );
202 // DECL_LINK( PopupHdl, Menu* );
203 DECL_LINK( TimerUpdate, Timer * );
205 virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
206 virtual void RequestingChilds( SvLBoxEntry* pParent );
207 virtual void GetFocus();
208 virtual void KeyInput(const KeyEvent& rKEvt);
210 virtual BOOL Select( SvLBoxEntry* pEntry, BOOL bSelect=TRUE );
214 //----------------------------------------------------------------------------
215 // TreeListBox fuer Globaldokumente
216 //----------------------------------------------------------------------------
218 class SwLBoxString : public SvLBoxString
220 public:
222 SwLBoxString( SvLBoxEntry* pEntry, USHORT nFlags,
223 const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
227 virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
228 SvLBoxEntry* pEntry);
231 namespace sfx2 { class DocumentInserter; }
232 namespace sfx2 { class FileDialogHelper; }
234 class SwGlobalTree : public SvTreeListBox
236 private:
237 AutoTimer aUpdateTimer;
238 String aContextStrings[GLOBAL_CONTEXT_COUNT];
240 ImageList aEntryImages;
242 SwWrtShell* pActiveShell; //
243 SvLBoxEntry* pEmphasisEntry; // Drag'n Drop-Emphasis
244 SvLBoxEntry* pDDSource; // Quelle beim DnD
245 SwGlblDocContents* pSwGlblDocContents; // Array mit sortierten Inhalten
247 Window* pDefParentWin;
248 SwGlblDocContent* pDocContent;
249 sfx2::DocumentInserter* pDocInserter;
251 BOOL bIsInternalDrag :1;
252 BOOL bLastEntryEmphasis :1; // Drag'n Drop
253 BOOL bIsImageListInitialized : 1;
255 static const SfxObjectShell* pShowShell;
257 void InsertRegion( const SwGlblDocContent* _pContent,
258 const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles );
260 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
262 using SvLBox::DoubleClickHdl;
263 using SvLBox::ExecuteDrop;
264 using Window::Update;
266 protected:
268 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
270 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
272 virtual void DataChanged( const DataChangedEvent& rDCEvt );
274 virtual void RequestHelp( const HelpEvent& rHEvt );
276 virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
277 virtual BOOL NotifyMoving( SvLBoxEntry* pTarget,
278 SvLBoxEntry* pEntry,
279 SvLBoxEntry*& rpNewParent,
280 ULONG& rNewChildPos
282 virtual BOOL NotifyCopying( SvLBoxEntry* pTarget,
283 SvLBoxEntry* pEntry,
284 SvLBoxEntry*& rpNewParent,
285 ULONG& rNewChildPos
288 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
289 virtual void DragFinished( sal_Int8 );
290 virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
291 SvLBoxEntry* );
292 virtual BOOL NotifyAcceptDrop( SvLBoxEntry* );
294 virtual void MouseButtonDown( const MouseEvent& rMEvt );
295 virtual void KeyInput(const KeyEvent& rKEvt);
296 virtual void GetFocus();
297 virtual void SelectHdl();
298 virtual void DeselectHdl();
299 virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
301 void Clear();
303 DECL_LINK( PopupHdl, Menu* );
304 DECL_LINK( Timeout, Timer* );
305 DECL_LINK( DoubleClickHdl, SwGlobalTree * );
307 BOOL IsInternalDrag() const {return bIsInternalDrag != 0;}
308 SwNavigationPI* GetParentWindow()
309 { return (SwNavigationPI*)Window::GetParent(); }
311 void OpenDoc(const SwGlblDocContent*);
312 void GotoContent(const SwGlblDocContent*);
313 USHORT GetEnableFlags() const;
315 static const SfxObjectShell* GetShowShell() {return pShowShell;}
316 static void SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
317 DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
319 virtual PopupMenu* CreateContextMenu( void );
320 virtual void ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );
322 public:
323 SwGlobalTree(Window* pParent, const ResId& rResId);
324 virtual ~SwGlobalTree();
326 void TbxMenuHdl(USHORT nTbxId, ToolBox* pBox);
327 void InsertRegion( const SwGlblDocContent* pCont,
328 const String* pFileName = 0 );
329 void EditContent(const SwGlblDocContent* pCont );
331 void ShowTree();
332 void HideTree();
334 void ExecCommand(USHORT nCmd);
336 void Display(BOOL bOnlyUpdateUserData = FALSE);
338 BOOL Update(BOOL bHard);
341 #endif