LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/utlui - content.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1643 0.1 %
Date: 2012-12-17 Functions: 2 82 2.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10