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