xref: /aoo42x/main/sw/source/ui/utlui/content.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #ifndef _SVSTDARR_HXX
32 #define _SVSTDARR_STRINGSDTOR
33 #include <svl/svstdarr.hxx>
34 #endif
35 #include <svl/urlbmk.hxx>
36 #include <tools/urlobj.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <vcl/help.hxx>
40 #include <sot/formats.hxx>
41 #include <vcl/sound.hxx>
42 #include <uiitems.hxx>
43 #include <fmtinfmt.hxx>
44 #include <txtinet.hxx>
45 #include <fmtfld.hxx>
46 #include <swmodule.hxx>
47 #include <wrtsh.hxx>
48 #include <view.hxx>
49 #include <errhdl.hxx>
50 #include <docsh.hxx>
51 #include <content.hxx>
52 #include <frmfmt.hxx>
53 #include <fldbas.hxx>
54 #include <txtatr.hxx>
55 #include <IMark.hxx>
56 #include <section.hxx>
57 #include <tox.hxx>
58 #define NAVIPI_CXX
59 #include <navipi.hxx>
60 #include <navicont.hxx>
61 #include <navicfg.hxx>
62 #include <edtwin.hxx>
63 #include <doc.hxx>
64 #include <unotools.hxx>
65 #include <crsskip.hxx>
66 #include <cmdid.h>
67 #include <helpid.h>
68 #include <navipi.hrc>
69 #include <utlui.hrc>
70 #include <misc.hrc>
71 #include <comcore.hrc>
72 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
73 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
74 #include <com/sun/star/text/XTextTablesSupplier.hpp>
75 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
76 #include <com/sun/star/text/XDocumentIndex.hpp>
77 #include <com/sun/star/text/XBookmarksSupplier.hpp>
78 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
79 #include <com/sun/star/text/XTextFramesSupplier.hpp>
80 #include <dcontact.hxx>
81 #include <svx/svdogrp.hxx>
82 #include <svx/svdmodel.hxx>
83 #include <svx/svdpage.hxx>
84 #include <svx/svdview.hxx>
85 #include <vcl/scrbar.hxx>
86 #include <comcore.hrc>
87 #include <SwRewriter.hxx>
88 #include <hints.hxx>
89 #include <numrule.hxx>
90 #include <swundo.hxx>
91 #include <ndtxt.hxx>
92 #include <PostItMgr.hxx>
93 #include <postithelper.hxx>
94 #include <redline.hxx>
95 #include <docary.hxx>
96 
97 #include "swabstdlg.hxx"
98 #include "globals.hrc"
99 #include <unomid.h>
100 
101 
102 #define CTYPE_CNT	0
103 #define CTYPE_CTT	1
104 
105 using namespace ::std;
106 using namespace ::com::sun::star;
107 using namespace ::com::sun::star::text;
108 using namespace ::com::sun::star::uno;
109 using namespace ::com::sun::star::container;
110 
111 
112 #define NAVI_BOOKMARK_DELIM		(sal_Unicode)1
113 
114 /***************************************************************************
115 
116 ***************************************************************************/
117 
118 typedef SwContent* SwContentPtr;
119 SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0,4)
120 SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr)
121 
122 sal_Bool SwContentTree::bIsInDrag = sal_False;
123 
124 
125 namespace
126 {
127     static sal_Bool lcl_IsContent(SvLBoxEntry* pEntry)
128     {
129         return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
130     }
131 
132 
133     static sal_Bool lcl_IsContentType(SvLBoxEntry* pEntry)
134     {
135         return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
136     }
137 
138 
139     static sal_Bool lcl_FindShell(SwWrtShell* pShell)
140     {
141         sal_Bool bFound = sal_False;
142         SwView *pView = SwModule::GetFirstView();
143         while (pView)
144         {
145             if(pShell == &pView->GetWrtShell())
146             {
147                 bFound = sal_True;
148                 break;
149             }
150             pView = SwModule::GetNextView(pView);
151         }
152         return bFound;
153     }
154 
155     static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark)
156     {
157         return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK;
158     }
159 }
160 
161 /***************************************************************************
162 	Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhalstyp
163 ***************************************************************************/
164 
165 
166 SwContent::SwContent(const SwContentType* pCnt, const String& rName, long nYPos) :
167     SwTypeNumber(CTYPE_CNT),
168 	pParent(pCnt),
169 	sContentName(rName),
170 	nYPosition(nYPos),
171 	bInvisible(sal_False)
172 {
173 }
174 
175 
176 sal_uInt8	SwTypeNumber::GetTypeId()
177 {
178 	return nTypeId;
179 }
180 
181 SwTypeNumber::~SwTypeNumber()
182 {
183 }
184 
185 sal_Bool SwContent::IsProtect() const
186 {
187 	return sal_False;
188 }
189 
190 sal_Bool SwPostItContent::IsProtect() const
191 {
192 	if (mbPostIt)
193 		return pFld->IsProtect();
194 	else
195 		return false;
196 }
197 
198 sal_Bool SwURLFieldContent::IsProtect() const
199 {
200 	return pINetAttr->IsProtect();
201 }
202 
203 SwGraphicContent::~SwGraphicContent()
204 {
205 }
206 SwTOXBaseContent::~SwTOXBaseContent()
207 {
208 }
209 
210 /***************************************************************************
211 	Beschreibung: 	Inhaltstyp, kennt seine Inhalte und die WrtShell
212 ***************************************************************************/
213 
214 
215 SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) :
216 	SwTypeNumber(CTYPE_CTT),
217 	pWrtShell(pShell),
218     pMember(0),
219     sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)),
220     sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)),
221     nMemberCount(0),
222 	nContentType(nType),
223 	nOutlineLevel(nLevel),
224     bMemberFilled(sal_False),
225 	bDataValid(sal_False),
226 	bEdit(sal_False),
227     bDelete(sal_True)
228 {
229 	Init();
230 }
231 
232 /***************************************************************************
233 	Beschreibung: 	Initialisierung
234 ***************************************************************************/
235 
236 
237 void SwContentType::Init(sal_Bool* pbInvalidateWindow)
238 {
239 	// wenn sich der MemberCount aendert ...
240 	sal_uInt16 nOldMemberCount = nMemberCount;
241 	nMemberCount = 0;
242 	switch(nContentType)
243 	{
244 		case CONTENT_TYPE_OUTLINE	:
245 		{
246 			sTypeToken = C2S(pMarkToOutline);
247             sal_uInt16 nOutlineCount = nMemberCount =
248                 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
249 			if(nOutlineLevel < MAXLEVEL)
250 			{
251 				for(sal_uInt16 j = 0; j < nOutlineCount; j++)
252 				{
253                     if(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(j) > nOutlineLevel )
254 						nMemberCount --;
255 				}
256 			}
257 			bDelete = sal_False;
258 		}
259 		break;
260 
261 		case CONTENT_TYPE_TABLE 	:
262 			sTypeToken = C2S(pMarkToTable);
263 			nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True);
264 			bEdit = sal_True;
265 		break;
266 
267 		case CONTENT_TYPE_FRAME     :
268 		case CONTENT_TYPE_GRAPHIC   :
269 		case CONTENT_TYPE_OLE       :
270 		{
271 			FlyCntType eType = FLYCNTTYPE_FRM;
272 			sTypeToken = C2S(pMarkToFrame);
273 			if(nContentType == CONTENT_TYPE_OLE)
274 			{
275 				eType = FLYCNTTYPE_OLE;
276 				sTypeToken = C2S(pMarkToOLE);
277 			}
278 			else if(nContentType == CONTENT_TYPE_GRAPHIC)
279 			{
280 				eType = FLYCNTTYPE_GRF;
281 				sTypeToken = C2S(pMarkToGraphic);
282 			}
283 			nMemberCount = pWrtShell->GetFlyCount(eType);
284 			bEdit = sal_True;
285 		}
286 		break;
287         case CONTENT_TYPE_BOOKMARK:
288         {
289             IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
290             nMemberCount = static_cast<sal_uInt16>(count_if(
291                 pMarkAccess->getBookmarksBegin(),
292                 pMarkAccess->getBookmarksEnd(),
293                 &lcl_IsUiVisibleBookmark));
294             sTypeToken = aEmptyStr;
295             bEdit = sal_True;
296         }
297         break;
298 		case CONTENT_TYPE_REGION :
299 		{
300 			SwContentArr* 	pOldMember = 0;
301 			sal_uInt16 nOldRegionCount = 0;
302 			sal_Bool bInvalidate = sal_False;
303 			if(!pMember)
304 				pMember = new SwContentArr;
305 			else if(pMember->Count())
306 			{
307 				pOldMember = pMember;
308 				nOldRegionCount = pOldMember->Count();
309 				pMember = new SwContentArr;
310 			}
311 			const Point aNullPt;
312 			nMemberCount = pWrtShell->GetSectionFmtCount();
313 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
314 			{
315 				const SwSectionFmt* pFmt;
316 				SectionType eTmpType;
317 				if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
318 				(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
319 				&& TOX_HEADER_SECTION != eTmpType )
320 				{
321                     const String& rSectionName =
322                         pFmt->GetSection()->GetSectionName();
323                     sal_uInt8 nLevel = 0;
324 					SwSectionFmt* pParentFmt = pFmt->GetParent();
325 					while(pParentFmt)
326 					{
327 						nLevel++;
328 						pParentFmt = pParentFmt->GetParent();
329 					}
330 
331 					SwContent* pCnt = new SwRegionContent(this, rSectionName,
332 							nLevel,
333 							pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
334 
335 					SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
336 					if( !pFmt->GetInfo( aAskItem ) &&
337 						!aAskItem.pObject )		// not visible
338 						pCnt->SetInvisible();
339 					pMember->Insert(pCnt);//, pMember->Count());
340 
341 					sal_uInt16 nPos = pMember->Count() - 1;
342 					if(nOldRegionCount > nPos &&
343 						(pOldMember->GetObject(nPos))->IsInvisible()
344 								!= pCnt->IsInvisible())
345 							bInvalidate = sal_True;
346 				}
347 			}
348 			nMemberCount = pMember->Count();
349 			sTypeToken = C2S(pMarkToRegion);
350 			bEdit = sal_True;
351 			bDelete = sal_False;
352 			if(pOldMember)
353 			{
354 				pOldMember->DeleteAndDestroy(0, pOldMember->Count());
355 				delete pOldMember;
356 				if(pbInvalidateWindow && bInvalidate)
357 					*pbInvalidateWindow = sal_True;
358 			}
359 		}
360 		break;
361 		case CONTENT_TYPE_INDEX:
362 		{
363 			nMemberCount = pWrtShell->GetTOXCount();
364 			bEdit = sal_True;
365 			bDelete = sal_False;
366 		}
367 		break;
368 		case CONTENT_TYPE_REFERENCE:
369 		{
370 			nMemberCount = pWrtShell->GetRefMarks( 0 );
371 			bDelete = sal_False;
372 		}
373 		break;
374 		case CONTENT_TYPE_URLFIELD:
375 		{
376 			nMemberCount = 0;
377 			if(!pMember)
378 				pMember = new SwContentArr;
379 			else if(pMember->Count())
380 				pMember->DeleteAndDestroy(0, pMember->Count());
381 
382 			SwGetINetAttrs aArr;
383 			nMemberCount = pWrtShell->GetINetAttrs( aArr );
384 			for( sal_uInt16 n = 0; n < nMemberCount; ++n )
385 			{
386 				SwGetINetAttr* p = aArr[ n ];
387 				SwURLFieldContent* pCnt = new SwURLFieldContent(
388 									this,
389 									p->sText,
390 									INetURLObject::decode(
391 										p->rINetAttr.GetINetFmt().GetValue(),
392 										INET_HEX_ESCAPE,
393 						   				INetURLObject::DECODE_UNAMBIGUOUS,
394 										RTL_TEXTENCODING_UTF8 ),
395 									&p->rINetAttr,
396 									n );
397 				pMember->Insert( pCnt );//, n );
398 			}
399 			bEdit = sal_True;
400 			nOldMemberCount = nMemberCount;
401 			bDelete = sal_False;
402 		}
403 		break;
404 		case CONTENT_TYPE_POSTIT:
405 		{
406 			nMemberCount = 0;
407 			if(!pMember)
408 				pMember = new SwContentArr;
409 			else if(pMember->Count())
410 				pMember->DeleteAndDestroy(0, pMember->Count());
411 
412 			SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
413 			if (aMgr)
414 			{
415 				for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
416 				{
417 					if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
418 					{
419 						SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster());
420 						if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
421 							(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
422 						{
423 							String sEntry = aFmtFld->GetFld()->GetPar2();
424 							RemoveNewline(sEntry);
425 							SwPostItContent* pCnt = new SwPostItContent(
426 												this,
427 												sEntry,
428 												(const SwFmtFld*)aFmtFld,
429 												nMemberCount);
430 							pMember->Insert(pCnt);
431 							nMemberCount++;
432 						}
433 					}
434 					/*
435 					//	this code can be used once we want redline comments in the margin
436 					else	// redcomment
437 					{
438 						SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster());
439 						if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) )
440 						{
441 							String sEntry = pRedline->GetComment();
442 							RemoveNewline(sEntry);
443 							SwPostItContent* pCnt = new SwPostItContent(
444 												this,
445 												sEntry, // hier steht der Text
446 												pRedline,
447 												nMemberCount);
448 							pMember->Insert(pCnt);
449 							nMemberCount++;
450 						}
451 					}
452 					*/
453 				}
454 			}
455 			//
456 			sTypeToken = aEmptyStr;
457 			bEdit = sal_True;
458 			nOldMemberCount = nMemberCount;
459 		}
460 		break;
461 		case CONTENT_TYPE_DRAWOBJECT:
462         {
463             sTypeToken = aEmptyStr;
464             nMemberCount = 0;
465             SdrModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel();
466             if(pModel)
467             {
468                 SdrPage* pPage = pModel->GetPage(0);
469                 sal_uInt32 nCount = pPage->GetObjCount();
470                 for( sal_uInt32 i=0; i< nCount; i++ )
471                 {
472                     SdrObject* pTemp = pPage->GetObj(i);
473                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
474 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
475                     if ( pTemp->GetName().Len() )
476                     // <--
477                         nMemberCount++;
478                 }
479             }
480         }
481 		break;
482 	}
483 	// ... dann koennen die Daten auch nicht mehr gueltig sein
484 	// abgesehen von denen, die schon korrigiert wurden, dann ist
485 	// nOldMemberCount doch nicht so old
486 	if(	nOldMemberCount != nMemberCount )
487 		bDataValid = sal_False;
488 }
489 
490 /***************************************************************************
491 	Beschreibung:
492 ***************************************************************************/
493 
494 
495 SwContentType::~SwContentType()
496 {
497 	delete pMember;
498 }
499 
500 /***************************************************************************
501 	Beschreibung:	 Inhalt liefern, dazu gfs. die Liste fuellen
502 ***************************************************************************/
503 
504 
505 const SwContent* SwContentType::GetMember(sal_uInt16 nIndex)
506 {
507 	if(!bDataValid || !pMember)
508 	{
509 		FillMemberList();
510 	}
511 	if(nIndex < pMember->Count())
512 		return pMember->GetObject(nIndex);
513 	else
514 		return 0;
515 
516 }
517 
518 
519 /***************************************************************************
520 	Beschreibung:
521 ***************************************************************************/
522 
523 
524 void	SwContentType::Invalidate()
525 {
526 	bDataValid = sal_False;
527 }
528 
529 /***************************************************************************
530 	Beschreibung: Liste der Inhalte fuellen
531 ***************************************************************************/
532 
533 
534 void	SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged)
535 {
536 	SwContentArr* 	pOldMember = 0;
537 	int nOldMemberCount = -1;
538 	SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 );
539 	if(pMember && pbLevelOrVisibiblityChanged)
540 	{
541 		pOldMember = pMember;
542 		nOldMemberCount = pOldMember->Count();
543 		pMember = new SwContentArr;
544 		*pbLevelOrVisibiblityChanged = sal_False;
545 	}
546 	else if(!pMember)
547 		pMember = new SwContentArr;
548 	else if(pMember->Count())
549 		pMember->DeleteAndDestroy(0, pMember->Count());
550 	switch(nContentType)
551 	{
552 		case CONTENT_TYPE_OUTLINE	:
553 		{
554             sal_uInt16 nOutlineCount = nMemberCount =
555                 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount());
556 
557 			sal_uInt16 nPos = 0;
558 			for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
559 			{
560                 const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i);
561 				if(nLevel >= nOutlineLevel )
562 					nMemberCount--;
563 				else
564 				{
565                     String aEntry(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i));
566 					aEntry.EraseLeadingChars();
567 					SwNavigationPI::CleanEntry( aEntry );
568 					SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel,
569 														pWrtShell->IsOutlineMovable( i ), nPos );
570 					pMember->Insert(pCnt);//, nPos);
571 					// bei gleicher Anzahl und vorhandenem pOldMember wird die
572 					// alte mit der neuen OutlinePos verglichen
573 					// cast fuer Win16
574 					if(nOldMemberCount > (int)nPos &&
575 						((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel)
576 						*pbLevelOrVisibiblityChanged = sal_True;
577 
578 					nPos++;
579 				}
580 			}
581 
582 		}
583 		break;
584 
585 		case CONTENT_TYPE_TABLE 	:
586 		{
587 			DBG_ASSERT(nMemberCount ==
588 					pWrtShell->GetTblFrmFmtCount(sal_True),
589 					"MemberCount differiert");
590 			Point aNullPt;
591 			nMemberCount =	pWrtShell->GetTblFrmFmtCount(sal_True);
592 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
593 			{
594 				const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, sal_True);
595 				String sTblName( rTblFmt.GetName() );
596 
597 				SwContent* pCnt = new SwContent(this, sTblName,
598 						rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() );
599 				if( !rTblFmt.GetInfo( aAskItem ) &&
600 					!aAskItem.pObject )		// not visible
601 					pCnt->SetInvisible();
602 
603 				pMember->Insert(pCnt);//, i);
604 
605 				if(nOldMemberCount > (int)i &&
606 					(pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
607 						*pbLevelOrVisibiblityChanged = sal_True;
608 			}
609 		}
610 		break;
611 		case CONTENT_TYPE_OLE       :
612 		case CONTENT_TYPE_FRAME     :
613 		case CONTENT_TYPE_GRAPHIC   :
614 		{
615 			FlyCntType eType = FLYCNTTYPE_FRM;
616 			if(nContentType == CONTENT_TYPE_OLE)
617 				eType = FLYCNTTYPE_OLE;
618 			else if(nContentType == CONTENT_TYPE_GRAPHIC)
619 				eType = FLYCNTTYPE_GRF;
620 			DBG_ASSERT(nMemberCount == 	pWrtShell->GetFlyCount(eType),
621 					"MemberCount differiert");
622 			Point aNullPt;
623 			nMemberCount = pWrtShell->GetFlyCount(eType);
624 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
625 			{
626 				const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType);
627 				String sFrmName = pFrmFmt->GetName();
628 
629 				SwContent* pCnt;
630 				if(CONTENT_TYPE_GRAPHIC == nContentType)
631 				{
632 					String sLink;
633 					pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt);
634 					pCnt = new SwGraphicContent(this, sFrmName,
635 								INetURLObject::decode( sLink, INET_HEX_ESCAPE,
636 						   				INetURLObject::DECODE_UNAMBIGUOUS,
637 										RTL_TEXTENCODING_UTF8 ),
638 								pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top());
639 				}
640 				else
641 				{
642 					pCnt = new SwContent(this, sFrmName,
643 							pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() );
644 				}
645 				if( !pFrmFmt->GetInfo( aAskItem ) &&
646 					!aAskItem.pObject )		// not visible
647 					pCnt->SetInvisible();
648 				pMember->Insert(pCnt);//, i);
649 				if(nOldMemberCount > (int)i &&
650 					(pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible())
651 						*pbLevelOrVisibiblityChanged = sal_True;
652 			}
653 		}
654 		break;
655         case CONTENT_TYPE_BOOKMARK:
656         {
657             IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
658             for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin();
659                 ppBookmark != pMarkAccess->getBookmarksEnd();
660                 ppBookmark++)
661             {
662                 if(lcl_IsUiVisibleBookmark(*ppBookmark))
663                 {
664                     const String& rBkmName = ppBookmark->get()->GetName();
665                     //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert
666                     SwContent* pCnt = new SwContent(this, rBkmName, 0);
667                     pMember->Insert(pCnt);//, pMember->Count());
668                 }
669             }
670         }
671 		break;
672 		case CONTENT_TYPE_REGION    :
673 		{
674 			const Point aNullPt;
675 			nMemberCount = pWrtShell->GetSectionFmtCount();
676 			for(sal_uInt16 i = 0; i < nMemberCount; i++)
677 			{
678 				const SwSectionFmt* pFmt;
679 				SectionType eTmpType;
680 				if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() &&
681 				(eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
682 				&& TOX_HEADER_SECTION != eTmpType )
683 				{
684                     String sSectionName = pFmt->GetSection()->GetSectionName();
685 
686                     sal_uInt8 nLevel = 0;
687 					SwSectionFmt* pParentFmt = pFmt->GetParent();
688 					while(pParentFmt)
689 					{
690 						nLevel++;
691 						pParentFmt = pParentFmt->GetParent();
692 					}
693 
694 					SwContent* pCnt = new SwRegionContent(this, sSectionName,
695 							nLevel,
696 							pFmt->FindLayoutRect( sal_False, &aNullPt ).Top());
697 					if( !pFmt->GetInfo( aAskItem ) &&
698 						!aAskItem.pObject )		// not visible
699 						pCnt->SetInvisible();
700 					pMember->Insert(pCnt);//, pMember->Count());
701 
702 					sal_uInt16 nPos = pMember->Count() - 1;
703 					if(nOldMemberCount > nPos &&
704 						(pOldMember->GetObject(nPos))->IsInvisible()
705 								!= pCnt->IsInvisible())
706 							*pbLevelOrVisibiblityChanged = sal_True;
707 				}
708 			}
709 			nMemberCount = pMember->Count();
710 		}
711 		break;
712 		case CONTENT_TYPE_REFERENCE:
713 		{
714 			SvStringsDtor aRefMarks;
715 			nMemberCount = pWrtShell->GetRefMarks( &aRefMarks );
716 
717 			for(sal_uInt16 i=0; i<nMemberCount; i++)
718 			{
719 				//Referenzen nach Alphabet sortiert
720 				SwContent* pCnt = new SwContent(
721 							this, *aRefMarks.GetObject(i), 0);
722 				pMember->Insert(pCnt);//, i);
723 			}
724 		}
725 		break;
726 		case CONTENT_TYPE_URLFIELD:
727 		{
728 			SwGetINetAttrs aArr;
729 			nMemberCount = pWrtShell->GetINetAttrs( aArr );
730 			for( sal_uInt16 n = 0; n < nMemberCount; ++n )
731 			{
732 				SwGetINetAttr* p = aArr[ n ];
733 				SwURLFieldContent* pCnt = new SwURLFieldContent(
734 									this,
735 									p->sText,
736 									INetURLObject::decode(
737 										p->rINetAttr.GetINetFmt().GetValue(),
738 										INET_HEX_ESCAPE,
739 						   				INetURLObject::DECODE_UNAMBIGUOUS,
740 										RTL_TEXTENCODING_UTF8 ),
741 									&p->rINetAttr,
742 									n );
743 				pMember->Insert( pCnt );//, n );
744 			}
745 		}
746 		break;
747 		case CONTENT_TYPE_INDEX:
748 		{
749 
750 			sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount();
751 			for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ )
752 			{
753 				const SwTOXBase* pBase = pWrtShell->GetTOX( nTox );
754 				String sTOXNm( pBase->GetTOXName() );
755 
756 				SwContent* pCnt = new SwTOXBaseContent(
757 						this, sTOXNm, nTox, *pBase);
758 
759 				if( !pBase->GetInfo( aAskItem ) &&
760 					!aAskItem.pObject )		// not visible
761 					pCnt->SetInvisible();
762 
763 				pMember->Insert( pCnt );//, nTox );
764 				sal_uInt16 nPos = pMember->Count() - 1;
765 				if(nOldMemberCount > nPos &&
766 					(pOldMember->GetObject(nPos))->IsInvisible()
767 							!= pCnt->IsInvisible())
768 						*pbLevelOrVisibiblityChanged = sal_True;
769 			}
770 		}
771 		break;
772 		case CONTENT_TYPE_POSTIT:
773 		{
774 			nMemberCount = 0;
775 			if(!pMember)
776 				pMember = new SwContentArr;
777 			else if(pMember->Count())
778 				pMember->DeleteAndDestroy(0, pMember->Count());
779 			SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
780 			if (aMgr)
781 			{
782 				for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
783 				{
784 					if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit
785 					{
786 						SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster());
787 						if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() &&
788 							(*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
789 						{
790 							String sEntry = aFmtFld->GetFld()->GetPar2();
791 							RemoveNewline(sEntry);
792 							SwPostItContent* pCnt = new SwPostItContent(
793 												this,
794 												sEntry,
795 												(const SwFmtFld*)aFmtFld,
796 												nMemberCount);
797 							pMember->Insert(pCnt);
798 							nMemberCount++;
799 						}
800 					}
801 					/*	this code can be used once we want redline comments in the margin
802 					else	// redcomment
803 					{
804 						SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster());
805 						if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) )
806 						{
807 							String sEntry = pRedline->GetComment();
808 							RemoveNewline(sEntry);
809 							SwPostItContent* pCnt = new SwPostItContent(
810 												this,
811 												sEntry,
812 												pRedline,
813 												nMemberCount);
814 							pMember->Insert(pCnt);
815 							nMemberCount++;
816 						}
817 					}
818 					*/
819 				}
820 			}
821 			//
822 		}
823 		break;
824 		case CONTENT_TYPE_DRAWOBJECT:
825         {
826             nMemberCount = 0;
827 			if(!pMember)
828 				pMember = new SwContentArr;
829 			else if(pMember->Count())
830 				pMember->DeleteAndDestroy(0, pMember->Count());
831 
832             IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess();
833             SdrModel* pModel = pIDDMA->GetDrawModel();
834             if(pModel)
835             {
836                 SdrPage* pPage = pModel->GetPage(0);
837                 sal_uInt32 nCount = pPage->GetObjCount();
838                 for( sal_uInt32 i=0; i< nCount; i++ )
839                 {
840                     SdrObject* pTemp = pPage->GetObj(i);
841                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
842 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len())
843                     if ( pTemp->GetName().Len() )
844                     // <--
845                     {
846                         SwContact* pContact = (SwContact*)pTemp->GetUserCall();
847                         long nYPos = 0;
848                         const Point aNullPt;
849                         if(pContact && pContact->GetFmt())
850                             nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top();
851                         SwContent* pCnt = new SwContent(
852                                             this,
853                                             pTemp->GetName(),
854                                             nYPos);
855                         if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer()))
856                             pCnt->SetInvisible();
857                         pMember->Insert(pCnt);
858                         nMemberCount++;
859                         if(nOldMemberCount > (int)i &&
860                             (pOldMember->GetObject((sal_uInt16)i))->IsInvisible() != pCnt->IsInvisible())
861                                 *pbLevelOrVisibiblityChanged = sal_True;
862                     }
863                 }
864             }
865         }
866         break;
867 	}
868 	bDataValid = sal_True;
869 	if(pOldMember)
870 		pOldMember->DeleteAndDestroy(0, pOldMember->Count());
871 
872 }
873 
874 /***************************************************************************
875 	Beschreibung: TreeListBox fuer Inhaltsanzeige
876 ***************************************************************************/
877 
878 
879 SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) :
880 		SvTreeListBox( pParent, rResId ),
881 
882         sSpace(C2S("                    ")),
883 
884         sRemoveIdx(SW_RES(ST_REMOVE_INDEX)),
885         sUpdateIdx(SW_RES(ST_UPDATE)),
886         sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)),
887         sRename(SW_RES(ST_RENAME)),
888         sReadonlyIdx(SW_RES(ST_READONLY_IDX)),
889         sInvisible(SW_RES(ST_INVISIBLE)),
890 
891 	sPostItShow(SW_RES(ST_POSTIT_SHOW)),
892 	sPostItHide(SW_RES(ST_POSTIT_HIDE)),
893 	sPostItDelete(SW_RES(ST_POSTIT_DELETE)),
894 
895         pHiddenShell(0),
896 	pActiveShell(0),
897 	pConfig(SW_MOD()->GetNavigationConfig()),
898 
899         nActiveBlock(0),
900 	nHiddenBlock(0),
901 
902         nRootType(USHRT_MAX),
903         nLastSelType(USHRT_MAX),
904         nOutlineLevel(MAXLEVEL),
905 
906         bIsActive(sal_True),
907 		bIsConstant(sal_False),
908 		bIsHidden(sal_False),
909         bDocChgdInDragging(sal_False),
910 		bIsInternalDrag(sal_False),
911 		bIsRoot(sal_False),
912 		bIsIdleClear(sal_False),
913 		bIsLastReadOnly(sal_False),
914 		bIsOutlineMoveable(sal_True),
915 		bViewHasChanged(sal_False),
916 		bIsImageListInitialized(sal_False)
917 {
918 	sal_uInt16 i;
919 
920 	SetHelpId(HID_NAVIGATOR_TREELIST);
921 
922 	SetNodeDefaultImages();
923 	SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
924 	SetDragDropMode(SV_DRAGDROP_APP_COPY);
925 	for( i = 0; i < CONTENT_TYPE_MAX; i++)
926 	{
927 		aActiveContentArr[i] 	= 0;
928 		aHiddenContentArr[i] 	= 0;
929 	}
930 	for( i = 0; i < CONTEXT_COUNT; i++  )
931 	{
932 		aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST);
933 	}
934 	nActiveBlock = pConfig->GetActiveBlock();
935 	aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate));
936 	aUpdTimer.SetTimeout(1000);
937 	Clear();
938     EnableContextMenuHandling();
939     SetStyle( GetStyle() | WB_QUICK_SEARCH );
940 }
941 
942 /***************************************************************************
943 	Beschreibung:
944 ***************************************************************************/
945 
946 
947 SwContentTree::~SwContentTree()
948 {
949 	Clear(); // vorher gfs. Inhaltstypen loeschen
950 	bIsInDrag = sal_False;
951 }
952 
953 /***************************************************************************
954 	Drag&Drop methods
955 ***************************************************************************/
956 
957 void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
958 {
959 	if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE )
960 	{
961 		ReleaseMouse();
962 
963 		TransferDataContainer* pContainer = new TransferDataContainer;
964         uno::Reference<
965             datatransfer::XTransferable > xRef( pContainer );
966 
967 		sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
968 		if( FillTransferData( *pContainer, nDragMode ))
969 		{
970 			SwContentTree::SetInDrag(sal_True);
971 			pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() );
972 		}
973 	}
974 	else
975 		SvTreeListBox::StartDrag( nAction, rPosPixel );
976 }
977 
978 void SwContentTree::DragFinished( sal_Int8 nAction )
979 {
980     //to prevent the removing of the selected entry in external drag and drop
981     // the drag action mustn't be MOVE
982     SvTreeListBox::DragFinished( bIsInternalDrag ? nAction : DND_ACTION_COPY );
983 	SwContentTree::SetInDrag(sal_False);
984 	bIsInternalDrag = sal_False;
985 }
986 
987 /***************************************************************************
988 	Beschreibung:   QueryDrop wird im Navigator ausgefuehrt
989 ***************************************************************************/
990 sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt )
991 {
992 	sal_Int8 nRet = DND_ACTION_NONE;
993 	if( bIsRoot )
994 	{
995 		if( bIsOutlineMoveable )
996 			nRet = SvTreeListBox::AcceptDrop( rEvt );
997 	}
998 	else if( !bIsInDrag )
999 		nRet = GetParentWindow()->AcceptDrop( rEvt );
1000 	return nRet;
1001 }
1002 
1003 /***************************************************************************
1004 	Beschreibung:	Drop wird im Navigator ausgefuehrt
1005 ***************************************************************************/
1006 sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
1007 {
1008 	if( bIsRoot )
1009 		return SvTreeListBox::ExecuteDrop( rEvt );
1010 	return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt);
1011 }
1012 
1013 
1014 /***************************************************************************
1015 	Beschreibung:	Handler fuer Dragging und ContextMenu
1016 ***************************************************************************/
1017 PopupMenu* SwContentTree::CreateContextMenu( void )
1018 {
1019     PopupMenu* pPop = new PopupMenu;
1020     PopupMenu* pSubPop1 = new PopupMenu;
1021     PopupMenu* pSubPop2 = new PopupMenu;
1022     PopupMenu* pSubPop3 = new PopupMenu;
1023     PopupMenu* pSubPop4 = new PopupMenu; // Edit
1024 
1025     sal_uInt16 i;
1026     for(i = 1; i <= MAXLEVEL; i++ )
1027     {
1028         pSubPop1->InsertItem( i + 100, String::CreateFromInt32(i));
1029     }
1030     pSubPop1->CheckItem(100 + nOutlineLevel);
1031     for(i=0; i < 3; i++ )
1032     {
1033         pSubPop2->InsertItem( i + 201, aContextStrings[
1034                 ST_HYPERLINK - ST_CONTEXT_FIRST + i]);
1035     }
1036     pSubPop2->CheckItem( 201 +
1037                     GetParentWindow()->GetRegionDropMode());
1038     //Liste der offenen Dateien einfuegen
1039     sal_uInt16 nId = 301;
1040     const SwView* pActiveView = ::GetActiveView();
1041     SwView *pView = SwModule::GetFirstView();
1042     while (pView)
1043     {
1044         String sInsert = pView->GetDocShell()->GetTitle();
1045         if(pView == pActiveView)
1046         {
1047             sInsert += '(';
1048             sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST];
1049             sInsert += ')';
1050         }
1051         pSubPop3->InsertItem(nId, sInsert);
1052         if(bIsConstant && pActiveShell == &pView->GetWrtShell())
1053             pSubPop3->CheckItem(nId);
1054         pView = SwModule::GetNextView(pView);
1055         nId++;
1056     }
1057     pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]);
1058     if(pHiddenShell)
1059     {
1060         String sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle();
1061         sHiddenEntry += C2S(" ( ");
1062         sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST];
1063         sHiddenEntry += C2S(" )");
1064         pSubPop3->InsertItem(nId, sHiddenEntry);
1065     }
1066 
1067     if(bIsActive)
1068         pSubPop3->CheckItem( --nId );
1069     else if(bIsHidden)
1070         pSubPop3->CheckItem( nId );
1071 
1072     pPop->InsertItem( 1, aContextStrings[ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]);
1073     pPop->InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]);
1074     pPop->InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]);
1075     //jetzt noch bearbeiten
1076     SvLBoxEntry* pEntry = 0;
1077     //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen
1078     if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr())
1079             && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry))
1080     {
1081         const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent();
1082         const sal_uInt16 nContentType = pContType->GetType();
1083         sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly();
1084         sal_Bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible();
1085         sal_Bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect();
1086         sal_Bool bEditable = pContType->IsEditable() &&
1087             ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
1088         sal_Bool bDeletable = pContType->IsDeletable() &&
1089             ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType);
1090         sal_Bool bRenamable = bEditable && !bReadonly &&
1091             (CONTENT_TYPE_TABLE == nContentType ||
1092                 CONTENT_TYPE_FRAME == nContentType ||
1093                 CONTENT_TYPE_GRAPHIC == nContentType ||
1094                 CONTENT_TYPE_OLE == nContentType ||
1095                 CONTENT_TYPE_BOOKMARK == nContentType ||
1096                 CONTENT_TYPE_REGION == nContentType||
1097                 CONTENT_TYPE_INDEX == nContentType);
1098 
1099         if(!bReadonly && (bEditable || bDeletable))
1100         {
1101             sal_Bool bSubPop4 = sal_False;
1102             if(CONTENT_TYPE_INDEX == nContentType)
1103             {
1104                 bSubPop4 = sal_True;
1105                 pSubPop4->InsertItem(401, sRemoveIdx);
1106                 pSubPop4->InsertItem(402, sUpdateIdx);
1107 
1108                 const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase();
1109                 if(!pBase->IsTOXBaseInReadonly())
1110                     pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1111                 pSubPop4->InsertItem(405, sReadonlyIdx);
1112 
1113                 pSubPop4->CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase));
1114                 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1115             }
1116             else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly)
1117             {
1118                 bSubPop4 = sal_True;
1119                 pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1120                 pSubPop4->InsertItem(404, sUnprotTbl);
1121                 sal_Bool bFull = sal_False;
1122                 String sTblName = ((SwContent*)pEntry->GetUserData())->GetName();
1123                 sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull );
1124                 pSubPop4->EnableItem(403, !bFull );
1125                 pSubPop4->EnableItem(404, bProt );
1126                 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1127             }
1128             else if(bEditable || bDeletable)
1129             {
1130 
1131 				if(bEditable && bDeletable)
1132                 {
1133                     pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1134                     pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1135                     bSubPop4 = sal_True;
1136                 }
1137                 else if(bEditable)
1138                     pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]);
1139                 else if(bDeletable)
1140 				{
1141                     pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]);
1142 				}
1143             }
1144             //Rename object
1145             if(bRenamable)
1146             {
1147                 if(bSubPop4)
1148                     pSubPop4->InsertItem(502, sRename);
1149                 else
1150                     pPop->InsertItem(502, sRename);
1151             }
1152 
1153             if(bSubPop4)
1154             {
1155                 pPop->InsertItem(4, pContType->GetSingleName());
1156                 pPop->SetPopupMenu(4, pSubPop4);
1157             }
1158         }
1159     }
1160     else if( pEntry )
1161 	{
1162 		SwContentType* pType = (SwContentType*)pEntry->GetUserData();
1163 		if ( (pType->GetType() == CONTENT_TYPE_POSTIT) &&  (!pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) )
1164 		{
1165 				pSubPop4->InsertItem(600, sPostItShow );
1166 				pSubPop4->InsertItem(601, sPostItHide );
1167 				pSubPop4->InsertItem(602, sPostItDelete );
1168 				/*
1169 				pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort"));
1170 				PopupMenu* pMenuSort = new PopupMenu;
1171 				pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position"));
1172 				pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author"));
1173 				pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date"));
1174 				pSubPop4->SetPopupMenu(603, pMenuSort);
1175 				*/
1176 			    pPop->InsertItem(4, pType->GetSingleName());
1177                 pPop->SetPopupMenu(4, pSubPop4);
1178 		}
1179 	}
1180 
1181     pPop->SetPopupMenu( 1, pSubPop1 );
1182     pPop->SetPopupMenu( 2, pSubPop2 );
1183     pPop->SetPopupMenu( 3, pSubPop3 );
1184     return pPop;
1185 
1186 }
1187 /***************************************************************************
1188 	Beschreibung:	Einrueckung fuer outlines (und sections)
1189 ***************************************************************************/
1190 
1191 
1192 long	SwContentTree::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
1193 {
1194 	sal_uInt16 nLevel = 0;
1195 	if(lcl_IsContent(pEntry))
1196 	{
1197 		nLevel++;
1198 		SwContent* pCnt = (SwContent *) pEntry->GetUserData();
1199 		const SwContentType*	pParent;
1200 		if(pCnt &&	0 != (pParent = pCnt->GetParent()))
1201 		{
1202 			if(pParent->GetType() == CONTENT_TYPE_OUTLINE)
1203                 nLevel = nLevel + ((SwOutlineContent*)pCnt)->GetOutlineLevel();
1204 			else if(pParent->GetType() == CONTENT_TYPE_REGION)
1205                 nLevel = nLevel + ((SwRegionContent*)pCnt)->GetRegionLevel();
1206 		}
1207 	}
1208 	sal_uInt16 nBasis = bIsRoot ? 0 : 5;
1209 	return nLevel * 10 + nBasis + pTab->GetPos();  //empirisch ermittelt
1210 }
1211 
1212 /***************************************************************************
1213 	Beschreibung:	Inhalte werden erst auf Anforderung in die Box eingefuegt
1214 ***************************************************************************/
1215 
1216 
1217 void  SwContentTree::RequestingChilds( SvLBoxEntry* pParent )
1218 {
1219 	// ist es ein Inhaltstyp?
1220 	if(lcl_IsContentType(pParent))
1221 	{
1222 		if(!pParent->HasChilds())
1223 		{
1224 			DBG_ASSERT(pParent->GetUserData(), "keine UserData?");
1225 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1226 
1227 			sal_uInt16 nCount = pCntType->GetMemberCount();
1228 			for(sal_uInt16 i = 0; i < nCount; i++)
1229 			{
1230 				const SwContent* pCnt = pCntType->GetMember(i);
1231 				if(pCnt)
1232 				{
1233 					String sEntry = pCnt->GetName();
1234 					if(!sEntry.Len())
1235 						sEntry = sSpace;
1236                     InsertEntry(sEntry, pParent,
1237 							sal_False, LIST_APPEND, (void*)pCnt);
1238 				}
1239 
1240 			}
1241 		}
1242 	}
1243 }
1244 /***************************************************************************
1245 	Beschreibung:	Expand - Zustand fuer Inhaltstypen merken
1246 ***************************************************************************/
1247 
1248 
1249 sal_Bool  SwContentTree::Expand( SvLBoxEntry* pParent )
1250 {
1251 	if(!bIsRoot)
1252 	{
1253 		if(lcl_IsContentType(pParent))
1254 		{
1255 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1256 			sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition
1257 			if(bIsActive || bIsConstant)
1258 			{
1259 				nActiveBlock |= nOr;
1260 				pConfig->SetActiveBlock(nActiveBlock);
1261 			}
1262 			else
1263 				nHiddenBlock |= nOr;
1264 		}
1265 	}
1266 	return SvTreeListBox::Expand(pParent);
1267 }
1268 /***************************************************************************
1269 	Beschreibung:	Collapse - Zustand fuer Inhaltstypen merken
1270 ***************************************************************************/
1271 
1272 
1273 sal_Bool  SwContentTree::Collapse( SvLBoxEntry* pParent )
1274 {
1275 	sal_Bool bRet;
1276 	if(!bIsRoot)
1277 	{
1278 		if(lcl_IsContentType(pParent))
1279 		{
1280 			SwContentType* pCntType = (SwContentType*)pParent->GetUserData();
1281 			sal_uInt16 nAnd = 1 << pCntType->GetType();
1282 			nAnd = ~nAnd;
1283 			if(bIsActive || bIsConstant)
1284 			{
1285 				nActiveBlock &= nAnd;
1286 				pConfig->SetActiveBlock(nActiveBlock);
1287 			}
1288 			else
1289 				nHiddenBlock &= nAnd;
1290 		}
1291 			bRet = SvTreeListBox::Collapse(pParent);
1292 	}
1293 	else
1294 		bRet = sal_False;
1295 	return bRet;
1296 }
1297 
1298 
1299 /***************************************************************************
1300 	Beschreibung:	Auch auf Doppelclick wird zunaechst nur aufgeklappt
1301 ***************************************************************************/
1302 
1303 
1304 IMPL_LINK( SwContentTree, ContentDoubleClickHdl, SwContentTree *, EMPTYARG )
1305 {
1306 	SvLBoxEntry* pEntry = GetCurEntry();
1307 	// ist es ein Inhaltstyp?
1308 	DBG_ASSERT(pEntry, "kein aktueller Eintrag!");
1309 	if(pEntry)
1310 	{
1311 		if(lcl_IsContentType(pEntry))
1312 			RequestingChilds(pEntry);
1313 		else if(bIsActive || bIsConstant)
1314 		{
1315 			if(bIsConstant)
1316 			{
1317 				pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
1318 			}
1319 			//Inhaltstyp anspringen:
1320 			SwContent* pCnt = (SwContent*)pEntry->GetUserData();
1321 			DBG_ASSERT( pCnt, "keine UserData");
1322 			GotoContent(pCnt);
1323 			if(pCnt->GetParent()->GetType()	== CONTENT_TYPE_FRAME)
1324 				pActiveShell->EnterStdMode();
1325 		}
1326 	}
1327 	return 0;
1328 }
1329 
1330 /***************************************************************************
1331 	Beschreibung:	Anzeigen der Datei
1332 ***************************************************************************/
1333 
1334 
1335 void SwContentTree::Display( sal_Bool bActive )
1336 {
1337 	if(!bIsImageListInitialized)
1338 	{
1339         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
1340         aEntryImages = ImageList(SW_RES(nResId));
1341 		bIsImageListInitialized = sal_True;
1342 	}
1343 	// erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder
1344 	// zu selektieren -> die UserDaten sind hier nicht mehr gueltig!
1345 	SvLBoxEntry* pOldSelEntry = FirstSelected();
1346 	String sEntryName;	// Name des Eintrags
1347 	sal_uInt16 nEntryRelPos = 0; // rel. Pos zu seinem Parent
1348     sal_uInt32 nOldEntryCount = GetEntryCount();
1349     sal_Int32 nOldScrollPos = 0;
1350 	if(pOldSelEntry)
1351 	{
1352         ScrollBar* pVScroll = GetVScroll();
1353         if(pVScroll && pVScroll->IsVisible())
1354             nOldScrollPos = pVScroll->GetThumbPos();
1355 
1356         sEntryName = GetEntryText(pOldSelEntry);
1357 		if(GetParent(pOldSelEntry))
1358 		{
1359 			nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(GetParent(pOldSelEntry)));
1360 		}
1361 	}
1362 	Clear();
1363 	SetUpdateMode( sal_False );
1364 	if(bActive && !bIsConstant && !bIsActive)
1365 		bIsActive = bActive;
1366 	bIsHidden = !bActive;
1367 	SwWrtShell* pShell = GetWrtShell();
1368 	sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True;
1369 	if(bReadOnly != bIsLastReadOnly)
1370 	{
1371 		bIsLastReadOnly = bReadOnly;
1372 		sal_Bool bDisable =  pShell == 0 || bReadOnly;
1373 		SwNavigationPI* pNavi = GetParentWindow();
1374 		pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable);
1375 		pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable);
1376 		pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable);
1377 		pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable);
1378 		pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable);
1379 	}
1380 	if(pShell)
1381 	{
1382 		SvLBoxEntry* pSelEntry = 0;
1383 		if(nRootType == USHRT_MAX)
1384 		{
1385 			for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE;
1386                         nCntType <= CONTENT_TYPE_DRAWOBJECT; nCntType++ )
1387 			{
1388 				SwContentType** ppContentT = bActive ?
1389 								&aActiveContentArr[nCntType] :
1390 									&aHiddenContentArr[nCntType];
1391 				if(!*ppContentT)
1392 					(*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel );
1393 
1394 
1395 				String sEntry = (*ppContentT)->GetName();
1396 				SvLBoxEntry* pEntry;
1397 				const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType);
1398 				sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount();
1399 				pEntry = InsertEntry(sEntry, rImage, rImage,
1400 								0, bChOnDemand, LIST_APPEND, (*ppContentT));
1401 				if(nCntType == nLastSelType)
1402 					pSelEntry = pEntry;
1403                 sal_Int32 nExpandOptions = bIsActive || bIsConstant ?
1404 											nActiveBlock :
1405 												nHiddenBlock;
1406 				if(nExpandOptions & (1 << nCntType))
1407 				{
1408 					Expand(pEntry);
1409 					if(nEntryRelPos && nCntType == nLastSelType)
1410 					{
1411 						// jetzt vielleicht noch ein Child selektieren
1412 						SvLBoxEntry* pChild = pEntry;
1413 						SvLBoxEntry* pTemp = 0;
1414 						sal_uInt16 nPos = 1;
1415 						while(0 != (pChild = Next(pChild)))
1416 						{
1417 							// der alte Text wird leicht bevorzugt
1418 							if(sEntryName == GetEntryText(pChild) ||
1419 								nPos == nEntryRelPos )
1420 							{
1421 								pSelEntry = pChild;
1422 								break;
1423 							}
1424 							pTemp = pChild;
1425 							nPos++;
1426 						}
1427 						if(!pSelEntry || lcl_IsContentType(pSelEntry))
1428 							pSelEntry = pTemp;
1429 					}
1430 
1431 				}
1432 			}
1433 			if(pSelEntry)
1434 			{
1435 				MakeVisible(pSelEntry);
1436 				Select(pSelEntry);
1437             }
1438             else
1439                 nOldScrollPos = 0;
1440 		}
1441 		else
1442 		{
1443 			SwContentType** ppRootContentT = bActive ?
1444 								&aActiveContentArr[nRootType] :
1445 									&aHiddenContentArr[nRootType];
1446 			if(!(*ppRootContentT))
1447 				(*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel );
1448 			const Image& rImage = aEntryImages.GetImage(20000 + nRootType);
1449 			SvLBoxEntry* pParent = InsertEntry(
1450 					(*ppRootContentT)->GetName(), rImage, rImage,
1451 						0, sal_False, LIST_APPEND, *ppRootContentT);
1452 
1453 			for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ )
1454 			{
1455 				const SwContent* pCnt = (*ppRootContentT)->GetMember(i);
1456 				if(pCnt)
1457 				{
1458 					String sEntry = pCnt->GetName();
1459 					if(!sEntry.Len())
1460 						sEntry = sSpace;
1461                     InsertEntry( sEntry, pParent,
1462 								sal_False, LIST_APPEND, (void*)pCnt);
1463 				}
1464 			}
1465 			Expand(pParent);
1466 			if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive )
1467 			{
1468 				//feststellen, wo der Cursor steht
1469 				const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL);
1470 				SvLBoxEntry* pEntry = First();
1471 
1472 				while( 0 != (pEntry = Next(pEntry)) )
1473 				{
1474 					if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos)
1475 					{
1476 						MakeVisible(pEntry);
1477 						Select(pEntry);
1478 					}
1479 				}
1480 
1481 			}
1482 			else
1483 			{
1484 				// jetzt vielleicht noch ein Child selektieren
1485 				SvLBoxEntry* pChild = pParent;
1486 				SvLBoxEntry* pTemp = 0;
1487 				sal_uInt16 nPos = 1;
1488 				while(0 != (pChild = Next(pChild)))
1489 				{
1490 					// der alte Text wird leicht bevorzugt
1491 					if(sEntryName == GetEntryText(pChild) ||
1492 						nPos == nEntryRelPos )
1493 					{
1494 						pSelEntry = pChild;
1495 						break;
1496 					}
1497 					pTemp = pChild;
1498 					nPos++;
1499 				}
1500 				if(!pSelEntry)
1501 					pSelEntry = pTemp;
1502 				if(pSelEntry)
1503 				{
1504 					MakeVisible(pSelEntry);
1505 					Select(pSelEntry);
1506 				}
1507 			}
1508 		}
1509 	}
1510 	SetUpdateMode( sal_True );
1511     ScrollBar* pVScroll = GetVScroll();
1512     if(GetEntryCount() == nOldEntryCount &&
1513         nOldScrollPos && pVScroll && pVScroll->IsVisible()
1514         && pVScroll->GetThumbPos() != nOldScrollPos)
1515     {
1516         sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos;
1517         ScrollOutputArea( (short)nDelta );
1518     }
1519 
1520 }
1521 
1522 /***************************************************************************
1523 	Beschreibung:	Im Clear muessen auch die ContentTypes geloescht werden
1524 ***************************************************************************/
1525 
1526 
1527 void SwContentTree::Clear()
1528 {
1529 	SetUpdateMode(sal_False);
1530 	SvTreeListBox::Clear();
1531 	SetUpdateMode(sal_True);
1532 }
1533 
1534 /***************************************************************************
1535 	Beschreibung:
1536 ***************************************************************************/
1537 
1538 sal_Bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
1539 											sal_Int8& rDragMode )
1540 {
1541 	SwWrtShell* pWrtShell = GetWrtShell();
1542 	DBG_ASSERT(pWrtShell, "keine Shell!");
1543 	SvLBoxEntry* pEntry = GetCurEntry();
1544 	if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell)
1545 		return sal_False;
1546 	String sEntry;
1547 	SwContent* pCnt = ((SwContent*)pEntry->GetUserData());
1548 
1549 	sal_uInt16 nActType = pCnt->GetParent()->GetType();
1550 	String sUrl;
1551 	sal_Bool bOutline = sal_False;
1552 	String sOutlineText;
1553 	switch( nActType )
1554 	{
1555 		case CONTENT_TYPE_OUTLINE:
1556 		{
1557 			sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos();
1558             DBG_ASSERT(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
1559                        "outlinecnt veraendert");
1560 
1561             // #100738# make sure outline may actually be copied
1562             if( pWrtShell->IsOutlineCopyable( nPos ) )
1563             {
1564                 const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule();
1565                 const SwTxtNode* pTxtNd =
1566                         pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos);
1567                 if( pTxtNd && pOutlRule && pTxtNd->IsNumbered())
1568                 {
1569                     SwNumberTree::tNumberVector aNumVector =
1570                         pTxtNd->GetNumberVector();
1571                     for( sal_Int8 nLevel = 0;
1572                          nLevel <= pTxtNd->GetActualListLevel();
1573                          nLevel++ )
1574                     {
1575                         sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel];
1576                         nVal ++;
1577                         nVal = nVal - pOutlRule->Get(nLevel).GetStart();
1578                         sEntry += String::CreateFromInt32( nVal );
1579                         sEntry += '.';
1580                     }
1581                 }
1582                 sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false);
1583                 sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true);
1584                 bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable();
1585                 bOutline = sal_True;
1586             }
1587 		}
1588 		break;
1589 		case CONTENT_TYPE_POSTIT:
1590 		case CONTENT_TYPE_INDEX:
1591 		case CONTENT_TYPE_REFERENCE :
1592 			// koennen weder als URL noch als Bereich eingefuegt werden
1593 		break;
1594 		case CONTENT_TYPE_URLFIELD:
1595 			sUrl = ((SwURLFieldContent*)pCnt)->GetURL();
1596 		// kein break;
1597 		case CONTENT_TYPE_OLE:
1598 		case CONTENT_TYPE_GRAPHIC:
1599 			if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE)
1600 				break;
1601 			else
1602 				rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
1603 		default:
1604 			sEntry = GetEntryText(pEntry);
1605 	}
1606 
1607 	sal_Bool bRet = sal_False;
1608 	if(sEntry.Len())
1609 	{
1610 		const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
1611 		if(!sUrl.Len())
1612 		{
1613 			if(pDocShell->HasName())
1614 			{
1615 				SfxMedium* pMedium = pDocShell->GetMedium();
1616 				sUrl = pMedium->GetURLObject().GetURLNoMark();
1617 				// nur, wenn primaer ein Link eingefuegt werden soll
1618 				bRet = sal_True;
1619 			}
1620 			else if(	nActType == CONTENT_TYPE_REGION ||
1621 						nActType == CONTENT_TYPE_BOOKMARK )
1622 			{
1623 				// fuer Bereich und Textmarken ist ein Link auch ohne
1624 				// Dateiname ins eigene Dokument erlaubt
1625 				bRet = sal_True;
1626 			}
1627 			else if(bIsConstant &&
1628 					( !::GetActiveView() ||
1629 						pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
1630 			{
1631 				// Urls von inaktiven Views ohne Dateinamen koennen auch nicht
1632 				// gedraggt werden
1633 				bRet = sal_False;
1634 			}
1635 			else
1636 			{
1637 				bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE;
1638 				rDragMode = DND_ACTION_MOVE;
1639 			}
1640 
1641 			const String& rToken = pCnt->GetParent()->GetTypeToken();
1642 			sUrl += '#';
1643 			sUrl += sEntry;
1644 			if(rToken.Len())
1645 			{
1646 				sUrl += cMarkSeperator;
1647 				sUrl += rToken;
1648 			}
1649 		}
1650 		else
1651 			bRet = sal_True;
1652 
1653 		if( bRet )
1654 		{
1655 			//fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer
1656 			if(bOutline)
1657 				sEntry = sOutlineText;
1658 
1659 			{
1660 				NaviContentBookmark aBmk( sUrl, sEntry,
1661 									GetParentWindow()->GetRegionDropMode(),
1662 									pDocShell);
1663 				aBmk.Copy( rTransfer );
1664 			}
1665 
1666 			// fuer fremde DocShells muss eine INetBookmark
1667 			// dazugeliefert werden
1668 			if( pDocShell->HasName() )
1669 			{
1670 				INetBookmark aBkmk( sUrl, sEntry );
1671 				rTransfer.CopyINetBookmark( aBkmk );
1672 			}
1673 		}
1674 	}
1675 	return bRet;
1676 }
1677 /***************************************************************************
1678 	Beschreibung:	Umschalten der Anzeige auf Root
1679 ***************************************************************************/
1680 
1681 
1682 sal_Bool SwContentTree::ToggleToRoot()
1683 {
1684 	if(!bIsRoot)
1685 	{
1686 		SvLBoxEntry* pEntry = GetCurEntry();
1687 		const SwContentType* pCntType;
1688 		if(pEntry)
1689 		{
1690 			if(lcl_IsContentType(pEntry))
1691 				pCntType = (SwContentType*)pEntry->GetUserData();
1692 			else
1693 				pCntType = ((SwContent*)pEntry->GetUserData())->GetParent();
1694 			nRootType = pCntType->GetType();
1695 			bIsRoot = sal_True;
1696 			Display(bIsActive || bIsConstant);
1697 		}
1698 	}
1699 	else
1700 	{
1701 		nRootType = USHRT_MAX;
1702 		bIsRoot = sal_False;
1703 		FindActiveTypeAndRemoveUserData();
1704 		Display(bIsActive || bIsConstant);
1705 	}
1706 	pConfig->SetRootType( nRootType );
1707 	GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot);
1708 	return bIsRoot;
1709 }
1710 
1711 /***************************************************************************
1712 	Beschreibung:	Angezeigten Inhalt auf Gueltigkeit pruefen
1713 ***************************************************************************/
1714 
1715 
1716 sal_Bool SwContentTree::HasContentChanged()
1717 {
1718 /*
1719 	-Parallel durch das lokale Array und die Treelistbox laufen.
1720 	-Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen
1721 	und der Contenttype wird als UserData neu gesetzt.
1722 	- ist der Root-Modus aktiv, wird nur dieser aktualisiert,
1723 	fuer die nicht angezeigten Inhaltstypen gilt:
1724 		die Memberliste wird geloescht und der Membercount aktualisiert
1725 	Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden
1726 	Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch
1727 	gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt.
1728 
1729 */
1730 
1731 	sal_Bool bRepaint = sal_False;
1732 	sal_Bool bInvalidate = sal_False;
1733 
1734 	if(!bIsActive && ! bIsConstant)
1735 	{
1736 		for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
1737 		{
1738 			if(aActiveContentArr[i])
1739 				aActiveContentArr[i]->Invalidate();
1740 		}
1741 	}
1742 	else if(bIsRoot)
1743 	{
1744 		sal_Bool bOutline = sal_False;
1745 		SvLBoxEntry* pEntry = First();
1746 		if(!pEntry)
1747 			bRepaint = sal_True;
1748 		else
1749 		{
1750 			sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType();
1751 			bOutline = nRootType == CONTENT_TYPE_OUTLINE;
1752 			SwContentType* pArrType = aActiveContentArr[nType];
1753 			if(!pArrType)
1754 				bRepaint = sal_True;
1755 			else
1756 			{
1757 				sal_uInt16 nSelLevel = USHRT_MAX;
1758 
1759 				SvLBoxEntry* pFirstSel;
1760 				if(bOutline &&
1761 						0 != ( pFirstSel = FirstSelected()) &&
1762 							lcl_IsContent(pFirstSel))
1763 				{
1764 					nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel();
1765 					SwWrtShell* pSh = GetWrtShell();
1766 					sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
1767                     bRepaint |= nOutlinePos != USHRT_MAX &&
1768                                 pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel;
1769 				}
1770 
1771 				pArrType->Init(&bInvalidate);
1772 				pArrType->FillMemberList();
1773 				pEntry->SetUserData((void*)pArrType);
1774 				if(!bRepaint)
1775 				{
1776 					if(GetChildCount(pEntry) != pArrType->GetMemberCount())
1777 							bRepaint = sal_True;
1778 					else
1779 					{
1780 						sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
1781 						for(sal_uInt16 j = 0; j < nChildCount; j++)
1782 						{
1783 							pEntry = Next(pEntry);
1784 							const SwContent* pCnt = pArrType->GetMember(j);
1785 							pEntry->SetUserData((void*)pCnt);
1786 							String sEntryText = GetEntryText(pEntry);
1787 							if( sEntryText != pCnt->GetName() &&
1788 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
1789 								bRepaint = sal_True;
1790 						}
1791 					}
1792 				}
1793 			}
1794 		}
1795 		if( !bRepaint && bOutline )
1796 		{
1797 			//feststellen, wo der Cursor steht
1798 			const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL);
1799             SvLBoxEntry* pFirstEntry = First();
1800 
1801             while( 0 != (pFirstEntry = Next(pFirstEntry)) )
1802 			{
1803                 if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos)
1804 				{
1805                     if(FirstSelected() != pFirstEntry)
1806 					{
1807                         Select(pFirstEntry);
1808                         MakeVisible(pFirstEntry);
1809 					}
1810 				}
1811 			}
1812 
1813 		}
1814 
1815 	}
1816 	else
1817 	{
1818 		SvLBoxEntry* pEntry = First();
1819 		while ( pEntry )
1820 		{
1821 			sal_Bool bNext = sal_True; // mindestens ein Next muss sein
1822 			SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData();
1823 			sal_uInt16 nType = pTreeType->GetType();
1824 			sal_uInt16 nTreeCount = pTreeType->GetMemberCount();
1825 			SwContentType* pArrType = aActiveContentArr[nType];
1826 			if(!pArrType)
1827 				bRepaint = sal_True;
1828 			else
1829 			{
1830 				pArrType->Init(&bInvalidate);
1831 				pEntry->SetUserData((void*)pArrType);
1832 				if(IsExpanded(pEntry))
1833 				{
1834 					sal_Bool bLevelOrVisibiblityChanged = sal_False;
1835 					// bLevelOrVisibiblityChanged is set if outlines have changed their level
1836 					// or if the visibility of objects (frames, sections, tables) has changed
1837 					// i.e. in header/footer
1838 					pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
1839 					if(bLevelOrVisibiblityChanged)
1840 						bInvalidate = sal_True;
1841 					sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
1842 					if(bLevelOrVisibiblityChanged)
1843 						bInvalidate = sal_True;
1844 
1845 					if(nChildCount != pArrType->GetMemberCount())
1846 						bRepaint = sal_True;
1847 					else
1848 					{
1849 						for(sal_uInt16 j = 0; j < nChildCount; j++)
1850 						{
1851 							pEntry = Next(pEntry);
1852 							bNext = sal_False;
1853 							const SwContent* pCnt = pArrType->GetMember(j);
1854 							pEntry->SetUserData((void*)pCnt);
1855 							String sEntryText = GetEntryText(pEntry);
1856 							if( sEntryText != pCnt->GetName() &&
1857 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
1858 								bRepaint = sal_True;
1859 						}
1860 					}
1861 
1862 				}
1863 				else if(pEntry->HasChilds())
1864 				{
1865 					//war der Eintrag einmal aufgeklappt, dann muessen auch
1866 					// die unsichtbaren Eintraege geprueft werden.
1867 					// zumindest muessen die Userdaten aktualisiert werden
1868 					sal_Bool bLevelOrVisibiblityChanged = sal_False;
1869 					// bLevelOrVisibiblityChanged is set if outlines have changed their level
1870 					// or if the visibility of objects (frames, sections, tables) has changed
1871 					// i.e. in header/footer
1872 					pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
1873 					sal_Bool bRemoveChildren = sal_False;
1874 					sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry);
1875 					if( nChildCount != pArrType->GetMemberCount() )
1876 					{
1877 						bRemoveChildren = sal_True;
1878 					}
1879 					else
1880 					{
1881 						SvLBoxEntry* pChild = FirstChild(pEntry);
1882 						for(sal_uInt16 j = 0; j < nChildCount; j++)
1883 						{
1884 							const SwContent* pCnt = pArrType->GetMember(j);
1885 							pChild->SetUserData((void*)pCnt);
1886 							String sEntryText = GetEntryText(pChild);
1887 							if( sEntryText != pCnt->GetName() &&
1888 								!(sEntryText == sSpace && !pCnt->GetName().Len()))
1889 								bRemoveChildren = sal_True;
1890 							pChild = Next(pChild);
1891 						}
1892 					}
1893 					if(bRemoveChildren)
1894 					{
1895 						SvLBoxEntry* pChild = FirstChild(pEntry);
1896 						SvLBoxEntry* pRemove = pChild;
1897 						for(sal_uInt16 j = 0; j < nChildCount; j++)
1898 						{
1899 							pChild = Next(pRemove);
1900 							GetModel()->Remove(pRemove);
1901 							pRemove = pChild;
1902 						}
1903 					}
1904 					if(!nChildCount)
1905 					{
1906 						pEntry->EnableChildsOnDemand(sal_False);
1907 						InvalidateEntry(pEntry);
1908 					}
1909 
1910 				}
1911 				else if((nTreeCount != 0)
1912 							!= (pArrType->GetMemberCount()!=0))
1913 				{
1914 					bRepaint = sal_True;
1915 				}
1916 			}
1917 			//hier muss noch der naechste Root-Entry gefunden werden
1918 			while( pEntry && (bNext || GetParent(pEntry ) ))
1919 			{
1920 				pEntry = Next(pEntry);
1921 				bNext = sal_False;
1922 			}
1923 		}
1924 	}
1925 	if(!bRepaint && bInvalidate)
1926 		Invalidate();
1927 	return bRepaint;
1928 }
1929 
1930 /***************************************************************************
1931 	Beschreibung: 	Bevor alle Daten geloescht werden, soll noch der letzte
1932  * 					aktive Eintrag festgestellt werden. Dann werden die
1933  * 					UserData geloescht
1934 ***************************************************************************/
1935 void SwContentTree::FindActiveTypeAndRemoveUserData()
1936 {
1937 	SvLBoxEntry* pEntry = FirstSelected();
1938 	if(pEntry)
1939 	{
1940 		// wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root
1941 		// die Gueltigkeit der UserData garantiert werden
1942 		SvLBoxEntry* pParent;
1943 		while(0 != (pParent = GetParent(pEntry)))
1944 			pEntry = pParent;
1945 		if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
1946 			nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType();
1947 	}
1948 //	else
1949 //		nLastSelType = USHRT_MAX;
1950 	pEntry = First();
1951 	while(pEntry)
1952 	{
1953 		pEntry->SetUserData(0);
1954 		pEntry = Next(pEntry);
1955 	}
1956 }
1957 
1958 /***************************************************************************
1959 	Beschreibung: 	Nachdem ein File auf den Navigator gedroppt wurde,
1960 					wird die neue Shell gesetzt
1961 ***************************************************************************/
1962 
1963 
1964 void SwContentTree::SetHiddenShell(SwWrtShell* pSh)
1965 {
1966 	pHiddenShell = pSh;
1967 	bIsHidden = sal_True;
1968 	bIsActive = bIsConstant = sal_False;
1969 	FindActiveTypeAndRemoveUserData();
1970 	for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
1971 	{
1972 		DELETEZ(aHiddenContentArr[i]);
1973 	}
1974 	Display(bIsActive);
1975 
1976 	GetParentWindow()->UpdateListBox();
1977 }
1978 /***************************************************************************
1979 	Beschreibung:	Dokumentwechsel - neue Shell setzen
1980 ***************************************************************************/
1981 
1982 
1983 void SwContentTree::SetActiveShell(SwWrtShell* pSh)
1984 {
1985 	if(bIsInternalDrag)
1986 		bDocChgdInDragging = sal_True;
1987 	sal_Bool bClear = pActiveShell != pSh;
1988 	if(bIsActive && bClear)
1989 	{
1990 		pActiveShell = pSh;
1991 		FindActiveTypeAndRemoveUserData();
1992 		Clear();
1993 	}
1994 	else if(bIsConstant)
1995 	{
1996 		if(!lcl_FindShell(pActiveShell))
1997 		{
1998 			pActiveShell = pSh;
1999 			bIsActive = sal_True;
2000 			bIsConstant = sal_False;
2001 			bClear = sal_True;
2002 		}
2003 	}
2004 	// nur wenn es die aktive View ist, wird das Array geloescht und
2005 	// die Anzeige neu gefuellt
2006 	if(bIsActive && bClear)
2007 	{
2008 		FindActiveTypeAndRemoveUserData();
2009 		for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
2010 		{
2011 			DELETEZ(aActiveContentArr[i]);
2012 		}
2013 		Display(sal_True);
2014 	}
2015 }
2016 
2017 /***************************************************************************
2018 	Beschreibung: 	Eine offene View als aktiv festlegen
2019 ***************************************************************************/
2020 
2021 
2022 void SwContentTree::SetConstantShell(SwWrtShell* pSh)
2023 {
2024 	pActiveShell = pSh;
2025 	bIsActive 		= sal_False;
2026 	bIsConstant 	= sal_True;
2027 	FindActiveTypeAndRemoveUserData();
2028 	for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++)
2029 	{
2030 		DELETEZ(aActiveContentArr[i]);
2031 	}
2032 	Display(sal_True);
2033 }
2034 /***************************************************************************
2035 	Beschreibung:	Kommandos des Navigators ausfuehren
2036 ***************************************************************************/
2037 
2038 
2039 void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier)
2040 {
2041 	sal_Bool nMove = sal_False;
2042 	switch( nCmd )
2043 	{
2044 		case FN_ITEM_DOWN:
2045 		case FN_ITEM_UP:   nMove = sal_True;
2046 		case FN_ITEM_LEFT:
2047 		case FN_ITEM_RIGHT:
2048 		if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
2049 				(bIsActive ||
2050                     (bIsConstant && pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
2051 		{
2052 			SwWrtShell* pShell = GetWrtShell();
2053 			sal_Int8 nActOutlineLevel = nOutlineLevel;
2054 			sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
2055 			SvLBoxEntry* pFirstEntry = FirstSelected();
2056 			if (pFirstEntry && lcl_IsContent(pFirstEntry))
2057 			{
2058 				if((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) ||
2059 					((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType()
2060 												== 	CONTENT_TYPE_OUTLINE)
2061 				{
2062 					nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos();
2063 				}
2064 			}
2065 			if ( nActPos < USHRT_MAX &&
2066 					( !nMove || pShell->IsOutlineMovable( nActPos )) )
2067 			{
2068 				pShell->StartAllAction();
2069 				pShell->GotoOutline( nActPos); // Falls Textselektion != BoxSelektion
2070 				pShell->Push();
2071 				pShell->MakeOutlineSel( nActPos, nActPos,
2072 									bModifier);
2073 				if( nMove )
2074 				{
2075 					short nDir = nCmd == FN_ITEM_UP ? -1 : 1;
2076 					if( !bModifier && ((nDir == -1 && nActPos > 0) ||
2077 						(nDir == 1 && nActPos < GetEntryCount() - 2 )) )
2078 					{
2079 						pShell->MoveOutlinePara( nDir );
2080 						//Cursor wieder an die aktuelle Position setzen
2081 						pShell->GotoOutline( nActPos + nDir);
2082 					}
2083 					else if(bModifier)
2084 					{
2085 						sal_uInt16 nActEndPos = nActPos;
2086 						SvLBoxEntry* pEntry = pFirstEntry;
2087 						sal_uInt16 nActLevel = ((SwOutlineContent*)
2088 								pFirstEntry->GetUserData())->GetOutlineLevel();
2089 						pEntry = Next(pEntry);
2090 						while( pEntry && CONTENT_TYPE_OUTLINE ==
2091 							((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() )
2092 						{
2093 							if(nActLevel >= ((SwOutlineContent*)
2094 								pEntry->GetUserData())->GetOutlineLevel())
2095 								break;
2096 							pEntry = Next(pEntry);
2097 							nActEndPos++;
2098 						}
2099 						sal_uInt16 nDest;
2100 						if(nDir == 1)
2101 						{
2102 							//Wenn der letzte Eintrag bewegt werden soll
2103 							//ist Schluss
2104 							if(pEntry && CONTENT_TYPE_OUTLINE ==
2105 								((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())
2106 							{
2107 								// pEntry zeigt jetzt auf den
2108 								// dem letzten sel. Eintrag folgenden E.
2109 								nDest = nActEndPos;
2110 								nDest++;
2111 								//hier muss der uebernaechste Eintrag
2112 								//gefunden werden. Die Selektion muss davor eingefuegt
2113 								//werden
2114 								while(pEntry )
2115 								{
2116 									pEntry = Next(pEntry);
2117 									// nDest++ darf nur ausgefuehrt werden,
2118 									// wenn pEntry != 0
2119 									if(pEntry && nDest++ &&
2120 									( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2121 									 CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2122 									{
2123 										nDest--;
2124 										break;
2125 									}
2126 								}
2127 								nDir = nDest - nActEndPos;
2128 								//wenn kein Eintrag gefunden wurde, der der Bedingung
2129 								//fuer das zuvor Einfuegen entspricht, muss etwas weniger
2130 								//geschoben werden
2131 							}
2132 							else
2133 								nDir = 0;
2134 						}
2135 						else
2136 						{
2137 							nDest = nActPos;
2138 							pEntry = pFirstEntry;
2139 							while(pEntry && nDest )
2140 							{
2141 								nDest--;
2142 								pEntry = Prev(pEntry);
2143 								if(pEntry &&
2144 									(nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()||
2145 									CONTENT_TYPE_OUTLINE !=
2146 								((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()))
2147 								{
2148 									break;
2149 								}
2150 							}
2151 							nDir = nDest - nActPos;
2152 						}
2153 						if(nDir)
2154 						{
2155 							pShell->MoveOutlinePara( nDir );
2156 							//Cursor wieder an die aktuelle Position setzen
2157 							pShell->GotoOutline( nActPos + nDir);
2158 						}
2159 					}
2160 				}
2161 				else
2162 				{
2163 					if( pShell->IsProtectedOutlinePara() )
2164 						Sound::Beep(); //konnte nicht umgestuft werden
2165 					else
2166 						pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 );
2167 				}
2168 
2169 				pShell->ClearMark();
2170 				pShell->Pop(sal_False); //Cursor steht jetzt wieder an der akt. Ueberschrift
2171 				pShell->EndAllAction();
2172 				if(aActiveContentArr[CONTENT_TYPE_OUTLINE])
2173 					aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2174 				Display(sal_True);
2175 				if(!bIsRoot)
2176 				{
2177                     const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
2178                     SvLBoxEntry* pFirst = First();
2179 
2180                     while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
2181 					{
2182                         if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos)
2183 						{
2184                             Select(pFirst);
2185                             MakeVisible(pFirst);
2186 						}
2187 					}
2188 				}
2189 			}
2190 			else
2191 				Sound::Beep(); //konnte nicht verschoben werden
2192 		}
2193 	}
2194 }
2195 /***************************************************************************
2196 	Beschreibung:
2197 ***************************************************************************/
2198 
2199 
2200 void	SwContentTree::ShowTree()
2201 {
2202 	aUpdTimer.Start();
2203 	SvTreeListBox::Show();
2204 }
2205 
2206 /***************************************************************************
2207 	Beschreibung:	zusammengefaltet wird nicht geidlet
2208 ***************************************************************************/
2209 
2210 
2211 void	SwContentTree::HideTree()
2212 {
2213 	aUpdTimer.Stop();
2214 	SvTreeListBox::Hide();
2215 }
2216 
2217 /***************************************************************************
2218 	Beschreibung:	Kein Idle mit Focus oder waehrend des Dragging
2219 ***************************************************************************/
2220 
2221 
2222 IMPL_LINK( SwContentTree, TimerUpdate, Timer*, EMPTYARG)
2223 {
2224 	// kein Update waehrend D&D
2225 	// Viewabfrage, da der Navigator zu spaet abgeraeumt wird
2226     SwView* pView = GetParentWindow()->GetCreateView();
2227 	if( (!HasFocus() || bViewHasChanged) &&
2228 		 !bIsInDrag && !bIsInternalDrag && pView &&
2229 		 pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() )
2230 	{
2231 		bViewHasChanged = sal_False;
2232 		bIsIdleClear = sal_False;
2233 		SwWrtShell* pActShell = pView->GetWrtShellPtr();
2234 		if( bIsConstant && !lcl_FindShell( pActiveShell ) )
2235 		{
2236 			SetActiveShell(pActShell);
2237 			GetParentWindow()->UpdateListBox();
2238 		}
2239 
2240 		if(bIsActive && pActShell != GetWrtShell())
2241 			SetActiveShell(pActShell);
2242 		else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
2243 					HasContentChanged())
2244 		{
2245 			FindActiveTypeAndRemoveUserData();
2246 			Display(sal_True);
2247 		}
2248 	}
2249 	else if(!pView && bIsActive && !bIsIdleClear)
2250 	{
2251 		if(pActiveShell)
2252 			SetActiveShell(0);
2253 		Clear();
2254 		bIsIdleClear = sal_True;
2255 	}
2256 	return 0;
2257 }
2258 
2259 /***************************************************************************
2260 	Beschreibung:
2261 ***************************************************************************/
2262 
2263 
2264 DragDropMode SwContentTree::NotifyStartDrag(
2265 				TransferDataContainer& rContainer,
2266 				SvLBoxEntry* pEntry )
2267 {
2268 	DragDropMode eMode = (DragDropMode)0;
2269 	if( bIsActive && nRootType == CONTENT_TYPE_OUTLINE &&
2270 		GetModel()->GetAbsPos( pEntry ) > 0
2271 		&& !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
2272 		eMode = GetDragDropMode();
2273 	else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName())
2274 		eMode = SV_DRAGDROP_APP_COPY;
2275 
2276 	sal_Int8 nDragMode;
2277 	FillTransferData( rContainer, nDragMode );
2278 	bDocChgdInDragging = sal_False;
2279 	bIsInternalDrag = sal_True;
2280 	return eMode;
2281 }
2282 
2283 
2284 /***************************************************************************
2285 	Beschreibung :	Nach dem Drag wird der aktuelle Absatz m i t
2286 					Childs verschoben
2287 ***************************************************************************/
2288 
2289 
2290 sal_Bool  SwContentTree::NotifyMoving( SvLBoxEntry*  pTarget,
2291 		SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uLong& )
2292 {
2293 	if(!bDocChgdInDragging)
2294 	{
2295 		sal_uInt16 nTargetPos = 0;
2296 		sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
2297 		if(!lcl_IsContent(pTarget))
2298 			nTargetPos = USHRT_MAX;
2299 		else
2300 			nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2301 		if(	MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2302 						nTargetPos != USHRT_MAX)
2303 		{
2304 			SvLBoxEntry* pNext = Next(pTarget);
2305 			if(pNext)
2306 				nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1;
2307 			else
2308                 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1;
2309 
2310 		}
2311 
2312 		DBG_ASSERT( pEntry &&
2313 			lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" );
2314 		GetParentWindow()->MoveOutline( nSourcePos,
2315 									nTargetPos,
2316 									sal_True);
2317 
2318 		aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2319 		Display(sal_True);
2320 	}
2321 	//TreeListBox wird aus dem Dokument neu geladen
2322 	return sal_False;
2323 }
2324 /***************************************************************************
2325 	Beschreibung : 	Nach dem Drag wird der aktuelle Absatz o h n e
2326 					Childs verschoben
2327 ***************************************************************************/
2328 
2329 
2330 sal_Bool  SwContentTree::NotifyCopying( SvLBoxEntry*  pTarget,
2331 		SvLBoxEntry*  pEntry, SvLBoxEntry*& , sal_uLong& )
2332 {
2333 	if(!bDocChgdInDragging)
2334 	{
2335 		sal_uInt16 nTargetPos = 0;
2336 		sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos();
2337 		if(!lcl_IsContent(pTarget))
2338 			nTargetPos = USHRT_MAX;
2339 		else
2340 			nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos();
2341 
2342 		if(	MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt
2343 						nTargetPos != USHRT_MAX)
2344 		{
2345 			SvLBoxEntry* pNext = Next(pTarget);
2346 			if(pNext)
2347 				nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1;
2348 			else
2349                 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1;
2350 
2351 		}
2352 
2353 
2354 		DBG_ASSERT( pEntry &&
2355 			lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" );
2356 		GetParentWindow()->MoveOutline( nSourcePos,	nTargetPos, sal_False);
2357 
2358 		//TreeListBox wird aus dem Dokument neu geladen
2359 		aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate();
2360 		Display(sal_True);
2361 	}
2362 	return sal_False;
2363 }
2364 
2365 /***************************************************************************
2366 	Beschreibung:	Kein Drop vor den ersten Eintrag - es ist ein SwContentType
2367 ***************************************************************************/
2368 
2369 sal_Bool  SwContentTree::NotifyAcceptDrop( SvLBoxEntry* pEntry)
2370 {
2371 	return pEntry != 0;
2372 }
2373 
2374 
2375 /***************************************************************************
2376 	Beschreibung: 	Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt,
2377  * 					dann soll die Basisfunktion des Controls gerufen werden
2378 ***************************************************************************/
2379 void  SwContentTree::MouseButtonDown( const MouseEvent& rMEvt )
2380 {
2381 	Point aPos( rMEvt.GetPosPixel());
2382 	SvLBoxEntry* pEntry = GetEntry( aPos, sal_True );
2383 	if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
2384 		Control::MouseButtonDown( rMEvt );
2385 	else
2386 		SvTreeListBox::MouseButtonDown( rMEvt );
2387 }
2388 
2389 /***************************************************************************
2390 	Beschreibung:	sofort aktualisieren
2391 ***************************************************************************/
2392 
2393 
2394 void  SwContentTree::GetFocus()
2395 {
2396     SwView* pActView = GetParentWindow()->GetCreateView();
2397 	if(pActView)
2398 	{
2399 		SwWrtShell* pActShell = pActView->GetWrtShellPtr();
2400 		if(bIsConstant && !lcl_FindShell(pActiveShell))
2401 		{
2402 			SetActiveShell(pActShell);
2403 		}
2404 
2405 		if(bIsActive && pActShell != GetWrtShell())
2406 			SetActiveShell(pActShell);
2407 		else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) &&
2408 					HasContentChanged())
2409 		{
2410 			Display(sal_True);
2411 		}
2412 	}
2413 	else if(bIsActive)
2414 		Clear();
2415 	SvTreeListBox::GetFocus();
2416 }
2417 
2418 /***************************************************************************
2419 	Beschreibung:
2420 ***************************************************************************/
2421 
2422 
2423 void  SwContentTree::KeyInput(const KeyEvent& rEvent)
2424 {
2425 	const KeyCode aCode = rEvent.GetKeyCode();
2426 	if(aCode.GetCode() == KEY_RETURN)
2427 	{
2428 		SvLBoxEntry* pEntry = FirstSelected();
2429 		if ( pEntry )
2430 		{
2431 			switch(aCode.GetModifier())
2432 			{
2433 				case KEY_MOD2:
2434 					// Boxen umschalten
2435 					GetParentWindow()->ToggleTree();
2436 				break;
2437 				case KEY_MOD1:
2438 					// RootModus umschalten
2439 					ToggleToRoot();
2440 				break;
2441 				case 0:
2442 					if(lcl_IsContentType(pEntry))
2443 					{
2444 						IsExpanded(pEntry) ?
2445 							Collapse(pEntry) :
2446 								Expand(pEntry);
2447 					}
2448 					else
2449 						ContentDoubleClickHdl(0);
2450 				break;
2451 			}
2452 		}
2453 	}
2454 	else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
2455 	{
2456 		SvLBoxEntry* pEntry = FirstSelected();
2457 		if(pEntry &&
2458 			lcl_IsContent(pEntry) &&
2459 				((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() &&
2460 					!pActiveShell->GetView().GetDocShell()->IsReadOnly())
2461 		{
2462 			EditEntry(pEntry, EDIT_MODE_DELETE);
2463             bViewHasChanged = sal_True;
2464             GetParentWindow()->UpdateListBox();
2465             TimerUpdate(&aUpdTimer);
2466             GrabFocus();
2467         }
2468 	}
2469 	else
2470 		SvTreeListBox::KeyInput(rEvent);
2471 
2472 }
2473 
2474 /***************************************************************************
2475 	Beschreibung:
2476 ***************************************************************************/
2477 
2478 
2479 void  SwContentTree::RequestHelp( const HelpEvent& rHEvt )
2480 {
2481 	sal_Bool bCallBase = sal_True;
2482 	if( rHEvt.GetMode() & HELPMODE_QUICK )
2483 	{
2484 		Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2485 		SvLBoxEntry* pEntry = GetEntry( aPos );
2486 		if( pEntry )
2487 		{
2488 			sal_uInt16 nType;
2489 			sal_Bool bBalloon = sal_False;
2490 			sal_Bool bContent = sal_False;
2491 			void* pUserData = pEntry->GetUserData();
2492 			if(lcl_IsContentType(pEntry))
2493 				nType = ((SwContentType*)pUserData)->GetType();
2494 			else
2495 			{
2496 				nType = ((SwContent*)pUserData)->GetParent()->GetType();
2497 				bContent = sal_True;
2498 			}
2499 			String sEntry;
2500 			sal_Bool bRet = sal_False;
2501 			if(bContent)
2502 			{
2503 				switch( nType )
2504 				{
2505 					case CONTENT_TYPE_URLFIELD:
2506 						sEntry = ((SwURLFieldContent*)pUserData)->GetURL();
2507 						bRet = sal_True;
2508 					break;
2509 
2510 					case CONTENT_TYPE_POSTIT:
2511 						sEntry = ((SwPostItContent*)pUserData)->GetName();
2512 						bRet = sal_True;
2513 						if(Help::IsBalloonHelpEnabled())
2514 							bBalloon = sal_True;
2515 					break;
2516 					case CONTENT_TYPE_OUTLINE:
2517 						sEntry = ((SwOutlineContent*)pUserData)->GetName();
2518 						bRet = sal_True;
2519 					break;
2520 					case CONTENT_TYPE_GRAPHIC:
2521 						sEntry = ((SwGraphicContent*)pUserData)->GetLink();
2522 #if OSL_DEBUG_LEVEL > 1
2523 						sEntry += ' ';
2524 						sEntry += String::CreateFromInt32(
2525 									((SwGraphicContent*)pUserData)->GetYPos());
2526 #endif
2527 						bRet = sal_True;
2528 					break;
2529 #if OSL_DEBUG_LEVEL > 1
2530 					case CONTENT_TYPE_TABLE:
2531 					case CONTENT_TYPE_FRAME:
2532 						sEntry = String::CreateFromInt32(
2533 										((SwContent*)pUserData)->GetYPos() );
2534 						bRet = sal_True;
2535 					break;
2536 #endif
2537 				}
2538 				if(((SwContent*)pUserData)->IsInvisible())
2539 				{
2540 					if(sEntry.Len())
2541 						sEntry += C2S(", ");
2542 					sEntry += sInvisible;
2543 					bRet = sal_True;
2544 				}
2545 			}
2546 			else
2547 			{
2548 				sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount();
2549 				sEntry = String::CreateFromInt32(nMemberCount);
2550 				sEntry += ' ';
2551 				sEntry += nMemberCount == 1
2552 							? ((SwContentType*)pUserData)->GetSingleName()
2553 							: ((SwContentType*)pUserData)->GetName();
2554 				bRet = sal_True;
2555 			}
2556 			if(bRet)
2557 			{
2558 				SvLBoxTab* pTab;
2559 				SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
2560 				if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA())
2561 				{
2562 					aPos = GetEntryPosition( pEntry );
2563 
2564 					aPos.X() = GetTabPos( pEntry, pTab );
2565 					Size aSize( pItem->GetSize( this, pEntry ) );
2566 
2567 					if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
2568 						aSize.Width() = GetSizePixel().Width() - aPos.X();
2569 
2570 					aPos = OutputToScreenPixel(aPos);
2571 					Rectangle aItemRect( aPos, aSize );
2572 					if(bBalloon)
2573 					{
2574 						aPos.X() += aSize.Width();
2575 						Help::ShowBalloon( this, aPos, aItemRect, sEntry );
2576 					}
2577 					else
2578 						Help::ShowQuickHelp( this, aItemRect, sEntry,
2579 							QUICKHELP_LEFT|QUICKHELP_VCENTER );
2580 					bCallBase = sal_False;
2581 				}
2582 			}
2583 			else
2584 			{
2585 				Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 );
2586 				bCallBase = sal_False;
2587 			}
2588 		}
2589 	}
2590 	if( bCallBase )
2591 		Window::RequestHelp( rHEvt );
2592 }
2593 
2594 /***************************************************************************
2595 	Beschreibung:
2596 ***************************************************************************/
2597 
2598 
2599 void    SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
2600 {
2601 	SvLBoxEntry* pFirst = FirstSelected();
2602     switch( nSelectedPopupEntry )
2603 	{
2604 		//Outlinelevel
2605 		case 101:
2606 		case 102:
2607 		case 103:
2608 		case 104:
2609 		case 105:
2610 		case 106:
2611 		case 107:
2612 		case 108:
2613 		case 109:
2614 		case 110:
2615             nSelectedPopupEntry -= 100;
2616             if(nOutlineLevel != nSelectedPopupEntry )
2617                 SetOutlineLevel((sal_Int8)nSelectedPopupEntry);
2618 		break;
2619 		case 201:
2620 		case 202:
2621 		case 203:
2622             GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201);
2623 		break;
2624 		case 401:
2625 		case 402:
2626             EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX);
2627 		break;
2628 		// Eintrag bearbeiten
2629 		case 403:
2630 			EditEntry(pFirst, EDIT_MODE_EDIT);
2631 		break;
2632 		case 404:
2633 			EditEntry(pFirst, EDIT_UNPROTECT_TABLE);
2634 		break;
2635 		case 405 :
2636 		{
2637 			const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData())
2638 																->GetTOXBase();
2639             pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase));
2640 		}
2641 		break;
2642 		case 4:
2643 		break;
2644 		case 501:
2645 			EditEntry(pFirst, EDIT_MODE_DELETE);
2646 		break;
2647 		case 502 :
2648 			EditEntry(pFirst, EDIT_MODE_RENAME);
2649 		break;
2650 		case 600:
2651 			pActiveShell->GetView().GetPostItMgr()->Show();
2652 			break;
2653 		case 601:
2654 			pActiveShell->GetView().GetPostItMgr()->Hide();
2655 			break;
2656 		case 602:
2657 			{
2658                 pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
2659 				pActiveShell->GetView().GetPostItMgr()->Delete();
2660 				break;
2661 			}
2662 		//Anzeige
2663         default: // nSelectedPopupEntry > 300
2664         if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
2665 		{
2666             nSelectedPopupEntry -= 300;
2667 			SwView *pView = SwModule::GetFirstView();
2668 			while (pView)
2669 			{
2670                 nSelectedPopupEntry --;
2671                 if(nSelectedPopupEntry == 0)
2672 				{
2673 					SetConstantShell(&pView->GetWrtShell());
2674 					break;
2675 				}
2676 				pView = SwModule::GetNextView(pView);
2677 			}
2678             if(nSelectedPopupEntry)
2679 			{
2680                 bViewHasChanged = bIsActive = nSelectedPopupEntry == 1;
2681 				bIsConstant = sal_False;
2682                 Display(nSelectedPopupEntry == 1);
2683 			}
2684 		}
2685 	}
2686 	GetParentWindow()->UpdateListBox();
2687 }
2688 
2689 /***************************************************************************
2690 	Beschreibung:
2691 ***************************************************************************/
2692 
2693 
2694 void SwContentTree::SetOutlineLevel(sal_uInt8 nSet)
2695 {
2696 	nOutlineLevel = nSet;
2697 	pConfig->SetOutlineLevel( nOutlineLevel );
2698 	SwContentType** ppContentT = bIsActive ?
2699 					&aActiveContentArr[CONTENT_TYPE_OUTLINE] :
2700 						&aHiddenContentArr[CONTENT_TYPE_OUTLINE];
2701 	if(*ppContentT)
2702 	{
2703 		(*ppContentT)->SetOutlineLevel(nOutlineLevel);
2704 		(*ppContentT)->Init();
2705 	}
2706 	Display(bIsActive);
2707 }
2708 
2709 /***************************************************************************
2710 	Beschreibung:	Moduswechsel: gedropptes Doc anzeigen
2711 ***************************************************************************/
2712 
2713 
2714 void SwContentTree::ShowHiddenShell()
2715 {
2716 	if(pHiddenShell)
2717 	{
2718 		bIsConstant = sal_False;
2719 		bIsActive = sal_False;
2720 		Display(sal_False);
2721 	}
2722 }
2723 
2724 /***************************************************************************
2725 	Beschreibung:	Moduswechsel: aktive Sicht anzeigen
2726 ***************************************************************************/
2727 
2728 
2729 void SwContentTree::ShowActualView()
2730 {
2731 	bIsActive = sal_True;
2732 	bIsConstant = sal_False;
2733 	Display(sal_True);
2734 	GetParentWindow()->UpdateListBox();
2735 }
2736 
2737 /*-----------------20.11.96 13.34-------------------
2738 	Beschreibung: Hier sollen die Buttons zum Verschieben von
2739 				  Outlines en-/disabled werden
2740 --------------------------------------------------*/
2741 
2742 sal_Bool  SwContentTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
2743 {
2744 	if(!pEntry)
2745 		return sal_False;
2746 	sal_Bool bEnable = sal_False;
2747 	SvLBoxEntry* pParentEntry = GetParent(pEntry);
2748 	if(!bIsLastReadOnly && (!IsVisible() ||
2749 		((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry) ||
2750 			(lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE))))
2751 		bEnable = sal_True;
2752 	SwNavigationPI* pNavi = GetParentWindow();
2753 	pNavi->aContentToolBox.EnableItem(FN_ITEM_UP ,  bEnable);
2754 	pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable);
2755 	pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable);
2756 	pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable);
2757 
2758 	return SvTreeListBox::Select(pEntry, bSelect);
2759 }
2760 
2761 /*-----------------27.11.96 12.56-------------------
2762 
2763 --------------------------------------------------*/
2764 
2765 void SwContentTree::SetRootType(sal_uInt16 nType)
2766 {
2767 	nRootType = nType;
2768 	bIsRoot = sal_True;
2769 	pConfig->SetRootType( nRootType );
2770 }
2771 
2772 /*-----------------10.01.97 12.19-------------------
2773 
2774 --------------------------------------------------*/
2775 
2776 void SwContentType::RemoveNewline(String& rEntry)
2777 {
2778 	sal_Unicode* pStr = rEntry.GetBufferAccess();
2779 	for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr )
2780 	{
2781 		if( *pStr == 10 || *pStr == 13 )
2782 			*pStr = 0x20;
2783 	}
2784 }
2785 
2786 /*-----------------14.01.97 16.38-------------------
2787 
2788 --------------------------------------------------*/
2789 
2790 void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode)
2791 {
2792 	SwContent* pCnt = (SwContent*)pEntry->GetUserData();
2793 	GotoContent(pCnt);
2794 	sal_uInt16 nType = pCnt->GetParent()->GetType();
2795 	sal_uInt16 nSlot = 0;
2796 
2797 	uno::Reference< container::XNameAccess >  xNameAccess, xSecond, xThird;
2798 	switch(nType)
2799 	{
2800 		case CONTENT_TYPE_TABLE 	:
2801 			if(nMode == EDIT_UNPROTECT_TABLE)
2802 			{
2803 				pActiveShell->GetView().GetDocShell()->
2804 						GetDoc()->UnProtectCells( pCnt->GetName());
2805 			}
2806 			else if(nMode == EDIT_MODE_DELETE)
2807 			{
2808 				pActiveShell->StartAction();
2809                 String sTable = SW_RES(STR_TABLE_NAME);
2810                 SwRewriter aRewriterTableName;
2811                 aRewriterTableName.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE));
2812                 aRewriterTableName.AddRule(UNDO_ARG2, pCnt->GetName());
2813                 aRewriterTableName.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE));
2814                 sTable = aRewriterTableName.Apply(sTable);
2815 
2816                 SwRewriter aRewriter;
2817                 aRewriter.AddRule(UNDO_ARG1, sTable);
2818 				pActiveShell->StartUndo(UNDO_DELETE, &aRewriter);
2819 				pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
2820 				pActiveShell->DeleteRow();
2821                 pActiveShell->EndUndo();
2822 				pActiveShell->EndAction();
2823 			}
2824 			else if(nMode == EDIT_MODE_RENAME)
2825 			{
2826 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2827 				uno::Reference< text::XTextTablesSupplier >  xTables(xModel, uno::UNO_QUERY);
2828 				xNameAccess = xTables->getTextTables();
2829 			}
2830 			else
2831 				nSlot = FN_FORMAT_TABLE_DLG;
2832 		break;
2833 
2834 		case CONTENT_TYPE_GRAPHIC   :
2835 			if(nMode == EDIT_MODE_DELETE)
2836 			{
2837 				pActiveShell->DelRight();
2838 			}
2839 			else if(nMode == EDIT_MODE_RENAME)
2840 			{
2841 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2842 				uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
2843 				xNameAccess = xGraphics->getGraphicObjects();
2844 				uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
2845 				xSecond = xFrms->getTextFrames();
2846 				uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
2847 				xThird = xObjs->getEmbeddedObjects();
2848 			}
2849 			else
2850 				nSlot = FN_FORMAT_GRAFIC_DLG;
2851 		break;
2852 
2853 		case CONTENT_TYPE_FRAME     :
2854 		case CONTENT_TYPE_OLE       :
2855 			if(nMode == EDIT_MODE_DELETE)
2856 			{
2857 				pActiveShell->DelRight();
2858 			}
2859 			else if(nMode == EDIT_MODE_RENAME)
2860 			{
2861 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2862 				uno::Reference< text::XTextFramesSupplier >  xFrms(xModel, uno::UNO_QUERY);
2863 				uno::Reference< text::XTextEmbeddedObjectsSupplier >  xObjs(xModel, uno::UNO_QUERY);
2864 				if(CONTENT_TYPE_FRAME == nType)
2865 				{
2866 					xNameAccess = xFrms->getTextFrames();
2867 					xSecond = xObjs->getEmbeddedObjects();
2868 				}
2869 				else
2870 				{
2871 					xNameAccess = xObjs->getEmbeddedObjects();
2872 					xSecond = xFrms->getTextFrames();
2873 				}
2874 				uno::Reference< text::XTextGraphicObjectsSupplier >  xGraphics(xModel, uno::UNO_QUERY);
2875 				xThird = xGraphics->getGraphicObjects();
2876 			}
2877 			else
2878 				nSlot = FN_FORMAT_FRAME_DLG;
2879 		break;
2880         case CONTENT_TYPE_BOOKMARK  :
2881             if(nMode == EDIT_MODE_DELETE)
2882             {
2883                 IDocumentMarkAccess* const pMarkAccess = pActiveShell->getIDocumentMarkAccess();
2884                 pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) );
2885             }
2886             else if(nMode == EDIT_MODE_RENAME)
2887             {
2888                 uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2889                 uno::Reference< text::XBookmarksSupplier >  xBkms(xModel, uno::UNO_QUERY);
2890                 xNameAccess = xBkms->getBookmarks();
2891             }
2892             else
2893                 nSlot = FN_INSERT_BOOKMARK;
2894         break;
2895 
2896 		case CONTENT_TYPE_REGION    :
2897 			if(nMode == EDIT_MODE_RENAME)
2898 			{
2899 				uno::Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2900 				uno::Reference< text::XTextSectionsSupplier >  xSects(xModel, uno::UNO_QUERY);
2901 				xNameAccess = xSects->getTextSections();
2902 			}
2903 			else
2904 				nSlot = FN_EDIT_REGION;
2905 		break;
2906 
2907 		case CONTENT_TYPE_URLFIELD:
2908 			nSlot = FN_EDIT_HYPERLINK;
2909 		break;
2910 		case CONTENT_TYPE_REFERENCE:
2911 			nSlot = FN_EDIT_FIELD;
2912 		break;
2913 
2914 		case CONTENT_TYPE_POSTIT:
2915 			pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
2916 			if(nMode == EDIT_MODE_DELETE)
2917 			{
2918 				if (((SwPostItContent*)pCnt)->IsPostIt())
2919 				{
2920                     pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0);
2921 					pActiveShell->DelRight();
2922 				}
2923 				/*
2924 				//	this code can be used once we want redline comments in the margin
2925 				else
2926 				{
2927 					SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline());
2928 					if (pComment)
2929 						pComment->Delete();
2930 				}
2931 				*/
2932 			}
2933 			else
2934 			{
2935 				if (((SwPostItContent*)pCnt)->IsPostIt())
2936 					nSlot = FN_POSTIT;
2937 				else
2938 					nSlot = FN_REDLINE_COMMENT;
2939 			}
2940 		break;
2941 		case CONTENT_TYPE_INDEX:
2942 		{
2943 			const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase();
2944 			switch(nMode)
2945 			{
2946 				case EDIT_MODE_EDIT:
2947 					if(pBase)
2948 					{
2949 						SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase);
2950 						pActiveShell->GetView().GetViewFrame()->
2951 							GetDispatcher()->Execute(FN_INSERT_MULTI_TOX,
2952 											SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0L);
2953 
2954 					}
2955 				break;
2956 				case EDIT_MODE_RMV_IDX:
2957 				case EDIT_MODE_DELETE:
2958 				{
2959 					if( pBase )
2960 						pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode);
2961 				}
2962 				break;
2963 				case EDIT_MODE_UPD_IDX:
2964 				case EDIT_MODE_RENAME:
2965 				{
2966 					Reference< frame::XModel >  xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel();
2967 					Reference< XDocumentIndexesSupplier >  xIndexes(xModel, UNO_QUERY);
2968 					Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes());
2969 					Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY);
2970 					if(EDIT_MODE_RENAME == nMode)
2971 						xNameAccess = xLocalNameAccess;
2972 					else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName()))
2973 					{
2974 						Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName());
2975 						Reference< XDocumentIndex> xIdx;
2976 						if(aIdx >>= xIdx)
2977 							xIdx->update();
2978 					}
2979 				}
2980 				break;
2981 			}
2982 		}
2983 		break;
2984         case CONTENT_TYPE_DRAWOBJECT :
2985             if(EDIT_MODE_DELETE == nMode)
2986                 nSlot = SID_DELETE;
2987         break;
2988 	}
2989 	if(nSlot)
2990 		pActiveShell->GetView().GetViewFrame()->
2991 					GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON);
2992 	else if(xNameAccess.is())
2993 	{
2994 		uno::Any aObj = xNameAccess->getByName(pCnt->GetName());
2995         uno::Reference< uno::XInterface >  xTmp;
2996         aObj >>= xTmp;
2997 		uno::Reference< container::XNamed >  xNamed(xTmp, uno::UNO_QUERY);
2998         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2999         DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
3000 
3001         AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg( this, xNamed, xNameAccess, DLG_RENAME_XNAMED );
3002         DBG_ASSERT(pDlg, "Dialogdiet fail!");
3003 		if(xSecond.is())
3004             pDlg->SetAlternativeAccess( xSecond, xThird);
3005 
3006 		String sForbiddenChars;
3007 		if(CONTENT_TYPE_BOOKMARK == nType)
3008 		{
3009             sForbiddenChars = C2S("/\\@:*?\";,.#");
3010 		}
3011 		else if(CONTENT_TYPE_TABLE == nType)
3012 		{
3013 			sForbiddenChars = C2S(" .<>");
3014 		}
3015         pDlg->SetForbiddenChars(sForbiddenChars);
3016         pDlg->Execute();
3017         delete pDlg;
3018 	}
3019 }
3020 
3021 /*-----------------14.01.97 16.53-------------------
3022 
3023 --------------------------------------------------*/
3024 
3025 void SwContentTree::GotoContent(SwContent* pCnt)
3026 {
3027 	pActiveShell->EnterStdMode();
3028 
3029 	sal_Bool bSel = sal_False;
3030 	sal_uInt16 nJumpType = pCnt->GetParent()->GetType();
3031 	switch(nJumpType)
3032 	{
3033 		case CONTENT_TYPE_OUTLINE	:
3034 		{
3035 			pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos());
3036 		}
3037 		break;
3038 		case CONTENT_TYPE_TABLE 	:
3039 		{
3040 			pActiveShell->GotoTable(pCnt->GetName());
3041 		}
3042 		break;
3043 		case CONTENT_TYPE_FRAME     :
3044 		case CONTENT_TYPE_GRAPHIC   :
3045 		case CONTENT_TYPE_OLE       :
3046 		{
3047 			if(pActiveShell->GotoFly(pCnt->GetName()))
3048 				bSel = sal_True;
3049 		}
3050 		break;
3051         case CONTENT_TYPE_BOOKMARK:
3052         {
3053             pActiveShell->GotoMark(pCnt->GetName());
3054         }
3055 		break;
3056 		case CONTENT_TYPE_REGION    :
3057 		{
3058 			pActiveShell->GotoRegion(pCnt->GetName());
3059 		}
3060 		break;
3061 		case CONTENT_TYPE_URLFIELD:
3062 		{
3063 			if(pActiveShell->GotoINetAttr(
3064 							*((SwURLFieldContent*)pCnt)->GetINetAttr() ))
3065 			{
3066 				pActiveShell->Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False);
3067 				pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True );
3068 			}
3069 
3070 		}
3071 		break;
3072 		case CONTENT_TYPE_REFERENCE:
3073 		{
3074 			pActiveShell->GotoRefMark(pCnt->GetName());
3075 		}
3076 		break;
3077 		case CONTENT_TYPE_INDEX:
3078 		{
3079 			if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName()))
3080 				pActiveShell->GotoPrevTOXBase(&pCnt->GetName());
3081 		}
3082 		break;
3083 		case CONTENT_TYPE_POSTIT:
3084 			pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell();
3085 			if (((SwPostItContent*)pCnt)->IsPostIt())
3086 				pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt());
3087 			else
3088 				pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline(
3089 						pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData()));
3090 
3091 		break;
3092 		case CONTENT_TYPE_DRAWOBJECT:
3093         {
3094             SdrView* pDrawView = pActiveShell->GetDrawView();
3095 			if (pDrawView)
3096 			{
3097 				pDrawView->SdrEndTextEdit();
3098 				pDrawView->UnmarkAll();
3099                 SdrModel* _pModel = pActiveShell->getIDocumentDrawModelAccess()->GetDrawModel();
3100                 SdrPage* pPage = _pModel->GetPage(0);
3101                 sal_uInt32 nCount = pPage->GetObjCount();
3102                 for( sal_uInt32 i=0; i< nCount; i++ )
3103                 {
3104                     SdrObject* pTemp = pPage->GetObj(i);
3105                     // --> OD 2006-03-09 #i51726# - all drawing objects can be named now
3106 //                    if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName())
3107                     if ( pTemp->GetName() == pCnt->GetName() )
3108                     // <--
3109                     {
3110                         SdrPageView* pPV = pDrawView->GetSdrPageView();
3111                         if( pPV )
3112                         {
3113                             pDrawView->MarkObj( pTemp, pPV );
3114                         }
3115                     }
3116                 }
3117             }
3118         }
3119 		break;
3120 	}
3121 	if(bSel)
3122 	{
3123 		pActiveShell->HideCrsr();
3124 		pActiveShell->EnterSelFrmMode();
3125 	}
3126 	SwView& rView = pActiveShell->GetView();
3127 	rView.StopShellTimer();
3128     rView.GetPostItMgr()->SetActiveSidebarWin(0);
3129 	rView.GetEditWin().GrabFocus();
3130 }
3131 /*-----------------06.02.97 19.14-------------------
3132     Jetzt nochtdie passende text::Bookmark
3133 --------------------------------------------------*/
3134 
3135 NaviContentBookmark::NaviContentBookmark()
3136     :
3137     nDocSh(0),
3138     nDefDrag( REGION_MODE_NONE )
3139 {
3140 }
3141 
3142 /*-----------------06.02.97 20.12-------------------
3143 
3144 --------------------------------------------------*/
3145 
3146 NaviContentBookmark::NaviContentBookmark( const String &rUrl,
3147 					const String& rDesc,
3148 					sal_uInt16 nDragType,
3149 					const SwDocShell* pDocSh ) :
3150 	aUrl( rUrl ),
3151 	aDescr(rDesc),
3152     nDocSh((long)pDocSh),
3153     nDefDrag( nDragType )
3154 {
3155 }
3156 
3157 void NaviContentBookmark::Copy( TransferDataContainer& rData ) const
3158 {
3159 	rtl_TextEncoding eSysCSet = gsl_getSystemTextEncoding();
3160 
3161 	ByteString sStr( aUrl, eSysCSet );
3162 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3163 	sStr += ByteString( aDescr, eSysCSet );
3164 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3165 	sStr += ByteString::CreateFromInt32( nDefDrag );
3166 	sStr += static_cast< char >(NAVI_BOOKMARK_DELIM);
3167 	sStr += ByteString::CreateFromInt32( nDocSh );
3168 	rData.CopyByteString( SOT_FORMATSTR_ID_SONLK, sStr );
3169 }
3170 
3171 sal_Bool NaviContentBookmark::Paste( TransferableDataHelper& rData )
3172 {
3173 	String sStr;
3174 	sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr );
3175 	if( bRet )
3176 	{
3177 		xub_StrLen nPos = 0;
3178 		aUrl	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos );
3179 		aDescr	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos );
3180         nDefDrag= (sal_uInt16)sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32();
3181 		nDocSh	= sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32();
3182 	}
3183 	return bRet;
3184 }
3185 
3186 
3187 /* -----------------------------09.12.99 13:50--------------------------------
3188 
3189  ---------------------------------------------------------------------------*/
3190 class SwContentLBoxString : public SvLBoxString
3191 {
3192 public:
3193 	SwContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
3194 		const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr)	{}
3195 
3196 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
3197 		SvLBoxEntry* pEntry);
3198 };
3199 
3200 /* -----------------------------09.12.99 13:49--------------------------------
3201 
3202  ---------------------------------------------------------------------------*/
3203 void SwContentTree::InitEntry(SvLBoxEntry* pEntry,
3204 		const XubString& rStr ,const Image& rImg1,const Image& rImg2,
3205         SvLBoxButtonKind eButtonKind)
3206 {
3207 	sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
3208 	SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
3209 	SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
3210 	SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() );
3211 	pEntry->ReplaceItem( pStr, nColToHilite );
3212 }
3213 /* -----------------------------09.12.99 13:49--------------------------------
3214 
3215  ---------------------------------------------------------------------------*/
3216 void SwContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
3217 	SvLBoxEntry* pEntry )
3218 {
3219 	if(lcl_IsContent(pEntry) &&
3220 			((SwContent *)pEntry->GetUserData())->IsInvisible())
3221 	{
3222 		//* pCont = (SwContent*)pEntry->GetUserData();
3223 		Font aOldFont( rDev.GetFont());
3224 		Font aFont(aOldFont);
3225 		Color aCol( COL_LIGHTGRAY );
3226 		aFont.SetColor( aCol );
3227 		rDev.SetFont( aFont );
3228 		rDev.DrawText( rPos, GetText() );
3229 		rDev.SetFont( aOldFont );
3230 	}
3231 	else
3232 		SvLBoxString::Paint( rPos, rDev, nFlags, pEntry);
3233 }
3234 /* -----------------------------06.05.2002 10:20------------------------------
3235 
3236  ---------------------------------------------------------------------------*/
3237 void    SwContentTree::DataChanged( const DataChangedEvent& rDCEvt )
3238 {
3239   if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
3240          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
3241     {
3242         sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP;
3243         aEntryImages = ImageList(SW_RES(nResId));
3244         FindActiveTypeAndRemoveUserData();
3245         Display(sal_True);
3246     }
3247     SvTreeListBox::DataChanged( rDCEvt );
3248 }
3249 
3250 
3251