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