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