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