Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _CONTTREE_HXX
29 : : #define _CONTTREE_HXX
30 : :
31 : : #include <svtools/svtreebx.hxx>
32 : : #include "swcont.hxx"
33 : :
34 : : #include <map>
35 : :
36 : : class SwWrtShell;
37 : : class SwContentType;
38 : : class SwNavigationPI;
39 : : class SwNavigationConfig;
40 : : class Menu;
41 : : class ToolBox;
42 : : class SwGlblDocContents;
43 : : class SwGlblDocContent;
44 : : class SfxObjectShell;
45 : :
46 : :
47 : : #define EDIT_MODE_EDIT 0
48 : : #define EDIT_MODE_UPD_IDX 1
49 : : #define EDIT_MODE_RMV_IDX 2
50 : : #define EDIT_UNPROTECT_TABLE 3
51 : : #define EDIT_MODE_DELETE 4
52 : : #define EDIT_MODE_RENAME 5
53 : :
54 : : //----------------------------------------------------------------------------
55 : : //----------------------------------------------------------------------------
56 : :
57 : : class SwContentTree : public SvTreeListBox
58 : : {
59 : : ImageList aEntryImages;
60 : : String sSpace;
61 : : AutoTimer aUpdTimer;
62 : :
63 : : SwContentType* aActiveContentArr[CONTENT_TYPE_MAX];
64 : : SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX];
65 : : String aContextStrings[CONTEXT_COUNT + 1];
66 : : String sRemoveIdx;
67 : : String sUpdateIdx;
68 : : String sUnprotTbl;
69 : : String sRename;
70 : : String sReadonlyIdx;
71 : : String sInvisible;
72 : : String sPostItShow;
73 : : String sPostItHide;
74 : : String sPostItDelete;
75 : :
76 : : SwWrtShell* pHiddenShell; // dropped Doc
77 : : SwWrtShell* pActiveShell; // the active or a const. open view
78 : : SwNavigationConfig* pConfig;
79 : :
80 : : std::map< void*, sal_Bool > mOutLineNodeMap;
81 : :
82 : : sal_Int32 nActiveBlock;
83 : : sal_uInt16 nHiddenBlock;
84 : : sal_uInt16 nRootType;
85 : : sal_uInt16 nLastSelType;
86 : : sal_uInt8 nOutlineLevel;
87 : :
88 : : sal_Bool bIsActive :1;
89 : : sal_Bool bIsConstant :1;
90 : : sal_Bool bIsHidden :1;
91 : : sal_Bool bDocChgdInDragging :1;
92 : : sal_Bool bIsInternalDrag :1;
93 : : sal_Bool bIsRoot :1;
94 : : sal_Bool bIsIdleClear :1;
95 : : sal_Bool bIsLastReadOnly :1;
96 : : sal_Bool bIsOutlineMoveable :1;
97 : : sal_Bool bViewHasChanged :1;
98 : : sal_Bool bIsImageListInitialized : 1;
99 : :
100 : : static sal_Bool bIsInDrag;
101 : :
102 : : void FindActiveTypeAndRemoveUserData();
103 : :
104 : : using SvLBox::ExecuteDrop;
105 : : using SvTreeListBox::EditEntry;
106 : : using SvListView::Expand;
107 : : using SvListView::Collapse;
108 : : using SvListView::Select;
109 : :
110 : : protected:
111 : : virtual void RequestHelp( const HelpEvent& rHEvt );
112 : : virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
113 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
114 : :
115 : 0 : SwNavigationPI* GetParentWindow(){return
116 : 0 : (SwNavigationPI*)Window::GetParent();}
117 : :
118 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
119 : : virtual void DragFinished( sal_Int8 );
120 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
121 : :
122 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
123 : :
124 : : sal_Bool FillTransferData( TransferDataContainer& rTransfer,
125 : : sal_Int8& rDragMode );
126 : : sal_Bool HasContentChanged();
127 : :
128 : : virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
129 : : SvLBoxEntry* );
130 : : virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* );
131 : :
132 : : virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget,
133 : : SvLBoxEntry* pEntry,
134 : : SvLBoxEntry*& rpNewParent,
135 : : sal_uLong& rNewChildPos
136 : : );
137 : : virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget,
138 : : SvLBoxEntry* pEntry,
139 : : SvLBoxEntry*& rpNewParent,
140 : : sal_uLong& rNewChildPos
141 : : );
142 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
143 : :
144 : : void EditEntry( SvLBoxEntry* pEntry, sal_uInt8 nMode );
145 : :
146 : : void GotoContent(SwContent* pCnt);
147 : 0 : static void SetInDrag(sal_Bool bSet) {bIsInDrag = bSet;}
148 : :
149 : : virtual PopupMenu* CreateContextMenu( void );
150 : : virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
151 : :
152 : : public:
153 : : SwContentTree(Window* pParent, const ResId& rResId);
154 : : ~SwContentTree();
155 : :
156 : : sal_Bool ToggleToRoot();
157 : : sal_Bool IsRoot() const {return bIsRoot;}
158 : : sal_uInt16 GetRootType() const {return nRootType;}
159 : : void SetRootType(sal_uInt16 nType);
160 : : void Display( sal_Bool bActiveView );
161 : : void Clear();
162 : : void SetHiddenShell(SwWrtShell* pSh);
163 : : void ShowHiddenShell();
164 : : void ShowActualView();
165 : : void SetActiveShell(SwWrtShell* pSh);
166 : : void SetConstantShell(SwWrtShell* pSh);
167 : :
168 : 0 : SwWrtShell* GetWrtShell()
169 : : {return bIsActive||bIsConstant ?
170 : : pActiveShell :
171 [ # # ][ # # ]: 0 : pHiddenShell;}
172 : :
173 : 0 : static sal_Bool IsInDrag() {return bIsInDrag;}
174 : : sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;}
175 : :
176 : : sal_Int32 GetActiveBlock() const {return nActiveBlock;}
177 : :
178 : 0 : sal_uInt8 GetOutlineLevel()const {return nOutlineLevel;}
179 : : void SetOutlineLevel(sal_uInt8 nSet);
180 : :
181 : : sal_Bool Expand( SvLBoxEntry* pParent );
182 : :
183 : : sal_Bool Collapse( SvLBoxEntry* pParent );
184 : :
185 : : void ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier);
186 : :
187 : : void ShowTree();
188 : : void HideTree();
189 : :
190 : 0 : sal_Bool IsConstantView() {return bIsConstant;}
191 : 0 : sal_Bool IsActiveView() {return bIsActive;}
192 : 0 : sal_Bool IsHiddenView() {return bIsHidden;}
193 : :
194 : 0 : const SwWrtShell* GetActiveWrtShell() {return pActiveShell;}
195 : 0 : SwWrtShell* GetHiddenWrtShell() {return pHiddenShell;}
196 : :
197 : : DECL_LINK( ContentDoubleClickHdl, void * );
198 : : DECL_LINK( TimerUpdate, void * );
199 : :
200 : : virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
201 : : virtual void RequestingChildren( SvLBoxEntry* pParent );
202 : : virtual void GetFocus();
203 : : virtual void KeyInput(const KeyEvent& rKEvt);
204 : :
205 : : virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
206 : : };
207 : :
208 : :
209 : : //----------------------------------------------------------------------------
210 : : // TreeListBox for global documents
211 : : //----------------------------------------------------------------------------
212 : :
213 [ # # ]: 0 : class SwLBoxString : public SvLBoxString
214 : : {
215 : : public:
216 : :
217 : 0 : SwLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
218 [ # # ]: 0 : const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
219 : : {
220 : 0 : }
221 : :
222 : : virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
223 : : SvLBoxEntry* pEntry);
224 : : };
225 : :
226 : : namespace sfx2 { class DocumentInserter; }
227 : : namespace sfx2 { class FileDialogHelper; }
228 : :
229 : : class SwGlobalTree : public SvTreeListBox
230 : : {
231 : : private:
232 : : AutoTimer aUpdateTimer;
233 : : String aContextStrings[GLOBAL_CONTEXT_COUNT];
234 : :
235 : : ImageList aEntryImages;
236 : :
237 : : SwWrtShell* pActiveShell; //
238 : : SvLBoxEntry* pEmphasisEntry; // Drag'n Drop emphasis
239 : : SvLBoxEntry* pDDSource; // source for Drag'n Drop
240 : : SwGlblDocContents* pSwGlblDocContents; // array with sorted content
241 : :
242 : : Window* pDefParentWin;
243 : : SwGlblDocContent* pDocContent;
244 : : sfx2::DocumentInserter* pDocInserter;
245 : :
246 : : sal_Bool bIsInternalDrag :1;
247 : : sal_Bool bLastEntryEmphasis :1; // Drag'n Drop
248 : : sal_Bool bIsImageListInitialized : 1;
249 : :
250 : : static const SfxObjectShell* pShowShell;
251 : :
252 : : void InsertRegion( const SwGlblDocContent* _pContent,
253 : : const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles );
254 : :
255 : : DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
256 : :
257 : : using SvLBox::DoubleClickHdl;
258 : : using SvLBox::ExecuteDrop;
259 : : using Window::Update;
260 : :
261 : : protected:
262 : :
263 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
264 : :
265 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
266 : :
267 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
268 : :
269 : : virtual void RequestHelp( const HelpEvent& rHEvt );
270 : :
271 : : virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* );
272 : : virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget,
273 : : SvLBoxEntry* pEntry,
274 : : SvLBoxEntry*& rpNewParent,
275 : : sal_uLong& rNewChildPos
276 : : );
277 : : virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget,
278 : : SvLBoxEntry* pEntry,
279 : : SvLBoxEntry*& rpNewParent,
280 : : sal_uLong& rNewChildPos
281 : : );
282 : :
283 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
284 : : virtual void DragFinished( sal_Int8 );
285 : : virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
286 : : SvLBoxEntry* );
287 : : virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* );
288 : :
289 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
290 : : virtual void KeyInput(const KeyEvent& rKEvt);
291 : : virtual void GetFocus();
292 : : virtual void SelectHdl();
293 : : virtual void DeselectHdl();
294 : : virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
295 : :
296 : : void Clear();
297 : :
298 : : DECL_LINK( PopupHdl, Menu* );
299 : : DECL_LINK( Timeout, void* );
300 : : DECL_LINK( DoubleClickHdl, void* );
301 : :
302 : : sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;}
303 : 0 : SwNavigationPI* GetParentWindow()
304 : 0 : { return (SwNavigationPI*)Window::GetParent(); }
305 : :
306 : : void OpenDoc(const SwGlblDocContent*);
307 : : void GotoContent(const SwGlblDocContent*);
308 : : sal_uInt16 GetEnableFlags() const;
309 : :
310 : 0 : static const SfxObjectShell* GetShowShell() {return pShowShell;}
311 : 0 : static void SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
312 : : DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
313 : :
314 : : virtual PopupMenu* CreateContextMenu( void );
315 : : virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
316 : :
317 : : public:
318 : : SwGlobalTree(Window* pParent, const ResId& rResId);
319 : : virtual ~SwGlobalTree();
320 : :
321 : : void TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox);
322 : : void InsertRegion( const SwGlblDocContent* pCont,
323 : : const String* pFileName = 0 );
324 : : void EditContent(const SwGlblDocContent* pCont );
325 : :
326 : : void ShowTree();
327 : : void HideTree();
328 : :
329 : : void ExecCommand(sal_uInt16 nCmd);
330 : :
331 : : void Display(sal_Bool bOnlyUpdateUserData = sal_False);
332 : :
333 : : sal_Bool Update(sal_Bool bHard);
334 : : };
335 : :
336 : : #endif
337 : :
338 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|