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