LCOV - code coverage report
Current view: top level - sc/source/ui/navipi - content.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 770 0.0 %
Date: 2012-08-25 Functions: 0 54 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1384 0.0 %

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

Generated by: LCOV version 1.10