xref: /AOO41X/main/sw/source/ui/inc/conttree.hxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
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 //IAccessibility2 Implementation 2009-----
40 //Solution:  Include  SdrObject  class
41 class SdrObject;
42 //-----IAccessibility2 Implementation 2009
43 
44 #define EDIT_MODE_EDIT			0
45 #define EDIT_MODE_UPD_IDX   	1
46 #define EDIT_MODE_RMV_IDX   	2
47 #define EDIT_UNPROTECT_TABLE 	3
48 #define EDIT_MODE_DELETE		4
49 #define EDIT_MODE_RENAME		5
50 
51 //----------------------------------------------------------------------------
52 //----------------------------------------------------------------------------
53 
54 class SwContentTree : public SvTreeListBox
55 {
56 	ImageList			aEntryImages;
57 	String				sSpace;
58 	AutoTimer			aUpdTimer;
59 
60 	SwContentType*		aActiveContentArr[CONTENT_TYPE_MAX];
61 	SwContentType*		aHiddenContentArr[CONTENT_TYPE_MAX];
62 	String				aContextStrings[CONTEXT_COUNT + 1];
63 	String              sRemoveIdx;
64 	String              sUpdateIdx;
65 	String              sUnprotTbl;
66 	String 				sRename;
67 	String				sReadonlyIdx;
68 	String				sInvisible;
69 	String				sPostItShow;
70 	String				sPostItHide;
71 	String				sPostItDelete;
72 
73 	SwWrtShell* 		pHiddenShell;	// gedropptes Doc
74 	SwWrtShell* 		pActiveShell;   // die aktive oder eine konst. offene View
75 	SwNavigationConfig*	pConfig;
76 
77     sal_Int32           nActiveBlock;
78 	sal_uInt16				nHiddenBlock;
79 	sal_uInt16 				nRootType;
80 	sal_uInt16				nLastSelType;
81 	sal_uInt8				nOutlineLevel;
82 
83 	sal_Bool				bIsActive 			:1;
84 	sal_Bool				bIsConstant 		:1;
85 	sal_Bool 				bIsHidden			:1;
86 	sal_Bool				bDocChgdInDragging  :1;
87 	sal_Bool 				bIsInternalDrag 	:1;
88 	sal_Bool				bIsRoot	  			:1;
89 	sal_Bool				bIsIdleClear		:1;
90 	sal_Bool				bIsLastReadOnly		:1;
91 	sal_Bool				bIsOutlineMoveable	:1;
92 	sal_Bool				bViewHasChanged  	:1;
93 	sal_Bool				bIsImageListInitialized : 1;
94 
95 	static sal_Bool			bIsInDrag;
96 	//IAccessibility2 Implementation 2009-----
97 	sal_Bool                bIsKeySpace;
98 	Rectangle 		    oldRectangle;
99 	//-----IAccessibility2 Implementation 2009
100 	void 				FindActiveTypeAndRemoveUserData();
101 
102     using SvLBox::ExecuteDrop;
103     using SvTreeListBox::EditEntry;
104     using SvListView::Expand;
105     using SvListView::Collapse;
106     using SvListView::Select;
107 
108 protected:
109 //  virtual void    Command( const CommandEvent& rCEvt );
110 	virtual void	RequestHelp( const HelpEvent& rHEvt );
111 	virtual void 	InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
112     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
113 
114 	SwNavigationPI* GetParentWindow(){return
115 						(SwNavigationPI*)Window::GetParent();}
116 
117 	virtual void 	StartDrag( sal_Int8 nAction, const Point& rPosPixel );
118 	virtual void 	DragFinished( sal_Int8 );
119 	virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
120 
121 	virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
122 
123 	sal_Bool 		FillTransferData( TransferDataContainer& rTransfer,
124 											sal_Int8& rDragMode );
125 	sal_Bool			HasContentChanged();
126 
127 	virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
128 										SvLBoxEntry* );
129 	virtual sal_Bool    NotifyAcceptDrop( SvLBoxEntry* );
130 
131 	virtual sal_Bool    NotifyMoving(   SvLBoxEntry*  pTarget,
132 									SvLBoxEntry*  pEntry,
133 									SvLBoxEntry*& rpNewParent,
134 									sal_uLong&        rNewChildPos
135 								);
136 	virtual sal_Bool    NotifyCopying(  SvLBoxEntry*  pTarget,
137 									SvLBoxEntry*  pEntry,
138 									SvLBoxEntry*& rpNewParent,
139 									sal_uLong&        rNewChildPos
140 								);
141 	virtual void    MouseButtonDown( const MouseEvent& rMEvt );
142 
143 	void			EditEntry( SvLBoxEntry* pEntry, sal_uInt8 nMode );
144 
145 	void			GotoContent(SwContent* pCnt);
146 	static void 	SetInDrag(sal_Bool bSet) {bIsInDrag = bSet;}
147 
148     virtual PopupMenu* CreateContextMenu( void );
149     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
150 
151 public:
152 	SwContentTree(Window* pParent, const ResId& rResId);
153 	~SwContentTree();
154 	//IAccessibility2 Implementation 2009-----
155 	String  		GetEntryAltText( SvLBoxEntry* pEntry ) const;
156 	String  		GetEntryLongDescription( SvLBoxEntry* pEntry ) const;
157 	SdrObject* 	GetDrawingObjectsByContent(const SwContent *pCnt);
158 	//-----IAccessibility2 Implementation 2009
159 
160 	sal_Bool			ToggleToRoot();
161 	sal_Bool 			IsRoot() const {return bIsRoot;}
162 	sal_uInt16 			GetRootType() const {return nRootType;}
163 	void 			SetRootType(sal_uInt16 nType);
164 	void 			Display( sal_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);
171 
172 	SwWrtShell* 	GetWrtShell()
173 						{return bIsActive||bIsConstant ?
174 									pActiveShell :
175 										pHiddenShell;}
176 
177 	static sal_Bool 	IsInDrag() {return bIsInDrag;}
178 	sal_Bool			IsInternalDrag() const {return bIsInternalDrag != 0;}
179 
180     sal_Int32       GetActiveBlock() const {return nActiveBlock;}
181 
182 	sal_uInt8 			GetOutlineLevel()const {return nOutlineLevel;}
183 	void			SetOutlineLevel(sal_uInt8 nSet);
184 
185 	sal_Bool			Expand( SvLBoxEntry* pParent );
186 
187 	sal_Bool			Collapse( SvLBoxEntry* pParent );
188 
189 	void 			ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier);
190 
191 	void			ShowTree();
192 	void			HideTree();
193 
194 	sal_Bool			IsConstantView() {return bIsConstant;}
195 	sal_Bool			IsActiveView()	 {return bIsActive;}
196 	sal_Bool 			IsHiddenView()	 {return bIsHidden;}
197 
198 	const SwWrtShell* 	GetActiveWrtShell() {return pActiveShell;}
199 	SwWrtShell*			GetHiddenWrtShell() {return pHiddenShell;}
200 
201 	DECL_LINK( ContentDoubleClickHdl, SwContentTree * );
202 //  DECL_LINK( PopupHdl, Menu* );
203 	DECL_LINK( TimerUpdate, Timer * );
204 
205 	virtual long    GetTabPos( SvLBoxEntry*, SvLBoxTab* );
206 	virtual void	RequestingChilds( SvLBoxEntry* pParent );
207 	virtual void    GetFocus();
208 	virtual void    KeyInput(const KeyEvent& rKEvt);
209 
210 	virtual sal_Bool	Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
211 	//IAccessibility2 Implementation 2009-----
212 	virtual sal_Int32  GetEntryRealChildsNum( SvLBoxEntry* pEntry ) const;
213 	//-----IAccessibility2 Implementation 2009
214 };
215 
216 
217 //----------------------------------------------------------------------------
218 // TreeListBox fuer Globaldokumente
219 //----------------------------------------------------------------------------
220 
221 class SwLBoxString : public SvLBoxString
222 {
223 public:
224 
225 	SwLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
226 		const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
227 	{
228 	}
229 
230 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
231 		SvLBoxEntry* pEntry);
232 };
233 
234 namespace sfx2 { class DocumentInserter; }
235 namespace sfx2 { class FileDialogHelper; }
236 
237 class SwGlobalTree : public SvTreeListBox
238 {
239 private:
240 	AutoTimer			aUpdateTimer;
241 	String				aContextStrings[GLOBAL_CONTEXT_COUNT];
242 
243 	ImageList			aEntryImages;
244 
245     SwWrtShell*             pActiveShell;   //
246     SvLBoxEntry*            pEmphasisEntry; // Drag'n Drop-Emphasis
247     SvLBoxEntry*            pDDSource;      // Quelle beim DnD
248     SwGlblDocContents*      pSwGlblDocContents; // Array mit sortierten Inhalten
249 
250     Window*                 pDefParentWin;
251     SwGlblDocContent*       pDocContent;
252     sfx2::DocumentInserter* pDocInserter;
253 
254 	sal_Bool 				bIsInternalDrag 	:1;
255 	sal_Bool 				bLastEntryEmphasis 	:1; // Drag'n Drop
256 	sal_Bool				bIsImageListInitialized : 1;
257 
258 	static const SfxObjectShell* pShowShell;
259 
260     void        InsertRegion( const SwGlblDocContent* _pContent,
261                               const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles );
262 
263     DECL_LINK(  DialogClosedHdl, sfx2::FileDialogHelper* );
264 
265     using SvLBox::DoubleClickHdl;
266     using SvLBox::ExecuteDrop;
267     using Window::Update;
268 
269 protected:
270 
271 	virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
272 
273 	virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
274 
275     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
276 
277 	virtual void	RequestHelp( const HelpEvent& rHEvt );
278 
279 	virtual long    GetTabPos( SvLBoxEntry*, SvLBoxTab* );
280 	virtual sal_Bool    NotifyMoving(   SvLBoxEntry*  pTarget,
281 									SvLBoxEntry*  pEntry,
282 									SvLBoxEntry*& rpNewParent,
283 									sal_uLong&        rNewChildPos
284 								);
285 	virtual sal_Bool    NotifyCopying(  SvLBoxEntry*  pTarget,
286 									SvLBoxEntry*  pEntry,
287 									SvLBoxEntry*& rpNewParent,
288 									sal_uLong&        rNewChildPos
289 								);
290 
291 	virtual void 	StartDrag( sal_Int8 nAction, const Point& rPosPixel );
292 	virtual void 	DragFinished( sal_Int8 );
293 	virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
294 										SvLBoxEntry* );
295 	virtual sal_Bool    NotifyAcceptDrop( SvLBoxEntry* );
296 
297 	virtual void    MouseButtonDown( const MouseEvent& rMEvt );
298 	virtual void    KeyInput(const KeyEvent& rKEvt);
299 	virtual void    GetFocus();
300 	virtual void	SelectHdl();
301 	virtual void	DeselectHdl();
302 	virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind);
303 
304 	void			Clear();
305 
306 	DECL_LINK( 		PopupHdl, Menu* );
307 	DECL_LINK( 		Timeout, Timer* );
308 	DECL_LINK( 		DoubleClickHdl, SwGlobalTree * );
309 
310 	sal_Bool			IsInternalDrag() const {return bIsInternalDrag != 0;}
311 	SwNavigationPI* GetParentWindow()
312 						{ return (SwNavigationPI*)Window::GetParent(); }
313 
314 	void 			OpenDoc(const SwGlblDocContent*);
315 	void 			GotoContent(const SwGlblDocContent*);
316 	sal_uInt16			GetEnableFlags() const;
317 
318 	static const SfxObjectShell* 	GetShowShell() {return pShowShell;}
319 	static void 	SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
320 	DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
321 
322     virtual PopupMenu* CreateContextMenu( void );
323     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
324 
325 public:
326 	SwGlobalTree(Window* pParent, const ResId& rResId);
327 	virtual ~SwGlobalTree();
328 
329 	void 				TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox);
330 	void 				InsertRegion( const SwGlblDocContent* pCont,
331 										const String* pFileName = 0 );
332 	void 				EditContent(const SwGlblDocContent* pCont );
333 
334 	void				ShowTree();
335 	void				HideTree();
336 
337 	void 				ExecCommand(sal_uInt16 nCmd);
338 
339 	void 				Display(sal_Bool bOnlyUpdateUserData = sal_False);
340 
341 	sal_Bool 				Update(sal_Bool bHard);
342 };
343 
344 #endif
345 
346