xref: /aoo41x/main/sw/source/ui/utlui/glbltree.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
28cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
29cdf0e10cSrcweir #include <svl/svstdarr.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32cdf0e10cSrcweir #include <svl/stritem.hxx>
33cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
34cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
35cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
36cdf0e10cSrcweir #include <svl/urihelper.hxx>
37cdf0e10cSrcweir #include <sfx2/docfile.hxx>
38cdf0e10cSrcweir #include <vcl/help.hxx>
39cdf0e10cSrcweir #include <sot/filelist.hxx>
40cdf0e10cSrcweir #include <svl/eitem.hxx>
41cdf0e10cSrcweir #include <svl/urlbmk.hxx>
42cdf0e10cSrcweir #include <svtools/filter.hxx>
43cdf0e10cSrcweir #include <sfx2/docinsert.hxx>
44cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <sfx2/app.hxx>
47cdf0e10cSrcweir #include <swmodule.hxx>
48cdf0e10cSrcweir #include <wrtsh.hxx>
49cdf0e10cSrcweir #include <view.hxx>
50cdf0e10cSrcweir #include <errhdl.hxx>
51cdf0e10cSrcweir #include <docsh.hxx>
52cdf0e10cSrcweir #include <content.hxx>
53cdf0e10cSrcweir #include <edglbldc.hxx>
54cdf0e10cSrcweir #include <section.hxx>
55cdf0e10cSrcweir #include <tox.hxx>
56cdf0e10cSrcweir #include <cnttab.hxx>
57cdf0e10cSrcweir #define NAVIPI_CXX
58cdf0e10cSrcweir #include <navipi.hxx>
59cdf0e10cSrcweir #include <navicont.hxx>
60cdf0e10cSrcweir #include <edtwin.hxx>
61cdf0e10cSrcweir #include <uitool.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include <cmdid.h>
64cdf0e10cSrcweir #include <helpid.h>
65cdf0e10cSrcweir #ifndef _NAVIPI_HRC
66cdf0e10cSrcweir #include <navipi.hrc>
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef _UTLUI_HRC
69cdf0e10cSrcweir #include <utlui.hrc>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef _COMCORE_HRC
72cdf0e10cSrcweir #include <comcore.hrc>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir #include <globals.hrc>
75cdf0e10cSrcweir #include "swabstdlg.hxx"
76cdf0e10cSrcweir 
77cdf0e10cSrcweir using namespace ::com::sun::star::uno;
78cdf0e10cSrcweir using ::rtl::OUString;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // Kontextmenue fuer GlobalTree
82cdf0e10cSrcweir #define CTX_INSERT_ANY_INDEX 10
83cdf0e10cSrcweir //#define CTX_INSERT_CNTIDX   11
84cdf0e10cSrcweir //#define CTX_INSERT_USRIDX   12
85cdf0e10cSrcweir #define CTX_INSERT_FILE     11
86cdf0e10cSrcweir #define CTX_INSERT_NEW_FILE 12
87cdf0e10cSrcweir #define CTX_INSERT_TEXT     13
88cdf0e10cSrcweir 
89cdf0e10cSrcweir #define CTX_UPDATE_SEL		20
90cdf0e10cSrcweir #define CTX_UPDATE_INDEX    21
91cdf0e10cSrcweir #define CTX_UPDATE_LINK     22
92cdf0e10cSrcweir #define CTX_UPDATE_ALL      23
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define CTX_UPDATE			1
95cdf0e10cSrcweir #define CTX_INSERT          2
96cdf0e10cSrcweir #define CTX_EDIT            3
97cdf0e10cSrcweir #define CTX_DELETE          4
98cdf0e10cSrcweir #define CTX_EDIT_LINK       5
99cdf0e10cSrcweir 
100cdf0e10cSrcweir #define GLOBAL_UPDATE_TIMEOUT 2000
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // Flags fuer PopupMenu-enable/disable
103cdf0e10cSrcweir #define ENABLE_INSERT_IDX	0x0001
104cdf0e10cSrcweir #define ENABLE_INSERT_FILE  0x0002
105cdf0e10cSrcweir #define ENABLE_INSERT_TEXT  0x0004
106cdf0e10cSrcweir #define ENABLE_EDIT         0x0008
107cdf0e10cSrcweir #define ENABLE_DELETE       0x0010
108cdf0e10cSrcweir #define ENABLE_UPDATE		0x0020
109cdf0e10cSrcweir #define ENABLE_UPDATE_SEL   0x0040
110cdf0e10cSrcweir #define ENABLE_EDIT_LINK    0x0080
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // TabPos nach links schieben
113cdf0e10cSrcweir #define  GLBL_TABPOS_SUB 5
114cdf0e10cSrcweir 
115cdf0e10cSrcweir const SfxObjectShell* SwGlobalTree::pShowShell = 0;
116cdf0e10cSrcweir static const char* __FAR_DATA aHelpForMenu[] =
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	0, 							//
119cdf0e10cSrcweir 	HID_GLBLTREE_UPDATE, 		//CTX_UPDATE
120cdf0e10cSrcweir 	HID_GLBLTREE_INSERT,		//CTX_INSERT
121cdf0e10cSrcweir 	HID_GLBLTREE_EDIT,			//CTX_EDIT
122cdf0e10cSrcweir 	HID_GLBLTREE_DEL,			//CTX_DELETE
123cdf0e10cSrcweir     HID_GLBLTREE_EDIT_LINK,     //CTX_EDIT_LINK
124cdf0e10cSrcweir 	0,						  //
125cdf0e10cSrcweir 	0,						  //
126cdf0e10cSrcweir 	0,						  //
127cdf0e10cSrcweir 	0,						  //
128cdf0e10cSrcweir 	HID_GLBLTREE_INS_IDX, 		//CTX_INSERT_ANY_INDEX
129cdf0e10cSrcweir 	HID_GLBLTREE_INS_FILE,		//CTX_INSERT_FILE
130cdf0e10cSrcweir 	HID_GLBLTREE_INS_NEW_FILE,	//CTX_INSERT_NEW_FILE
131cdf0e10cSrcweir 	HID_GLBLTREE_INS_TEXT,		//CTX_INSERT_TEXT
132cdf0e10cSrcweir 	0,							//
133cdf0e10cSrcweir 	0,							//
134cdf0e10cSrcweir 	0,							//
135cdf0e10cSrcweir 	0,							//
136cdf0e10cSrcweir 	0,							//
137cdf0e10cSrcweir 	0,							//
138cdf0e10cSrcweir 	HID_GLBLTREE_UPD_SEL, 		//CTX_UPDATE_SEL
139cdf0e10cSrcweir 	HID_GLBLTREE_UPD_IDX, 		//CTX_UPDATE_INDEX
140cdf0e10cSrcweir 	HID_GLBLTREE_UPD_LINK,		//CTX_UPDATE_LINK
141cdf0e10cSrcweir 	HID_GLBLTREEUPD_ALL			//CTX_UPDATE_ALL
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir /************************************************************************/
145cdf0e10cSrcweir /*																		*/
146cdf0e10cSrcweir /************************************************************************/
147cdf0e10cSrcweir /* -----------------------------24.08.00 12:04--------------------------------
148cdf0e10cSrcweir 
149cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
150cdf0e10cSrcweir class SwGlobalFrameListener_Impl : public SfxListener
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	sal_Bool bValid;
153cdf0e10cSrcweir public:
SwGlobalFrameListener_Impl(SfxViewFrame & rFrame)154cdf0e10cSrcweir 	SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) :
155cdf0e10cSrcweir 		bValid(sal_True)
156cdf0e10cSrcweir 		{
157cdf0e10cSrcweir 			StartListening(rFrame);
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
161cdf0e10cSrcweir 
IsValid() const162cdf0e10cSrcweir 	sal_Bool 				IsValid() const {return bValid;}
163cdf0e10cSrcweir };
164cdf0e10cSrcweir /* -----------------------------24.08.00 12:05--------------------------------
165cdf0e10cSrcweir 
166cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
Notify(SfxBroadcaster &,const SfxHint & rHint)167cdf0e10cSrcweir void    SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	if( rHint.ISA(SfxSimpleHint) &&
170cdf0e10cSrcweir 			(((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING))
171cdf0e10cSrcweir 		bValid = sal_False;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
175cdf0e10cSrcweir 
176cdf0e10cSrcweir --------------------------------------------------*/
SwGlobalTree(Window * pParent,const ResId & rResId)177cdf0e10cSrcweir SwGlobalTree::SwGlobalTree(Window* pParent, const ResId& rResId) :
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     SvTreeListBox(pParent, rResId),
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     pActiveShell        ( NULL ),
182cdf0e10cSrcweir     pEmphasisEntry      ( NULL ),
183cdf0e10cSrcweir     pDDSource           ( NULL ),
184cdf0e10cSrcweir     pSwGlblDocContents  ( NULL ),
185cdf0e10cSrcweir     pDefParentWin       ( NULL ),
186cdf0e10cSrcweir     pDocContent         ( NULL ),
187cdf0e10cSrcweir     pDocInserter        ( NULL ),
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     bIsInternalDrag         ( sal_False ),
190cdf0e10cSrcweir     bLastEntryEmphasis      ( sal_False ),
191cdf0e10cSrcweir     bIsImageListInitialized ( sal_False )
192cdf0e10cSrcweir 
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	SetDragDropMode(SV_DRAGDROP_APP_COPY  |
195cdf0e10cSrcweir 					SV_DRAGDROP_CTRL_MOVE |
196cdf0e10cSrcweir 					SV_DRAGDROP_ENABLE_TOP );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	aUpdateTimer.SetTimeout(GLOBAL_UPDATE_TIMEOUT);
199cdf0e10cSrcweir 	aUpdateTimer.SetTimeoutHdl(LINK(this, SwGlobalTree, Timeout));
200cdf0e10cSrcweir 	aUpdateTimer.Start();
201cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++)
202cdf0e10cSrcweir 	{
203cdf0e10cSrcweir 		aContextStrings[i] = SW_RESSTR(i+ ST_GLOBAL_CONTEXT_FIRST);
204cdf0e10cSrcweir 	}
205cdf0e10cSrcweir 	SetHelpId(HID_NAVIGATOR_GLOB_TREELIST);
206cdf0e10cSrcweir 	SelectHdl();
207cdf0e10cSrcweir 	SetDoubleClickHdl(LINK(this, SwGlobalTree, DoubleClickHdl));
208cdf0e10cSrcweir     EnableContextMenuHandling();
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
212cdf0e10cSrcweir 
213cdf0e10cSrcweir --------------------------------------------------*/
~SwGlobalTree()214cdf0e10cSrcweir SwGlobalTree::~SwGlobalTree()
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	delete pSwGlblDocContents;
217cdf0e10cSrcweir     delete pDocInserter;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
221cdf0e10cSrcweir 
222cdf0e10cSrcweir --------------------------------------------------*/
ExecuteDrop(const ExecuteDropEvent & rEvt)223cdf0e10cSrcweir sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir 	sal_Int8 nRet = DND_ACTION_NONE;
226cdf0e10cSrcweir 	SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
227cdf0e10cSrcweir 	if(pEmphasisEntry)
228cdf0e10cSrcweir 	{
229cdf0e10cSrcweir 		ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
230cdf0e10cSrcweir 		pEmphasisEntry = 0;
231cdf0e10cSrcweir 	}
232cdf0e10cSrcweir 	else if(bLastEntryEmphasis && pLast)
233cdf0e10cSrcweir 	{
234cdf0e10cSrcweir 		ImplShowTargetEmphasis( pLast, sal_False);
235cdf0e10cSrcweir 	}
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	SvLBoxEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel);
238cdf0e10cSrcweir 	if( bIsInternalDrag )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 		SvLBoxEntry* pDummy = 0;
241cdf0e10cSrcweir 		sal_uLong nInsertionPos = LIST_APPEND;
242cdf0e10cSrcweir 		NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos );
243cdf0e10cSrcweir 	}
244cdf0e10cSrcweir 	else
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		String sFileName;
249cdf0e10cSrcweir 		const SwGlblDocContent* pCnt = pDropEntry ?
250cdf0e10cSrcweir 					(const SwGlblDocContent*)pDropEntry->GetUserData() :
251cdf0e10cSrcweir 							0;
252cdf0e10cSrcweir 		if( aData.HasFormat( FORMAT_FILE_LIST ))
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			nRet = rEvt.mnAction;
255cdf0e10cSrcweir 			SwGlblDocContents* pTempContents = new SwGlblDocContents;
256cdf0e10cSrcweir 			int nAbsContPos = pDropEntry ?
257cdf0e10cSrcweir 								(int) GetModel()->GetAbsPos(pDropEntry):
258cdf0e10cSrcweir 									- 1;
259cdf0e10cSrcweir 			sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 			// Daten holen
262cdf0e10cSrcweir 			FileList aFileList;
263cdf0e10cSrcweir 			aData.GetFileList( FORMAT_FILE_LIST, aFileList );
264cdf0e10cSrcweir 			for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; )
265cdf0e10cSrcweir 			{
266cdf0e10cSrcweir 				sFileName = aFileList.GetFile(n);
267cdf0e10cSrcweir 				InsertRegion(pCnt, &sFileName);
268cdf0e10cSrcweir 				// nach dem Einfuegen muss die Liste der Contents neu
269cdf0e10cSrcweir 				// geholt werden, um nicht auf einem alten Content zu
270cdf0e10cSrcweir 				// arbeiten
271cdf0e10cSrcweir 				if(n)
272cdf0e10cSrcweir 				{
273cdf0e10cSrcweir 					pActiveShell->GetGlobalDocContent(*pTempContents);
274cdf0e10cSrcweir 					// wenn das file erfolgreich eingefuegt wurde,
275cdf0e10cSrcweir 					// dann muss auch der naechste Content geholt werden
276cdf0e10cSrcweir 					if(nEntryCount < pTempContents->Count())
277cdf0e10cSrcweir 					{
278cdf0e10cSrcweir 						nEntryCount++;
279cdf0e10cSrcweir 						nAbsContPos++;
280cdf0e10cSrcweir                         pCnt = pTempContents->GetObject( static_cast< sal_uInt16 >(nAbsContPos) );
281cdf0e10cSrcweir 					}
282cdf0e10cSrcweir 				}
283cdf0e10cSrcweir 			}
284cdf0e10cSrcweir 			delete pTempContents;
285cdf0e10cSrcweir 		}
286cdf0e10cSrcweir 		else if( 0 != (sFileName =
287cdf0e10cSrcweir 						SwNavigationPI::CreateDropFileName( aData )).Len())
288cdf0e10cSrcweir 		{
289cdf0e10cSrcweir 			INetURLObject aTemp(sFileName);
290cdf0e10cSrcweir 			GraphicDescriptor aDesc(aTemp);
291cdf0e10cSrcweir 			if( !aDesc.Detect() )	// keine Grafiken annehmen
292cdf0e10cSrcweir 			{
293cdf0e10cSrcweir 				nRet = rEvt.mnAction;
294cdf0e10cSrcweir 				InsertRegion(pCnt, &sFileName);
295cdf0e10cSrcweir 			}
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 	bLastEntryEmphasis = sal_False;
299cdf0e10cSrcweir 	return nRet;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir }
302cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
303cdf0e10cSrcweir 
304cdf0e10cSrcweir --------------------------------------------------*/
AcceptDrop(const AcceptDropEvent & rEvt)305cdf0e10cSrcweir sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	sal_Int8 nRet = rEvt.mnAction;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 	//initiate scrolling
310cdf0e10cSrcweir 	GetDropTarget( rEvt.maPosPixel );
311cdf0e10cSrcweir 	SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
312cdf0e10cSrcweir 	if( rEvt.mbLeaving )
313cdf0e10cSrcweir 	{
314cdf0e10cSrcweir 		if( pEmphasisEntry )
315cdf0e10cSrcweir 		{
316cdf0e10cSrcweir 			ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
317cdf0e10cSrcweir 			pEmphasisEntry = 0;
318cdf0e10cSrcweir 		}
319cdf0e10cSrcweir 		else if(bLastEntryEmphasis && pLast)
320cdf0e10cSrcweir 		{
321cdf0e10cSrcweir 			ImplShowTargetEmphasis( pLast, sal_False);
322cdf0e10cSrcweir 		}
323cdf0e10cSrcweir 		bLastEntryEmphasis = sal_False;
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 	else
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		SvLBoxEntry* pDropEntry = GetEntry( rEvt.maPosPixel );
328cdf0e10cSrcweir 		if(bIsInternalDrag)
329cdf0e10cSrcweir 		{
330cdf0e10cSrcweir 			if( pDDSource != pDropEntry )
331cdf0e10cSrcweir 				nRet = rEvt.mnAction;
332cdf0e10cSrcweir 		}
333cdf0e10cSrcweir 		else if( IsDropFormatSupported( FORMAT_FILE ) ||
334cdf0e10cSrcweir 		  		IsDropFormatSupported( FORMAT_STRING ) ||
335cdf0e10cSrcweir 		  		IsDropFormatSupported( FORMAT_FILE_LIST ) ||
336cdf0e10cSrcweir 		  		IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
337cdf0e10cSrcweir  		  		IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )||
338cdf0e10cSrcweir  		  		IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) ||
339cdf0e10cSrcweir  		  		IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ||
340cdf0e10cSrcweir  		  		IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
341cdf0e10cSrcweir  		  		IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME ))
342cdf0e10cSrcweir 				nRet = DND_ACTION_LINK;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 		if(pEmphasisEntry && pEmphasisEntry != pDropEntry)
345cdf0e10cSrcweir 			ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False );
346cdf0e10cSrcweir 		else if(pLast && bLastEntryEmphasis  && pDropEntry)
347cdf0e10cSrcweir 		{
348cdf0e10cSrcweir 			ImplShowTargetEmphasis( pLast, sal_False);
349cdf0e10cSrcweir 			bLastEntryEmphasis = sal_False;
350cdf0e10cSrcweir 		}
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 		if(pDropEntry)
353cdf0e10cSrcweir 			ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet );
354cdf0e10cSrcweir 		else if(pLast)
355cdf0e10cSrcweir 		{
356cdf0e10cSrcweir 			ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet );
357cdf0e10cSrcweir 			bLastEntryEmphasis = sal_True;
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 		pEmphasisEntry = pDropEntry;
360cdf0e10cSrcweir 	}
361cdf0e10cSrcweir 	return nRet;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
364cdf0e10cSrcweir 
365cdf0e10cSrcweir --------------------------------------------------*/
CreateContextMenu()366cdf0e10cSrcweir PopupMenu* SwGlobalTree::CreateContextMenu()
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     PopupMenu* pPop = 0;
369cdf0e10cSrcweir     if(pActiveShell &&
370cdf0e10cSrcweir         !pActiveShell->GetView().GetDocShell()->IsReadOnly())
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         sal_uInt16 nEnableFlags = GetEnableFlags();
373cdf0e10cSrcweir         pPop = new PopupMenu;
374cdf0e10cSrcweir         PopupMenu* pSubPop1 = new PopupMenu;
375cdf0e10cSrcweir         PopupMenu* pSubPop2 = new PopupMenu;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
378cdf0e10cSrcweir         {
379cdf0e10cSrcweir             pSubPop2->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
380cdf0e10cSrcweir             pSubPop2->SetHelpId(i, aHelpForMenu[i]);
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir         pSubPop2->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
383cdf0e10cSrcweir 
384cdf0e10cSrcweir         pSubPop1->InsertItem(CTX_INSERT_ANY_INDEX, aContextStrings[ST_INDEX  - ST_GLOBAL_CONTEXT_FIRST]);
385cdf0e10cSrcweir         pSubPop1->SetHelpId(CTX_INSERT_ANY_INDEX, aHelpForMenu[CTX_INSERT_ANY_INDEX]);
386cdf0e10cSrcweir         pSubPop1->InsertItem(CTX_INSERT_FILE, aContextStrings[ST_FILE   - ST_GLOBAL_CONTEXT_FIRST]);
387cdf0e10cSrcweir         pSubPop1->SetHelpId(CTX_INSERT_FILE, aHelpForMenu[CTX_INSERT_FILE]);
388cdf0e10cSrcweir         pSubPop1->InsertItem(CTX_INSERT_NEW_FILE, aContextStrings[ST_NEW_FILE   - ST_GLOBAL_CONTEXT_FIRST]);
389cdf0e10cSrcweir         pSubPop1->SetHelpId(CTX_INSERT_NEW_FILE, aHelpForMenu[CTX_INSERT_NEW_FILE]);
390cdf0e10cSrcweir         pSubPop1->InsertItem(CTX_INSERT_TEXT, aContextStrings[ST_TEXT   - ST_GLOBAL_CONTEXT_FIRST]);
391cdf0e10cSrcweir         pSubPop1->SetHelpId(CTX_INSERT_TEXT, aHelpForMenu[CTX_INSERT_TEXT]);
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         pPop->InsertItem(CTX_UPDATE, aContextStrings[ST_UPDATE - ST_GLOBAL_CONTEXT_FIRST]);
395cdf0e10cSrcweir         pPop->SetHelpId(CTX_UPDATE, aHelpForMenu[CTX_UPDATE]);
396cdf0e10cSrcweir         pPop->InsertItem(CTX_EDIT, aContextStrings[ST_EDIT_CONTENT - ST_GLOBAL_CONTEXT_FIRST]);
397cdf0e10cSrcweir         pPop->SetHelpId(CTX_EDIT, aHelpForMenu[CTX_EDIT]);
398cdf0e10cSrcweir         if(nEnableFlags&ENABLE_EDIT_LINK)
399cdf0e10cSrcweir         {
400cdf0e10cSrcweir             pPop->InsertItem(CTX_EDIT_LINK, aContextStrings[ST_EDIT_LINK - ST_GLOBAL_CONTEXT_FIRST]);
401cdf0e10cSrcweir             pPop->SetHelpId(CTX_EDIT_LINK, aHelpForMenu[CTX_EDIT_LINK]);
402cdf0e10cSrcweir         }
403cdf0e10cSrcweir         pPop->InsertItem(CTX_INSERT, aContextStrings[ST_INSERT - ST_GLOBAL_CONTEXT_FIRST]);
404cdf0e10cSrcweir         pPop->SetHelpId(CTX_INSERT, aHelpForMenu[CTX_INSERT]);
405cdf0e10cSrcweir         pPop->InsertSeparator() ;
406cdf0e10cSrcweir         pPop->InsertItem(CTX_DELETE, aContextStrings[ST_DELETE - ST_GLOBAL_CONTEXT_FIRST]);
407cdf0e10cSrcweir         pPop->SetHelpId(CTX_DELETE, aHelpForMenu[CTX_DELETE]);
408cdf0e10cSrcweir 
409cdf0e10cSrcweir         //evtl. disablen
410cdf0e10cSrcweir         pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX,  0 != (nEnableFlags & ENABLE_INSERT_IDX ));
411cdf0e10cSrcweir         pSubPop1->EnableItem(CTX_INSERT_TEXT,       0 != (nEnableFlags & ENABLE_INSERT_TEXT));
412cdf0e10cSrcweir         pSubPop1->EnableItem(CTX_INSERT_FILE,       0 != (nEnableFlags & ENABLE_INSERT_FILE));
413cdf0e10cSrcweir         pSubPop1->EnableItem(CTX_INSERT_NEW_FILE,   0 != (nEnableFlags & ENABLE_INSERT_FILE));
414cdf0e10cSrcweir 
415cdf0e10cSrcweir         pPop->EnableItem(CTX_UPDATE,    0 != (nEnableFlags & ENABLE_UPDATE));
416cdf0e10cSrcweir         pPop->EnableItem(CTX_INSERT,    0 != (nEnableFlags & ENABLE_INSERT_IDX));
417cdf0e10cSrcweir         pPop->EnableItem(CTX_EDIT,      0 != (nEnableFlags & ENABLE_EDIT));
418cdf0e10cSrcweir         pPop->EnableItem(CTX_DELETE,    0 != (nEnableFlags & ENABLE_DELETE));
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         pPop->SetPopupMenu( CTX_INSERT, pSubPop1 );
422cdf0e10cSrcweir         pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 );
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir     return pPop;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir /*-----------------16.06.97 10:41-------------------
427cdf0e10cSrcweir 
428cdf0e10cSrcweir --------------------------------------------------*/
TbxMenuHdl(sal_uInt16 nTbxId,ToolBox * pBox)429cdf0e10cSrcweir void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox)
430cdf0e10cSrcweir {
431cdf0e10cSrcweir 	sal_uInt16 nEnableFlags = GetEnableFlags();
432cdf0e10cSrcweir 	if(FN_GLOBAL_OPEN == nTbxId)
433cdf0e10cSrcweir 	{
434cdf0e10cSrcweir 		PopupMenu *pMenu = new PopupMenu;
435cdf0e10cSrcweir 		for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; i++)
436cdf0e10cSrcweir 		{
437cdf0e10cSrcweir 			pMenu->InsertItem( i, aContextStrings[ST_INDEX  - ST_GLOBAL_CONTEXT_FIRST - CTX_INSERT_ANY_INDEX + i] );
438cdf0e10cSrcweir 			pMenu->SetHelpId(i, aHelpForMenu[i] );
439cdf0e10cSrcweir 		}
440cdf0e10cSrcweir         pMenu->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX ));
441cdf0e10cSrcweir //      pMenu->EnableItem(CTX_INSERT_CNTIDX,    0 != (nEnableFlags & ENABLE_INSERT_IDX ));
442cdf0e10cSrcweir //      pMenu->EnableItem(CTX_INSERT_USRIDX,    0 != (nEnableFlags & ENABLE_INSERT_IDX ));
443cdf0e10cSrcweir         pMenu->EnableItem(CTX_INSERT_TEXT,      0 != (nEnableFlags & ENABLE_INSERT_TEXT));
444cdf0e10cSrcweir         pMenu->EnableItem(CTX_INSERT_FILE,      0 != (nEnableFlags & ENABLE_INSERT_FILE));
445cdf0e10cSrcweir         pMenu->EnableItem(CTX_INSERT_NEW_FILE,  0 != (nEnableFlags & ENABLE_INSERT_FILE));
446cdf0e10cSrcweir 		pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
447cdf0e10cSrcweir 		pMenu->Execute(	pBox, pBox->GetItemRect(nTbxId).BottomLeft());
448cdf0e10cSrcweir 		delete pMenu;
449cdf0e10cSrcweir 		pBox->EndSelection();
450cdf0e10cSrcweir 		pBox->Invalidate();
451cdf0e10cSrcweir 	}
452cdf0e10cSrcweir 	else if(FN_GLOBAL_UPDATE == nTbxId)
453cdf0e10cSrcweir 	{
454cdf0e10cSrcweir 		PopupMenu *pMenu = new PopupMenu;
455cdf0e10cSrcweir 		for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
456cdf0e10cSrcweir 		{
457cdf0e10cSrcweir 			pMenu->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] );
458cdf0e10cSrcweir 			pMenu->SetHelpId(i, aHelpForMenu[i] );
459cdf0e10cSrcweir 		}
460cdf0e10cSrcweir         pMenu->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL));
461cdf0e10cSrcweir 		pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
462cdf0e10cSrcweir 		pMenu->Execute(	pBox, pBox->GetItemRect(nTbxId).BottomLeft());
463cdf0e10cSrcweir 		delete pMenu;
464cdf0e10cSrcweir 		pBox->EndSelection();
465cdf0e10cSrcweir 		pBox->Invalidate();
466cdf0e10cSrcweir 	}
467cdf0e10cSrcweir }
468cdf0e10cSrcweir /*-----------------16.06.97 11:02-------------------
469cdf0e10cSrcweir 
470cdf0e10cSrcweir --------------------------------------------------*/
GetEnableFlags() const471cdf0e10cSrcweir sal_uInt16	SwGlobalTree::GetEnableFlags() const
472cdf0e10cSrcweir {
473cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstSelected();
474cdf0e10cSrcweir 	sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount();
475cdf0e10cSrcweir 	sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
476cdf0e10cSrcweir 	SvLBoxEntry* pPrevEntry = pEntry ? Prev(pEntry) : 0;
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	sal_uInt16 nRet = 0;
479cdf0e10cSrcweir 	if(nSelCount == 1 || !nEntryCount)
480cdf0e10cSrcweir 		nRet |= ENABLE_INSERT_IDX|ENABLE_INSERT_FILE;
481cdf0e10cSrcweir 	if(nSelCount == 1)
482cdf0e10cSrcweir 	{
483cdf0e10cSrcweir 		nRet |= ENABLE_EDIT;
484cdf0e10cSrcweir 		if(	((SwGlblDocContent*)pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN &&
485cdf0e10cSrcweir 					(!pPrevEntry || ((SwGlblDocContent*)pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN))
486cdf0e10cSrcweir 			nRet |= ENABLE_INSERT_TEXT;
487cdf0e10cSrcweir         if( GLBLDOC_SECTION == ((SwGlblDocContent*)pEntry->GetUserData())->GetType() )
488cdf0e10cSrcweir             nRet |= ENABLE_EDIT_LINK;
489cdf0e10cSrcweir     }
490cdf0e10cSrcweir 	else if(!nEntryCount)
491cdf0e10cSrcweir 	{
492cdf0e10cSrcweir 		nRet |= ENABLE_INSERT_TEXT;
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir 	if(nEntryCount)
495cdf0e10cSrcweir 		nRet |= ENABLE_UPDATE|ENABLE_DELETE;
496cdf0e10cSrcweir 	if(nSelCount)
497cdf0e10cSrcweir 		nRet |= ENABLE_UPDATE_SEL;
498cdf0e10cSrcweir 	return nRet;
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
502cdf0e10cSrcweir 
503cdf0e10cSrcweir --------------------------------------------------*/
RequestHelp(const HelpEvent & rHEvt)504cdf0e10cSrcweir void	 SwGlobalTree::RequestHelp( const HelpEvent& rHEvt )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir 	sal_Bool bParent = sal_True;
507cdf0e10cSrcweir 	Update(sal_True);
508cdf0e10cSrcweir 	Display(sal_True);
509cdf0e10cSrcweir 	if( rHEvt.GetMode() & HELPMODE_QUICK )
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir 		Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
512cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetEntry( aPos );
513cdf0e10cSrcweir 		const SwGlblDocContent* pCont = pEntry ?
514cdf0e10cSrcweir 							(const SwGlblDocContent*)pEntry->GetUserData() : 0;
515cdf0e10cSrcweir 		if( pCont &&  GLBLDOC_SECTION == pCont->GetType())
516cdf0e10cSrcweir 		{
517cdf0e10cSrcweir 			bParent = sal_False;
518cdf0e10cSrcweir 			SvLBoxTab* pTab;
519cdf0e10cSrcweir 			SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
520cdf0e10cSrcweir 			if(pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
521cdf0e10cSrcweir 			{
522cdf0e10cSrcweir 				const SwSection* pSect = pCont->GetSection();
523cdf0e10cSrcweir                 String sEntry = pSect->GetLinkFileName().GetToken(0, sfx2::cTokenSeperator);
524cdf0e10cSrcweir 				if(!pSect->IsConnectFlag())
525cdf0e10cSrcweir 					sEntry.Insert(aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST], 0 );
526cdf0e10cSrcweir                 Point aEntryPos = GetEntryPosition( pEntry );
527cdf0e10cSrcweir 
528cdf0e10cSrcweir                 aEntryPos.X() = GetTabPos( pEntry, pTab );
529cdf0e10cSrcweir 				Size aSize( pItem->GetSize( this, pEntry ) );
530cdf0e10cSrcweir 
531cdf0e10cSrcweir                 if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width())
532cdf0e10cSrcweir                     aSize.Width() = GetSizePixel().Width() - aEntryPos.X();
533cdf0e10cSrcweir 
534cdf0e10cSrcweir                 aEntryPos = OutputToScreenPixel(aEntryPos);
535cdf0e10cSrcweir                 Rectangle aItemRect( aEntryPos, aSize );
536cdf0e10cSrcweir 				if(Help::IsBalloonHelpEnabled())
537cdf0e10cSrcweir 				{
538cdf0e10cSrcweir                     aEntryPos.X() += aSize.Width();
539cdf0e10cSrcweir                     Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry );
540cdf0e10cSrcweir 				}
541cdf0e10cSrcweir 				else
542cdf0e10cSrcweir 					Help::ShowQuickHelp( this, aItemRect, sEntry,
543cdf0e10cSrcweir 						QUICKHELP_LEFT|QUICKHELP_VCENTER );
544cdf0e10cSrcweir 			}
545cdf0e10cSrcweir 		}
546cdf0e10cSrcweir 	}
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	if(bParent)
549cdf0e10cSrcweir 		SvTreeListBox::RequestHelp(rHEvt);
550cdf0e10cSrcweir }
551cdf0e10cSrcweir /*-----------------16.06.97 16:15-------------------
552cdf0e10cSrcweir 
553cdf0e10cSrcweir --------------------------------------------------*/
SelectHdl()554cdf0e10cSrcweir void	 SwGlobalTree::SelectHdl()
555cdf0e10cSrcweir {
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 	sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount();
558cdf0e10cSrcweir 	SvLBoxEntry* pSel = FirstSelected();
559cdf0e10cSrcweir 	sal_uInt16 nAbsPos = pSel ? (sal_uInt16)GetModel()->GetAbsPos(pSel) : 0;
560cdf0e10cSrcweir 	SwNavigationPI* pNavi = GetParentWindow();
561cdf0e10cSrcweir 	sal_Bool bReadonly = !pActiveShell ||
562cdf0e10cSrcweir 				pActiveShell->GetView().GetDocShell()->IsReadOnly();
563cdf0e10cSrcweir 	pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_EDIT,  nSelCount == 1 && !bReadonly);
564cdf0e10cSrcweir 	pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_OPEN,  nSelCount <= 1 && !bReadonly);
565cdf0e10cSrcweir 	pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_UPDATE,  GetEntryCount() > 0 && !bReadonly);
566cdf0e10cSrcweir 	pNavi->aGlobalToolBox.EnableItem(FN_ITEM_UP,
567cdf0e10cSrcweir 					nSelCount == 1 && nAbsPos && !bReadonly);
568cdf0e10cSrcweir 	pNavi->aGlobalToolBox.EnableItem(FN_ITEM_DOWN,
569cdf0e10cSrcweir 					nSelCount == 1 && nAbsPos < ((sal_uInt16)GetEntryCount()) - 1 && !bReadonly);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir }
572cdf0e10cSrcweir /*-----------------16.06.97 16:15-------------------
573cdf0e10cSrcweir 
574cdf0e10cSrcweir --------------------------------------------------*/
DeselectHdl()575cdf0e10cSrcweir void	 SwGlobalTree::DeselectHdl()
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	SelectHdl();
578cdf0e10cSrcweir }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir /*-----------------17.06.97 13:11-------------------
581cdf0e10cSrcweir 
582cdf0e10cSrcweir --------------------------------------------------*/
NotifyStartDrag(TransferDataContainer &,SvLBoxEntry * pEntry)583cdf0e10cSrcweir DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& ,
584cdf0e10cSrcweir 												SvLBoxEntry* pEntry )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir 	bIsInternalDrag = sal_True;
587cdf0e10cSrcweir 	pDDSource = pEntry;
588cdf0e10cSrcweir 	return SV_DRAGDROP_CTRL_MOVE;
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir /*-----------------21.06.97 12:44-------------------
592cdf0e10cSrcweir 
593cdf0e10cSrcweir --------------------------------------------------*/
GetTabPos(SvLBoxEntry *,SvLBoxTab * pTab)594cdf0e10cSrcweir long     SwGlobalTree::GetTabPos( SvLBoxEntry*, SvLBoxTab* pTab)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir 	return pTab->GetPos() - GLBL_TABPOS_SUB;
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir /*-----------------12.06.97 09:38-------------------
600cdf0e10cSrcweir 
601cdf0e10cSrcweir --------------------------------------------------*/
NotifyMoving(SvLBoxEntry * pTarget,SvLBoxEntry * pSource,SvLBoxEntry * &,sal_uLong &)602cdf0e10cSrcweir sal_Bool     SwGlobalTree::NotifyMoving(   SvLBoxEntry*  pTarget,
603cdf0e10cSrcweir 										SvLBoxEntry*  pSource,
604cdf0e10cSrcweir 										SvLBoxEntry*&,
605cdf0e10cSrcweir 										sal_uLong&
606cdf0e10cSrcweir 									)
607cdf0e10cSrcweir {
608cdf0e10cSrcweir     SvTreeList* _pModel = GetModel();
609cdf0e10cSrcweir     sal_uInt16 nSource = (sal_uInt16) _pModel->GetAbsPos(pSource);
610cdf0e10cSrcweir     sal_uInt16 nDest   = pTarget ? (sal_uInt16) _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->Count();
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 	if(	pActiveShell->MoveGlobalDocContent(
613cdf0e10cSrcweir 			*pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
614cdf0e10cSrcweir 			Update( sal_False ))
615cdf0e10cSrcweir 		Display();
616cdf0e10cSrcweir 	return sal_False;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir /*-----------------12.06.97 09:39-------------------
619cdf0e10cSrcweir 
620cdf0e10cSrcweir --------------------------------------------------*/
NotifyCopying(SvLBoxEntry *,SvLBoxEntry *,SvLBoxEntry * &,sal_uLong &)621cdf0e10cSrcweir sal_Bool     SwGlobalTree::NotifyCopying(  SvLBoxEntry*  /*pTarget*/,
622cdf0e10cSrcweir                                         SvLBoxEntry*  /*pEntry*/,
623cdf0e10cSrcweir                                         SvLBoxEntry*& /*rpNewParent*/,
624cdf0e10cSrcweir                                         sal_uLong&        /*rNewChildPos*/
625cdf0e10cSrcweir 									)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	return sal_False;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir /*-----------------12.06.97 09:39-------------------
630cdf0e10cSrcweir 
631cdf0e10cSrcweir --------------------------------------------------*/
NotifyAcceptDrop(SvLBoxEntry * pEntry)632cdf0e10cSrcweir sal_Bool SwGlobalTree::NotifyAcceptDrop( SvLBoxEntry* pEntry)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir 	return pEntry != 0;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir /*-----------------12.06.97 09:39-------------------
637cdf0e10cSrcweir 
638cdf0e10cSrcweir --------------------------------------------------*/
StartDrag(sal_Int8 nAction,const Point & rPt)639cdf0e10cSrcweir void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt )
640cdf0e10cSrcweir {
641cdf0e10cSrcweir 	if( 1 == GetSelectionCount() )
642cdf0e10cSrcweir 		SvTreeListBox::StartDrag( nAction, rPt );
643cdf0e10cSrcweir }
644cdf0e10cSrcweir /*-----------------12.06.97 09:39-------------------
645cdf0e10cSrcweir 
646cdf0e10cSrcweir --------------------------------------------------*/
DragFinished(sal_Int8 nAction)647cdf0e10cSrcweir void SwGlobalTree::DragFinished( sal_Int8 nAction )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir 	SvTreeListBox::DragFinished( nAction );
650cdf0e10cSrcweir 	bIsInternalDrag = sal_False;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir /***************************************************************************
654cdf0e10cSrcweir 	Beschreibung: 	Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
655cdf0e10cSrcweir  * 					dann soll die Basisfunktion des Controls gerufen werden
656cdf0e10cSrcweir ***************************************************************************/
MouseButtonDown(const MouseEvent & rMEvt)657cdf0e10cSrcweir void  SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir 	Point aPos( rMEvt.GetPosPixel());
660cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( aPos, sal_True );
661cdf0e10cSrcweir 	if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
662cdf0e10cSrcweir 		Control::MouseButtonDown( rMEvt );
663cdf0e10cSrcweir 	else
664cdf0e10cSrcweir 		SvTreeListBox::MouseButtonDown( rMEvt );
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir /*-----------------12.06.97 13:08-------------------
668cdf0e10cSrcweir 
669cdf0e10cSrcweir --------------------------------------------------*/
GetFocus()670cdf0e10cSrcweir void     SwGlobalTree::GetFocus()
671cdf0e10cSrcweir {
672cdf0e10cSrcweir 	if(Update( sal_False ))
673cdf0e10cSrcweir 		Display();
674cdf0e10cSrcweir 	SvTreeListBox::GetFocus();
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir /*-----------------12.06.97 12:34-------------------
678cdf0e10cSrcweir 
679cdf0e10cSrcweir --------------------------------------------------*/
KeyInput(const KeyEvent & rKEvt)680cdf0e10cSrcweir void     SwGlobalTree::KeyInput(const KeyEvent& rKEvt)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	const KeyCode aCode = rKEvt.GetKeyCode();
683cdf0e10cSrcweir 	if(aCode.GetCode() == KEY_RETURN)
684cdf0e10cSrcweir 	{
685cdf0e10cSrcweir 		switch(aCode.GetModifier())
686cdf0e10cSrcweir 		{
687cdf0e10cSrcweir 			case KEY_MOD2:
688cdf0e10cSrcweir 				// Boxen umschalten
689cdf0e10cSrcweir 				GetParentWindow()->ToggleTree();
690cdf0e10cSrcweir 			break;
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir 	}
693cdf0e10cSrcweir 	else
694cdf0e10cSrcweir 		SvTreeListBox::KeyInput(rKEvt);
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir /*-----------------17.06.97 11:59-------------------
698cdf0e10cSrcweir 
699cdf0e10cSrcweir --------------------------------------------------*/
Clear()700cdf0e10cSrcweir void SwGlobalTree::Clear()
701cdf0e10cSrcweir {
702cdf0e10cSrcweir 	pEmphasisEntry = 0;
703cdf0e10cSrcweir 	SvTreeListBox::Clear();
704cdf0e10cSrcweir }
705cdf0e10cSrcweir /*-----------------12.06.97 12:38-------------------
706cdf0e10cSrcweir 
707cdf0e10cSrcweir --------------------------------------------------*/
Display(sal_Bool bOnlyUpdateUserData)708cdf0e10cSrcweir void 	SwGlobalTree::Display(sal_Bool bOnlyUpdateUserData)
709cdf0e10cSrcweir {
710cdf0e10cSrcweir 	if(!bIsImageListInitialized)
711cdf0e10cSrcweir 	{
712cdf0e10cSrcweir         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
713cdf0e10cSrcweir         aEntryImages = ImageList(SW_RES(nResId));
714cdf0e10cSrcweir 		bIsImageListInitialized = sal_True;
715cdf0e10cSrcweir 	}
716cdf0e10cSrcweir 	sal_uInt16 nCount = pSwGlblDocContents->Count();
717cdf0e10cSrcweir 	if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->Count())
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		SvLBoxEntry* pEntry = First();
720cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++)
721cdf0e10cSrcweir 		{
722cdf0e10cSrcweir 			SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i);
723cdf0e10cSrcweir 			pEntry->SetUserData(pCont);
724cdf0e10cSrcweir 			pEntry = Next(pEntry);
725cdf0e10cSrcweir 		}
726cdf0e10cSrcweir 	}
727cdf0e10cSrcweir 	else
728cdf0e10cSrcweir 	{
729cdf0e10cSrcweir 		SetUpdateMode( sal_False );
730cdf0e10cSrcweir 		SvLBoxEntry* pOldSelEntry = FirstSelected();
731cdf0e10cSrcweir 		String sEntryName;	// Name des Eintrags
732cdf0e10cSrcweir 		sal_uInt16 nSelPos = USHRT_MAX;
733cdf0e10cSrcweir 		if(pOldSelEntry)
734cdf0e10cSrcweir 		{
735cdf0e10cSrcweir 			sEntryName = GetEntryText(pOldSelEntry);
736cdf0e10cSrcweir 			nSelPos = (sal_uInt16)GetModel()->GetAbsPos(pOldSelEntry);
737cdf0e10cSrcweir 		}
738cdf0e10cSrcweir 		Clear();
739cdf0e10cSrcweir 		if(!pSwGlblDocContents)
740cdf0e10cSrcweir 			Update( sal_False );
741cdf0e10cSrcweir 
742cdf0e10cSrcweir 		SvLBoxEntry* pSelEntry = 0;
743cdf0e10cSrcweir 		for( sal_uInt16 i = 0; i < nCount; i++)
744cdf0e10cSrcweir 		{
745cdf0e10cSrcweir 			SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i);
746cdf0e10cSrcweir 			String sEntry;
747cdf0e10cSrcweir 			Image aImage;
748cdf0e10cSrcweir 			switch( pCont->GetType()  )
749cdf0e10cSrcweir 			{
750cdf0e10cSrcweir 				case GLBLDOC_UNKNOWN:
751cdf0e10cSrcweir 				{
752cdf0e10cSrcweir 					sEntry = aContextStrings[ST_TEXT   - ST_GLOBAL_CONTEXT_FIRST];
753cdf0e10cSrcweir 					aImage = aEntryImages.GetImage(SID_SW_START + GLOBAL_CONTENT_TEXT);
754cdf0e10cSrcweir 				}
755cdf0e10cSrcweir 				break;
756cdf0e10cSrcweir 				case GLBLDOC_TOXBASE:
757cdf0e10cSrcweir 				{
758cdf0e10cSrcweir 					const SwTOXBase* pBase = pCont->GetTOX();
759cdf0e10cSrcweir 					sEntry = pBase->GetTitle();
760cdf0e10cSrcweir 					aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX);
761cdf0e10cSrcweir 				}
762cdf0e10cSrcweir 				break;
763cdf0e10cSrcweir 				case GLBLDOC_SECTION:
764cdf0e10cSrcweir 				{
765cdf0e10cSrcweir 					const SwSection* pSect = pCont->GetSection();
766cdf0e10cSrcweir                     sEntry = pSect->GetSectionName();
767cdf0e10cSrcweir 					aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION);
768cdf0e10cSrcweir 				}
769cdf0e10cSrcweir 				break;
770cdf0e10cSrcweir 			}
771cdf0e10cSrcweir 			SvLBoxEntry* pEntry = InsertEntry(sEntry, aImage, aImage,
772cdf0e10cSrcweir 						0, sal_False, LIST_APPEND, pCont);
773cdf0e10cSrcweir 			if(sEntry == sEntryName)
774cdf0e10cSrcweir 			{
775cdf0e10cSrcweir 				pSelEntry = pEntry;
776cdf0e10cSrcweir 			}
777cdf0e10cSrcweir 		}
778cdf0e10cSrcweir 		if(pSelEntry)
779cdf0e10cSrcweir 		{
780cdf0e10cSrcweir 			Select(pSelEntry);
781cdf0e10cSrcweir 		}
782cdf0e10cSrcweir 		else if(nSelPos != USHRT_MAX && nSelPos < nCount)
783cdf0e10cSrcweir 		{
784cdf0e10cSrcweir 			Select(GetEntry(nSelPos));
785cdf0e10cSrcweir 		}
786cdf0e10cSrcweir 		else if(nCount)
787cdf0e10cSrcweir 			Select(First());
788cdf0e10cSrcweir 		else
789cdf0e10cSrcweir 			SelectHdl();
790cdf0e10cSrcweir 		SetUpdateMode( sal_True );
791cdf0e10cSrcweir 	}
792cdf0e10cSrcweir }
793cdf0e10cSrcweir 
794cdf0e10cSrcweir /*-----------------13.06.97 10:32-------------------
795cdf0e10cSrcweir 
796cdf0e10cSrcweir --------------------------------------------------*/
InsertRegion(const SwGlblDocContent * pCont,const String * pFileName)797cdf0e10cSrcweir void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const String* pFileName )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir     Sequence< OUString > aFileNames;
800cdf0e10cSrcweir     if ( !pFileName )
801cdf0e10cSrcweir 	{
802cdf0e10cSrcweir         pDefParentWin = Application::GetDefDialogParent();
803cdf0e10cSrcweir         Application::SetDefDialogParent( this );
804cdf0e10cSrcweir         if ( pDocInserter )
805cdf0e10cSrcweir             delete pDocInserter;
806cdf0e10cSrcweir         pDocInserter = new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter"), true );
807cdf0e10cSrcweir         pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) );
808cdf0e10cSrcweir     }
809cdf0e10cSrcweir     else if ( pFileName->Len() )
810cdf0e10cSrcweir 	{
811cdf0e10cSrcweir         aFileNames.realloc(1);
812cdf0e10cSrcweir         INetURLObject aFileName;
813cdf0e10cSrcweir         aFileName.SetSmartURL( *pFileName );
814cdf0e10cSrcweir         aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE );
815cdf0e10cSrcweir         InsertRegion( pCont, aFileNames );
816cdf0e10cSrcweir 	}
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819cdf0e10cSrcweir /*-----------------18.06.97 12:42-------------------
820cdf0e10cSrcweir 
821cdf0e10cSrcweir --------------------------------------------------*/
EditContent(const SwGlblDocContent * pCont)822cdf0e10cSrcweir void 	SwGlobalTree::EditContent(const SwGlblDocContent* pCont )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir 	sal_uInt16 nSlot = 0;
825cdf0e10cSrcweir 	switch( pCont->GetType() )
826cdf0e10cSrcweir 	{
827cdf0e10cSrcweir 		case GLBLDOC_UNKNOWN:
828cdf0e10cSrcweir 			pActiveShell->GetView().GetEditWin().GrabFocus();
829cdf0e10cSrcweir 		break;
830cdf0e10cSrcweir 		case GLBLDOC_TOXBASE:
831cdf0e10cSrcweir 		{
832cdf0e10cSrcweir 			const SwTOXBase* pBase = pCont->GetTOX();
833cdf0e10cSrcweir 			if(pBase)
834cdf0e10cSrcweir 				nSlot = FN_INSERT_MULTI_TOX;
835cdf0e10cSrcweir 		}
836cdf0e10cSrcweir 		break;
837cdf0e10cSrcweir 		case GLBLDOC_SECTION:
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			OpenDoc(pCont);
840cdf0e10cSrcweir 
841cdf0e10cSrcweir 			nSlot = 0;
842cdf0e10cSrcweir 			pCont = 0;
843cdf0e10cSrcweir 		}
844cdf0e10cSrcweir 		break;
845cdf0e10cSrcweir 	}
846cdf0e10cSrcweir 	if(pCont)
847cdf0e10cSrcweir 		GotoContent(pCont);
848cdf0e10cSrcweir 	if(nSlot)
849cdf0e10cSrcweir 	{
850cdf0e10cSrcweir 		pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot);
851cdf0e10cSrcweir 		if(Update( sal_False ))
852cdf0e10cSrcweir 			Display();
853cdf0e10cSrcweir 	}
854cdf0e10cSrcweir }
855cdf0e10cSrcweir 
856cdf0e10cSrcweir /*-----------------13.06.97 14:22-------------------
857cdf0e10cSrcweir 
858cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlobalTree,PopupHdl,Menu *,pMenu)859cdf0e10cSrcweir IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu)
860cdf0e10cSrcweir {
861cdf0e10cSrcweir     ExcecuteContextMenuAction( pMenu->GetCurItemId());
862cdf0e10cSrcweir     return sal_True;
863cdf0e10cSrcweir }
864cdf0e10cSrcweir /* -----------------26.08.2003 11:57-----------------
865cdf0e10cSrcweir 
866cdf0e10cSrcweir  --------------------------------------------------*/
ExcecuteContextMenuAction(sal_uInt16 nSelectedPopupEntry)867cdf0e10cSrcweir void    SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
868cdf0e10cSrcweir //IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu)
869cdf0e10cSrcweir {
870cdf0e10cSrcweir //  sal_uInt16 nId = pMenu->GetCurItemId();
871cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstSelected();
872cdf0e10cSrcweir 	SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
873cdf0e10cSrcweir 	// wird waehrend des Dialogs ein RequestHelp gerufen,
874cdf0e10cSrcweir 	// dann geht der Content verloren. Deshalb wird hier eine
875cdf0e10cSrcweir 	// Kopie angelegt, in der nur die DocPos richtig gesetzt ist.
876cdf0e10cSrcweir 	SwGlblDocContent* pContCopy = 0;
877cdf0e10cSrcweir 	if(pCont)
878cdf0e10cSrcweir 		pContCopy = new SwGlblDocContent(pCont->GetDocPos());
879cdf0e10cSrcweir 	SfxDispatcher& rDispatch = *pActiveShell->GetView().GetViewFrame()->GetDispatcher();
880cdf0e10cSrcweir     sal_uInt16 nSlot = 0;
881cdf0e10cSrcweir     bool bDeleteContentCopy = true;
882cdf0e10cSrcweir     switch( nSelectedPopupEntry )
883cdf0e10cSrcweir 	{
884cdf0e10cSrcweir 		case CTX_UPDATE_SEL:
885cdf0e10cSrcweir 		{
886cdf0e10cSrcweir 			// zwei Durchlaeufe: zuerst die Bereiche, dann die Verzeichnisse
887cdf0e10cSrcweir 			// aktualisieren
888cdf0e10cSrcweir             SvLBoxEntry* pSelEntry = FirstSelected();
889cdf0e10cSrcweir             while( pSelEntry )
890cdf0e10cSrcweir 			{
891cdf0e10cSrcweir                 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
892cdf0e10cSrcweir                 if(GLBLDOC_SECTION == pContent->GetType() &&
893cdf0e10cSrcweir                     pContent->GetSection()->IsConnected())
894cdf0e10cSrcweir 				{
895cdf0e10cSrcweir                     ((SwSection*)pContent->GetSection())->UpdateNow();
896cdf0e10cSrcweir 				}
897cdf0e10cSrcweir 
898cdf0e10cSrcweir                 pSelEntry = NextSelected(pSelEntry);
899cdf0e10cSrcweir 			}
900cdf0e10cSrcweir             pSelEntry = FirstSelected();
901cdf0e10cSrcweir             while( pSelEntry )
902cdf0e10cSrcweir 			{
903cdf0e10cSrcweir                 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData();
904cdf0e10cSrcweir                 if(GLBLDOC_TOXBASE == pContent->GetType())
905cdf0e10cSrcweir                     pActiveShell->UpdateTableOf(*pContent->GetTOX());
906cdf0e10cSrcweir                 pSelEntry = NextSelected(pSelEntry);
907cdf0e10cSrcweir 			}
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 		}
910cdf0e10cSrcweir 		break;
911cdf0e10cSrcweir 		case CTX_UPDATE_INDEX:
912cdf0e10cSrcweir 		{
913cdf0e10cSrcweir 			nSlot = FN_UPDATE_TOX;
914cdf0e10cSrcweir 		}
915cdf0e10cSrcweir 		break;
916cdf0e10cSrcweir 		case CTX_UPDATE_LINK:
917cdf0e10cSrcweir 		case CTX_UPDATE_ALL:
918cdf0e10cSrcweir 		{
919cdf0e10cSrcweir 			pActiveShell->GetLinkManager().UpdateAllLinks(sal_True);
920cdf0e10cSrcweir             if(CTX_UPDATE_ALL == nSelectedPopupEntry)
921cdf0e10cSrcweir 				nSlot = FN_UPDATE_TOX;
922cdf0e10cSrcweir 			pCont = 0;
923cdf0e10cSrcweir 		}
924cdf0e10cSrcweir 		break;
925cdf0e10cSrcweir 		case CTX_EDIT:
926cdf0e10cSrcweir 		{
927cdf0e10cSrcweir 			DBG_ASSERT(pCont, "Edit ohne Entry ? " );
928cdf0e10cSrcweir 			EditContent(pCont);
929cdf0e10cSrcweir 		}
930cdf0e10cSrcweir 		break;
931cdf0e10cSrcweir         case CTX_EDIT_LINK:
932cdf0e10cSrcweir         {
933cdf0e10cSrcweir             DBG_ASSERT(pCont, "Edit ohne Entry ? " );
934cdf0e10cSrcweir             SfxStringItem aName(FN_EDIT_REGION,
935cdf0e10cSrcweir                     pCont->GetSection()->GetSectionName());
936cdf0e10cSrcweir             rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L);
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir         break;
939cdf0e10cSrcweir 		case CTX_DELETE:
940cdf0e10cSrcweir 		{
941cdf0e10cSrcweir 			// sind mehrere Eintraege selektiert, dann muss nach jedem delete
942cdf0e10cSrcweir 			// das Array neu gefuellt werden. Damit man sich nichts merken muss,
943cdf0e10cSrcweir 			// beginnt das Loeschen am Ende
944cdf0e10cSrcweir             SvLBoxEntry* pSelEntry = LastSelected();
945cdf0e10cSrcweir 			SwGlblDocContents* pTempContents  = 0;
946cdf0e10cSrcweir 			pActiveShell->StartAction();
947cdf0e10cSrcweir             while(pSelEntry)
948cdf0e10cSrcweir 			{
949cdf0e10cSrcweir 				pActiveShell->DeleteGlobalDocContent(
950cdf0e10cSrcweir 					pTempContents ? *pTempContents : *pSwGlblDocContents,
951cdf0e10cSrcweir                                      (sal_uInt16)GetModel()->GetAbsPos(pSelEntry));
952cdf0e10cSrcweir                 pSelEntry = PrevSelected(pSelEntry);
953cdf0e10cSrcweir                 if(pSelEntry)
954cdf0e10cSrcweir 				{
955cdf0e10cSrcweir 					pTempContents = new SwGlblDocContents;
956cdf0e10cSrcweir 					pActiveShell->GetGlobalDocContent(*pTempContents);
957cdf0e10cSrcweir 				}
958cdf0e10cSrcweir 			}
959cdf0e10cSrcweir 			delete pTempContents;
960cdf0e10cSrcweir 			pActiveShell->EndAction();
961cdf0e10cSrcweir 			pCont = 0;
962cdf0e10cSrcweir 		}
963cdf0e10cSrcweir 		break;
964cdf0e10cSrcweir 		case CTX_INSERT_ANY_INDEX:
965cdf0e10cSrcweir //		case CTX_INSERT_CNTIDX:
966cdf0e10cSrcweir //		case CTX_INSERT_USRIDX:
967cdf0e10cSrcweir 		{
968cdf0e10cSrcweir 			if(pContCopy)
969cdf0e10cSrcweir 			{
970cdf0e10cSrcweir 				SfxItemSet aSet(pActiveShell->GetView().GetPool(),
971cdf0e10cSrcweir 							RES_COL, RES_COL,
972cdf0e10cSrcweir 							RES_BACKGROUND, RES_BACKGROUND,
973cdf0e10cSrcweir 							RES_FRM_SIZE, RES_FRM_SIZE,
974cdf0e10cSrcweir 							SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
975cdf0e10cSrcweir 							RES_LR_SPACE, RES_LR_SPACE,
976cdf0e10cSrcweir 							FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE,
977cdf0e10cSrcweir 							0);
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
980cdf0e10cSrcweir                 DBG_ASSERT(pFact, "Dialogdiet fail!");
981cdf0e10cSrcweir                 AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX,
982cdf0e10cSrcweir 														this, aSet,
983cdf0e10cSrcweir 														*pActiveShell,
984cdf0e10cSrcweir 														0,
985cdf0e10cSrcweir 														USHRT_MAX,
986cdf0e10cSrcweir 														sal_True);
987cdf0e10cSrcweir                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
988cdf0e10cSrcweir 				if(RET_OK == pDlg->Execute())
989cdf0e10cSrcweir 				{
990cdf0e10cSrcweir 					SwTOXDescription&  rDesc = pDlg->GetTOXDescription(
991cdf0e10cSrcweir 												pDlg->GetCurrentTOXType());
992cdf0e10cSrcweir 					SwTOXMgr aMgr(pActiveShell);
993cdf0e10cSrcweir 					SwTOXBase* pToInsert = 0;
994cdf0e10cSrcweir 					if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet()))
995cdf0e10cSrcweir 						pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert );
996cdf0e10cSrcweir 				}
997cdf0e10cSrcweir 				pCont = 0;
998cdf0e10cSrcweir 				delete pDlg;
999cdf0e10cSrcweir 			}
1000cdf0e10cSrcweir 		}
1001cdf0e10cSrcweir 		break;
1002cdf0e10cSrcweir 		case CTX_INSERT_FILE:
1003cdf0e10cSrcweir 		{
1004cdf0e10cSrcweir             bDeleteContentCopy = false;
1005cdf0e10cSrcweir             pDocContent = pContCopy;
1006cdf0e10cSrcweir             InsertRegion( pContCopy );
1007cdf0e10cSrcweir             pCont = NULL;
1008cdf0e10cSrcweir 		}
1009cdf0e10cSrcweir 		break;
1010cdf0e10cSrcweir 		case CTX_INSERT_NEW_FILE:
1011cdf0e10cSrcweir 		{
1012cdf0e10cSrcweir 			SfxViewFrame* pGlobFrm = pActiveShell->GetView().GetViewFrame();
1013cdf0e10cSrcweir 			SwGlobalFrameListener_Impl aFrmListener(*pGlobFrm);
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir             sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : (sal_uLong)-1;
1016cdf0e10cSrcweir 			// neues Dok anlegen
1017cdf0e10cSrcweir 			SfxStringItem aFactory(SID_NEWDOCDIRECT,
1018cdf0e10cSrcweir 							SwDocShell::Factory().GetFilterContainer()->GetName());
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 			 const SfxFrameItem* pItem = (SfxFrameItem*)
1021cdf0e10cSrcweir 							rDispatch.Execute(SID_NEWDOCDIRECT,
1022cdf0e10cSrcweir 								SFX_CALLMODE_SYNCHRON, &aFactory, 0L);
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 			// sichern unter
1025cdf0e10cSrcweir 			SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0;
1026cdf0e10cSrcweir 			SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0;
1027cdf0e10cSrcweir 			if( pFrame )
1028cdf0e10cSrcweir 			{
1029cdf0e10cSrcweir 				const SfxBoolItem* pBool = (const SfxBoolItem*)
1030cdf0e10cSrcweir 						pFrame->GetDispatcher()->Execute(
1031cdf0e10cSrcweir 								SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON );
1032cdf0e10cSrcweir 				SfxObjectShell& rObj = *pFrame->GetObjectShell();
1033cdf0e10cSrcweir 				const SfxMedium* pMedium = rObj.GetMedium();
1034cdf0e10cSrcweir 				String sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI));
1035cdf0e10cSrcweir                 // Bereich mit dem Dok-Namen einfuegen
1036cdf0e10cSrcweir 				// eigenes Dok in den Vordergrund
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir 				if(aFrmListener.IsValid() && sNewFile.Len())
1039cdf0e10cSrcweir 				{
1040cdf0e10cSrcweir 					pGlobFrm->ToTop();
1041cdf0e10cSrcweir 					// durch das Update sind die Eintraege invalid
1042cdf0e10cSrcweir                     if(nEntryPos != (sal_uLong)-1)
1043cdf0e10cSrcweir 					{
1044cdf0e10cSrcweir 						Update( sal_False );
1045cdf0e10cSrcweir 						Display();
1046cdf0e10cSrcweir 						Select(GetModel()->GetEntryAtAbsPos(nEntryPos));
1047cdf0e10cSrcweir 						pEntry = FirstSelected();
1048cdf0e10cSrcweir 						pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0;
1049cdf0e10cSrcweir 					}
1050cdf0e10cSrcweir 					else
1051cdf0e10cSrcweir 					{
1052cdf0e10cSrcweir 						pEntry = 0;
1053cdf0e10cSrcweir 						pCont = 0;
1054cdf0e10cSrcweir 					}
1055cdf0e10cSrcweir 					if(pBool->GetValue())
1056cdf0e10cSrcweir 					{
1057cdf0e10cSrcweir 						InsertRegion(pCont, &sNewFile);
1058cdf0e10cSrcweir 						pFrame->ToTop();
1059cdf0e10cSrcweir 					}
1060cdf0e10cSrcweir 					else
1061cdf0e10cSrcweir 						pFrame->GetDispatcher()->Execute(SID_CLOSEWIN,
1062cdf0e10cSrcweir 												SFX_CALLMODE_SYNCHRON);
1063cdf0e10cSrcweir 				}
1064cdf0e10cSrcweir 				else
1065cdf0e10cSrcweir 				{
1066cdf0e10cSrcweir 					pFrame->ToTop();
1067cdf0e10cSrcweir                     return;
1068cdf0e10cSrcweir 				}
1069cdf0e10cSrcweir 			}
1070cdf0e10cSrcweir 		}
1071cdf0e10cSrcweir 		break;
1072cdf0e10cSrcweir 		case CTX_INSERT_TEXT:
1073cdf0e10cSrcweir 		{
1074cdf0e10cSrcweir 			if(pCont)
1075cdf0e10cSrcweir 				pActiveShell->InsertGlobalDocContent(*pCont);
1076cdf0e10cSrcweir 			else
1077cdf0e10cSrcweir 			{
1078cdf0e10cSrcweir 				pActiveShell->SplitNode(); // leeres Dokument
1079cdf0e10cSrcweir 				pActiveShell->Up( sal_False, 1 );
1080cdf0e10cSrcweir 			}
1081cdf0e10cSrcweir 			pActiveShell->GetView().GetEditWin().GrabFocus();
1082cdf0e10cSrcweir 		}
1083cdf0e10cSrcweir 		break;
1084cdf0e10cSrcweir 		case CTX_UPDATE:
1085cdf0e10cSrcweir 			pCont = 0;
1086cdf0e10cSrcweir 		break;
1087cdf0e10cSrcweir 		default:;
1088cdf0e10cSrcweir 		// hier passiert nichts
1089cdf0e10cSrcweir 	}
1090cdf0e10cSrcweir 	if(pCont)
1091cdf0e10cSrcweir 		GotoContent(pCont);
1092cdf0e10cSrcweir 	if(nSlot)
1093cdf0e10cSrcweir 		rDispatch.Execute(nSlot);
1094cdf0e10cSrcweir 	if(Update( sal_False ))
1095cdf0e10cSrcweir 		Display();
1096cdf0e10cSrcweir     if ( bDeleteContentCopy )
1097cdf0e10cSrcweir         delete pContCopy;
1098cdf0e10cSrcweir     else
1099cdf0e10cSrcweir         bDeleteContentCopy = true;
1100cdf0e10cSrcweir //  return sal_True;
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir /*-----------------16.06.97 07:57-------------------
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlobalTree,Timeout,Timer *,EMPTYARG)1106cdf0e10cSrcweir IMPL_LINK( SwGlobalTree, Timeout, Timer*, EMPTYARG )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir 	if(!HasFocus() && Update( sal_False ))
1109cdf0e10cSrcweir 		Display();
1110cdf0e10cSrcweir 	return 0;
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir /*-----------------13.06.97 16:56-------------------
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir --------------------------------------------------*/
GotoContent(const SwGlblDocContent * pCont)1116cdf0e10cSrcweir void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont)
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir 	pActiveShell->EnterStdMode();
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 	switch( pCont->GetType()  )
1121cdf0e10cSrcweir 	{
1122cdf0e10cSrcweir 		case GLBLDOC_UNKNOWN:
1123cdf0e10cSrcweir 			pActiveShell->GotoGlobalDocContent(*pCont);
1124cdf0e10cSrcweir 		break;
1125cdf0e10cSrcweir 		case GLBLDOC_TOXBASE:
1126cdf0e10cSrcweir 		{
1127cdf0e10cSrcweir 			String sName = pCont->GetTOX()->GetTOXName();
1128cdf0e10cSrcweir 			if (!pActiveShell->GotoNextTOXBase(&sName))
1129cdf0e10cSrcweir 				pActiveShell->GotoPrevTOXBase(&sName);
1130cdf0e10cSrcweir 		}
1131cdf0e10cSrcweir 		break;
1132cdf0e10cSrcweir 		case GLBLDOC_SECTION:
1133cdf0e10cSrcweir 		break;
1134cdf0e10cSrcweir 	}
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir /*-----------------16.06.97 07:42-------------------
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir --------------------------------------------------*/
ShowTree()1140cdf0e10cSrcweir void	SwGlobalTree::ShowTree()
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir 	aUpdateTimer.Start();
1143cdf0e10cSrcweir 	SvTreeListBox::Show();
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir /*-----------------16.06.97 07:42-------------------
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir --------------------------------------------------*/
HideTree()1148cdf0e10cSrcweir void	SwGlobalTree::HideTree()
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir 	aUpdateTimer.Stop();
1151cdf0e10cSrcweir 	SvTreeListBox::Hide();
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir /*-----------------18.06.97 10:02-------------------
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir --------------------------------------------------*/
ExecCommand(sal_uInt16 nCmd)1156cdf0e10cSrcweir void 	SwGlobalTree::ExecCommand(sal_uInt16 nCmd)
1157cdf0e10cSrcweir {
1158cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FirstSelected();
1159cdf0e10cSrcweir     DBG_ASSERT(pEntry, "gleich knallt's");
1160cdf0e10cSrcweir 	if(FN_GLOBAL_EDIT == nCmd)
1161cdf0e10cSrcweir 	{
1162cdf0e10cSrcweir 		const SwGlblDocContent* pCont = (const SwGlblDocContent*)
1163cdf0e10cSrcweir 												pEntry->GetUserData();
1164cdf0e10cSrcweir 		EditContent(pCont);
1165cdf0e10cSrcweir 	}
1166cdf0e10cSrcweir 	else
1167cdf0e10cSrcweir 	{
1168cdf0e10cSrcweir 		if(GetSelectionCount() == 1)
1169cdf0e10cSrcweir 		{
1170cdf0e10cSrcweir 			sal_Bool bMove = sal_False;
1171cdf0e10cSrcweir 			sal_uInt16 nSource = (sal_uInt16)GetModel()->GetAbsPos(pEntry);
1172cdf0e10cSrcweir 			sal_uInt16 nDest = nSource;
1173cdf0e10cSrcweir 			switch(nCmd)
1174cdf0e10cSrcweir 			{
1175cdf0e10cSrcweir 				case FN_ITEM_DOWN:
1176cdf0e10cSrcweir 				{
1177cdf0e10cSrcweir 					sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
1178cdf0e10cSrcweir 					bMove = nEntryCount > nSource + 1;
1179cdf0e10cSrcweir 					nDest+= 2;
1180cdf0e10cSrcweir 				}
1181cdf0e10cSrcweir 				break;
1182cdf0e10cSrcweir 				case FN_ITEM_UP:
1183cdf0e10cSrcweir 				{
1184cdf0e10cSrcweir 					if(nSource)
1185cdf0e10cSrcweir 						bMove = 0 != nSource;
1186cdf0e10cSrcweir 					nDest--;
1187cdf0e10cSrcweir 				}
1188cdf0e10cSrcweir 				break;
1189cdf0e10cSrcweir 			}
1190cdf0e10cSrcweir 			if(	bMove && pActiveShell->MoveGlobalDocContent(
1191cdf0e10cSrcweir 				*pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
1192cdf0e10cSrcweir 					Update( sal_False ))
1193cdf0e10cSrcweir 				Display();
1194cdf0e10cSrcweir 		}
1195cdf0e10cSrcweir 	}
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir /*-----------------16.06.97 07:43-------------------
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir --------------------------------------------------*/
Update(sal_Bool bHard)1201cdf0e10cSrcweir sal_Bool  	SwGlobalTree::Update(sal_Bool bHard)
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir 	SwView* pActView = GetParentWindow()->GetCreateView();
1204cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1205cdf0e10cSrcweir     if(pActView && pActView->GetWrtShellPtr())
1206cdf0e10cSrcweir 	{
1207cdf0e10cSrcweir 		const SwWrtShell* pOldShell = pActiveShell;
1208cdf0e10cSrcweir 		pActiveShell = pActView->GetWrtShellPtr();
1209cdf0e10cSrcweir 		if(pActiveShell != pOldShell)
1210cdf0e10cSrcweir         {
1211cdf0e10cSrcweir             delete pSwGlblDocContents;
1212cdf0e10cSrcweir             pSwGlblDocContents = 0;
1213cdf0e10cSrcweir         }
1214cdf0e10cSrcweir         if(!pSwGlblDocContents)
1215cdf0e10cSrcweir 		{
1216cdf0e10cSrcweir 			pSwGlblDocContents = new SwGlblDocContents;
1217cdf0e10cSrcweir 			bRet = sal_True;
1218cdf0e10cSrcweir 			pActiveShell->GetGlobalDocContent(*pSwGlblDocContents);
1219cdf0e10cSrcweir 		}
1220cdf0e10cSrcweir 		else
1221cdf0e10cSrcweir 		{
1222cdf0e10cSrcweir 			sal_Bool bCopy = sal_False;
1223cdf0e10cSrcweir 			SwGlblDocContents* pTempContents  = new SwGlblDocContents;
1224cdf0e10cSrcweir 			pActiveShell->GetGlobalDocContent(*pTempContents);
1225cdf0e10cSrcweir 			if(pTempContents->Count() != pSwGlblDocContents->Count() ||
1226cdf0e10cSrcweir 					pTempContents->Count() != GetEntryCount())
1227cdf0e10cSrcweir 			{
1228cdf0e10cSrcweir 				bRet = sal_True;
1229cdf0e10cSrcweir 				bCopy = sal_True;
1230cdf0e10cSrcweir 			}
1231cdf0e10cSrcweir 			else
1232cdf0e10cSrcweir 			{
1233cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < pTempContents->Count() && !bCopy; i++)
1234cdf0e10cSrcweir 				{
1235cdf0e10cSrcweir 					SwGlblDocContent* pLeft = pTempContents->GetObject(i);
1236cdf0e10cSrcweir 					SwGlblDocContent* pRight = pSwGlblDocContents->GetObject(i);
1237cdf0e10cSrcweir 					GlobalDocContentType eType = pLeft->GetType();
1238cdf0e10cSrcweir 					SvLBoxEntry* pEntry = GetEntry(i);
1239cdf0e10cSrcweir 					String sTemp = GetEntryText(pEntry);
1240cdf0e10cSrcweir 					if (
1241cdf0e10cSrcweir 					     eType != pRight->GetType() ||
1242cdf0e10cSrcweir 					     (
1243cdf0e10cSrcweir 					       eType == GLBLDOC_SECTION &&
1244cdf0e10cSrcweir 					       pLeft->GetSection()->GetSectionName() != sTemp
1245cdf0e10cSrcweir 					     ) ||
1246cdf0e10cSrcweir 					     (
1247cdf0e10cSrcweir 					       eType == GLBLDOC_TOXBASE &&
1248cdf0e10cSrcweir 					       pLeft->GetTOX()->GetTitle() != sTemp
1249cdf0e10cSrcweir 					     )
1250cdf0e10cSrcweir 					   )
1251cdf0e10cSrcweir 					{
1252cdf0e10cSrcweir 						bCopy = bRet = sal_True;
1253cdf0e10cSrcweir 					}
1254cdf0e10cSrcweir 				}
1255cdf0e10cSrcweir 			}
1256cdf0e10cSrcweir 			if(bCopy || bHard)
1257cdf0e10cSrcweir 			{
1258cdf0e10cSrcweir 				sal_uInt16 i;
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 				pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count());
1261cdf0e10cSrcweir 				for( i = 0; i < pTempContents->Count(); i++)
1262cdf0e10cSrcweir 				{
1263cdf0e10cSrcweir 					pSwGlblDocContents->Insert(pTempContents->GetObject(i));
1264cdf0e10cSrcweir 				}
1265cdf0e10cSrcweir 				for( i = pTempContents->Count(); i; i--)
1266cdf0e10cSrcweir 					pTempContents->Remove(i - 1);
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir 			}
1269cdf0e10cSrcweir 			delete pTempContents;
1270cdf0e10cSrcweir 		}
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir 	}
1273cdf0e10cSrcweir 	else
1274cdf0e10cSrcweir 	{
1275cdf0e10cSrcweir 		Clear();
1276cdf0e10cSrcweir 		if(pSwGlblDocContents)
1277cdf0e10cSrcweir 			pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count());
1278cdf0e10cSrcweir 	}
1279cdf0e10cSrcweir 	// hier muss noch eine Veraenderungspruefung rein!
1280cdf0e10cSrcweir 	return bRet;
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir /*-----------------25.06.97 16:20-------------------
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir --------------------------------------------------*/
OpenDoc(const SwGlblDocContent * pCont)1286cdf0e10cSrcweir void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont)
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir     String sFileName(pCont->GetSection()->GetLinkFileName().GetToken(0,
1289cdf0e10cSrcweir             sfx2::cTokenSeperator));
1290cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
1291cdf0e10cSrcweir 	const SfxObjectShell* pCurr = SfxObjectShell::GetFirst();
1292cdf0e10cSrcweir 	while( !bFound && pCurr )
1293cdf0e10cSrcweir 	{
1294cdf0e10cSrcweir 		if(pCurr->GetMedium() &&
1295cdf0e10cSrcweir 			String(pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)) == sFileName)
1296cdf0e10cSrcweir 		{
1297cdf0e10cSrcweir 			bFound = sal_True;
1298cdf0e10cSrcweir 			SwGlobalTree::SetShowShell(pCurr);
1299cdf0e10cSrcweir 			Application::PostUserEvent( STATIC_LINK(
1300cdf0e10cSrcweir 						this, SwGlobalTree, ShowFrameHdl ) );
1301cdf0e10cSrcweir 			pCurr = 0;
1302cdf0e10cSrcweir 		}
1303cdf0e10cSrcweir 		else
1304cdf0e10cSrcweir 			pCurr = SfxObjectShell::GetNext(*pCurr);
1305cdf0e10cSrcweir 	}
1306cdf0e10cSrcweir 	if(!bFound)
1307cdf0e10cSrcweir 	{
1308cdf0e10cSrcweir 		SfxStringItem aURL(SID_FILE_NAME,
1309cdf0e10cSrcweir 			sFileName);
1310cdf0e10cSrcweir 		SfxBoolItem aReadOnly(SID_DOC_READONLY, sal_False);
1311cdf0e10cSrcweir 		SfxStringItem aTargetFrameName( SID_TARGETNAME, String::CreateFromAscii("_blank") );
1312cdf0e10cSrcweir 		SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle());
1313cdf0e10cSrcweir 		pActiveShell->GetView().GetViewFrame()->GetDispatcher()->
1314cdf0e10cSrcweir 				Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON,
1315cdf0e10cSrcweir 							&aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L);
1316cdf0e10cSrcweir 	}
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir /*-----------------25.06.97 16:08-------------------
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir --------------------------------------------------*/
IMPL_LINK(SwGlobalTree,DoubleClickHdl,SwGlobalTree *,EMPTYARG)1322cdf0e10cSrcweir IMPL_LINK( 	SwGlobalTree, DoubleClickHdl, SwGlobalTree *, EMPTYARG )
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetCurEntry();
1325cdf0e10cSrcweir 	SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
1326cdf0e10cSrcweir 	if(pCont->GetType() == GLBLDOC_SECTION)
1327cdf0e10cSrcweir 		OpenDoc(pCont);
1328cdf0e10cSrcweir 	else
1329cdf0e10cSrcweir 	{
1330cdf0e10cSrcweir 		GotoContent(pCont);
1331cdf0e10cSrcweir 		pActiveShell->GetView().GetEditWin().GrabFocus();
1332cdf0e10cSrcweir 	}
1333cdf0e10cSrcweir 	return 0;
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir /*-----------------07.10.97 08:09-------------------
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir --------------------------------------------------*/
IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree,ShowFrameHdl,SwGlobalTree *,EMPTYARG)1339cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG)
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir 	if(SwGlobalTree::GetShowShell())
1342cdf0e10cSrcweir 		SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop();
1343cdf0e10cSrcweir 	SwGlobalTree::SetShowShell(0);
1344cdf0e10cSrcweir 	return 0;
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir /* -----------------04.11.98 10:43-------------------
1347cdf0e10cSrcweir  *
1348cdf0e10cSrcweir  * --------------------------------------------------*/
InitEntry(SvLBoxEntry * pEntry,const XubString & rStr,const Image & rImg1,const Image & rImg2,SvLBoxButtonKind eButtonKind)1349cdf0e10cSrcweir void SwGlobalTree::InitEntry(SvLBoxEntry* pEntry,
1350cdf0e10cSrcweir 		const XubString& rStr ,const Image& rImg1,const Image& rImg2,
1351cdf0e10cSrcweir         SvLBoxButtonKind eButtonKind)
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir 	sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
1354cdf0e10cSrcweir 	SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
1355cdf0e10cSrcweir 	SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
1356cdf0e10cSrcweir 	SwLBoxString* pStr = new SwLBoxString( pEntry, 0, pCol->GetText() );
1357cdf0e10cSrcweir 	pEntry->ReplaceItem( pStr, nColToHilite );
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir /* -----------------04.11.98 10:39-------------------
1360cdf0e10cSrcweir  *
1361cdf0e10cSrcweir  * --------------------------------------------------*/
1362cdf0e10cSrcweir 
Paint(const Point & rPos,SvLBox & rDev,sal_uInt16 nFlags,SvLBoxEntry * pEntry)1363cdf0e10cSrcweir void SwLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
1364cdf0e10cSrcweir 	SvLBoxEntry* pEntry )
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir 	SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData();
1367cdf0e10cSrcweir 	const SwSection* pSect;
1368cdf0e10cSrcweir 	if(pCont->GetType() == GLBLDOC_SECTION &&
1369cdf0e10cSrcweir 		!(pSect = pCont->GetSection())->IsConnectFlag()	)
1370cdf0e10cSrcweir 	{
1371cdf0e10cSrcweir 		Font aOldFont( rDev.GetFont());
1372cdf0e10cSrcweir 		Font aFont(aOldFont);
1373cdf0e10cSrcweir 		Color aCol( COL_LIGHTRED );
1374cdf0e10cSrcweir 		aFont.SetColor( aCol );
1375cdf0e10cSrcweir 		rDev.SetFont( aFont );
1376cdf0e10cSrcweir 		rDev.DrawText( rPos, GetText() );
1377cdf0e10cSrcweir 		rDev.SetFont( aOldFont );
1378cdf0e10cSrcweir 	}
1379cdf0e10cSrcweir 	else
1380cdf0e10cSrcweir 		SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir /* -----------------------------06.05.2002 10:20------------------------------
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
DataChanged(const DataChangedEvent & rDCEvt)1385cdf0e10cSrcweir void    SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1388cdf0e10cSrcweir          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1389cdf0e10cSrcweir     {
1390cdf0e10cSrcweir         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
1391cdf0e10cSrcweir         aEntryImages = ImageList(SW_RES(nResId));
1392cdf0e10cSrcweir         Update(sal_True);
1393cdf0e10cSrcweir     }
1394cdf0e10cSrcweir     SvTreeListBox::DataChanged( rDCEvt );
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir 
InsertRegion(const SwGlblDocContent * _pContent,const Sequence<OUString> & _rFiles)1397cdf0e10cSrcweir void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles )
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir     sal_Int32 nFiles = _rFiles.getLength();
1400cdf0e10cSrcweir     if ( nFiles )
1401cdf0e10cSrcweir     {
1402cdf0e10cSrcweir         sal_Bool bMove = sal_False;
1403cdf0e10cSrcweir         if ( !_pContent )
1404cdf0e10cSrcweir         {
1405cdf0e10cSrcweir             SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible();
1406cdf0e10cSrcweir             _pContent = (SwGlblDocContent*)pLast->GetUserData();
1407cdf0e10cSrcweir             bMove = sal_True;
1408cdf0e10cSrcweir         }
1409cdf0e10cSrcweir         String sFilePassword;
1410cdf0e10cSrcweir         sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount();
1411cdf0e10cSrcweir         const OUString* pFileNames = _rFiles.getConstArray();
1412cdf0e10cSrcweir         SwWrtShell& rSh = GetParentWindow()->GetCreateView()->GetWrtShell();
1413cdf0e10cSrcweir         rSh.StartAction();
1414cdf0e10cSrcweir         // after insertion of the first new content the 'pCont' parameter becomes invalid
1415cdf0e10cSrcweir         // find the index of the 'anchor' content to always use a current anchor content
1416cdf0e10cSrcweir         sal_uInt16 nAnchorContent = pSwGlblDocContents->Count() - 1;
1417cdf0e10cSrcweir         if ( !bMove )
1418cdf0e10cSrcweir         {
1419cdf0e10cSrcweir             for( sal_uInt16 nContent = 0; nContent < pSwGlblDocContents->Count(); ++nContent )
1420cdf0e10cSrcweir             {
1421cdf0e10cSrcweir                 if( *_pContent == *pSwGlblDocContents->GetObject( nContent ) )
1422cdf0e10cSrcweir                 {
1423cdf0e10cSrcweir                     nAnchorContent = nContent;
1424cdf0e10cSrcweir                     break;
1425cdf0e10cSrcweir                 }
1426cdf0e10cSrcweir             }
1427cdf0e10cSrcweir         }
1428cdf0e10cSrcweir         SwGlblDocContents aTempContents;
1429cdf0e10cSrcweir         for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile )
1430cdf0e10cSrcweir         {
1431cdf0e10cSrcweir             //update the global document content after each inserted document
1432cdf0e10cSrcweir             rSh.GetGlobalDocContent(aTempContents);
1433cdf0e10cSrcweir             SwGlblDocContent* pAnchorContent = 0;
1434cdf0e10cSrcweir             DBG_ASSERT(aTempContents.Count() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed");
1435cdf0e10cSrcweir             if ( aTempContents.Count() > (nAnchorContent + nFile) )
1436cdf0e10cSrcweir                 pAnchorContent = aTempContents.GetObject(nAnchorContent + (sal_uInt16)nFile);
1437cdf0e10cSrcweir             else
1438cdf0e10cSrcweir                 pAnchorContent = aTempContents.GetObject(aTempContents.Count() - 1);
1439cdf0e10cSrcweir             String sFileName(pFileNames[nFile]);
1440cdf0e10cSrcweir             INetURLObject aFileUrl;
1441cdf0e10cSrcweir             aFileUrl.SetSmartURL( sFileName );
1442cdf0e10cSrcweir             String sSectionName(String(aFileUrl.GetLastName(
1443cdf0e10cSrcweir                 INetURLObject::DECODE_UNAMBIGUOUS)).GetToken(0,
1444cdf0e10cSrcweir                 sfx2::cTokenSeperator));
1445cdf0e10cSrcweir             sal_uInt16 nSectCount = rSh.GetSectionFmtCount();
1446cdf0e10cSrcweir             String sTempSectionName(sSectionName);
1447cdf0e10cSrcweir             sal_uInt16 nAddNumber = 0;
1448cdf0e10cSrcweir             sal_uInt16 nCount = 0;
1449cdf0e10cSrcweir             // evtl : und Index anhaengen, wenn der Bereichsname schon vergeben ist
1450cdf0e10cSrcweir             while ( nCount < nSectCount )
1451cdf0e10cSrcweir             {
1452cdf0e10cSrcweir                 const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount);
1453cdf0e10cSrcweir                 if ((rFmt.GetSection()->GetSectionName() == sTempSectionName)
1454cdf0e10cSrcweir                     && rFmt.IsInNodesArr())
1455cdf0e10cSrcweir                 {
1456cdf0e10cSrcweir                     nCount = 0;
1457cdf0e10cSrcweir                     nAddNumber++;
1458cdf0e10cSrcweir                     sTempSectionName = sSectionName;
1459cdf0e10cSrcweir                     sTempSectionName += ':';
1460cdf0e10cSrcweir                     sTempSectionName += String::CreateFromInt32( nAddNumber );
1461cdf0e10cSrcweir                 }
1462cdf0e10cSrcweir                 else
1463cdf0e10cSrcweir                     nCount++;
1464cdf0e10cSrcweir             }
1465cdf0e10cSrcweir 
1466cdf0e10cSrcweir             if ( nAddNumber )
1467cdf0e10cSrcweir                 sSectionName = sTempSectionName;
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir             SwSectionData aSectionData(CONTENT_SECTION, sSectionName);
1470cdf0e10cSrcweir             aSectionData.SetProtectFlag(true);
1471cdf0e10cSrcweir             aSectionData.SetHidden(false);
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir             aSectionData.SetLinkFileName(sFileName);
1474cdf0e10cSrcweir             aSectionData.SetType(FILE_LINK_SECTION);
1475cdf0e10cSrcweir             aSectionData.SetLinkFilePassword( sFilePassword );
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir             rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData );
1478cdf0e10cSrcweir         }
1479cdf0e10cSrcweir         if ( bMove )
1480cdf0e10cSrcweir         {
1481cdf0e10cSrcweir             Update( sal_False );
1482cdf0e10cSrcweir             rSh.MoveGlobalDocContent(
1483cdf0e10cSrcweir                 *pSwGlblDocContents, nEntryCount, nEntryCount + (sal_uInt16)nFiles, nEntryCount - (sal_uInt16)nFiles );
1484cdf0e10cSrcweir         }
1485cdf0e10cSrcweir         rSh.EndAction();
1486cdf0e10cSrcweir         Update( sal_False );
1487cdf0e10cSrcweir         Display();
1488cdf0e10cSrcweir     }
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir 
IMPL_LINK(SwGlobalTree,DialogClosedHdl,sfx2::FileDialogHelper *,_pFileDlg)1491cdf0e10cSrcweir IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir     Application::SetDefDialogParent( pDefParentWin );
1494cdf0e10cSrcweir     if ( ERRCODE_NONE == _pFileDlg->GetError() )
1495cdf0e10cSrcweir     {
1496cdf0e10cSrcweir         SfxMediumList* pMedList = pDocInserter->CreateMediumList();
1497cdf0e10cSrcweir         if ( pMedList )
1498cdf0e10cSrcweir         {
1499cdf0e10cSrcweir             Sequence< OUString >aFileNames( pMedList->Count() );
1500cdf0e10cSrcweir             OUString* pFileNames = aFileNames.getArray();
1501cdf0e10cSrcweir             SfxMedium* pMed = pMedList->First();
1502cdf0e10cSrcweir             sal_Int32 nPos = 0;
1503cdf0e10cSrcweir             while ( pMed )
1504cdf0e10cSrcweir             {
1505cdf0e10cSrcweir                 String sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
1506cdf0e10cSrcweir                 sFileName += sfx2::cTokenSeperator;
1507cdf0e10cSrcweir                 sFileName += pMed->GetFilter()->GetFilterName();
1508cdf0e10cSrcweir                 sFileName += sfx2::cTokenSeperator;
1509cdf0e10cSrcweir                 pFileNames[nPos++] = sFileName;
1510cdf0e10cSrcweir                 pMed = pMedList->Next();
1511cdf0e10cSrcweir             }
1512cdf0e10cSrcweir             delete pMedList;
1513cdf0e10cSrcweir             InsertRegion( pDocContent, aFileNames );
1514cdf0e10cSrcweir             DELETEZ( pDocContent );
1515cdf0e10cSrcweir         }
1516cdf0e10cSrcweir     }
1517cdf0e10cSrcweir     return 0;
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir 
1520