xref: /trunk/main/sw/source/ui/inc/conttree.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONTTREE_HXX
24 #define _CONTTREE_HXX
25 
26 #include <svtools/svtreebx.hxx>
27 #include "swcont.hxx"
28 
29 class SwWrtShell;
30 class SwContentType;
31 class SwNavigationPI;
32 class SwNavigationConfig;
33 class Menu;
34 class ToolBox;
35 class SwGlblDocContents;
36 class SwGlblDocContent;
37 class SfxObjectShell;
38 
39 
40 #define EDIT_MODE_EDIT			0
41 #define EDIT_MODE_UPD_IDX   	1
42 #define EDIT_MODE_RMV_IDX   	2
43 #define EDIT_UNPROTECT_TABLE 	3
44 #define EDIT_MODE_DELETE		4
45 #define EDIT_MODE_RENAME		5
46 
47 //----------------------------------------------------------------------------
48 //----------------------------------------------------------------------------
49 
50 class SwContentTree : public SvTreeListBox
51 {
52 	ImageList			aEntryImages;
53 	String				sSpace;
54 	AutoTimer			aUpdTimer;
55 
56 	SwContentType*		aActiveContentArr[CONTENT_TYPE_MAX];
57 	SwContentType*		aHiddenContentArr[CONTENT_TYPE_MAX];
58 	String				aContextStrings[CONTEXT_COUNT + 1];
59 	String              sRemoveIdx;
60 	String              sUpdateIdx;
61 	String              sUnprotTbl;
62 	String 				sRename;
63 	String				sReadonlyIdx;
64 	String				sInvisible;
65 	String				sPostItShow;
66 	String				sPostItHide;
67 	String				sPostItDelete;
68 
69 	SwWrtShell* 		pHiddenShell;	// gedropptes Doc
70 	SwWrtShell* 		pActiveShell;   // die aktive oder eine konst. offene View
71 	SwNavigationConfig*	pConfig;
72 
73     sal_Int32           nActiveBlock;
74 	sal_uInt16				nHiddenBlock;
75 	sal_uInt16 				nRootType;
76 	sal_uInt16				nLastSelType;
77 	sal_uInt8				nOutlineLevel;
78 
79 	sal_Bool				bIsActive 			:1;
80 	sal_Bool				bIsConstant 		:1;
81 	sal_Bool 				bIsHidden			:1;
82 	sal_Bool				bDocChgdInDragging  :1;
83 	sal_Bool 				bIsInternalDrag 	:1;
84 	sal_Bool				bIsRoot	  			:1;
85 	sal_Bool				bIsIdleClear		:1;
86 	sal_Bool				bIsLastReadOnly		:1;
87 	sal_Bool				bIsOutlineMoveable	:1;
88 	sal_Bool				bViewHasChanged  	:1;
89 	sal_Bool				bIsImageListInitialized : 1;
90 
91 	static sal_Bool			bIsInDrag;
92 
93 	void 				FindActiveTypeAndRemoveUserData();
94 
95     using SvLBox::ExecuteDrop;
96     using SvTreeListBox::EditEntry;
97     using SvListView::Expand;
98     using SvListView::Collapse;
99     using SvListView::Select;
100 
101 protected:
102 //  virtual void    Command( const CommandEvent& rCEvt );
103 	virtual void	RequestHelp( const HelpEvent& rHEvt );
104 	virtual void 	InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
105     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
106 
107 	SwNavigationPI* GetParentWindow(){return
108 						(SwNavigationPI*)Window::GetParent();}
109 
110 	virtual void 	StartDrag( sal_Int8 nAction, const Point& rPosPixel );
111 	virtual void 	DragFinished( sal_Int8 );
112 	virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
113 
114 	virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
115 
116 	sal_Bool 		FillTransferData( TransferDataContainer& rTransfer,
117 											sal_Int8& rDragMode );
118 	sal_Bool			HasContentChanged();
119 
120 	virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
121 										SvLBoxEntry* );
122 	virtual sal_Bool    NotifyAcceptDrop( SvLBoxEntry* );
123 
124 	virtual sal_Bool    NotifyMoving(   SvLBoxEntry*  pTarget,
125 									SvLBoxEntry*  pEntry,
126 									SvLBoxEntry*& rpNewParent,
127 									sal_uLong&        rNewChildPos
128 								);
129 	virtual sal_Bool    NotifyCopying(  SvLBoxEntry*  pTarget,
130 									SvLBoxEntry*  pEntry,
131 									SvLBoxEntry*& rpNewParent,
132 									sal_uLong&        rNewChildPos
133 								);
134 	virtual void    MouseButtonDown( const MouseEvent& rMEvt );
135 
136 	void			EditEntry( SvLBoxEntry* pEntry, sal_uInt8 nMode );
137 
138 	void			GotoContent(SwContent* pCnt);
139 	static void 	SetInDrag(sal_Bool bSet) {bIsInDrag = bSet;}
140 
141     virtual PopupMenu* CreateContextMenu( void );
142     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
143 
144 public:
145 	SwContentTree(Window* pParent, const ResId& rResId);
146 	~SwContentTree();
147 
148 	sal_Bool			ToggleToRoot();
149 	sal_Bool 			IsRoot() const {return bIsRoot;}
150 	sal_uInt16 			GetRootType() const {return nRootType;}
151 	void 			SetRootType(sal_uInt16 nType);
152 	void 			Display( sal_Bool bActiveView );
153 	void			Clear();
154 	void 			SetHiddenShell(SwWrtShell* pSh);
155 	void 			ShowHiddenShell();
156 	void			ShowActualView();
157 	void 			SetActiveShell(SwWrtShell* pSh);
158 	void			SetConstantShell(SwWrtShell* pSh);
159 
160 	SwWrtShell* 	GetWrtShell()
161 						{return bIsActive||bIsConstant ?
162 									pActiveShell :
163 										pHiddenShell;}
164 
165 	static sal_Bool 	IsInDrag() {return bIsInDrag;}
166 	sal_Bool			IsInternalDrag() const {return bIsInternalDrag != 0;}
167 
168     sal_Int32       GetActiveBlock() const {return nActiveBlock;}
169 
170 	sal_uInt8 			GetOutlineLevel()const {return nOutlineLevel;}
171 	void			SetOutlineLevel(sal_uInt8 nSet);
172 
173 	sal_Bool			Expand( SvLBoxEntry* pParent );
174 
175 	sal_Bool			Collapse( SvLBoxEntry* pParent );
176 
177 	void 			ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier);
178 
179 	void			ShowTree();
180 	void			HideTree();
181 
182 	sal_Bool			IsConstantView() {return bIsConstant;}
183 	sal_Bool			IsActiveView()	 {return bIsActive;}
184 	sal_Bool 			IsHiddenView()	 {return bIsHidden;}
185 
186 	const SwWrtShell* 	GetActiveWrtShell() {return pActiveShell;}
187 	SwWrtShell*			GetHiddenWrtShell() {return pHiddenShell;}
188 
189 	DECL_LINK( ContentDoubleClickHdl, SwContentTree * );
190 //  DECL_LINK( PopupHdl, Menu* );
191 	DECL_LINK( TimerUpdate, Timer * );
192 
193 	virtual long    GetTabPos( SvLBoxEntry*, SvLBoxTab* );
194 	virtual void	RequestingChilds( SvLBoxEntry* pParent );
195 	virtual void    GetFocus();
196 	virtual void    KeyInput(const KeyEvent& rKEvt);
197 
198 	virtual sal_Bool	Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
199 };
200 
201 
202 //----------------------------------------------------------------------------
203 // TreeListBox fuer Globaldokumente
204 //----------------------------------------------------------------------------
205 
206 class SwLBoxString : public SvLBoxString
207 {
208 public:
209 
210 	SwLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
211 		const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
212 	{
213 	}
214 
215 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
216 		SvLBoxEntry* pEntry);
217 };
218 
219 namespace sfx2 { class DocumentInserter; }
220 namespace sfx2 { class FileDialogHelper; }
221 
222 class SwGlobalTree : public SvTreeListBox
223 {
224 private:
225 	AutoTimer			aUpdateTimer;
226 	String				aContextStrings[GLOBAL_CONTEXT_COUNT];
227 
228 	ImageList			aEntryImages;
229 
230     SwWrtShell*             pActiveShell;   //
231     SvLBoxEntry*            pEmphasisEntry; // Drag'n Drop-Emphasis
232     SvLBoxEntry*            pDDSource;      // Quelle beim DnD
233     SwGlblDocContents*      pSwGlblDocContents; // Array mit sortierten Inhalten
234 
235     Window*                 pDefParentWin;
236     SwGlblDocContent*       pDocContent;
237     sfx2::DocumentInserter* pDocInserter;
238 
239 	sal_Bool 				bIsInternalDrag 	:1;
240 	sal_Bool 				bLastEntryEmphasis 	:1; // Drag'n Drop
241 	sal_Bool				bIsImageListInitialized : 1;
242 
243 	static const SfxObjectShell* pShowShell;
244 
245     void        InsertRegion( const SwGlblDocContent* _pContent,
246                               const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles );
247 
248     DECL_LINK(  DialogClosedHdl, sfx2::FileDialogHelper* );
249 
250     using SvLBox::DoubleClickHdl;
251     using SvLBox::ExecuteDrop;
252     using Window::Update;
253 
254 protected:
255 
256 	virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
257 
258 	virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
259 
260     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
261 
262 	virtual void	RequestHelp( const HelpEvent& rHEvt );
263 
264 	virtual long    GetTabPos( SvLBoxEntry*, SvLBoxTab* );
265 	virtual sal_Bool    NotifyMoving(   SvLBoxEntry*  pTarget,
266 									SvLBoxEntry*  pEntry,
267 									SvLBoxEntry*& rpNewParent,
268 									sal_uLong&        rNewChildPos
269 								);
270 	virtual sal_Bool    NotifyCopying(  SvLBoxEntry*  pTarget,
271 									SvLBoxEntry*  pEntry,
272 									SvLBoxEntry*& rpNewParent,
273 									sal_uLong&        rNewChildPos
274 								);
275 
276 	virtual void 	StartDrag( sal_Int8 nAction, const Point& rPosPixel );
277 	virtual void 	DragFinished( sal_Int8 );
278 	virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
279 										SvLBoxEntry* );
280 	virtual sal_Bool    NotifyAcceptDrop( SvLBoxEntry* );
281 
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(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
288 
289 	void			Clear();
290 
291 	DECL_LINK( 		PopupHdl, Menu* );
292 	DECL_LINK( 		Timeout, Timer* );
293 	DECL_LINK( 		DoubleClickHdl, SwGlobalTree * );
294 
295 	sal_Bool			IsInternalDrag() const {return bIsInternalDrag != 0;}
296 	SwNavigationPI* GetParentWindow()
297 						{ return (SwNavigationPI*)Window::GetParent(); }
298 
299 	void 			OpenDoc(const SwGlblDocContent*);
300 	void 			GotoContent(const SwGlblDocContent*);
301 	sal_uInt16			GetEnableFlags() const;
302 
303 	static const SfxObjectShell* 	GetShowShell() {return pShowShell;}
304 	static void 	SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
305 	DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
306 
307     virtual PopupMenu* CreateContextMenu( void );
308     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
309 
310 public:
311 	SwGlobalTree(Window* pParent, const ResId& rResId);
312 	virtual ~SwGlobalTree();
313 
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 );
318 
319 	void				ShowTree();
320 	void				HideTree();
321 
322 	void 				ExecCommand(sal_uInt16 nCmd);
323 
324 	void 				Display(sal_Bool bOnlyUpdateUserData = sal_False);
325 
326 	sal_Bool 				Update(sal_Bool bHard);
327 };
328 
329 #endif
330 
331