LCOV - code coverage report
Current view: top level - sc/source/ui/navipi - content.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 900 0.1 %
Date: 2014-04-11 Functions: 2 61 3.3 %
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 <svx/svditer.hxx>
      21             : #include <svx/svdobj.hxx>
      22             : #include <svx/svdpage.hxx>
      23             : #include <svx/svdpagv.hxx>
      24             : #include <svx/svdview.hxx>
      25             : #include <svx/svdxcgv.hxx>
      26             : #include <sfx2/linkmgr.hxx>
      27             : #include <sfx2/docfile.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : #include <vcl/help.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <tools/urlobj.hxx>
      32             : #include <svl/urlbmk.hxx>
      33             : #include <svtools/svlbitm.hxx>
      34             : #include <svtools/treelistentry.hxx>
      35             : #include <stdlib.h>
      36             : 
      37             : #include "content.hxx"
      38             : #include "navipi.hxx"
      39             : #include "global.hxx"
      40             : #include "docsh.hxx"
      41             : #include "scmod.hxx"
      42             : #include "rangenam.hxx"
      43             : #include "dbdata.hxx"
      44             : #include "tablink.hxx"
      45             : #include "popmenu.hxx"
      46             : #include "drwlayer.hxx"
      47             : #include "transobj.hxx"
      48             : #include "drwtrans.hxx"
      49             : #include "lnktrans.hxx"
      50             : #include "formulacell.hxx"
      51             : #include "dociter.hxx"
      52             : #include "scresid.hxx"
      53             : #include "globstr.hrc"
      54             : #include "navipi.hrc"
      55             : #include "arealink.hxx"
      56             : #include "navicfg.hxx"
      57             : #include "navsett.hxx"
      58             : #include "postit.hxx"
      59             : #include "tabvwsh.hxx"
      60             : #include "drawview.hxx"
      61             : #include "clipparam.hxx"
      62             : #include "markdata.hxx"
      63             : 
      64             : using namespace com::sun::star;
      65             : 
      66             : //  Reihenfolge der Kategorien im Navigator -------------------------------------
      67             : 
      68             : static const sal_uInt16 pTypeList[SC_CONTENT_COUNT] =
      69             : {
      70             :     SC_CONTENT_ROOT,            // ROOT (0) muss vorne stehen
      71             :     SC_CONTENT_TABLE,
      72             :     SC_CONTENT_RANGENAME,
      73             :     SC_CONTENT_DBAREA,
      74             :     SC_CONTENT_AREALINK,
      75             :     SC_CONTENT_GRAPHIC,
      76             :     SC_CONTENT_OLEOBJECT,
      77             :     SC_CONTENT_NOTE,
      78             :     SC_CONTENT_DRAWING
      79             : };
      80             : 
      81             : bool ScContentTree::bIsInDrag = false;
      82             : 
      83             : 
      84           0 : ScDocShell* ScContentTree::GetManualOrCurrent()
      85             : {
      86           0 :     ScDocShell* pSh = NULL;
      87           0 :     if ( !aManualDoc.isEmpty() )
      88             :     {
      89           0 :         TypeId aScType = TYPE(ScDocShell);
      90           0 :         SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
      91           0 :         while ( pObjSh && !pSh )
      92             :         {
      93           0 :             if ( pObjSh->GetTitle() == aManualDoc )
      94           0 :                 pSh = PTR_CAST( ScDocShell, pObjSh );
      95           0 :             pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
      96             :         }
      97             :     }
      98             :     else
      99             :     {
     100             :         //  Current nur, wenn keine manuell eingestellt ist
     101             :         //  (damit erkannt wird, wenn das Dokument nicht mehr existiert)
     102             : 
     103           0 :         SfxViewShell* pViewSh = SfxViewShell::Current();
     104           0 :         if ( pViewSh )
     105             :         {
     106           0 :             SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
     107           0 :             pSh = PTR_CAST( ScDocShell, pObjSh );
     108             :         }
     109             :     }
     110             : 
     111           0 :     return pSh;
     112             : }
     113             : 
     114             : 
     115             : //          ScContentTree
     116             : 
     117             : 
     118           0 : ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
     119             :     SvTreeListBox   ( pParent, rResId ),
     120             :     aEntryImages    ( ScResId( RID_IMAGELIST_NAVCONT ) ),
     121             :     nRootType       ( SC_CONTENT_ROOT ),
     122             :     bHiddenDoc      ( false ),
     123             :     pHiddenDocument ( NULL ),
     124           0 :     bisInNavigatoeDlg  ( false )
     125             : {
     126             :     sal_uInt16 i;
     127           0 :     for (i=0; i<SC_CONTENT_COUNT; i++)
     128           0 :         pPosList[pTypeList[i]] = i;         // invers zum suchen
     129             : 
     130           0 :     pParentWindow = (ScNavigatorDlg*)pParent;
     131             : 
     132           0 :     pRootNodes[0] = NULL;
     133           0 :     for (i=1; i<SC_CONTENT_COUNT; i++)
     134           0 :         InitRoot(i);
     135             : 
     136           0 :     SetNodeDefaultImages();
     137             : 
     138           0 :     SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
     139             : 
     140           0 :     pTmpEntry= NULL;
     141           0 :     m_bFirstPaint=true;
     142             : 
     143           0 :     SetStyle( GetStyle() | WB_QUICK_SEARCH );
     144           0 : }
     145             : 
     146           0 : ScContentTree::~ScContentTree()
     147             : {
     148           0 : }
     149             : 
     150             : // helper function for  GetEntryAltText and GetEntryLongDescription
     151           0 : OUString ScContentTree::getAltLongDescText( SvTreeListEntry* pEntry, bool isAltText) const
     152             : {
     153           0 :     SdrObject* pFound = NULL;
     154             : 
     155             :     sal_uInt16 nType;
     156             :     sal_uLong nChild;
     157           0 :     GetEntryIndexes( nType, nChild, pEntry );
     158           0 :     switch( nType )
     159             :     {
     160             :     case SC_CONTENT_OLEOBJECT:
     161             :     case SC_CONTENT_GRAPHIC:
     162             :     case SC_CONTENT_DRAWING:
     163             :         {
     164           0 :             ScDocument* pDoc = ( const_cast< ScContentTree* >(this) )->GetSourceDocument();
     165           0 :             SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
     166           0 :             ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
     167           0 :             SfxObjectShell* pShell = pDoc->GetDocumentShell();
     168           0 :             if (pDrawLayer && pShell)
     169             :             {
     170           0 :                 sal_uInt16 nTabCount = pDoc->GetTableCount();
     171           0 :                 for (sal_uInt16 nTab=0; nTab<nTabCount; nTab++)
     172             :                 {
     173           0 :                     SdrPage* pPage = pDrawLayer->GetPage(nTab);
     174             :                     DBG_ASSERT(pPage,"Page ?");
     175           0 :                     if (pPage)
     176             :                     {
     177           0 :                         SdrObjListIter aIter( *pPage, eIter );
     178           0 :                         SdrObject* pObject = aIter.Next();
     179           0 :                         while (pObject)
     180             :                         {
     181           0 :                             if( ScDrawLayer::GetVisibleName( pObject ) == GetEntryText( pEntry ) )
     182             :                             {
     183           0 :                                 pFound = pObject;
     184           0 :                                 break;
     185             :                             }
     186           0 :                             pObject = aIter.Next();
     187           0 :                         }
     188             :                     }
     189             :                 }
     190             :             }
     191           0 :              if( pFound )
     192             :              {
     193           0 :                 if( isAltText )
     194           0 :                     return pFound->GetTitle();
     195             :                 else
     196           0 :                     return pFound->GetDescription();
     197             :              }
     198             :         }
     199           0 :         break;
     200             :     }
     201           0 :     return OUString();
     202             : }
     203             : 
     204           0 : OUString  ScContentTree::GetEntryAltText( SvTreeListEntry* pEntry ) const
     205             : {
     206           0 :     return getAltLongDescText( pEntry, true );
     207             : }
     208             : 
     209           0 : OUString ScContentTree::GetEntryLongDescription( SvTreeListEntry* pEntry ) const
     210             : {
     211           0 :     return getAltLongDescText( pEntry, false );
     212             : }
     213             : 
     214           0 : void ScContentTree::InitRoot( sal_uInt16 nType )
     215             : {
     216           0 :     if ( !nType )
     217           0 :         return;
     218             : 
     219           0 :     if ( nRootType && nRootType != nType )              // ausgeblendet ?
     220             :     {
     221           0 :         pRootNodes[nType] = NULL;
     222           0 :         return;
     223             :     }
     224             : 
     225           0 :     const Image& rImage = aEntryImages.GetImage( nType );
     226           0 :     OUString aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
     227             :     // wieder an die richtige Position:
     228           0 :     sal_uInt16 nPos = nRootType ? 0 : pPosList[nType]-1;
     229           0 :     SvTreeListEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, false, nPos );
     230             : 
     231           0 :     pRootNodes[nType] = pNew;
     232             : }
     233             : 
     234           0 : void ScContentTree::ClearAll()
     235             : {
     236             :     //There are one method in Control::SetUpdateMode(), and one override method SvTreeListBox::SetUpdateMode(). Here although
     237             :     //SvTreeListBox::SetUpdateMode() is called in refresh method, it only call SvTreeListBox::SetUpdateMode(), not Control::SetUpdateMode().
     238             :     //In SvTreeList::Clear(), Broadcast( LISTACTION_CLEARED ) will be called and finally, it will be trapped into the event yield() loop. And
     239             :     //the InitRoot() method won't be called. Then if a user click or press key to update the navigator tree, crash happens.
     240             :     //So the solution is to disable the UpdateMode of Control, then call Clear(), then recover the update mode
     241           0 :     sal_Bool bOldUpdate = Control::IsUpdateMode();
     242           0 :     Control::SetUpdateMode(false);
     243           0 :     Clear();
     244           0 :     Control::SetUpdateMode(bOldUpdate);
     245           0 :     for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
     246           0 :         InitRoot(i);
     247           0 : }
     248             : 
     249           0 : void ScContentTree::ClearType(sal_uInt16 nType)
     250             : {
     251           0 :     if (!nType)
     252           0 :         ClearAll();
     253             :     else
     254             :     {
     255           0 :         SvTreeListEntry* pParent = pRootNodes[nType];
     256           0 :         if ( !pParent || GetChildCount(pParent) )       // nicht, wenn ohne Children schon da
     257             :         {
     258           0 :             if (pParent)
     259           0 :                 GetModel()->Remove( pParent );          // mit allen Children
     260           0 :             InitRoot( nType );                          // ggf. neu eintragen
     261             :         }
     262             :     }
     263           0 : }
     264             : 
     265           0 : void ScContentTree::InsertContent( sal_uInt16 nType, const OUString& rValue )
     266             : {
     267           0 :     if (nType >= SC_CONTENT_COUNT)
     268             :     {
     269             :         OSL_FAIL("ScContentTree::InsertContent mit falschem Typ");
     270           0 :         return;
     271             :     }
     272             : 
     273           0 :     SvTreeListEntry* pParent = pRootNodes[nType];
     274           0 :     if (pParent)
     275           0 :         InsertEntry( rValue, pParent );
     276             :     else
     277             :     {
     278             :         OSL_FAIL("InsertContent ohne Parent");
     279             :     }
     280             : }
     281             : 
     282           0 : void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const
     283             : {
     284           0 :     rnRootIndex = SC_CONTENT_ROOT;
     285           0 :     rnChildIndex = SC_CONTENT_NOCHILD;
     286             : 
     287           0 :     if( !pEntry )
     288           0 :         return;
     289             : 
     290           0 :     SvTreeListEntry* pParent = GetParent( pEntry );
     291           0 :     bool bFound = false;
     292           0 :     for( sal_uInt16 nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
     293             :     {
     294           0 :         if( pEntry == pRootNodes[ nRoot ] )
     295             :         {
     296           0 :             rnRootIndex = nRoot;
     297           0 :             rnChildIndex = ~0UL;
     298           0 :             bFound = true;
     299             :         }
     300           0 :         else if( pParent && (pParent == pRootNodes[ nRoot ]) )
     301             :         {
     302           0 :             rnRootIndex = nRoot;
     303             : 
     304             :             // search the entry in all child entries of the parent
     305           0 :             sal_uLong nEntry = 0;
     306           0 :             SvTreeListEntry* pIterEntry = FirstChild( pParent );
     307           0 :             while( !bFound && pIterEntry )
     308             :             {
     309           0 :                 if ( pEntry == pIterEntry )
     310             :                 {
     311           0 :                     rnChildIndex = nEntry;
     312           0 :                     bFound = true;  // exit the while loop
     313             :                 }
     314           0 :                 pIterEntry = NextSibling( pIterEntry );
     315           0 :                 ++nEntry;
     316             :             }
     317             : 
     318           0 :             bFound = true;  // exit the for loop
     319             :         }
     320             :     }
     321             : }
     322             : 
     323           0 : sal_uLong ScContentTree::GetChildIndex( SvTreeListEntry* pEntry ) const
     324             : {
     325             :     sal_uInt16 nRoot;
     326             :     sal_uLong nChild;
     327           0 :     GetEntryIndexes( nRoot, nChild, pEntry );
     328           0 :     return nChild;
     329             : }
     330             : 
     331           0 : static OUString lcl_GetDBAreaRange( ScDocument* pDoc, const OUString& rDBName )
     332             : {
     333           0 :     OUString aRet;
     334           0 :     if (pDoc)
     335             :     {
     336           0 :         ScDBCollection* pDbNames = pDoc->GetDBCollection();
     337           0 :         const ScDBData* pData = pDbNames->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rDBName));
     338           0 :         if (pData)
     339             :         {
     340           0 :             ScRange aRange;
     341           0 :             pData->GetArea(aRange);
     342           0 :             aRet = aRange.Format(SCR_ABS_3D, pDoc);
     343             :         }
     344             :     }
     345           0 :     return aRet;
     346             : }
     347             : 
     348           0 : IMPL_LINK_NOARG(ScContentTree, ContentDoubleClickHdl)
     349             : {
     350             :     sal_uInt16 nType;
     351             :     sal_uLong nChild;
     352           0 :     SvTreeListEntry* pEntry = GetCurEntry();
     353           0 :     GetEntryIndexes( nType, nChild, pEntry );
     354             : 
     355           0 :     if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
     356             :     {
     357           0 :         if ( bHiddenDoc )
     358           0 :             return 0;               //! spaeter...
     359             : 
     360           0 :         OUString aText( GetEntryText( pEntry ) );
     361             : 
     362           0 :         if ( !aManualDoc.isEmpty() )
     363           0 :             pParentWindow->SetCurrentDoc( aManualDoc );
     364             : 
     365           0 :         switch( nType )
     366             :         {
     367             :             case SC_CONTENT_TABLE:
     368           0 :                 pParentWindow->SetCurrentTableStr( aText );
     369           0 :             break;
     370             : 
     371             :             case SC_CONTENT_RANGENAME:
     372           0 :                 pParentWindow->SetCurrentCellStr( aText );
     373           0 :             break;
     374             : 
     375             :             case SC_CONTENT_DBAREA:
     376             :             {
     377             :                 //  Wenn gleiche Bereichs- und DB-Namen existieren, wird
     378             :                 //  bei SID_CURRENTCELL der Bereichsname genommen.
     379             :                 //  DB-Bereiche darum direkt ueber die Adresse anspringen.
     380             : 
     381           0 :                 OUString aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
     382           0 :                 if (!aRangeStr.isEmpty())
     383           0 :                     pParentWindow->SetCurrentCellStr( aRangeStr );
     384             :             }
     385           0 :             break;
     386             : 
     387             :             case SC_CONTENT_OLEOBJECT:
     388             :             case SC_CONTENT_GRAPHIC:
     389             :             case SC_CONTENT_DRAWING:
     390           0 :                 pParentWindow->SetCurrentObject( aText );
     391           0 :             break;
     392             : 
     393             :             case SC_CONTENT_NOTE:
     394             :             {
     395           0 :                 ScAddress aPos = GetNotePos( nChild );
     396           0 :                 pParentWindow->SetCurrentTable( aPos.Tab() );
     397           0 :                 pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
     398             :             }
     399           0 :             break;
     400             : 
     401             :             case SC_CONTENT_AREALINK:
     402             :             {
     403           0 :                 const ScAreaLink* pLink = GetLink( nChild );
     404           0 :                 if( pLink )
     405             :                 {
     406           0 :                     ScRange aRange = pLink->GetDestArea();
     407           0 :                     ScDocument* pSrcDoc = GetSourceDocument();
     408           0 :                     OUString aRangeStr(aRange.Format(SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention()));
     409           0 :                     pParentWindow->SetCurrentCellStr( aRangeStr );
     410             :                 }
     411             :             }
     412           0 :             break;
     413             :         }
     414             : 
     415           0 :         ScNavigatorDlg::ReleaseFocus();     // set focus into document
     416             :     }
     417             : 
     418           0 :     return 0;
     419             : }
     420             : 
     421           0 : void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
     422             : {
     423           0 :     SvTreeListBox::MouseButtonDown( rMEvt );
     424           0 :     StoreSettings();
     425           0 : }
     426             : 
     427           0 : void ScContentTree::KeyInput( const KeyEvent& rKEvt )
     428             : {
     429           0 :     bool bUsed = false;
     430             : 
     431           0 :     const KeyCode aCode = rKEvt.GetKeyCode();
     432           0 :     if (aCode.GetCode() == KEY_RETURN)
     433             :     {
     434           0 :         switch (aCode.GetModifier())
     435             :         {
     436             :             case KEY_MOD1:
     437           0 :                 ToggleRoot();       // toggle root mode (as in Writer)
     438           0 :                 bUsed = true;
     439           0 :                 break;
     440             :             case 0:
     441             :             {
     442           0 :                 SvTreeListEntry* pEntry = GetCurEntry();
     443           0 :                 if( pEntry )
     444             :                 {
     445             :                     sal_uInt16 nType;
     446             :                     sal_uLong nChild;
     447           0 :                     GetEntryIndexes( nType, nChild, pEntry );
     448             : 
     449           0 :                     if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
     450             :                     {
     451           0 :                         if ( IsExpanded( pEntry ) )
     452           0 :                             Collapse( pEntry );
     453             :                         else
     454           0 :                             Expand( pEntry );
     455             :                     }
     456             :                     else
     457           0 :                         ContentDoubleClickHdl(0);      // select content as if double clicked
     458             :                 }
     459             : 
     460           0 :                 bUsed = true;
     461             :             }
     462           0 :             break;
     463             :         }
     464             :     }
     465             :     //Make KEY_SPACE has same function as DoubleClick
     466           0 :     if ( bisInNavigatoeDlg )
     467             :     {
     468           0 :         if(aCode.GetCode() == KEY_SPACE )
     469             :         {
     470           0 :             bUsed = true;
     471             :             sal_uInt16 nType;
     472             :             sal_uLong nChild;
     473           0 :             SvTreeListEntry* pEntry = GetCurEntry();
     474           0 :             GetEntryIndexes( nType, nChild, pEntry );
     475           0 :             if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
     476             :             {
     477           0 :                 if ( bHiddenDoc )
     478           0 :                     return ;                //! spaeter...
     479           0 :                 OUString aText( GetEntryText( pEntry ) );
     480           0 :                 sKeyString = aText;
     481           0 :                 if (!aManualDoc.isEmpty())
     482           0 :                     pParentWindow->SetCurrentDoc( aManualDoc );
     483           0 :                 switch( nType )
     484             :                 {
     485             :                     case SC_CONTENT_OLEOBJECT:
     486             :                     case SC_CONTENT_GRAPHIC:
     487             :                     case SC_CONTENT_DRAWING:
     488             :                     {
     489           0 :                         Window* pWindow=(Window*)GetParent(pEntry);
     490           0 :                         ScNavigatorDlg* pScNavigatorDlg = (ScNavigatorDlg*)pWindow;
     491           0 :                         ScTabViewShell* pScTabViewShell = NULL;
     492           0 :                         ScDrawView* pScDrawView = NULL;
     493           0 :                         if (pScNavigatorDlg!=NULL)
     494           0 :                               pScTabViewShell=pScNavigatorDlg->GetTabViewShell();
     495           0 :                         if(pScTabViewShell !=NULL)
     496           0 :                               pScDrawView =pScTabViewShell->GetViewData()->GetScDrawView();
     497           0 :                         if(pScDrawView!=NULL)
     498             :                          {
     499           0 :                             pScDrawView->SelectCurrentViewObject(aText );
     500           0 :                             sal_Bool bHasMakredObject = sal_False;
     501           0 :                             SvTreeListEntry* pParent = pRootNodes[nType];
     502           0 :                             SvTreeListEntry* pBeginEntry = NULL;
     503           0 :                             if( pParent )
     504           0 :                                 pBeginEntry = FirstChild(pParent);
     505           0 :                             while( pBeginEntry )
     506             :                             {
     507           0 :                                 OUString aTempText( GetEntryText( pBeginEntry ) );
     508           0 :                                  if( pScDrawView->GetObjectIsMarked( pScDrawView->GetObjectByName( aTempText ) ) )
     509             :                                  {
     510           0 :                                     bHasMakredObject = sal_True;
     511           0 :                                     break;
     512             :                                   }
     513           0 :                                 pBeginEntry =  Next( pBeginEntry );
     514           0 :                             }
     515           0 :                             if(  !bHasMakredObject && pScTabViewShell)
     516           0 :                                 pScTabViewShell->SetDrawShell(false);
     517           0 :                             ObjectFresh( nType,pEntry );
     518             :                         }
     519             :                     }
     520           0 :                     break;
     521           0 :                  }
     522             :             }
     523             :            }
     524             :        }
     525             : 
     526           0 :     if( !bUsed )
     527             :     {
     528           0 :         if(aCode.GetCode() == KEY_F5 )
     529             :         {
     530           0 :             StoreSettings();
     531           0 :             SvTreeListBox::KeyInput(rKEvt);
     532             :         }
     533             :         else
     534             :         {
     535           0 :             SvTreeListBox::KeyInput(rKEvt);
     536           0 :             StoreSettings();
     537             :         }
     538             :     }
     539             : }
     540             : 
     541           0 : sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
     542             : {
     543           0 :     return DND_ACTION_NONE;
     544             : }
     545             : 
     546           0 : sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
     547             : {
     548           0 :     return DND_ACTION_NONE;
     549             : }
     550             : 
     551           0 : void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
     552             : {
     553           0 :     DoDrag();
     554           0 : }
     555             : 
     556           0 : void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
     557             : {
     558           0 : }
     559             : 
     560           0 : void ScContentTree::Command( const CommandEvent& rCEvt )
     561             : {
     562           0 :     bool bDone = false;
     563             : 
     564           0 :     switch ( rCEvt.GetCommand() )
     565             :     {
     566             :         case COMMAND_STARTDRAG:
     567             :             //  Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
     568             :             //  (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
     569             :             //  den StarView MouseMove-Handler, der Command() aufruft, umbringen.
     570             :             //  Deshalb Drag&Drop asynchron:
     571             : 
     572           0 :             Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
     573             : 
     574           0 :             bDone = true;
     575           0 :             break;
     576             : 
     577             :         case COMMAND_CONTEXTMENU:
     578             :             {
     579             :                 //  Drag-Drop Modus
     580             : 
     581           0 :                 PopupMenu aPop;
     582           0 :                 ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
     583           0 :                 aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
     584           0 :                 aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
     585           0 :                 aPop.SetPopupMenu( 1, &aDropMenu );
     586             : 
     587             :                 //  angezeigtes Dokument
     588             : 
     589           0 :                 ScPopupMenu aDocMenu;
     590           0 :                 aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
     591           0 :                 sal_uInt16 i=0;
     592           0 :                 sal_uInt16 nPos=0;
     593             :                 //  geladene Dokumente
     594           0 :                 ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
     595           0 :                 SfxObjectShell* pSh = SfxObjectShell::GetFirst();
     596           0 :                 while ( pSh )
     597             :                 {
     598           0 :                     if ( pSh->ISA(ScDocShell) )
     599             :                     {
     600           0 :                         OUString aName = pSh->GetTitle();
     601           0 :                         OUString aEntry = aName;
     602           0 :                         if ( pSh == pCurrentSh )
     603           0 :                             aEntry += pParentWindow->aStrActive;
     604             :                         else
     605           0 :                             aEntry += pParentWindow->aStrNotActive;
     606           0 :                         aDocMenu.InsertItem( ++i, aEntry );
     607           0 :                         if ( !bHiddenDoc && aName == aManualDoc )
     608           0 :                             nPos = i;
     609             :                     }
     610           0 :                     pSh = SfxObjectShell::GetNext( *pSh );
     611             :                 }
     612             :                 //  "aktives Fenster"
     613           0 :                 aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
     614           0 :                 if (!bHiddenDoc && aManualDoc.isEmpty())
     615           0 :                     nPos = i;
     616             :                 //  verstecktes Dokument
     617           0 :                 if ( !aHiddenTitle.isEmpty() )
     618             :                 {
     619           0 :                     OUString aEntry = aHiddenTitle;
     620           0 :                     aEntry += pParentWindow->aStrHidden;
     621           0 :                     aDocMenu.InsertItem( ++i, aEntry );
     622           0 :                     if (bHiddenDoc)
     623           0 :                         nPos = i;
     624             :                 }
     625           0 :                 aDocMenu.CheckItem( nPos );
     626           0 :                 aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
     627           0 :                 aPop.SetPopupMenu( 2, &aDocMenu );
     628             : 
     629             :                 //  ausfuehren
     630             : 
     631           0 :                 aPop.Execute( this, rCEvt.GetMousePosPixel() );
     632             : 
     633           0 :                 if ( aDropMenu.WasHit() )               //  Drag-Drop Modus
     634             :                 {
     635           0 :                     sal_uInt16 nId = aDropMenu.GetSelected();
     636           0 :                     if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
     637           0 :                         pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
     638             :                 }
     639           0 :                 else if ( aDocMenu.WasHit() )           //  angezeigtes Dokument
     640             :                 {
     641           0 :                     sal_uInt16 nId = aDocMenu.GetSelected();
     642           0 :                     OUString aName = aDocMenu.GetItemText(nId);
     643           0 :                     SelectDoc( aName );
     644           0 :                 }
     645             :             }
     646           0 :             break;
     647             :     }
     648             : 
     649           0 :     if (!bDone)
     650           0 :         SvTreeListBox::Command(rCEvt);
     651           0 : }
     652             : 
     653           0 : void ScContentTree::RequestHelp( const HelpEvent& rHEvt )
     654             : {
     655           0 :     bool bDone = false;
     656           0 :     if( rHEvt.GetMode() & HELPMODE_QUICK )
     657             :     {
     658           0 :         Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
     659           0 :         SvTreeListEntry* pEntry = GetEntry( aPos );
     660           0 :         if ( pEntry )
     661             :         {
     662           0 :             bool bRet = false;
     663           0 :             OUString aHelpText;
     664           0 :             SvTreeListEntry* pParent = GetParent(pEntry);
     665           0 :             if ( !pParent )                                 // Top-Level ?
     666             :             {
     667           0 :                 aHelpText = OUString::number( GetChildCount(pEntry) ) +
     668           0 :                             " " + GetEntryText(pEntry);
     669           0 :                 bRet = true;
     670             :             }
     671           0 :             else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
     672             :             {
     673           0 :                 aHelpText = GetEntryText(pEntry);           // Notizen als Help-Text
     674           0 :                 bRet = true;
     675             :             }
     676           0 :             else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
     677             :             {
     678           0 :                 sal_uLong nIndex = GetChildIndex(pEntry);
     679           0 :                 if( nIndex != SC_CONTENT_NOCHILD )
     680             :                 {
     681           0 :                     const ScAreaLink* pLink = GetLink(nIndex);
     682           0 :                     if (pLink)
     683             :                     {
     684           0 :                         aHelpText = pLink->GetFile();           // Source-Datei als Help-Text
     685           0 :                         bRet = true;
     686             :                     }
     687             :                 }
     688             :             }
     689             : 
     690           0 :             if (bRet)
     691             :             {
     692             :                 SvLBoxTab* pTab;
     693           0 :                 SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
     694           0 :                 if( pItem )
     695             :                 {
     696           0 :                     aPos = GetEntryPosition( pEntry );
     697           0 :                     aPos.X() = GetTabPos( pEntry, pTab );
     698           0 :                     aPos = OutputToScreenPixel(aPos);
     699           0 :                     Size aSize( pItem->GetSize( this, pEntry ) );
     700             : 
     701           0 :                     Rectangle aItemRect( aPos, aSize );
     702           0 :                     Help::ShowQuickHelp( this, aItemRect, aHelpText );
     703           0 :                     bDone = true;
     704             :                 }
     705           0 :             }
     706             :         }
     707             :     }
     708           0 :     if (!bDone)
     709           0 :         Window::RequestHelp( rHEvt );
     710           0 : }
     711             : 
     712           0 : ScDocument* ScContentTree::GetSourceDocument()
     713             : {
     714           0 :     if (bHiddenDoc)
     715           0 :         return pHiddenDocument;
     716             :     else
     717             :     {
     718           0 :         ScDocShell* pSh = GetManualOrCurrent();
     719           0 :         if (pSh)
     720           0 :             return pSh->GetDocument();
     721             : 
     722             :     }
     723           0 :     return NULL;
     724             : }
     725             : 
     726             : //Move along and draw "*" sign .
     727           0 : void ScContentTree::ObjectFresh( sal_uInt16 nType, SvTreeListEntry* pEntry )
     728             : {
     729           0 :     if ( bHiddenDoc && !pHiddenDocument )
     730           0 :         return;     // anderes Dokument angezeigt
     731           0 :       if(nType ==SC_CONTENT_GRAPHIC||nType ==SC_CONTENT_OLEOBJECT||nType ==SC_CONTENT_DRAWING)
     732             :         {
     733           0 :         SetUpdateMode(false);
     734           0 :         ClearType( nType );
     735           0 :         GetDrawNames( nType/*, nId*/ );
     736           0 :         if( !pEntry )
     737           0 :             ApplySettings();
     738           0 :         SetUpdateMode(true);
     739           0 :         if( pEntry )
     740             :         {
     741           0 :             SvTreeListEntry* pParent = pRootNodes[nType];
     742           0 :             SvTreeListEntry* pBeginEntry = NULL;
     743           0 :             SvTreeListEntry* pOldEntry = NULL;
     744           0 :             if( pParent )
     745           0 :                 pBeginEntry = FirstChild(pParent);
     746           0 :             while( pBeginEntry )
     747             :             {
     748           0 :                 OUString aTempText( GetEntryText( pBeginEntry ) );
     749           0 :                 if( aTempText ==  sKeyString )
     750             :                 {
     751           0 :                     pOldEntry = pBeginEntry;
     752           0 :                     break;
     753             :                 }
     754           0 :                 pBeginEntry =  Next( pBeginEntry );
     755           0 :             }
     756           0 :             if( pOldEntry )
     757             :             {
     758           0 :                 Expand(pParent);
     759           0 :                 Select( pOldEntry, true);
     760             :             }
     761             :         }
     762             :         }
     763             : }
     764             : 
     765           0 : void ScContentTree::Refresh( sal_uInt16 nType )
     766             : {
     767           0 :     if ( bHiddenDoc && !pHiddenDocument )
     768           0 :         return;                                 // anderes Dokument angezeigt
     769             : 
     770             :     //  wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
     771             : 
     772           0 :     if ( nType == SC_CONTENT_NOTE )
     773           0 :         if (!NoteStringsChanged())
     774           0 :             return;
     775           0 :     if ( nType == SC_CONTENT_GRAPHIC )
     776           0 :         if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
     777           0 :             return;
     778           0 :     if ( nType == SC_CONTENT_OLEOBJECT )
     779           0 :         if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
     780           0 :             return;
     781           0 :     if ( nType == SC_CONTENT_DRAWING )
     782           0 :         if (!DrawNamesChanged(SC_CONTENT_DRAWING))
     783           0 :             return;
     784             : 
     785           0 :     SetUpdateMode(false);
     786             : 
     787           0 :     ClearType( nType );
     788             : 
     789           0 :     if ( !nType || nType == SC_CONTENT_TABLE )
     790           0 :         GetTableNames();
     791           0 :     if ( !nType || nType == SC_CONTENT_RANGENAME )
     792           0 :         GetAreaNames();
     793           0 :     if ( !nType || nType == SC_CONTENT_DBAREA )
     794           0 :         GetDbNames();
     795           0 :     if ( !nType || nType == SC_CONTENT_GRAPHIC )
     796           0 :         GetGraphicNames();
     797           0 :     if ( !nType || nType == SC_CONTENT_OLEOBJECT )
     798           0 :         GetOleNames();
     799           0 :     if ( !nType || nType == SC_CONTENT_DRAWING )
     800           0 :         GetDrawingNames();
     801           0 :     if ( !nType || nType == SC_CONTENT_NOTE )
     802           0 :         GetNoteStrings();
     803           0 :     if ( !nType || nType == SC_CONTENT_AREALINK )
     804           0 :         GetLinkNames();
     805             : 
     806           0 :     ApplySettings();
     807           0 :     SetUpdateMode(true);
     808             : }
     809             : 
     810           0 : void ScContentTree::GetTableNames()
     811             : {
     812           0 :     if ( nRootType && nRootType != SC_CONTENT_TABLE )       // ausgeblendet ?
     813           0 :         return;
     814             : 
     815           0 :     ScDocument* pDoc = GetSourceDocument();
     816           0 :     if (!pDoc)
     817           0 :         return;
     818             : 
     819           0 :     OUString aName;
     820           0 :     SCTAB nCount = pDoc->GetTableCount();
     821           0 :     for ( SCTAB i=0; i<nCount; i++ )
     822             :     {
     823           0 :         pDoc->GetName( i, aName );
     824           0 :         InsertContent( SC_CONTENT_TABLE, aName );
     825           0 :     }
     826             : }
     827             : 
     828             : namespace {
     829             : 
     830           0 : OUString createLocalRangeName(const OUString& rName, const OUString& rTableName)
     831             : {
     832           0 :     OUStringBuffer aString (rName);
     833           0 :     aString.append(" (");
     834           0 :     aString.append(rTableName);
     835           0 :     aString.append(")");
     836           0 :     return aString.makeStringAndClear();
     837             : }
     838             : }
     839             : 
     840           0 : void ScContentTree::GetAreaNames()
     841             : {
     842           0 :     if ( nRootType && nRootType != SC_CONTENT_RANGENAME )       // ausgeblendet ?
     843           0 :         return;
     844             : 
     845           0 :     ScDocument* pDoc = GetSourceDocument();
     846           0 :     if (!pDoc)
     847           0 :         return;
     848             : 
     849           0 :     ScRange aDummy;
     850           0 :     std::set<OUString> aSet;
     851           0 :     ScRangeName* pRangeNames = pDoc->GetRangeName();
     852           0 :     if (!pRangeNames->empty())
     853             :     {
     854           0 :         ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
     855           0 :         for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
     856             :         {
     857           0 :             if (itr->second->IsValidReference(aDummy))
     858           0 :                 aSet.insert(itr->second->GetName());
     859             :         }
     860             :     }
     861           0 :     for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i)
     862             :     {
     863           0 :         ScRangeName* pLocalRangeName = pDoc->GetRangeName(i);
     864           0 :         if (pLocalRangeName && !pLocalRangeName->empty())
     865             :         {
     866           0 :             OUString aTableName;
     867           0 :             pDoc->GetName(i, aTableName);
     868           0 :             for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
     869             :             {
     870           0 :                 if (itr->second->IsValidReference(aDummy))
     871           0 :                     aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
     872           0 :             }
     873             :         }
     874             :     }
     875             : 
     876           0 :     if (!aSet.empty())
     877             :     {
     878           0 :         for (std::set<OUString>::iterator itr = aSet.begin();
     879           0 :                 itr != aSet.end(); ++itr)
     880             :         {
     881           0 :             InsertContent(SC_CONTENT_RANGENAME, *itr);
     882             :         }
     883           0 :     }
     884             : }
     885             : 
     886           0 : void ScContentTree::GetDbNames()
     887             : {
     888           0 :     if ( nRootType && nRootType != SC_CONTENT_DBAREA )      // ausgeblendet ?
     889           0 :         return;
     890             : 
     891           0 :     ScDocument* pDoc = GetSourceDocument();
     892           0 :     if (!pDoc)
     893           0 :         return;
     894             : 
     895           0 :     ScDBCollection* pDbNames = pDoc->GetDBCollection();
     896           0 :     const ScDBCollection::NamedDBs& rDBs = pDbNames->getNamedDBs();
     897           0 :     ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
     898           0 :     for (; itr != itrEnd; ++itr)
     899             :     {
     900           0 :         const OUString& aStrName = itr->GetName();
     901           0 :         InsertContent(SC_CONTENT_DBAREA, aStrName);
     902             :     }
     903             : }
     904             : 
     905           0 : bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier )
     906             : {
     907           0 :     bool bRet = false;
     908           0 :     switch ( nContentType )
     909             :     {
     910             :         case SC_CONTENT_GRAPHIC:
     911           0 :             bRet = ( nObjIdentifier == OBJ_GRAF );
     912           0 :             break;
     913             :         case SC_CONTENT_OLEOBJECT:
     914           0 :             bRet = ( nObjIdentifier == OBJ_OLE2 );
     915           0 :             break;
     916             :         case SC_CONTENT_DRAWING:
     917           0 :             bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 );    // everything else
     918           0 :             break;
     919             :         default:
     920             :             OSL_FAIL("unknown content type");
     921             :     }
     922           0 :     return bRet;
     923             : }
     924             : 
     925           0 : void ScContentTree::GetDrawNames( sal_uInt16 nType )
     926             : {
     927           0 :     if ( nRootType && nRootType != nType )              // ausgeblendet ?
     928           0 :         return;
     929             : 
     930           0 :     ScDocument* pDoc = GetSourceDocument();
     931           0 :     if (!pDoc)
     932           0 :         return;
     933             : 
     934             :     // iterate in flat mode for groups
     935           0 :     SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
     936             : 
     937           0 :     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
     938           0 :     SfxObjectShell* pShell = pDoc->GetDocumentShell();
     939           0 :     if (pDrawLayer && pShell)
     940             :     {
     941           0 :         SCTAB nTabCount = pDoc->GetTableCount();
     942           0 :         for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     943             :         {
     944           0 :             SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     945             :             OSL_ENSURE(pPage,"Page ?");
     946           0 :             if (pPage)
     947             :             {
     948           0 :                 SdrObjListIter aIter( *pPage, eIter );
     949           0 :                 SdrObject* pObject = aIter.Next();
     950           0 :                 while (pObject)
     951             :                 {
     952           0 :                     if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
     953             :                     {
     954           0 :                         OUString aName = ScDrawLayer::GetVisibleName( pObject );
     955           0 :                         if (!aName.isEmpty())
     956             :                         {
     957           0 :                             if( bisInNavigatoeDlg )
     958             :                             {
     959           0 :                                 if (nType >= SC_CONTENT_COUNT)
     960             :                                 {
     961             :                                     SAL_WARN("sc", "ScContentTree::InsertContent mit falschem Typ");
     962           0 :                                     return;
     963             :                                 }
     964             : 
     965           0 :                                 SvTreeListEntry* pParent = pRootNodes[nType];
     966           0 :                                 if (pParent)
     967             :                                 {
     968           0 :                                     SvTreeListEntry* pChild=InsertEntry( aName, pParent );
     969           0 :                                     if(pChild)
     970           0 :                                         pChild->SetMarked(false);
     971           0 :                                     Window* pWindow=NULL;
     972           0 :                                     ScTabViewShell* pScTabViewShell=NULL;
     973           0 :                                     ScDrawView* pScDrawView=NULL;
     974           0 :                                     ScNavigatorDlg* pScNavigatorDlg=NULL;
     975           0 :                                     if(pChild)
     976           0 :                                          pWindow=(Window*)GetParent(pChild);
     977           0 :                                     if(pWindow)
     978           0 :                                             pScNavigatorDlg = (ScNavigatorDlg*)pWindow;
     979           0 :                                     if (pScNavigatorDlg!=NULL)
     980           0 :                                           pScTabViewShell=pScNavigatorDlg->GetTabViewShell();
     981           0 :                                     if(pScTabViewShell !=NULL)
     982           0 :                                           pScDrawView =pScTabViewShell->GetViewData()->GetScDrawView();
     983           0 :                                     if(pScDrawView!=NULL)
     984             :                                      {
     985           0 :                                          sal_Bool bMarked =pScDrawView->GetObjectIsMarked(pObject);
     986           0 :                                          pChild->SetMarked( bMarked );
     987             :                                       }
     988             :                                 }//end if parent
     989             :                                 else
     990             :                                     SAL_WARN("sc", "InsertContent ohne Parent");
     991             :                             }
     992           0 :                         }
     993             : 
     994             :                     }
     995             : 
     996           0 :                     pObject = aIter.Next();
     997           0 :                 }
     998             :             }
     999             :         }
    1000             :     }
    1001             : }
    1002             : 
    1003           0 : void ScContentTree::GetGraphicNames()
    1004             : {
    1005           0 :     GetDrawNames( SC_CONTENT_GRAPHIC );
    1006           0 : }
    1007             : 
    1008           0 : void ScContentTree::GetOleNames()
    1009             : {
    1010           0 :     GetDrawNames( SC_CONTENT_OLEOBJECT );
    1011           0 : }
    1012             : 
    1013           0 : void ScContentTree::GetDrawingNames()
    1014             : {
    1015           0 :     GetDrawNames( SC_CONTENT_DRAWING );
    1016           0 : }
    1017             : 
    1018           0 : void ScContentTree::GetLinkNames()
    1019             : {
    1020           0 :     if ( nRootType && nRootType != SC_CONTENT_AREALINK )                // ausgeblendet ?
    1021           0 :         return;
    1022             : 
    1023           0 :     ScDocument* pDoc = GetSourceDocument();
    1024           0 :     if (!pDoc)
    1025           0 :         return;
    1026             : 
    1027           0 :     sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
    1028             :     OSL_ENSURE(pLinkManager, "kein LinkManager am Dokument?");
    1029           0 :     const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
    1030           0 :     sal_uInt16 nCount = rLinks.size();
    1031           0 :     for (sal_uInt16 i=0; i<nCount; i++)
    1032             :     {
    1033           0 :         ::sfx2::SvBaseLink* pBase = *rLinks[i];
    1034           0 :         if (pBase->ISA(ScAreaLink))
    1035           0 :             InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
    1036             : 
    1037             :             //  in der Liste die Namen der Quellbereiche
    1038             :     }
    1039             : }
    1040             : 
    1041           0 : const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex )
    1042             : {
    1043           0 :     ScDocument* pDoc = GetSourceDocument();
    1044           0 :     if (!pDoc)
    1045           0 :         return NULL;
    1046             : 
    1047           0 :     sal_uLong nFound = 0;
    1048           0 :     sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
    1049             :     OSL_ENSURE(pLinkManager, "kein LinkManager am Dokument?");
    1050           0 :     const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
    1051           0 :     sal_uInt16 nCount = rLinks.size();
    1052           0 :     for (sal_uInt16 i=0; i<nCount; i++)
    1053             :     {
    1054           0 :         ::sfx2::SvBaseLink* pBase = *rLinks[i];
    1055           0 :         if (pBase->ISA(ScAreaLink))
    1056             :         {
    1057           0 :             if (nFound == nIndex)
    1058           0 :                 return (const ScAreaLink*) pBase;
    1059           0 :             ++nFound;
    1060             :         }
    1061             :     }
    1062             : 
    1063             :     OSL_FAIL("link not found");
    1064           0 :     return NULL;
    1065             : }
    1066             : 
    1067           0 : static OUString lcl_NoteString( const ScPostIt& rNote )
    1068             : {
    1069           0 :     OUString aText = rNote.GetText();
    1070             :     sal_Int32 nAt;
    1071           0 :     while ( (nAt = aText.indexOf( '\n' )) != -1 )
    1072           0 :         aText = aText.replaceAt( nAt, 1, " " );
    1073           0 :     return aText;
    1074             : }
    1075             : 
    1076           0 : void ScContentTree::GetNoteStrings()
    1077             : {
    1078           0 :     if ( nRootType && nRootType != SC_CONTENT_NOTE )        // ausgeblendet ?
    1079           0 :         return;
    1080             : 
    1081           0 :     ScDocument* pDoc = GetSourceDocument();
    1082           0 :     if (!pDoc)
    1083           0 :         return;
    1084             : 
    1085             :     // loop over cell notes
    1086           0 :     std::vector<sc::NoteEntry> aEntries;
    1087           0 :     pDoc->GetAllNoteEntries(aEntries);
    1088           0 :     std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
    1089           0 :     for (; it != itEnd; ++it)
    1090           0 :         InsertContent(SC_CONTENT_NOTE, lcl_NoteString(*it->mpNote));
    1091             : }
    1092             : 
    1093           0 : ScAddress ScContentTree::GetNotePos( sal_uLong nIndex )
    1094             : {
    1095           0 :     ScDocument* pDoc = GetSourceDocument();
    1096           0 :     if (!pDoc)
    1097           0 :         return ScAddress();
    1098             : 
    1099           0 :     return pDoc->GetNotePosition(nIndex);
    1100             : }
    1101             : 
    1102           0 : bool ScContentTree::NoteStringsChanged()
    1103             : {
    1104           0 :     ScDocument* pDoc = GetSourceDocument();
    1105           0 :     if (!pDoc)
    1106           0 :         return false;
    1107             : 
    1108           0 :     SvTreeListEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
    1109           0 :     if (!pParent)
    1110           0 :         return false;
    1111             : 
    1112           0 :     SvTreeListEntry* pEntry = FirstChild( pParent );
    1113             : 
    1114           0 :     std::vector<sc::NoteEntry> aEntries;
    1115           0 :     pDoc->GetAllNoteEntries(aEntries);
    1116           0 :     std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
    1117           0 :     for (; it != itEnd; ++it)
    1118             :     {
    1119           0 :         const ScPostIt* pNote = it->mpNote;
    1120           0 :         if (!pEntry)
    1121           0 :             return true;
    1122             : 
    1123           0 :         if (lcl_NoteString(*pNote) != GetEntryText(pEntry))
    1124           0 :             return true;
    1125             : 
    1126           0 :         pEntry = NextSibling(pEntry);
    1127             :     }
    1128             : 
    1129           0 :     if ( pEntry )
    1130           0 :         return true;
    1131             : 
    1132           0 :     return false;
    1133             : }
    1134             : 
    1135           0 : bool ScContentTree::DrawNamesChanged( sal_uInt16 nType )
    1136             : {
    1137           0 :     ScDocument* pDoc = GetSourceDocument();
    1138           0 :     if (!pDoc)
    1139           0 :         return false;
    1140             : 
    1141           0 :     SvTreeListEntry* pParent = pRootNodes[nType];
    1142           0 :     if (!pParent)
    1143           0 :         return false;
    1144             : 
    1145           0 :     SvTreeListEntry* pEntry = FirstChild( pParent );
    1146             : 
    1147             :     // iterate in flat mode for groups
    1148           0 :     SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
    1149             : 
    1150           0 :     bool bEqual = true;
    1151           0 :     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
    1152           0 :     SfxObjectShell* pShell = pDoc->GetDocumentShell();
    1153           0 :     if (pDrawLayer && pShell)
    1154             :     {
    1155           0 :         SCTAB nTabCount = pDoc->GetTableCount();
    1156           0 :         for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
    1157             :         {
    1158           0 :             SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
    1159             :             OSL_ENSURE(pPage,"Page ?");
    1160           0 :             if (pPage)
    1161             :             {
    1162           0 :                 SdrObjListIter aIter( *pPage, eIter );
    1163           0 :                 SdrObject* pObject = aIter.Next();
    1164           0 :                 while (pObject && bEqual)
    1165             :                 {
    1166           0 :                     if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
    1167             :                     {
    1168           0 :                         if ( !pEntry )
    1169           0 :                             bEqual = false;
    1170             :                         else
    1171             :                         {
    1172           0 :                             if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
    1173           0 :                                 bEqual = false;
    1174             : 
    1175           0 :                             pEntry = NextSibling( pEntry );
    1176             :                         }
    1177             :                     }
    1178           0 :                     pObject = aIter.Next();
    1179           0 :                 }
    1180             :             }
    1181             :         }
    1182             :     }
    1183             : 
    1184           0 :     if ( pEntry )
    1185           0 :         bEqual = false;             // kommt noch was
    1186             : 
    1187           0 :     return !bEqual;
    1188             : }
    1189             : 
    1190           0 : static bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const OUString& rName, ScRange& rRange )
    1191             : {
    1192           0 :     bool bFound = false;
    1193             : 
    1194           0 :     if ( nType == SC_CONTENT_RANGENAME )
    1195             :     {
    1196           0 :         ScRangeName* pList = pDoc->GetRangeName();
    1197           0 :         if (pList)
    1198             :         {
    1199           0 :             const ScRangeData* p = pList->findByUpperName(ScGlobal::pCharClass->uppercase(rName));
    1200           0 :             if (p && p->IsValidReference(rRange))
    1201           0 :                 bFound = true;
    1202             :         }
    1203             :     }
    1204           0 :     else if ( nType == SC_CONTENT_DBAREA )
    1205             :     {
    1206           0 :         ScDBCollection* pList = pDoc->GetDBCollection();
    1207           0 :         if (pList)
    1208             :         {
    1209           0 :             const ScDBData* p = pList->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rName));
    1210           0 :             if (p)
    1211             :             {
    1212             :                 SCTAB nTab;
    1213             :                 SCCOL nCol1, nCol2;
    1214             :                 SCROW nRow1, nRow2;
    1215           0 :                 p->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
    1216           0 :                 rRange = ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
    1217           0 :                 bFound = true;
    1218             :             }
    1219             :         }
    1220             :     }
    1221             : 
    1222           0 :     return bFound;
    1223             : }
    1224             : 
    1225           0 : static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, sal_uInt16 nType, Window* pWin )
    1226             : {
    1227           0 :     ScDocument* pSrcDoc = pSrcShell->GetDocument();
    1228           0 :     ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
    1229           0 :     if (pModel)
    1230             :     {
    1231           0 :         bool bOle = ( nType == SC_CONTENT_OLEOBJECT );
    1232           0 :         bool bGraf = ( nType == SC_CONTENT_GRAPHIC );
    1233           0 :         sal_uInt16 nDrawId = sal::static_int_cast<sal_uInt16>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
    1234           0 :         SCTAB nTab = 0;
    1235           0 :         SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
    1236           0 :         if (pObject)
    1237             :         {
    1238           0 :             SdrView aEditView( pModel );
    1239           0 :             aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
    1240           0 :             SdrPageView* pPV = aEditView.GetSdrPageView();
    1241           0 :             aEditView.MarkObj(pObject, pPV);
    1242             : 
    1243           0 :             SdrModel* pDragModel = aEditView.GetMarkedObjModel();
    1244             : 
    1245           0 :             TransferableObjectDescriptor aObjDesc;
    1246           0 :             pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
    1247           0 :             aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
    1248             :             // maSize is set in ScDrawTransferObj ctor
    1249             : 
    1250           0 :             ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
    1251           0 :             uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
    1252             : 
    1253           0 :             pTransferObj->SetDragSourceObj( pObject, nTab );
    1254           0 :             pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
    1255             : 
    1256           0 :             SC_MOD()->SetDragObject( NULL, pTransferObj );
    1257           0 :             pWin->ReleaseMouse();
    1258           0 :             pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
    1259             :         }
    1260             :     }
    1261           0 : }
    1262             : 
    1263           0 : static void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, sal_uInt16 nFlags, Window* pWin )
    1264             : {
    1265           0 :     ScMarkData aMark;
    1266           0 :     aMark.SelectTable( rRange.aStart.Tab(), true );
    1267           0 :     aMark.SetMarkArea( rRange );
    1268             : 
    1269           0 :     ScDocument* pSrcDoc = pSrcShell->GetDocument();
    1270           0 :     if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
    1271           0 :                                                    rRange.aEnd.Col(),   rRange.aEnd.Row(),
    1272           0 :                                                    aMark ) )
    1273             :     {
    1274           0 :         ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
    1275           0 :         ScClipParam aClipParam(rRange, false);
    1276           0 :         pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aMark);
    1277             :         // pClipDoc->ExtendMerge( rRange, sal_True );
    1278             : 
    1279           0 :         TransferableObjectDescriptor aObjDesc;
    1280           0 :         pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
    1281           0 :         aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
    1282             :         // maSize is set in ScTransferObj ctor
    1283             : 
    1284           0 :         ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
    1285           0 :         uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
    1286             : 
    1287           0 :         pTransferObj->SetDragSource( pSrcShell, aMark );
    1288           0 :         pTransferObj->SetDragSourceFlags( nFlags );
    1289             : 
    1290           0 :         SC_MOD()->SetDragObject( pTransferObj, NULL );      // for internal D&D
    1291           0 :         pWin->ReleaseMouse();
    1292           0 :         pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
    1293           0 :     }
    1294           0 : }
    1295             : 
    1296           0 : void ScContentTree::DoDrag()
    1297             : {
    1298           0 :     ScDocumentLoader* pDocLoader = NULL;
    1299           0 :     bIsInDrag = true;
    1300             : 
    1301           0 :     ScModule* pScMod = SC_MOD();
    1302             : 
    1303             :     sal_uInt16 nType;
    1304             :     sal_uLong nChild;
    1305           0 :     SvTreeListEntry* pEntry = GetCurEntry();
    1306           0 :     GetEntryIndexes( nType, nChild, pEntry );
    1307             : 
    1308           0 :     if( pEntry &&
    1309           0 :         (nChild != SC_CONTENT_NOCHILD) &&
    1310           0 :         (nType != SC_CONTENT_ROOT) &&
    1311           0 :         (nType != SC_CONTENT_NOTE) &&
    1312           0 :         (nType != SC_CONTENT_AREALINK) )
    1313             :     {
    1314           0 :         OUString aText( GetEntryText( pEntry ) );
    1315             : 
    1316           0 :         ScDocument* pLocalDoc = NULL;                   // fuer URL-Drop
    1317           0 :         OUString aDocName;
    1318           0 :         if (bHiddenDoc)
    1319           0 :             aDocName = aHiddenName;
    1320             :         else
    1321             :         {
    1322           0 :             ScDocShell* pDocSh = GetManualOrCurrent();
    1323           0 :             if (pDocSh)
    1324             :             {
    1325           0 :                 if (pDocSh->HasName())
    1326           0 :                     aDocName = pDocSh->GetMedium()->GetName();
    1327             :                 else
    1328           0 :                     pLocalDoc = pDocSh->GetDocument();      // Drop nur in dieses Dokument
    1329             :             }
    1330             :         }
    1331             : 
    1332           0 :         bool bDoLinkTrans = false;      // use ScLinkTransferObj
    1333           0 :         OUString aLinkURL;                // for ScLinkTransferObj
    1334           0 :         OUString aLinkText;
    1335             : 
    1336           0 :         sal_uInt16 nDropMode = pParentWindow->GetDropMode();
    1337           0 :         switch ( nDropMode )
    1338             :         {
    1339             :             case SC_DROPMODE_URL:
    1340             :                 {
    1341           0 :                     OUString aUrl = aDocName + "#" + aText;
    1342             : 
    1343           0 :                     pScMod->SetDragJump( pLocalDoc, aUrl, aText );
    1344             : 
    1345           0 :                     if (!aDocName.isEmpty())
    1346             :                     {
    1347             :                         //  provide URL to outside only if the document has a name
    1348             :                         //  (without name, only internal D&D via SetDragJump)
    1349             : 
    1350           0 :                         aLinkURL = aUrl;
    1351           0 :                         aLinkText = aText;
    1352             :                     }
    1353           0 :                     bDoLinkTrans = true;
    1354             :                 }
    1355           0 :                 break;
    1356             :             case SC_DROPMODE_LINK:
    1357             :                 {
    1358           0 :                     if ( !aDocName.isEmpty() )           // link only to named documents
    1359             :                     {
    1360             :                         // for internal D&D, set flag to insert a link
    1361             : 
    1362           0 :                         switch ( nType )
    1363             :                         {
    1364             :                             case SC_CONTENT_TABLE:
    1365           0 :                                 pScMod->SetDragLink( aDocName, aText, EMPTY_OUSTRING );
    1366           0 :                                 bDoLinkTrans = true;
    1367           0 :                                 break;
    1368             :                             case SC_CONTENT_RANGENAME:
    1369             :                             case SC_CONTENT_DBAREA:
    1370           0 :                                 pScMod->SetDragLink( aDocName, EMPTY_OUSTRING, aText );
    1371           0 :                                 bDoLinkTrans = true;
    1372           0 :                                 break;
    1373             : 
    1374             :                             // other types cannot be linked
    1375             :                         }
    1376             :                     }
    1377             :                 }
    1378           0 :                 break;
    1379             :             case SC_DROPMODE_COPY:
    1380             :                 {
    1381           0 :                     ScDocShell* pSrcShell = NULL;
    1382           0 :                     if ( bHiddenDoc )
    1383             :                     {
    1384           0 :                         OUString aFilter, aOptions;
    1385           0 :                         OUString aURL = aHiddenName;
    1386           0 :                         pDocLoader = new ScDocumentLoader( aURL, aFilter, aOptions );
    1387           0 :                         if (!pDocLoader->IsError())
    1388           0 :                             pSrcShell = pDocLoader->GetDocShell();
    1389             :                     }
    1390             :                     else
    1391           0 :                         pSrcShell = GetManualOrCurrent();
    1392             : 
    1393           0 :                     if ( pSrcShell )
    1394             :                     {
    1395           0 :                         ScDocument* pSrcDoc = pSrcShell->GetDocument();
    1396           0 :                         if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA )
    1397             :                         {
    1398           0 :                             ScRange aRange;
    1399           0 :                             if ( lcl_GetRange( pSrcDoc, nType, aText, aRange ) )
    1400             :                             {
    1401           0 :                                 lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
    1402           0 :                             }
    1403             :                         }
    1404           0 :                         else if ( nType == SC_CONTENT_TABLE )
    1405             :                         {
    1406             :                             SCTAB nTab;
    1407           0 :                             if ( pSrcDoc->GetTable( aText, nTab ) )
    1408             :                             {
    1409           0 :                                 ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
    1410           0 :                                 lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
    1411             :                             }
    1412             :                         }
    1413           0 :                         else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT ||
    1414           0 :                                     nType == SC_CONTENT_DRAWING )
    1415             :                         {
    1416           0 :                             lcl_DoDragObject( pSrcShell, aText, nType, this );
    1417             : 
    1418             :                             //  in ExecuteDrag kann der Navigator geloescht worden sein
    1419             :                             //  -> nicht mehr auf Member zugreifen !!!
    1420             :                         }
    1421             :                     }
    1422             :                 }
    1423           0 :                 break;
    1424             :         }
    1425             : 
    1426           0 :         if (bDoLinkTrans)
    1427             :         {
    1428           0 :             ScLinkTransferObj* pTransferObj = new ScLinkTransferObj;
    1429           0 :             uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
    1430             : 
    1431           0 :             if ( !aLinkURL.isEmpty() )
    1432           0 :                 pTransferObj->SetLinkURL( aLinkURL, aLinkText );
    1433             : 
    1434             :             //  SetDragJump / SetDragLink has been done above
    1435             : 
    1436           0 :             ReleaseMouse();
    1437           0 :             pTransferObj->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
    1438           0 :         }
    1439             :     }
    1440             : 
    1441           0 :     bIsInDrag = false;              // static Member
    1442             : 
    1443           0 :     delete pDocLoader;              // falls Dokument zum Draggen geladen wurde
    1444           0 : }
    1445             : 
    1446           0 : IMPL_STATIC_LINK(ScContentTree, ExecDragHdl, void*, EMPTYARG)
    1447             : {
    1448             :     //  als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
    1449             :     //  Navigator geloescht werden darf
    1450             : 
    1451           0 :     pThis->DoDrag();
    1452           0 :     return 0;
    1453             : }
    1454             : 
    1455           0 : bool ScContentTree::LoadFile( const OUString& rUrl )
    1456             : {
    1457           0 :     OUString aDocName = rUrl;
    1458           0 :     sal_Int32 nPos = aDocName.indexOf('#');
    1459           0 :     if ( nPos != -1 )
    1460           0 :         aDocName = aDocName.copy(0, nPos);           // nur der Name, ohne #...
    1461             : 
    1462           0 :     bool bReturn = false;
    1463           0 :     OUString aURL = aDocName;
    1464           0 :     OUString aFilter, aOptions;
    1465           0 :     ScDocumentLoader aLoader( aURL, aFilter, aOptions );
    1466           0 :     if ( !aLoader.IsError() )
    1467             :     {
    1468           0 :         bHiddenDoc = true;
    1469           0 :         aHiddenName = aDocName;
    1470           0 :         aHiddenTitle = aLoader.GetTitle();
    1471           0 :         pHiddenDocument = aLoader.GetDocument();
    1472             : 
    1473           0 :         Refresh();                      // Inhalte aus geladenem Dokument holen
    1474             : 
    1475           0 :         pHiddenDocument = NULL;
    1476             : 
    1477           0 :         pParentWindow->GetDocNames( &aHiddenTitle );            // Liste fuellen
    1478             :     }
    1479             : 
    1480             :     //  Dokument wird im dtor von ScDocumentLoader wieder geschlossen
    1481             : 
    1482           0 :     return bReturn;
    1483             : }
    1484             : 
    1485           0 : void ScContentTree::InitWindowBits( bool bButtons )
    1486             : {
    1487           0 :     WinBits nFlags = GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL;
    1488           0 :     if (bButtons)
    1489           0 :         nFlags |= WB_HASBUTTONS | WB_HASBUTTONSATROOT;
    1490             : 
    1491           0 :     SetStyle( nFlags );
    1492           0 : }
    1493             : 
    1494           0 : void ScContentTree::SetRootType( sal_uInt16 nNew )
    1495             : {
    1496           0 :     if ( nNew != nRootType )
    1497             :     {
    1498           0 :         nRootType = nNew;
    1499           0 :         InitWindowBits( nNew == 0 );
    1500           0 :         Refresh();
    1501             : 
    1502           0 :         ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
    1503           0 :         rCfg.SetRootType( nRootType );
    1504             :     }
    1505           0 : }
    1506             : 
    1507           0 : void ScContentTree::ToggleRoot()        // nach Selektion
    1508             : {
    1509           0 :     sal_uInt16 nNew = SC_CONTENT_ROOT;
    1510           0 :     if ( nRootType == SC_CONTENT_ROOT )
    1511             :     {
    1512           0 :         SvTreeListEntry* pEntry = GetCurEntry();
    1513           0 :         if (pEntry)
    1514             :         {
    1515           0 :             SvTreeListEntry* pParent = GetParent(pEntry);
    1516           0 :             for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++)
    1517           0 :                 if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] )
    1518           0 :                     nNew = i;
    1519             :         }
    1520             :     }
    1521             : 
    1522           0 :     SetRootType( nNew );
    1523           0 : }
    1524             : 
    1525           0 : void ScContentTree::ResetManualDoc()
    1526             : {
    1527           0 :     aManualDoc = "";
    1528           0 :     bHiddenDoc = false;
    1529             : 
    1530           0 :     ActiveDocChanged();
    1531           0 : }
    1532             : 
    1533           0 : void ScContentTree::ActiveDocChanged()
    1534             : {
    1535           0 :     if ( !bHiddenDoc && aManualDoc.isEmpty() )
    1536           0 :         Refresh();                                  // Inhalte nur wenn automatisch
    1537             : 
    1538             :         //  Listbox muss immer geupdated werden, wegen aktiv-Flag
    1539             : 
    1540           0 :     OUString aCurrent;
    1541           0 :     if ( bHiddenDoc )
    1542           0 :         aCurrent = aHiddenTitle;
    1543             :     else
    1544             :     {
    1545           0 :         ScDocShell* pSh = GetManualOrCurrent();
    1546           0 :         if (pSh)
    1547           0 :             aCurrent = pSh->GetTitle();
    1548             :         else
    1549             :         {
    1550             :             //  eingestelltes Dokument existiert nicht mehr
    1551             : 
    1552           0 :             aManualDoc = "";             // wieder automatisch
    1553           0 :             Refresh();
    1554           0 :             pSh = GetManualOrCurrent();     // sollte jetzt aktives sein
    1555           0 :             if (pSh)
    1556           0 :                 aCurrent = pSh->GetTitle();
    1557             :         }
    1558             :     }
    1559           0 :     pParentWindow->GetDocNames( &aCurrent );        // selektieren
    1560           0 : }
    1561             : 
    1562           0 : void ScContentTree::SetManualDoc(const OUString& rName)
    1563             : {
    1564           0 :     aManualDoc = rName;
    1565           0 :     if (!bHiddenDoc)
    1566             :     {
    1567           0 :         Refresh();
    1568           0 :         pParentWindow->GetDocNames( &aManualDoc );      // selektieren
    1569             :     }
    1570           0 : }
    1571             : 
    1572           0 : void ScContentTree::SelectDoc(const OUString& rName)      // rName wie im Menue/Listbox angezeigt
    1573             : {
    1574           0 :     if ( rName == pParentWindow->aStrActiveWin )
    1575             :     {
    1576           0 :         ResetManualDoc();
    1577           0 :         return;
    1578             :     }
    1579             : 
    1580             :     //  "aktiv" oder "inaktiv" weglassen
    1581             : 
    1582           0 :     OUString aRealName = rName;
    1583           0 :     sal_Int32 nLen = rName.getLength();
    1584           0 :     sal_Int32 nActiveStart = nLen - pParentWindow->aStrActive.getLength();
    1585           0 :     if ( rName.copy( nActiveStart ) == pParentWindow->aStrActive )
    1586           0 :         aRealName = rName.copy( 0, nActiveStart );
    1587           0 :     sal_Int32 nNotActiveStart = nLen - pParentWindow->aStrNotActive.getLength();
    1588           0 :     if ( rName.copy( nNotActiveStart ) == pParentWindow->aStrNotActive )
    1589           0 :         aRealName = rName.copy( 0, nNotActiveStart );
    1590             : 
    1591           0 :     bool bLoaded = false;
    1592             : 
    1593             :         // ist es ein normal geladenes Doc ?
    1594             : 
    1595           0 :     SfxObjectShell* pSh = SfxObjectShell::GetFirst();
    1596           0 :     while ( pSh && !bLoaded )
    1597             :     {
    1598           0 :         if ( pSh->ISA(ScDocShell) )
    1599           0 :             if ( pSh->GetTitle() == aRealName )
    1600           0 :                 bLoaded = true;
    1601           0 :         pSh = SfxObjectShell::GetNext( *pSh );
    1602             :     }
    1603             : 
    1604           0 :     if (bLoaded)
    1605             :     {
    1606           0 :         bHiddenDoc = false;
    1607           0 :         SetManualDoc(aRealName);
    1608             :     }
    1609           0 :     else if (!aHiddenTitle.isEmpty())                // verstecktes ausgewaehlt
    1610             :     {
    1611           0 :         if (!bHiddenDoc)
    1612           0 :             LoadFile(aHiddenName);
    1613             :     }
    1614             :     else
    1615             :     {
    1616             :         OSL_FAIL("SelectDoc: nicht gefunden");
    1617           0 :     }
    1618             : }
    1619             : 
    1620           0 : void ScContentTree::ApplySettings()
    1621             : {
    1622           0 :     const ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
    1623           0 :     if( pSettings )
    1624             :     {
    1625           0 :         sal_uInt16 nRootSel = pSettings->GetRootSelected();
    1626           0 :         sal_uLong nChildSel = pSettings->GetChildSelected();
    1627             : 
    1628           0 :         for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
    1629             :         {
    1630           0 :             if( pRootNodes[ nEntry ] )
    1631             :             {
    1632             :                 // expand
    1633           0 :                 bool bExp = pSettings->IsExpanded( nEntry );
    1634           0 :                 if( bExp != IsExpanded( pRootNodes[ nEntry ] ) )
    1635             :                 {
    1636           0 :                     if( bExp )
    1637           0 :                         Expand( pRootNodes[ nEntry ] );
    1638             :                     else
    1639           0 :                         Collapse( pRootNodes[ nEntry ] );
    1640             :                 }
    1641             : 
    1642             :                 // select
    1643           0 :                 if( nRootSel == nEntry )
    1644             :                 {
    1645           0 :                     SvTreeListEntry* pEntry = NULL;
    1646           0 :                     if( bExp && (nChildSel != SC_CONTENT_NOCHILD) )
    1647           0 :                         pEntry = GetEntry( pRootNodes[ nEntry ], nChildSel );
    1648           0 :                     Select( pEntry ? pEntry : pRootNodes[ nEntry ] );
    1649             :                 }
    1650             :             }
    1651             :         }
    1652             :     }
    1653           0 : }
    1654             : 
    1655           0 : void ScContentTree::StoreSettings() const
    1656             : {
    1657           0 :     ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
    1658           0 :     if( pSettings )
    1659             :     {
    1660           0 :         for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
    1661             :         {
    1662           0 :             sal_Bool bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] );
    1663           0 :             pSettings->SetExpanded( nEntry, bExp );
    1664             :         }
    1665             :         sal_uInt16 nRoot;
    1666             :         sal_uLong nChild;
    1667           0 :         GetEntryIndexes( nRoot, nChild, GetCurEntry() );
    1668           0 :         pSettings->SetRootSelected( nRoot );
    1669           0 :         pSettings->SetChildSelected( nChild );
    1670             :     }
    1671           0 : }
    1672             : 
    1673           0 : void ScContentTree::InitEntry(SvTreeListEntry* pEntry,
    1674             :     const OUString& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind)
    1675             : {
    1676           0 :     sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
    1677           0 :     SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
    1678           0 :     SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
    1679           0 :     SvLBoxString* pStr = new SvLBoxString( pEntry, 0, pCol->GetText() );
    1680           0 :     pEntry->ReplaceItem( pStr, nColToHilite );
    1681         102 : }
    1682             : 
    1683             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10