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

Generated by: LCOV version 1.10