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